babylon.module.d.ts 6.2 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596130597130598130599130600130601130602130603130604130605130606130607130608130609130610130611130612130613130614130615130616130617130618130619130620130621130622130623130624130625130626130627130628130629130630130631130632130633130634130635130636130637130638130639130640130641130642130643130644130645130646130647130648130649130650130651130652130653130654130655130656130657130658130659130660130661130662130663130664130665130666130667130668130669130670130671130672130673130674130675130676130677130678130679130680130681130682130683130684130685130686130687130688130689130690130691130692130693130694130695130696130697130698130699130700130701130702130703130704130705130706130707130708130709130710130711130712130713130714130715130716130717130718130719130720130721130722130723130724130725130726130727130728130729130730130731130732130733130734130735130736130737130738130739130740130741130742130743130744130745130746130747130748130749130750130751130752130753130754130755130756130757130758130759130760130761130762130763130764130765130766130767130768130769130770130771130772130773130774130775130776130777130778130779130780130781130782130783130784130785130786130787130788130789130790130791130792130793130794130795130796130797130798130799130800130801130802130803130804130805130806130807130808130809130810130811130812130813130814130815130816130817130818130819130820130821130822130823130824130825130826130827130828130829130830130831130832130833130834130835130836130837130838130839130840130841130842130843130844130845130846130847130848130849130850130851130852130853130854130855130856130857130858130859130860130861130862130863130864130865130866130867130868130869130870130871130872130873130874130875130876130877130878130879130880130881130882130883130884130885130886130887130888130889130890130891130892130893130894130895130896130897130898130899130900130901130902130903130904130905130906130907130908130909130910130911130912130913130914130915130916130917130918130919130920130921130922130923130924130925130926130927130928130929130930130931130932130933130934130935130936130937130938130939130940130941130942130943130944130945130946130947130948130949130950130951130952130953130954130955130956130957130958130959130960130961130962130963130964130965130966130967130968130969130970130971130972130973130974130975130976130977130978130979130980130981130982130983130984130985130986130987130988130989130990130991130992130993130994130995130996130997130998130999131000131001131002131003131004131005131006131007131008131009131010131011131012131013131014131015131016131017131018131019131020131021131022131023131024131025131026131027131028131029131030131031131032131033131034131035131036131037131038131039131040131041131042131043131044131045131046131047131048131049131050131051131052131053131054131055131056131057131058131059131060131061131062131063131064131065131066131067131068131069131070131071131072131073131074131075131076131077131078131079131080131081131082131083131084131085131086131087131088131089131090131091131092131093131094131095131096131097131098131099131100131101131102131103131104131105131106131107131108131109131110131111131112131113131114131115131116131117131118131119131120131121131122131123131124131125131126131127131128131129131130131131131132131133131134131135131136131137131138131139131140131141131142131143131144131145131146131147131148131149131150131151131152131153131154131155131156131157131158131159131160131161131162131163131164131165131166131167131168131169131170131171131172131173131174131175131176131177131178131179131180131181131182131183131184131185131186131187131188131189131190131191131192131193131194131195131196131197131198131199131200131201131202131203131204131205131206131207131208131209131210131211131212131213131214131215131216131217131218131219131220131221131222131223131224131225131226131227131228131229131230131231131232131233131234131235131236131237131238131239131240131241131242131243131244131245131246131247131248131249131250131251131252131253131254131255131256131257131258131259131260131261131262131263131264131265131266131267131268131269131270131271131272131273131274131275131276131277131278131279131280131281131282131283131284131285131286131287131288131289131290131291131292131293131294131295131296131297131298131299131300131301131302131303131304131305131306131307131308131309131310131311131312131313131314131315131316131317131318131319131320131321131322131323131324131325131326131327131328131329131330131331131332131333131334131335131336131337131338131339131340131341131342131343131344131345131346131347131348131349131350131351131352131353131354131355131356131357131358131359131360131361131362131363131364131365131366131367131368131369131370131371131372131373131374131375131376131377131378131379131380131381131382131383131384131385131386131387131388131389131390131391131392131393131394131395131396131397131398131399131400131401131402131403131404131405131406131407131408131409131410131411131412131413131414131415131416131417131418131419131420131421131422131423131424131425131426131427131428131429131430131431131432131433131434131435131436131437131438131439131440131441131442131443131444131445131446131447131448131449131450131451131452131453131454131455131456131457131458131459131460131461131462131463131464131465131466131467131468131469131470131471131472131473131474131475131476131477131478131479131480131481131482131483131484131485131486131487131488131489131490131491131492131493131494131495131496131497131498131499131500131501131502131503131504131505131506131507131508131509131510131511131512131513131514131515131516131517131518131519131520131521131522131523131524131525131526131527131528131529131530131531131532131533131534131535131536131537131538131539131540131541131542131543131544131545131546131547131548131549131550131551131552131553131554131555131556131557131558131559131560131561131562131563131564131565131566131567131568131569131570131571131572131573131574131575131576131577131578131579131580131581131582131583131584131585131586131587131588131589131590131591131592131593131594131595131596131597131598131599131600131601131602131603131604131605131606131607131608131609131610131611131612131613131614131615131616131617131618131619131620131621131622131623131624131625131626131627131628131629131630131631131632131633131634131635131636131637131638131639131640131641131642131643131644131645131646131647131648131649131650131651131652131653131654131655131656131657131658131659131660131661131662131663131664131665131666131667131668131669131670131671131672131673131674131675131676131677131678131679131680131681131682131683131684131685131686131687131688131689131690131691131692131693131694131695131696131697131698131699131700131701131702131703131704131705131706131707131708131709131710131711131712131713131714131715131716131717131718131719131720131721131722131723131724131725131726131727131728131729131730131731131732131733131734131735131736131737131738131739131740131741131742131743131744131745131746131747131748131749131750131751131752131753131754131755131756131757131758131759131760131761131762131763131764131765131766131767131768131769131770131771131772131773131774131775131776131777131778131779131780131781131782131783131784131785131786131787131788131789131790131791131792131793131794131795131796131797131798131799131800131801131802131803131804131805131806131807131808131809131810131811131812131813131814131815131816131817131818131819131820131821131822131823131824131825131826131827131828131829131830131831131832131833131834131835131836131837131838131839131840131841131842131843131844131845131846131847131848131849131850131851131852131853131854131855131856131857131858131859131860131861131862131863131864131865131866131867131868131869131870131871131872131873131874131875131876131877131878131879131880131881131882131883131884131885131886131887131888131889131890131891131892131893131894131895131896131897131898131899131900131901131902131903131904131905131906131907131908131909131910131911131912131913131914131915131916131917131918131919131920131921131922131923131924131925131926131927131928131929131930131931131932131933131934131935131936131937131938131939131940131941131942131943131944131945131946131947131948131949131950131951131952131953131954131955131956131957131958131959131960131961131962131963131964131965131966131967131968131969131970131971131972131973131974131975131976131977131978131979131980131981131982131983131984131985131986131987131988131989131990131991131992131993131994131995131996131997131998131999132000132001132002132003132004132005132006132007132008132009132010132011132012132013132014132015132016132017132018132019132020132021132022132023132024132025132026132027132028132029132030132031132032132033132034132035132036132037132038132039132040132041132042132043132044132045132046132047132048132049132050132051132052132053132054132055132056132057132058132059132060132061132062132063132064132065132066132067132068132069132070132071132072132073132074132075132076132077132078132079132080132081132082132083132084132085132086132087132088132089132090132091132092132093132094132095132096132097132098132099132100132101132102132103132104132105132106132107132108132109132110132111132112132113132114132115132116132117132118132119132120132121132122132123132124132125132126132127132128132129132130132131132132132133132134132135132136132137132138132139132140132141132142132143132144132145132146132147132148132149132150132151132152132153132154132155132156132157132158132159132160132161132162132163132164132165132166132167132168132169132170132171132172132173132174132175132176132177132178132179132180132181132182132183132184132185132186132187132188132189132190132191132192132193132194132195132196132197132198132199132200132201132202132203132204132205132206132207132208132209132210132211132212132213132214132215132216132217132218132219132220132221132222132223132224132225132226132227132228132229132230132231132232132233132234132235132236132237132238132239132240132241132242132243132244132245132246132247132248132249132250132251132252132253132254132255132256132257132258132259132260132261132262132263132264132265132266132267132268132269132270132271132272132273132274132275132276132277132278132279132280132281132282132283132284132285132286132287132288132289132290132291132292132293132294132295132296132297132298132299132300132301132302132303132304132305132306132307132308132309132310132311132312132313132314132315132316132317132318132319132320132321132322132323132324132325132326132327132328132329132330132331132332132333132334132335132336132337132338132339132340132341132342132343132344132345132346132347132348132349132350132351132352132353132354132355132356132357132358132359132360132361132362132363132364132365132366132367132368132369132370132371132372132373132374132375132376132377132378132379132380132381132382132383132384132385132386132387132388132389132390132391132392132393132394132395132396132397132398132399132400132401132402132403132404132405132406132407132408132409132410132411132412132413132414132415132416132417132418132419132420132421132422132423132424132425132426132427132428132429132430132431132432132433132434132435132436132437132438132439132440132441132442132443132444132445132446132447132448132449132450132451132452132453132454132455132456132457132458132459132460132461132462132463132464132465132466132467132468132469132470132471132472132473132474132475132476132477132478132479132480132481132482132483132484132485132486132487132488132489132490132491132492132493132494132495132496132497132498132499132500132501132502132503132504132505132506132507132508132509132510132511132512132513132514132515132516132517132518132519132520132521132522132523132524132525132526132527132528132529132530132531132532132533132534132535132536132537132538132539132540132541132542132543132544132545132546132547132548132549132550132551132552132553132554132555132556132557132558132559132560132561132562132563132564132565132566132567132568132569132570132571132572132573132574132575132576132577132578132579132580132581132582132583132584132585132586132587132588132589132590132591132592132593132594132595132596132597132598132599132600132601132602132603132604132605132606132607132608132609132610132611132612132613132614132615132616132617132618132619132620132621132622132623132624132625132626132627132628132629132630132631132632132633132634132635132636132637132638132639132640132641132642132643132644132645132646132647132648132649132650132651132652132653132654132655132656132657132658132659132660132661132662132663132664132665132666132667132668132669132670132671132672132673132674132675132676132677132678132679132680132681132682132683132684132685132686132687132688132689132690132691132692132693132694132695132696132697132698132699132700132701132702132703132704132705132706132707132708132709132710132711132712132713132714132715132716132717132718132719132720132721132722132723132724132725132726132727132728132729132730132731132732132733132734132735132736132737132738132739132740132741132742132743132744132745132746132747132748132749132750132751132752132753132754132755132756132757132758132759132760132761132762132763132764132765132766132767132768132769132770132771132772132773132774132775132776132777132778132779132780132781132782132783132784132785132786132787132788132789132790132791132792132793132794132795132796132797132798132799132800132801132802132803132804132805132806132807132808132809132810132811132812132813132814132815132816132817132818132819132820132821132822132823132824132825132826132827132828132829132830132831132832132833132834132835132836132837132838132839132840132841132842132843132844132845132846132847132848132849132850132851132852132853132854132855132856132857132858132859132860132861132862132863132864132865132866132867132868132869132870132871132872132873132874132875132876132877132878132879132880132881132882132883132884132885132886132887132888132889132890132891132892132893132894132895132896132897132898132899132900132901132902132903132904132905132906132907132908132909132910132911132912132913132914132915132916132917132918132919132920132921132922132923132924132925132926132927132928132929132930132931132932132933132934132935132936132937132938132939132940132941132942132943132944132945132946132947132948132949132950132951132952132953132954132955132956132957132958132959132960132961132962132963132964132965132966132967132968132969132970132971132972132973132974132975132976132977132978132979132980132981132982132983132984132985132986132987132988132989132990132991132992132993132994132995132996132997132998132999133000133001133002133003133004133005133006133007133008133009133010133011133012133013133014133015133016133017133018133019133020133021133022133023133024133025133026133027133028133029133030133031133032133033133034133035133036133037133038133039133040133041133042133043133044133045133046133047133048133049133050133051133052133053133054133055133056133057133058133059133060133061133062133063133064133065133066133067133068133069133070133071133072133073133074133075133076133077133078133079133080133081133082133083133084133085133086133087133088133089133090133091133092133093133094133095133096133097133098133099133100133101133102133103133104133105133106133107133108133109133110133111133112133113133114133115133116133117133118133119133120133121133122133123133124133125133126133127133128133129133130133131133132133133133134133135133136133137133138133139133140133141133142133143133144133145133146133147133148133149133150133151133152133153133154133155133156133157133158133159133160133161133162133163133164133165133166133167133168133169133170133171133172133173133174133175133176133177133178133179133180133181133182133183133184133185133186133187133188133189133190133191133192133193133194133195133196133197133198133199133200133201133202133203133204133205133206133207133208133209133210133211133212133213133214133215133216133217133218133219133220133221133222133223133224133225133226133227133228133229133230133231133232133233133234133235133236133237133238133239133240133241133242133243133244133245133246133247133248133249133250133251133252133253133254133255133256133257133258133259133260133261133262133263133264133265133266133267133268133269133270133271133272133273133274133275133276133277133278133279133280133281133282133283133284133285133286133287133288133289133290133291133292133293133294133295133296133297133298133299133300133301133302133303133304133305133306133307133308133309133310133311133312133313133314133315133316133317133318133319133320133321133322133323133324133325133326133327133328133329133330133331133332133333133334133335133336133337133338133339133340133341133342133343133344133345133346133347133348133349133350133351133352133353133354133355133356133357133358133359133360133361133362133363133364133365133366133367133368133369133370133371133372133373133374133375133376133377133378133379133380133381133382133383133384133385133386133387133388133389133390133391133392133393133394133395133396133397133398133399133400133401133402133403133404133405133406133407133408133409133410133411133412133413133414133415133416133417133418133419133420133421133422133423133424133425133426133427133428133429133430133431133432133433133434133435133436133437133438133439133440133441133442133443133444133445133446133447133448133449133450133451133452133453133454133455133456133457133458133459133460133461133462133463133464133465133466133467133468133469133470133471133472133473133474133475133476133477133478133479133480133481133482133483133484133485133486133487133488133489133490133491133492133493133494133495133496133497133498133499133500133501133502133503133504133505133506133507133508133509133510133511133512133513133514133515133516133517133518133519133520133521133522133523133524133525133526133527133528133529133530133531133532133533133534133535133536133537133538133539133540133541133542133543133544133545133546133547133548133549133550133551133552133553133554133555133556133557133558133559133560133561133562133563133564133565133566133567133568133569133570133571133572133573133574133575133576133577133578133579133580133581133582133583133584133585133586133587133588133589133590133591133592133593133594133595133596133597133598133599133600133601133602133603133604133605133606133607133608133609133610133611133612133613133614133615133616133617133618133619133620133621133622133623133624133625133626133627133628133629133630133631133632133633133634133635133636133637133638133639133640133641133642133643133644133645133646133647133648133649133650133651133652133653133654133655133656133657133658133659133660133661133662133663133664133665133666133667133668133669133670133671133672133673133674133675133676133677133678133679133680133681133682133683133684133685133686133687133688133689133690133691133692133693133694133695133696133697133698133699133700133701133702133703133704133705133706133707133708133709133710133711133712133713133714133715133716133717133718133719133720133721133722133723133724133725133726133727133728133729133730133731133732133733133734133735133736133737133738133739133740133741133742133743133744133745133746133747133748133749133750133751133752133753133754133755133756133757133758133759133760133761133762133763133764133765133766133767133768133769133770133771133772133773133774133775133776133777133778133779133780133781133782133783133784133785133786133787133788133789133790133791133792133793133794133795133796133797133798133799133800133801133802133803133804133805133806133807133808133809133810133811133812133813133814133815133816133817133818133819133820133821133822133823133824133825133826133827133828133829133830133831133832133833133834133835133836133837133838133839133840133841133842133843133844133845133846133847133848133849133850133851133852133853133854133855133856133857133858133859133860133861133862133863133864133865133866133867133868133869133870133871133872133873133874133875133876133877133878133879133880133881133882133883133884133885133886133887133888133889133890133891133892133893133894133895133896133897133898133899133900133901133902133903133904133905133906133907133908133909133910133911133912133913133914133915133916133917133918133919133920133921133922133923133924133925133926133927133928133929133930133931133932133933133934133935133936133937133938133939133940133941133942133943133944133945133946133947133948133949133950133951133952133953133954133955133956133957133958133959133960133961133962133963133964133965133966133967133968133969133970133971133972133973133974133975133976133977133978133979133980133981133982133983133984133985133986133987133988133989133990133991133992133993133994133995133996133997133998133999134000134001134002134003134004134005134006134007134008134009134010134011134012134013134014134015134016134017134018134019134020134021134022134023134024134025134026134027134028134029134030134031134032134033134034134035134036134037134038134039134040134041134042134043134044134045134046134047134048134049134050134051134052134053134054134055134056134057134058134059134060134061134062134063134064134065134066134067134068134069134070134071134072134073134074134075134076134077134078134079134080134081134082134083134084134085134086134087134088134089134090134091134092134093134094134095134096134097134098134099134100134101134102134103134104134105134106134107134108134109134110134111134112134113134114134115134116134117134118134119134120134121134122134123134124134125134126134127134128134129134130134131134132134133134134134135134136134137134138134139134140134141134142134143134144134145134146134147134148134149134150134151134152134153134154134155134156134157134158134159134160134161134162134163134164134165134166134167134168134169134170134171134172134173134174134175134176134177134178134179134180134181134182134183134184134185134186134187134188134189134190134191134192134193134194134195134196134197134198134199134200134201134202134203134204134205134206134207134208134209134210134211134212134213134214134215134216134217134218134219134220134221134222134223134224134225134226134227134228134229134230134231134232134233134234134235134236134237134238134239134240134241134242134243134244134245134246134247134248134249134250134251134252134253134254134255134256134257134258134259134260134261134262134263134264134265134266134267134268134269134270134271134272134273134274134275134276134277134278134279134280134281134282134283134284134285134286134287134288134289134290134291134292134293134294134295134296134297134298134299134300134301134302134303134304134305134306134307134308134309134310134311134312134313134314134315134316134317134318134319134320134321134322134323134324134325134326134327134328134329134330134331134332134333134334134335134336134337134338134339134340134341134342134343134344134345134346134347134348134349134350134351134352134353134354134355134356134357134358134359134360134361134362134363134364134365134366134367134368134369134370134371134372134373134374134375134376134377134378134379134380134381134382134383134384134385134386134387134388134389134390134391134392134393134394134395134396134397134398134399134400134401134402134403134404134405134406134407134408134409134410134411134412134413134414134415134416134417134418134419134420134421134422134423134424134425134426134427134428134429134430134431134432134433134434134435134436134437134438134439134440134441134442134443134444134445134446134447134448134449134450134451134452134453134454134455134456134457134458134459134460134461134462134463134464134465134466134467134468134469134470134471134472134473134474134475134476134477134478134479134480134481134482134483134484134485134486134487134488134489134490134491134492134493134494134495134496134497134498134499134500134501134502134503134504134505134506134507134508134509134510134511134512134513134514134515134516134517134518134519134520134521134522134523134524134525134526134527134528134529134530134531134532134533134534134535134536134537134538134539134540134541134542134543134544134545134546134547134548134549134550134551134552134553134554134555134556134557134558134559134560134561134562134563134564134565134566134567134568134569134570134571134572134573134574134575134576134577134578134579134580134581134582134583134584134585134586134587134588134589134590134591134592134593134594134595134596134597134598134599134600134601134602134603134604134605134606134607134608134609134610134611134612134613134614134615134616134617134618134619134620134621134622134623134624134625134626134627134628134629134630134631134632134633134634134635134636134637134638134639134640134641134642134643134644134645134646134647134648134649134650134651134652134653134654134655134656134657134658134659134660134661134662134663134664134665134666134667134668134669134670134671134672134673134674134675134676134677134678134679134680134681134682134683134684134685134686134687134688134689134690134691134692134693134694134695134696134697134698134699134700134701134702134703134704134705134706134707134708134709134710134711134712134713134714134715134716134717134718134719134720134721134722134723134724134725134726134727134728134729134730134731134732134733134734134735134736134737134738134739134740134741134742134743134744134745134746134747134748134749134750134751134752134753134754134755134756134757134758134759134760134761134762134763134764134765134766134767134768134769134770134771134772134773134774134775134776134777134778134779134780134781134782134783134784134785134786134787134788134789134790134791134792134793134794134795134796134797134798134799134800134801134802134803134804134805134806134807134808134809134810134811134812134813134814134815134816134817134818134819134820134821134822134823134824134825134826134827134828134829134830134831134832134833134834134835134836134837134838134839134840134841134842134843134844134845134846134847134848134849134850134851134852134853134854134855134856134857134858134859134860134861134862134863134864134865134866134867134868134869134870134871134872134873134874134875134876134877134878134879134880134881134882134883134884134885134886134887134888134889134890134891134892134893134894134895134896134897134898134899134900134901134902134903134904134905134906134907134908134909134910134911134912134913134914134915134916134917134918134919134920134921134922134923134924134925134926134927134928134929134930134931134932134933134934134935134936134937134938134939134940134941134942134943134944134945134946134947134948134949134950134951134952134953134954134955134956134957134958134959134960134961134962134963134964134965134966134967134968134969134970134971134972134973134974134975134976134977134978134979134980134981134982134983134984134985134986134987134988134989134990134991134992134993134994134995134996134997134998134999135000135001135002135003135004135005135006135007135008135009135010135011135012135013135014135015135016135017135018135019135020135021135022135023135024135025135026135027135028135029135030135031135032135033135034135035135036135037135038135039135040135041135042135043135044135045135046135047135048135049135050135051135052135053135054135055135056135057135058135059135060135061135062135063135064135065135066135067135068135069135070135071135072135073135074135075135076135077135078135079135080135081135082135083135084135085135086135087135088135089135090135091135092135093135094135095135096135097135098135099135100135101135102135103135104135105135106135107135108135109135110135111135112135113135114135115135116135117135118135119135120135121135122135123135124135125135126135127135128135129135130135131135132135133135134135135135136135137135138135139135140135141135142135143135144135145135146135147135148135149135150135151135152135153135154135155135156135157135158135159135160135161135162135163135164135165135166135167135168135169135170135171135172135173135174135175135176135177135178135179135180135181135182135183135184135185135186135187135188135189135190135191135192135193135194135195135196135197135198135199135200135201135202135203135204135205135206135207135208135209135210135211135212135213135214135215135216135217135218135219135220135221135222135223135224135225135226135227135228135229135230135231135232135233135234135235135236135237135238135239135240135241135242135243135244135245135246135247135248135249135250135251135252135253135254135255135256135257135258135259135260135261135262135263135264135265135266135267135268135269135270135271135272135273135274135275135276135277135278135279135280135281135282135283135284135285135286135287135288135289135290135291135292135293135294135295135296135297135298135299135300135301135302135303135304135305135306135307135308135309135310135311135312135313135314135315135316135317135318135319135320135321135322135323135324135325135326135327135328135329135330135331135332135333135334135335135336135337135338135339135340135341135342135343135344135345135346135347135348135349135350135351135352135353135354135355135356135357135358135359135360135361135362135363135364135365135366135367135368135369135370135371135372135373135374135375135376135377135378135379135380135381135382135383135384135385135386135387135388135389135390135391135392135393135394135395135396135397135398135399135400135401135402135403135404135405135406135407135408135409135410135411135412135413135414135415135416135417135418135419135420135421135422135423135424135425135426135427135428135429135430135431135432135433135434135435135436135437135438135439135440135441135442135443135444135445135446135447135448135449135450135451135452135453135454135455135456135457135458135459135460135461135462135463135464135465135466135467135468135469135470135471135472135473135474135475135476135477135478135479135480135481135482135483135484135485135486135487135488135489135490135491135492135493135494135495135496135497135498135499135500135501135502135503135504135505135506135507135508135509135510135511135512135513135514135515135516135517135518135519135520135521135522135523135524135525135526135527135528135529135530135531135532135533135534135535135536135537135538135539135540135541135542135543135544135545135546135547135548135549135550135551135552135553135554135555135556135557135558135559135560135561135562135563135564135565135566135567135568135569135570135571135572135573135574135575135576135577135578135579135580135581135582135583135584135585135586135587135588135589135590135591135592135593135594135595135596135597135598135599135600135601135602135603135604135605135606135607135608135609135610135611135612135613135614135615135616135617135618135619135620135621135622135623135624135625135626135627135628135629135630135631135632135633135634135635135636135637135638135639135640135641135642135643135644135645135646135647135648135649135650135651135652135653135654135655135656135657135658135659135660135661135662135663135664135665135666135667135668135669135670135671135672135673135674135675135676135677135678135679135680135681135682135683135684135685135686135687135688135689135690135691135692135693135694135695135696135697135698135699135700135701135702135703135704135705135706135707135708135709135710135711135712135713135714135715135716135717135718135719135720135721135722135723135724135725135726135727135728135729135730135731135732135733135734135735135736135737135738135739135740135741135742135743135744135745135746135747135748135749135750135751135752135753135754135755135756135757135758135759135760135761135762135763135764135765135766135767135768135769135770135771135772135773135774135775135776135777135778135779135780135781135782135783135784135785135786135787135788135789135790135791135792135793135794135795135796135797135798135799135800135801135802135803135804135805135806135807135808135809135810135811135812135813135814135815135816135817135818135819135820135821135822135823135824135825135826135827135828135829135830135831135832135833135834135835135836135837135838135839135840135841135842135843135844135845135846135847135848135849135850135851135852135853135854135855135856135857135858135859135860135861135862135863135864135865135866135867135868135869135870135871135872135873135874135875135876135877135878135879135880135881135882135883135884135885135886135887135888135889135890135891135892135893135894135895135896135897135898135899135900135901135902135903135904135905135906135907135908135909135910135911135912135913135914135915135916135917135918135919135920135921135922135923135924135925135926135927135928135929135930135931135932135933135934135935135936135937135938135939135940135941135942135943135944135945135946135947135948135949135950135951135952135953135954135955135956135957135958135959135960135961135962135963135964135965135966135967135968135969135970135971135972135973135974135975135976135977135978135979135980135981135982135983135984135985135986135987135988135989135990135991135992135993135994135995135996135997135998135999136000136001136002136003136004136005136006136007136008136009136010136011136012136013136014136015136016136017136018136019136020136021136022136023136024136025136026136027136028136029136030136031136032136033136034136035136036136037136038136039136040136041136042136043136044136045136046136047136048136049136050136051136052136053136054136055136056136057136058136059136060136061136062136063136064136065136066136067136068136069136070136071136072136073136074136075136076136077136078136079136080136081136082136083136084136085136086136087136088136089136090136091136092136093136094136095136096136097136098136099136100136101136102136103136104136105136106136107136108136109136110136111136112136113136114136115136116136117136118136119136120136121136122136123136124136125136126136127136128136129136130136131136132136133136134136135136136136137136138136139136140136141136142136143136144136145136146136147136148136149136150136151136152136153136154136155136156136157136158136159136160136161136162136163136164136165136166136167136168136169136170136171136172136173136174136175136176136177136178136179136180136181136182136183136184136185136186136187136188136189136190136191136192136193136194136195136196136197136198136199136200136201136202136203136204136205136206136207136208136209136210136211136212136213136214136215136216136217136218136219136220136221136222136223136224136225136226136227136228136229136230136231136232136233136234136235136236136237136238136239136240136241136242136243136244136245136246136247136248136249136250136251136252136253136254136255136256136257136258136259136260136261136262136263136264136265136266136267136268136269136270136271136272136273136274136275136276136277136278136279136280136281136282136283136284136285136286136287136288136289136290136291136292136293136294136295136296136297136298136299136300136301136302136303136304136305136306136307136308136309136310136311136312136313136314136315136316136317136318136319136320136321136322136323136324136325136326136327136328136329136330136331136332136333136334136335136336136337136338136339136340136341136342136343136344136345136346136347136348136349136350136351136352136353136354136355136356136357136358136359136360136361136362136363136364136365136366136367136368136369136370136371136372136373136374136375136376136377136378136379136380136381136382136383136384136385136386136387136388136389136390136391136392136393136394136395136396136397136398136399136400136401136402136403136404136405136406136407136408136409136410136411136412136413136414136415136416136417136418136419136420136421136422136423136424136425136426136427136428136429136430136431136432136433136434136435136436136437136438136439136440136441136442136443136444136445136446136447136448136449136450136451136452136453136454136455136456136457136458136459136460136461136462136463136464136465136466136467136468136469136470136471136472136473136474136475136476136477136478136479136480136481136482136483136484136485136486136487136488136489136490136491136492136493136494136495136496136497136498136499136500136501136502136503136504136505136506136507136508136509136510136511136512136513136514136515136516136517136518136519136520136521136522136523136524136525136526136527136528136529136530136531136532136533136534136535136536136537136538136539136540136541136542136543136544136545136546136547136548136549136550136551136552136553136554136555136556136557136558136559136560136561136562136563136564136565136566136567136568136569136570136571136572136573136574136575136576136577136578136579136580136581136582136583136584136585136586136587136588136589136590136591136592136593136594136595136596136597136598136599136600136601136602136603136604136605136606136607136608136609136610136611136612136613136614136615136616136617136618136619136620136621136622136623136624136625136626136627136628136629136630136631136632136633136634136635136636136637136638136639136640136641136642136643136644136645136646136647136648136649136650136651136652136653136654136655136656136657136658136659136660136661136662136663136664136665136666136667136668136669136670136671136672136673136674136675136676136677136678136679136680136681136682136683136684136685136686136687136688136689136690136691136692136693136694136695136696136697136698136699136700136701136702136703136704136705136706136707136708136709136710136711136712136713136714136715136716136717136718136719136720136721136722136723136724136725136726136727136728136729136730136731136732136733136734136735136736136737136738136739136740136741136742136743136744136745136746136747136748136749136750136751136752136753136754136755136756136757136758136759136760136761136762136763136764136765136766136767136768136769136770136771136772136773136774136775136776136777136778136779136780136781136782136783136784136785136786136787136788136789136790136791136792136793136794136795136796136797136798136799136800136801136802136803136804136805136806136807136808136809136810136811136812136813136814136815136816136817136818136819136820136821136822136823136824136825136826136827136828136829136830136831136832136833136834136835136836136837136838136839136840136841136842136843136844136845136846136847136848136849136850136851136852136853136854136855136856136857136858136859136860136861136862136863136864136865136866136867136868136869136870136871136872136873136874136875136876136877136878136879136880136881136882136883136884136885136886136887136888136889136890136891136892136893136894136895136896136897136898136899136900136901136902136903136904136905136906136907136908136909136910136911136912136913136914136915136916136917136918136919136920136921136922136923136924136925136926136927136928136929136930136931136932136933136934136935136936136937136938136939136940136941136942136943136944136945136946136947136948136949136950136951136952136953136954136955136956136957136958136959136960136961136962136963136964136965136966136967136968136969136970136971136972136973136974136975136976136977136978136979136980136981136982136983136984136985136986136987136988136989136990136991136992136993136994136995136996136997136998136999137000137001137002137003137004137005137006137007137008137009137010137011137012137013137014137015137016137017137018137019137020137021137022137023137024137025137026137027137028137029137030137031137032137033137034137035137036137037137038137039137040137041137042137043137044137045137046137047137048137049137050137051137052137053137054137055137056137057137058137059137060137061137062137063137064137065137066137067137068137069137070137071137072137073137074137075137076137077137078137079137080137081137082137083137084137085137086137087137088137089137090137091137092137093137094137095137096137097137098137099137100137101137102137103137104137105137106137107137108137109137110137111137112137113137114137115137116137117137118137119137120137121137122137123137124137125137126137127137128137129137130137131137132137133137134137135137136137137137138137139137140137141137142137143137144137145137146137147137148137149137150137151137152137153137154137155137156137157137158137159137160137161137162137163137164137165137166137167137168137169137170137171137172137173137174137175137176137177137178137179137180137181137182137183137184137185137186137187137188137189137190137191137192137193137194137195137196137197137198137199137200137201137202137203137204137205137206137207137208137209137210137211137212137213137214137215137216137217137218137219137220137221137222137223137224137225137226137227137228137229137230137231137232137233137234137235137236137237137238137239137240137241137242137243137244137245137246137247137248137249137250137251137252137253137254137255137256137257137258137259137260137261137262137263137264137265137266137267137268137269137270137271137272137273137274137275137276137277137278137279137280137281137282137283137284137285137286137287137288137289137290137291137292137293137294137295137296137297137298137299137300137301137302137303137304137305137306137307137308137309137310137311137312137313137314137315137316137317137318137319137320137321137322137323137324137325137326137327137328137329137330137331137332137333137334137335137336137337137338137339137340137341137342137343137344137345137346137347137348137349137350137351137352137353137354137355137356137357137358137359137360137361137362137363137364137365137366137367137368137369137370137371137372137373137374137375137376137377137378137379137380137381137382137383137384137385137386137387137388137389137390137391137392137393137394137395137396137397137398137399137400137401137402137403137404137405137406137407137408137409137410137411137412137413137414137415137416137417137418137419137420137421137422137423137424137425137426137427137428137429137430137431137432137433137434137435137436137437137438137439137440137441137442137443137444137445137446137447137448137449137450137451137452137453137454137455137456137457137458137459137460137461137462137463137464137465137466137467137468137469137470137471137472137473137474137475137476137477137478137479137480137481137482137483137484137485137486137487137488137489137490137491137492137493137494137495137496137497137498137499137500137501137502137503137504137505137506137507137508137509137510137511137512137513137514137515137516137517137518137519137520137521137522137523137524137525137526137527137528137529137530137531137532137533137534137535137536137537137538137539137540137541137542137543137544137545137546137547137548137549137550137551137552137553137554137555137556137557137558137559137560137561137562137563137564137565137566137567137568137569137570137571137572137573137574137575137576137577137578137579137580137581137582137583137584137585137586137587137588137589137590137591137592137593137594137595137596137597137598137599137600137601137602137603137604137605137606137607137608137609137610137611137612137613137614137615137616137617137618137619137620137621137622137623137624137625137626137627137628137629137630137631137632137633137634137635137636137637137638137639137640137641137642137643137644137645137646137647137648137649137650137651137652137653137654137655137656137657137658137659137660137661137662137663137664137665137666137667137668137669137670137671137672137673137674137675137676137677137678137679137680137681137682137683137684137685137686137687137688137689137690137691137692137693137694137695137696137697137698137699137700137701137702137703137704137705137706137707137708137709137710137711137712137713137714137715137716137717137718137719137720137721137722137723137724137725137726137727137728137729137730137731137732137733137734137735137736137737137738137739137740137741137742137743137744137745137746137747137748137749137750137751137752137753137754137755137756137757137758137759137760137761137762137763137764137765137766137767137768137769137770137771137772137773137774137775137776137777137778137779137780137781137782137783137784137785137786137787137788137789137790137791137792137793137794137795137796137797137798137799137800137801137802137803137804137805137806137807137808137809137810137811137812137813137814137815137816137817137818137819137820137821137822137823137824137825137826137827137828137829137830137831137832137833137834137835137836137837137838137839137840137841137842137843137844137845137846137847137848137849137850137851137852137853137854137855137856137857137858137859137860137861137862137863137864137865137866137867137868137869137870137871137872137873137874137875137876137877137878137879137880137881137882137883137884137885137886137887137888137889137890137891137892137893137894137895137896137897137898137899137900137901137902137903137904137905137906137907137908137909137910137911137912137913137914137915137916137917137918137919137920137921137922137923137924137925137926137927137928137929137930137931137932137933137934137935137936137937137938137939137940137941137942137943137944137945137946137947137948137949137950137951137952137953137954137955137956137957137958137959137960137961137962137963137964137965137966137967137968137969137970137971137972137973137974137975137976137977137978137979137980137981137982137983137984137985137986137987137988137989137990137991137992137993137994137995137996137997137998137999138000138001138002138003138004138005138006138007138008138009138010138011138012138013138014138015138016138017138018138019138020138021138022138023138024138025138026138027138028138029138030138031138032138033138034138035138036138037138038138039138040138041138042138043138044138045138046138047138048138049138050138051138052138053138054138055138056138057138058138059138060138061138062138063138064138065138066138067138068138069138070138071138072138073138074138075138076138077138078138079138080138081138082138083138084138085138086138087138088138089138090138091138092138093138094138095138096138097138098138099138100138101138102138103138104138105138106138107138108138109138110138111138112138113138114138115138116138117138118138119138120138121138122138123138124138125138126138127138128138129138130138131138132138133138134138135138136138137138138138139138140138141138142138143138144138145138146138147138148138149138150138151138152138153138154138155138156138157138158138159138160138161138162138163138164138165138166138167138168138169138170138171138172138173138174138175138176138177138178138179138180138181138182138183138184138185138186138187138188138189138190138191138192138193138194138195138196138197138198138199138200138201138202138203138204138205138206138207138208138209138210138211138212138213138214138215138216138217138218138219138220138221138222138223138224138225138226138227138228138229138230138231138232138233138234138235138236138237138238138239138240138241138242138243138244138245138246138247138248138249138250138251138252138253138254138255138256138257138258138259138260138261138262138263138264138265138266138267138268138269138270138271138272138273138274138275138276138277138278138279138280138281138282138283138284138285138286138287138288138289138290138291138292138293138294138295138296138297138298138299138300138301138302138303138304138305138306138307138308138309138310138311138312138313138314138315138316138317138318138319138320138321138322138323138324138325138326138327138328138329138330138331138332138333138334138335138336138337138338138339138340138341138342138343138344138345138346138347138348138349138350138351138352138353138354138355138356138357138358138359138360138361138362138363138364138365138366138367138368138369138370138371138372138373138374138375138376138377138378138379138380138381138382138383138384138385138386138387138388138389138390138391138392138393138394138395138396138397138398138399138400138401138402138403138404138405138406138407138408138409138410138411138412138413138414138415138416138417138418138419138420138421138422138423138424138425138426138427138428138429138430138431138432138433138434138435138436138437138438138439138440138441138442138443138444138445138446138447138448138449138450138451138452138453138454138455138456138457138458138459138460138461138462138463138464138465138466138467138468138469138470138471138472138473138474138475138476138477138478138479138480138481138482138483138484138485138486138487138488138489138490138491138492138493138494138495138496138497138498138499138500138501138502138503138504138505138506138507138508138509138510138511138512138513138514138515138516138517138518138519138520138521138522138523138524138525138526138527138528138529138530138531138532138533138534138535138536138537138538138539138540138541138542138543138544138545138546138547138548138549138550138551138552138553138554138555138556138557138558138559138560138561138562138563138564138565138566138567138568138569138570138571138572138573138574138575138576138577138578138579138580138581138582138583138584138585138586138587138588138589138590138591138592138593138594138595138596138597138598138599138600138601138602138603138604138605138606138607138608138609138610138611138612138613138614138615138616138617138618138619138620138621138622138623138624138625138626138627138628138629138630138631138632138633138634138635138636138637138638138639138640138641138642138643138644138645138646138647138648138649138650138651138652138653138654138655138656138657138658138659138660138661138662138663138664138665138666138667138668138669138670138671138672138673138674138675138676138677138678138679138680138681138682138683138684138685138686138687138688138689138690138691138692138693138694138695138696138697138698138699138700138701138702138703138704138705138706138707138708138709138710138711138712138713138714138715138716138717138718138719138720138721138722138723138724138725138726138727138728138729138730138731138732138733138734138735138736138737138738138739138740138741138742138743138744138745138746138747138748138749138750138751138752138753138754138755138756138757138758138759138760138761138762138763138764138765138766138767138768138769138770138771138772138773138774138775138776138777138778138779138780138781138782138783138784138785138786138787138788138789138790138791138792138793138794138795138796138797138798138799138800138801138802138803138804138805138806138807138808138809138810138811138812138813138814138815138816138817138818138819138820138821138822138823138824138825138826138827138828138829138830138831138832138833138834138835138836138837138838138839138840138841138842138843138844138845138846138847138848138849138850138851138852138853138854138855138856138857138858138859138860138861138862138863138864138865138866138867138868138869138870138871138872138873138874138875138876138877138878138879138880138881138882138883138884138885138886138887138888138889138890138891138892138893138894138895138896138897138898138899138900138901138902138903138904138905138906138907138908138909138910138911138912138913138914138915138916138917138918138919138920138921138922138923138924138925138926138927138928138929138930138931138932138933138934138935138936138937138938138939138940138941138942138943138944138945138946138947138948138949138950138951138952138953138954138955138956138957138958138959138960138961138962138963138964138965138966138967138968138969138970138971138972138973138974138975138976138977138978138979138980138981138982138983138984138985138986138987138988138989138990138991138992138993138994138995138996138997138998138999139000139001139002139003139004139005139006139007139008139009139010139011139012139013139014139015139016139017139018139019139020139021139022139023139024139025139026139027139028139029139030139031139032139033139034139035139036139037139038139039139040139041139042139043139044139045139046139047139048139049139050139051139052139053139054139055139056139057139058139059139060139061139062139063139064139065139066139067139068139069139070139071139072139073139074139075139076139077139078139079139080139081139082139083139084139085139086139087139088139089139090139091139092139093139094139095139096139097139098139099139100139101139102139103139104139105139106139107139108139109139110139111139112139113139114139115139116139117139118139119139120139121139122139123139124139125139126139127139128139129139130139131139132139133139134139135139136139137139138139139139140139141139142139143139144139145139146139147139148139149139150139151139152139153139154139155139156139157139158139159139160139161139162139163139164139165139166139167139168139169139170139171139172139173139174139175139176139177139178139179139180139181139182139183139184139185139186139187139188139189139190139191139192139193139194139195139196139197139198139199139200139201139202139203139204139205139206139207139208139209139210139211139212139213139214139215139216139217139218139219139220139221139222139223139224139225139226139227139228139229139230139231139232139233139234139235139236139237139238139239139240139241139242139243139244139245139246139247139248139249139250139251139252139253139254139255139256139257139258139259139260139261139262139263139264139265139266139267139268139269139270139271139272139273139274139275139276139277139278139279139280139281139282139283139284139285139286139287139288139289139290139291139292139293139294139295139296139297139298139299139300139301139302139303139304139305139306139307139308139309139310139311139312139313139314139315139316139317139318139319139320139321139322139323139324139325139326139327139328139329139330139331139332139333139334139335139336139337139338139339139340139341139342139343139344139345139346139347139348139349139350139351139352139353139354139355139356139357139358139359139360139361139362139363139364139365139366139367139368139369139370139371139372139373139374139375139376139377139378139379139380139381139382139383139384139385139386139387139388139389139390139391139392139393139394139395139396139397139398139399139400139401139402139403139404139405139406139407139408139409139410139411139412139413139414139415139416139417139418139419139420139421139422139423139424139425139426139427139428139429139430139431139432139433139434139435139436139437139438139439139440139441139442139443139444139445139446139447139448139449139450139451139452139453139454139455139456139457139458139459139460139461139462139463139464139465139466139467139468139469139470139471139472139473139474139475139476139477139478139479139480139481139482139483139484139485139486139487139488139489139490139491139492139493139494139495139496139497139498139499139500139501139502139503139504139505139506139507139508139509139510139511139512139513139514139515139516139517139518139519139520139521139522139523139524139525139526139527139528139529139530139531139532139533139534139535139536139537139538139539139540139541139542139543139544139545139546139547139548139549139550139551139552139553139554139555139556139557139558139559139560139561139562139563139564139565139566139567139568139569139570139571139572139573139574139575139576139577139578139579139580139581139582139583139584139585139586139587139588139589139590139591139592139593139594139595139596139597139598139599139600139601139602139603139604139605139606139607139608139609139610139611139612139613139614139615139616139617139618139619139620139621139622139623139624139625139626139627139628139629139630139631139632139633139634139635139636139637139638139639139640139641139642139643139644139645139646139647139648139649139650139651139652139653139654139655139656139657139658139659139660139661139662139663139664139665139666139667139668139669139670139671139672139673139674139675139676139677139678139679139680139681139682139683139684139685139686139687139688139689139690139691139692139693139694139695139696139697139698139699139700139701139702139703139704139705139706139707139708139709139710139711139712139713139714139715139716139717139718139719139720139721139722139723139724139725139726139727139728139729139730139731139732139733139734139735139736139737139738139739139740139741139742139743139744139745139746139747139748139749139750139751139752139753139754139755139756139757139758139759139760139761139762139763139764139765139766139767139768139769139770139771139772139773139774139775139776139777139778139779139780139781139782139783139784139785139786139787139788139789139790139791139792139793139794139795139796139797139798139799139800139801139802139803139804139805139806139807139808139809139810139811139812139813139814139815139816139817139818139819139820139821139822139823139824139825139826139827139828139829139830139831139832139833139834139835139836139837139838139839139840139841139842139843139844139845139846139847139848139849139850139851139852139853139854139855139856139857139858139859139860139861139862139863139864139865139866139867139868139869139870139871139872139873139874139875139876139877139878139879139880139881139882139883139884139885139886139887139888139889139890139891139892139893139894139895139896139897139898139899139900139901139902139903139904139905139906139907139908139909139910139911139912139913139914139915139916139917139918139919139920139921139922139923139924139925139926139927139928139929139930139931139932139933139934139935139936139937139938139939139940139941139942139943139944139945139946139947139948139949139950139951139952139953139954139955139956139957139958139959139960139961139962139963139964139965139966139967139968139969139970139971139972139973139974139975139976139977139978139979139980139981139982139983139984139985139986139987139988139989139990139991139992139993139994139995139996139997139998139999140000140001140002140003140004140005140006140007140008140009140010140011140012140013140014140015140016140017140018140019140020140021140022140023140024140025140026140027140028140029140030140031140032140033140034140035140036140037140038140039140040140041140042140043140044140045140046140047140048140049140050140051140052140053140054140055140056140057140058140059140060140061140062140063140064140065140066140067140068140069140070140071140072140073140074140075140076140077140078140079140080140081140082140083140084140085140086140087140088140089140090140091140092140093140094140095140096140097140098140099140100140101140102140103140104140105140106140107140108140109140110140111140112140113140114140115140116140117140118140119140120140121140122140123140124140125140126140127140128140129140130140131140132140133140134140135140136140137140138140139140140140141140142140143140144140145140146140147140148140149140150140151140152140153140154140155140156140157140158140159140160140161140162140163140164140165140166140167140168140169140170140171140172140173140174140175140176140177140178140179140180140181140182140183140184140185140186140187140188140189140190140191140192140193140194140195140196140197140198140199140200140201140202140203140204140205140206140207140208140209140210140211140212140213140214140215140216140217140218140219140220140221140222140223140224140225140226140227140228140229140230140231140232140233140234140235140236140237140238140239140240140241140242140243140244140245140246140247140248140249140250140251140252140253140254140255140256140257140258140259140260140261140262140263140264140265140266140267140268140269140270140271140272140273140274140275140276140277140278140279140280140281140282140283140284140285140286140287140288140289140290140291140292140293140294140295140296140297140298140299140300140301140302140303140304140305140306140307140308140309140310140311140312140313140314140315140316140317140318140319140320140321140322140323140324140325140326140327140328140329140330140331140332140333140334140335140336140337140338140339140340140341140342140343140344140345140346140347140348140349140350140351140352140353140354140355140356140357140358140359140360140361140362140363140364140365140366140367140368140369140370140371140372140373140374140375140376140377140378140379140380140381140382140383140384140385140386140387140388140389140390140391140392140393140394140395140396140397140398140399140400140401140402140403140404140405140406140407140408140409140410140411140412140413140414140415140416140417140418140419140420140421140422140423140424140425140426140427140428140429140430140431140432140433140434140435140436140437140438140439140440140441140442140443140444140445140446140447140448140449140450140451140452140453140454140455140456140457140458140459140460140461140462140463140464140465140466140467140468140469140470140471140472140473140474140475140476140477140478140479140480140481140482140483140484140485140486140487140488140489140490140491140492140493140494140495140496140497140498140499140500140501140502140503140504140505140506140507140508140509140510140511140512140513140514140515140516140517140518140519140520140521140522140523140524140525140526140527140528140529140530140531140532140533140534140535140536140537140538140539140540140541140542140543140544140545140546140547140548140549140550140551140552140553140554140555140556140557140558140559140560140561140562140563140564140565140566140567140568140569140570140571140572140573140574140575140576140577140578140579140580140581140582140583140584140585140586140587140588140589140590140591140592140593140594140595140596140597140598140599140600140601140602140603140604140605140606140607140608140609140610140611140612140613140614140615140616140617140618140619140620140621140622140623140624140625140626140627140628140629140630140631140632140633140634140635140636140637140638140639140640140641140642140643140644140645140646140647140648140649140650140651140652140653140654140655140656140657140658140659140660140661140662140663140664140665140666140667140668140669140670140671140672140673140674140675140676140677140678140679140680140681140682140683140684140685140686140687140688140689140690140691140692140693140694140695140696140697140698140699140700140701140702140703140704140705140706140707140708140709140710140711140712140713140714140715140716140717140718140719140720140721140722140723140724140725140726140727140728140729140730140731140732140733140734140735140736140737140738140739140740140741140742140743140744140745140746140747140748140749140750140751140752140753140754140755140756140757140758140759140760140761140762140763140764140765140766140767140768140769140770140771140772140773140774140775140776140777140778140779140780140781140782140783140784140785140786140787140788140789140790140791140792140793140794140795140796140797140798140799140800140801140802140803140804140805140806140807140808140809140810140811140812140813140814140815140816140817140818140819140820140821140822140823140824140825140826140827140828140829140830140831140832140833140834140835140836140837140838140839140840140841140842140843140844140845140846140847140848140849140850140851140852140853140854140855140856140857140858140859140860140861140862140863140864140865140866140867140868140869140870140871140872140873140874140875140876140877140878140879140880140881140882140883140884140885140886140887140888140889140890140891140892140893140894140895140896140897140898140899140900140901140902140903140904140905140906140907140908140909140910140911140912140913140914140915140916140917140918140919140920140921140922140923140924140925140926140927140928140929140930140931140932140933140934140935140936140937140938140939140940140941140942140943140944140945140946140947140948140949140950140951140952140953140954140955140956140957140958140959140960140961140962140963140964140965140966140967140968140969140970140971140972140973140974140975140976140977140978140979140980140981140982140983140984140985140986140987140988140989140990140991140992140993140994140995140996140997140998140999141000141001141002141003141004141005141006141007141008141009141010141011141012141013141014141015141016141017141018141019141020141021141022141023141024141025141026141027141028141029141030141031141032141033141034141035141036141037141038141039141040141041141042141043141044141045141046141047141048141049141050141051141052141053141054141055141056141057141058141059141060141061141062141063141064141065141066141067141068141069141070141071141072141073141074141075141076141077141078141079141080141081141082141083141084141085141086141087141088141089141090141091141092141093141094141095141096141097141098141099141100141101141102141103141104141105141106141107141108141109141110141111141112141113141114141115141116141117141118141119141120141121141122141123141124141125141126141127141128141129141130141131141132141133141134141135141136141137141138141139141140141141141142141143141144141145141146141147141148141149141150141151141152141153141154141155141156141157141158141159141160141161141162141163141164141165141166141167141168141169141170141171141172141173141174141175141176141177141178141179141180141181141182141183141184141185141186141187141188141189141190141191141192141193141194141195141196141197141198141199141200141201141202141203141204141205141206141207141208141209141210141211141212141213141214141215141216141217141218141219141220141221141222141223141224141225141226141227141228141229141230141231141232141233141234141235141236141237141238141239141240141241141242141243141244141245141246141247141248141249141250141251141252141253141254141255141256141257141258141259141260141261141262141263141264141265141266141267141268141269141270141271141272141273141274141275141276141277141278141279141280141281141282141283141284141285141286141287141288141289141290141291141292141293141294141295141296141297141298141299141300141301141302141303141304141305141306141307141308141309141310141311141312141313141314141315141316141317141318141319141320141321141322141323141324141325141326141327141328141329141330141331141332141333141334141335141336141337141338141339141340141341141342141343141344141345141346141347141348141349141350141351141352141353141354141355141356141357141358141359141360141361141362141363141364141365141366141367141368141369141370141371141372141373141374141375141376141377141378141379141380141381141382141383141384141385141386141387141388141389141390141391141392141393141394141395141396141397141398141399141400141401141402141403141404141405141406141407141408141409141410141411141412141413141414141415141416141417141418141419141420141421141422141423141424141425141426141427141428141429141430141431141432141433141434141435141436141437141438141439141440141441141442141443141444141445141446141447141448141449141450141451141452141453141454141455141456141457141458141459141460141461141462141463141464141465141466141467141468141469141470141471141472141473141474141475141476141477141478141479141480141481141482141483141484141485141486141487141488141489141490141491141492141493141494141495141496141497141498141499141500141501141502141503141504141505141506141507141508141509141510141511141512141513141514141515141516141517141518141519141520141521141522141523141524141525141526141527141528141529141530141531141532141533141534141535141536141537141538141539141540141541141542141543141544141545141546141547141548141549141550141551141552141553141554141555141556141557141558141559141560141561141562141563141564141565141566141567141568141569141570141571141572141573141574141575141576141577141578141579141580141581141582141583141584141585141586141587141588141589141590141591141592141593141594141595141596141597141598141599141600141601141602141603141604141605141606141607141608141609141610141611141612141613141614141615141616141617141618141619141620141621141622141623141624141625141626141627141628141629141630141631141632141633141634141635141636141637141638141639141640141641141642141643141644141645141646141647141648141649141650141651141652141653141654141655141656141657141658141659141660141661141662141663141664141665141666141667141668141669141670141671141672141673141674141675141676141677141678141679141680141681141682141683141684141685141686141687141688141689141690141691141692141693141694141695141696141697141698141699141700141701141702141703141704141705141706141707141708141709141710141711141712141713141714141715141716141717141718141719141720141721141722141723141724141725141726141727141728141729141730141731141732141733141734141735141736141737141738141739141740141741141742141743141744141745141746141747141748141749141750141751141752141753141754141755141756141757141758141759141760141761141762141763141764141765141766141767141768141769141770141771141772141773141774141775141776141777141778141779141780141781141782141783141784141785141786141787141788141789141790141791141792141793141794141795141796141797141798141799141800141801141802141803141804141805141806141807141808141809141810141811141812141813141814141815141816141817141818141819141820141821141822141823141824141825141826141827141828141829141830141831141832141833141834141835141836141837141838141839141840141841141842141843141844141845141846141847141848141849141850141851141852141853141854141855141856141857141858141859141860141861141862141863141864141865141866141867141868141869141870141871141872141873141874141875141876141877141878141879141880141881141882141883141884141885141886141887141888141889141890141891141892141893141894141895141896141897141898141899141900141901141902141903141904141905141906141907141908141909141910141911141912141913141914141915141916141917141918141919141920141921141922141923141924141925141926141927141928141929141930141931141932141933141934141935141936141937141938141939141940141941141942141943141944141945141946141947141948141949141950141951141952141953141954141955141956141957141958141959141960141961141962141963141964141965141966141967141968141969141970141971141972141973141974141975141976141977141978141979141980141981141982141983141984141985141986141987141988141989141990141991141992141993141994141995141996141997141998141999142000142001142002142003142004142005142006142007142008142009142010142011142012142013142014142015142016142017142018142019142020142021142022142023142024142025142026142027142028142029142030142031142032142033142034142035142036142037142038142039142040142041142042142043142044142045142046142047142048142049142050142051142052142053142054142055142056142057142058142059142060142061142062142063142064142065142066142067142068142069142070142071142072142073142074142075142076142077142078142079142080142081142082142083142084142085142086142087142088142089142090142091142092142093142094142095142096142097142098142099142100142101142102142103142104142105142106142107142108142109142110142111142112142113142114142115142116142117142118142119142120142121142122142123142124142125142126142127142128142129142130142131142132142133142134142135142136142137142138142139142140142141142142142143142144142145142146142147142148142149142150142151142152142153142154142155142156142157142158142159142160142161142162142163142164142165142166142167142168142169142170142171142172142173142174142175142176142177142178142179142180142181142182142183142184142185142186142187142188142189142190142191142192142193142194142195142196142197142198142199142200142201142202142203142204142205142206142207142208142209142210142211142212142213142214142215142216142217142218142219142220142221142222142223142224142225142226142227142228142229142230142231142232142233142234142235142236142237142238142239142240142241142242142243142244142245142246142247142248142249142250142251142252142253142254142255142256142257142258142259142260142261142262142263142264142265142266142267142268142269142270142271142272142273142274142275142276142277142278142279142280142281142282142283142284142285142286142287142288142289142290142291142292142293142294142295142296142297142298142299142300142301142302142303142304142305142306142307142308142309142310142311142312142313142314142315142316142317142318142319142320142321142322142323142324142325142326142327142328142329142330142331142332142333142334142335142336142337142338142339142340142341142342142343142344142345142346142347142348142349142350142351142352142353142354142355142356142357142358142359142360142361142362142363142364142365142366142367142368142369142370142371142372142373142374142375142376142377142378142379142380142381142382142383142384142385142386142387142388142389142390142391142392142393142394142395142396142397142398142399142400142401142402142403142404142405142406142407142408142409142410142411142412142413142414142415142416142417142418142419142420142421142422142423142424142425142426142427142428142429142430142431142432142433142434142435142436142437142438142439142440142441142442142443142444142445142446142447142448142449142450142451142452142453142454142455142456142457142458142459142460142461142462142463142464142465142466142467142468142469142470142471142472142473142474142475142476142477142478142479142480142481142482142483142484142485142486142487142488142489142490142491142492142493142494142495142496142497142498142499142500142501142502142503142504142505142506142507142508142509142510142511142512142513142514142515142516142517142518142519142520142521142522142523142524142525142526142527142528142529142530142531142532142533142534142535142536142537142538142539142540142541142542142543142544142545142546142547142548142549142550142551142552142553142554142555142556142557142558142559142560142561142562142563142564142565142566142567142568142569142570142571142572142573142574142575142576142577142578142579142580142581142582142583142584142585142586142587142588142589142590142591142592142593142594142595142596142597142598142599142600142601142602142603142604142605142606142607142608142609142610142611142612142613142614142615142616142617142618142619142620142621142622142623142624142625142626142627142628142629142630142631142632142633142634142635142636142637142638142639142640142641142642142643142644142645142646142647142648142649142650142651142652142653142654142655142656142657142658142659142660142661142662142663142664142665142666142667142668142669142670142671142672142673142674142675142676142677142678142679142680142681142682142683142684142685142686142687142688142689142690142691142692142693142694142695142696142697142698142699142700142701142702142703142704142705142706142707142708142709142710142711142712142713142714142715142716142717142718142719142720142721142722142723142724142725142726142727142728142729142730142731142732142733142734142735142736142737142738142739142740142741142742142743142744142745142746142747142748142749142750142751142752142753142754142755142756142757142758142759142760142761142762142763142764142765142766142767142768142769142770142771142772142773142774142775142776142777142778142779142780142781142782142783142784142785142786142787142788142789142790142791142792142793142794142795142796142797142798142799142800142801142802142803142804142805142806142807142808142809142810142811142812142813142814142815142816142817142818142819142820142821142822142823142824142825142826142827142828142829142830142831142832142833142834142835142836142837142838142839142840142841142842142843142844142845142846142847142848142849142850142851142852142853142854142855142856142857142858142859142860142861142862142863142864142865142866142867142868142869142870142871142872142873142874142875142876142877142878142879142880142881142882142883142884142885142886142887142888142889142890142891142892142893142894142895142896142897142898142899142900142901142902142903142904142905142906142907142908142909142910142911142912142913142914142915142916142917142918142919142920142921142922142923142924142925142926142927142928142929142930142931142932142933142934142935142936142937142938142939142940142941142942142943142944142945142946142947142948142949142950142951142952142953142954142955142956142957142958142959142960142961142962142963142964142965142966142967142968142969142970142971142972142973142974142975142976142977142978142979142980142981142982142983142984142985142986142987142988142989142990142991142992142993142994142995142996142997142998142999143000143001143002143003143004143005143006143007143008143009143010143011143012143013143014143015143016143017143018143019143020143021143022143023143024143025143026143027143028143029143030143031143032143033143034143035143036143037143038143039143040143041143042143043143044143045143046143047143048143049143050143051143052143053143054143055143056143057143058143059143060143061143062143063143064143065143066143067143068143069143070143071143072143073143074143075143076143077143078143079143080143081143082143083143084143085143086143087143088143089143090143091143092143093143094143095143096143097143098143099143100143101143102143103143104143105143106143107143108143109143110143111143112143113143114143115143116143117143118143119143120143121143122143123143124143125143126143127143128143129143130143131143132143133143134143135143136143137143138143139143140143141143142143143143144143145143146143147143148143149143150143151143152143153143154143155143156143157143158143159143160143161143162143163143164143165143166143167143168143169143170143171143172143173143174143175143176143177143178143179143180143181143182143183143184143185143186143187143188143189143190143191143192143193143194143195143196143197143198143199143200143201143202143203143204143205143206143207143208143209143210143211143212143213143214143215143216143217143218143219143220143221143222143223143224143225143226143227143228143229143230143231143232143233143234143235143236143237143238143239143240143241143242143243143244143245143246143247143248143249143250143251143252143253143254143255143256143257143258143259143260143261143262143263143264143265143266143267143268143269143270143271143272143273143274143275143276143277143278143279143280143281143282143283143284143285143286143287143288143289143290143291143292143293143294143295143296143297143298143299143300143301143302143303143304143305143306143307143308143309143310143311143312143313143314143315143316143317143318143319143320143321143322143323143324143325143326143327143328143329143330143331143332143333143334143335143336143337143338143339143340143341143342143343143344143345143346143347143348143349143350143351143352143353143354143355143356143357143358143359143360143361143362143363143364143365143366143367143368143369143370143371143372143373143374143375143376143377143378143379143380143381143382143383143384143385143386143387143388143389143390143391143392143393143394143395143396143397143398143399143400143401143402143403143404143405143406143407143408143409143410143411143412143413143414143415143416143417143418143419143420143421143422143423143424143425143426143427143428143429143430143431143432143433143434143435143436143437143438143439143440143441143442143443143444143445143446143447143448143449143450143451143452143453143454143455143456143457143458143459143460143461143462143463143464143465143466143467143468143469143470143471143472143473143474143475143476143477143478143479143480143481143482143483143484143485143486143487143488143489143490143491143492143493143494143495143496143497143498143499143500143501143502143503143504143505143506143507143508143509143510143511143512143513143514143515143516143517143518143519143520143521143522143523143524143525143526143527143528143529143530143531143532143533143534143535143536143537143538143539143540143541143542143543143544143545143546143547143548143549143550143551143552143553143554143555143556143557143558143559143560143561143562143563143564143565143566143567143568143569143570143571143572143573143574143575143576143577143578143579143580143581143582143583143584143585143586143587143588143589143590143591143592143593143594143595143596143597143598143599143600143601143602143603143604143605143606143607143608143609143610143611143612143613143614143615143616143617143618143619143620143621143622143623143624143625143626143627143628143629143630143631143632143633143634143635143636143637143638143639143640143641143642143643143644143645143646143647143648143649143650143651143652143653143654143655143656143657143658143659143660143661143662143663143664143665143666143667143668143669143670143671143672143673143674143675143676143677143678143679143680143681143682143683143684143685143686143687143688143689143690143691143692143693143694143695143696143697143698143699143700143701143702143703143704143705143706143707143708143709143710143711143712143713143714143715143716143717143718143719143720143721143722143723143724143725143726143727143728143729143730143731143732143733143734143735143736143737143738143739143740143741143742143743143744143745143746143747143748143749143750143751143752143753143754143755143756143757143758143759143760143761143762143763143764143765143766143767143768143769143770143771143772143773143774143775143776143777143778143779143780143781143782143783143784143785143786143787143788143789143790143791143792143793143794143795143796143797143798143799143800143801143802143803143804143805143806143807143808143809143810143811143812143813143814143815143816143817143818143819143820143821143822143823143824143825143826143827143828143829143830143831143832143833143834143835143836143837143838143839143840143841143842143843143844143845143846143847143848143849143850143851143852143853143854143855143856143857143858143859143860143861143862143863143864143865143866143867143868143869143870143871143872143873143874143875143876143877143878143879143880143881143882143883143884143885143886143887143888143889143890143891143892143893143894143895143896143897143898143899143900143901143902143903143904143905143906143907143908143909143910143911143912143913143914143915143916143917143918143919143920143921143922143923143924143925143926143927143928143929143930143931143932143933143934143935143936143937143938143939143940143941143942143943143944143945143946143947143948143949143950143951143952143953143954143955143956143957143958143959143960143961143962143963143964143965143966143967143968143969143970143971143972143973143974143975143976143977143978143979143980143981143982143983143984143985143986143987143988143989143990143991143992143993143994143995143996143997143998143999144000144001144002144003144004144005144006144007144008144009144010144011144012144013144014144015144016144017144018144019144020144021144022144023144024144025144026144027144028144029144030144031144032144033144034144035144036144037144038144039144040144041144042144043144044144045144046144047144048144049144050144051144052144053144054144055144056144057144058144059144060144061144062144063144064144065144066144067144068144069144070144071144072144073144074144075144076144077144078144079144080144081144082144083144084144085144086144087144088144089144090144091144092144093144094144095144096144097144098144099144100144101144102144103144104144105144106144107144108144109144110144111144112144113144114144115144116144117144118144119144120144121144122144123144124144125144126144127144128144129144130144131144132144133144134144135144136144137144138144139144140144141144142144143144144144145144146144147144148144149144150144151144152144153144154144155144156144157144158144159144160144161144162144163144164144165144166144167144168144169144170144171144172144173144174144175144176144177144178144179144180144181144182144183144184144185144186144187144188144189144190144191144192144193144194144195144196144197144198144199144200144201144202144203144204144205144206144207144208144209144210144211144212144213144214144215144216144217144218144219144220144221144222144223144224144225144226144227144228144229144230144231144232144233144234144235144236144237144238144239144240144241144242144243144244144245144246144247144248144249144250144251144252144253144254144255144256144257144258144259144260144261144262144263144264144265144266144267144268144269144270144271144272144273144274144275144276144277144278144279144280144281144282144283144284144285144286144287144288144289144290144291144292144293144294144295144296144297144298144299144300144301144302144303144304144305144306144307144308144309144310144311144312144313144314144315144316144317144318144319144320144321144322144323144324144325144326144327144328144329144330144331144332144333144334144335144336144337144338144339144340144341144342144343144344144345144346144347144348144349144350144351144352144353144354144355144356144357144358144359144360144361144362144363144364144365144366144367144368144369144370144371144372144373144374144375144376144377144378144379144380144381144382144383144384144385144386144387144388144389144390144391144392144393144394144395144396144397144398144399144400144401144402144403144404144405144406144407144408144409144410144411144412144413144414144415144416144417144418144419144420144421144422144423144424144425144426144427144428144429144430144431144432144433144434144435144436144437144438144439144440144441144442144443144444144445144446144447144448144449144450144451144452144453144454144455144456144457144458144459144460144461144462144463144464144465144466144467144468144469144470144471144472144473144474144475144476144477144478144479144480144481144482144483144484144485144486144487144488144489144490144491144492144493144494144495144496144497144498144499144500144501144502144503144504144505144506144507144508144509144510144511144512144513144514144515144516144517144518144519144520144521144522144523144524144525144526144527144528144529144530144531144532144533144534144535144536144537144538144539144540144541144542144543144544144545144546144547144548144549144550144551144552144553144554144555144556144557144558144559144560144561144562144563144564144565144566144567144568144569144570144571144572144573144574144575144576144577144578144579144580144581144582144583144584144585144586144587144588144589144590144591144592144593144594144595144596144597144598144599144600144601144602144603144604144605144606144607144608144609144610144611144612144613144614144615144616144617144618144619144620144621144622144623144624144625144626144627144628144629144630144631144632144633144634144635144636144637144638144639144640144641144642144643144644144645144646144647144648144649144650144651144652144653144654144655144656144657144658144659144660144661144662144663144664144665144666144667144668144669144670144671144672144673144674144675144676144677144678144679144680144681144682144683144684144685144686144687144688144689144690144691144692144693144694144695144696144697144698144699144700144701144702144703144704144705144706144707144708144709144710144711144712144713144714144715144716144717144718144719144720144721144722144723144724144725144726144727144728144729144730144731144732144733144734144735144736144737144738144739144740144741144742144743144744144745144746144747144748144749144750144751144752144753144754144755144756144757144758144759144760144761144762144763144764144765144766144767144768144769144770144771144772144773144774144775144776144777144778144779144780144781144782144783144784144785144786144787144788144789144790144791144792144793144794144795144796144797144798144799144800144801144802144803144804144805144806144807144808144809144810144811144812144813144814144815144816144817144818144819144820144821144822144823144824144825144826144827144828144829144830144831144832144833144834144835144836144837144838144839144840144841144842144843144844144845144846144847144848144849144850144851144852144853144854144855144856144857144858144859144860144861144862144863144864144865144866144867144868144869144870144871144872144873144874144875144876144877144878144879144880144881144882144883144884144885144886144887144888144889144890144891144892144893144894144895144896144897144898144899144900144901144902144903144904144905144906144907144908144909144910144911144912144913144914144915144916144917144918144919144920144921144922144923144924144925144926144927144928144929144930144931144932144933144934144935144936144937144938144939144940144941144942144943144944144945144946144947144948144949144950144951144952144953144954144955144956144957144958144959144960144961144962144963144964144965144966144967144968144969144970144971144972144973144974144975144976144977144978144979144980144981144982144983144984144985144986144987144988144989144990144991144992144993144994144995144996144997144998144999145000145001145002145003145004145005145006145007145008145009145010145011145012145013145014145015145016145017145018145019145020145021145022145023145024145025145026145027145028145029145030145031145032145033145034145035145036145037145038145039145040145041145042145043145044145045145046145047145048145049145050145051145052145053145054145055145056145057145058145059145060145061145062145063145064145065145066145067145068145069145070145071145072145073145074145075145076145077145078145079145080145081145082145083145084145085145086145087145088145089145090145091145092145093145094145095145096145097145098145099145100145101145102145103145104145105145106145107145108145109145110145111145112145113145114145115145116145117145118145119145120145121145122145123145124145125145126145127145128145129145130145131145132145133145134145135145136145137145138145139145140145141145142145143145144145145145146145147145148145149145150145151145152145153145154145155145156145157145158145159145160145161145162145163145164145165145166145167145168145169145170145171145172145173145174145175145176145177145178145179145180145181145182145183145184145185145186145187145188145189145190145191145192145193145194145195145196145197145198145199145200145201145202145203145204145205145206145207145208145209145210145211145212145213145214145215145216145217145218145219145220145221145222145223145224145225145226145227145228145229145230145231145232145233145234145235145236145237145238145239145240145241145242145243145244145245145246145247145248145249145250145251145252145253145254145255145256145257145258145259145260145261145262145263145264145265145266145267145268145269145270145271145272145273145274145275145276145277145278145279145280145281145282145283145284145285145286145287145288145289145290145291145292145293145294145295145296145297145298145299145300145301145302145303145304145305145306145307145308145309145310145311145312145313145314145315145316145317145318145319145320145321145322145323145324145325145326145327145328145329145330145331145332145333145334145335145336145337145338145339145340145341145342145343145344145345145346145347145348145349145350145351145352145353145354145355145356145357145358145359145360145361145362145363145364145365145366145367145368145369145370145371145372145373145374145375145376145377145378
  1. declare module "babylonjs/types" {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /**
  41. * Type modifier to make object properties readonly.
  42. */
  43. export type DeepImmutableObject<T> = {
  44. readonly [K in keyof T]: DeepImmutable<T[K]>;
  45. };
  46. /** @hidden */
  47. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  48. }
  49. }
  50. declare module "babylonjs/Misc/observable" {
  51. import { Nullable } from "babylonjs/types";
  52. /**
  53. * A class serves as a medium between the observable and its observers
  54. */
  55. export class EventState {
  56. /**
  57. * Create a new EventState
  58. * @param mask defines the mask associated with this state
  59. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  60. * @param target defines the original target of the state
  61. * @param currentTarget defines the current target of the state
  62. */
  63. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  64. /**
  65. * Initialize the current event state
  66. * @param mask defines the mask associated with this state
  67. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  68. * @param target defines the original target of the state
  69. * @param currentTarget defines the current target of the state
  70. * @returns the current event state
  71. */
  72. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  73. /**
  74. * An Observer can set this property to true to prevent subsequent observers of being notified
  75. */
  76. skipNextObservers: boolean;
  77. /**
  78. * Get the mask value that were used to trigger the event corresponding to this EventState object
  79. */
  80. mask: number;
  81. /**
  82. * The object that originally notified the event
  83. */
  84. target?: any;
  85. /**
  86. * The current object in the bubbling phase
  87. */
  88. currentTarget?: any;
  89. /**
  90. * This will be populated with the return value of the last function that was executed.
  91. * If it is the first function in the callback chain it will be the event data.
  92. */
  93. lastReturnValue?: any;
  94. }
  95. /**
  96. * Represent an Observer registered to a given Observable object.
  97. */
  98. export class Observer<T> {
  99. /**
  100. * Defines the callback to call when the observer is notified
  101. */
  102. callback: (eventData: T, eventState: EventState) => void;
  103. /**
  104. * Defines the mask of the observer (used to filter notifications)
  105. */
  106. mask: number;
  107. /**
  108. * Defines the current scope used to restore the JS context
  109. */
  110. scope: any;
  111. /** @hidden */
  112. _willBeUnregistered: boolean;
  113. /**
  114. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  115. */
  116. unregisterOnNextCall: boolean;
  117. /**
  118. * Creates a new observer
  119. * @param callback defines the callback to call when the observer is notified
  120. * @param mask defines the mask of the observer (used to filter notifications)
  121. * @param scope defines the current scope used to restore the JS context
  122. */
  123. constructor(
  124. /**
  125. * Defines the callback to call when the observer is notified
  126. */
  127. callback: (eventData: T, eventState: EventState) => void,
  128. /**
  129. * Defines the mask of the observer (used to filter notifications)
  130. */
  131. mask: number,
  132. /**
  133. * Defines the current scope used to restore the JS context
  134. */
  135. scope?: any);
  136. }
  137. /**
  138. * Represent a list of observers registered to multiple Observables object.
  139. */
  140. export class MultiObserver<T> {
  141. private _observers;
  142. private _observables;
  143. /**
  144. * Release associated resources
  145. */
  146. dispose(): void;
  147. /**
  148. * Raise a callback when one of the observable will notify
  149. * @param observables defines a list of observables to watch
  150. * @param callback defines the callback to call on notification
  151. * @param mask defines the mask used to filter notifications
  152. * @param scope defines the current scope used to restore the JS context
  153. * @returns the new MultiObserver
  154. */
  155. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  156. }
  157. /**
  158. * The Observable class is a simple implementation of the Observable pattern.
  159. *
  160. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  161. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  162. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  163. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  164. */
  165. export class Observable<T> {
  166. private _observers;
  167. private _eventState;
  168. private _onObserverAdded;
  169. /**
  170. * Gets the list of observers
  171. */
  172. get observers(): Array<Observer<T>>;
  173. /**
  174. * Creates a new observable
  175. * @param onObserverAdded defines a callback to call when a new observer is added
  176. */
  177. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  178. /**
  179. * Create a new Observer with the specified callback
  180. * @param callback the callback that will be executed for that Observer
  181. * @param mask the mask used to filter observers
  182. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  183. * @param scope optional scope for the callback to be called from
  184. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  185. * @returns the new observer created for the callback
  186. */
  187. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  188. /**
  189. * Create a new Observer with the specified callback and unregisters after the next notification
  190. * @param callback the callback that will be executed for that Observer
  191. * @returns the new observer created for the callback
  192. */
  193. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  194. /**
  195. * Remove an Observer from the Observable object
  196. * @param observer the instance of the Observer to remove
  197. * @returns false if it doesn't belong to this Observable
  198. */
  199. remove(observer: Nullable<Observer<T>>): boolean;
  200. /**
  201. * Remove a callback from the Observable object
  202. * @param callback the callback to remove
  203. * @param scope optional scope. If used only the callbacks with this scope will be removed
  204. * @returns false if it doesn't belong to this Observable
  205. */
  206. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  207. private _deferUnregister;
  208. private _remove;
  209. /**
  210. * Moves the observable to the top of the observer list making it get called first when notified
  211. * @param observer the observer to move
  212. */
  213. makeObserverTopPriority(observer: Observer<T>): void;
  214. /**
  215. * Moves the observable to the bottom of the observer list making it get called last when notified
  216. * @param observer the observer to move
  217. */
  218. makeObserverBottomPriority(observer: Observer<T>): void;
  219. /**
  220. * Notify all Observers by calling their respective callback with the given data
  221. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  222. * @param eventData defines the data to send to all observers
  223. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  224. * @param target defines the original target of the state
  225. * @param currentTarget defines the current target of the state
  226. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  227. */
  228. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  229. /**
  230. * Calling this will execute each callback, expecting it to be a promise or return a value.
  231. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  232. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  233. * and it is crucial that all callbacks will be executed.
  234. * The order of the callbacks is kept, callbacks are not executed parallel.
  235. *
  236. * @param eventData The data to be sent to each callback
  237. * @param mask is used to filter observers defaults to -1
  238. * @param target defines the callback target (see EventState)
  239. * @param currentTarget defines he current object in the bubbling phase
  240. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  241. */
  242. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  243. /**
  244. * Notify a specific observer
  245. * @param observer defines the observer to notify
  246. * @param eventData defines the data to be sent to each callback
  247. * @param mask is used to filter observers defaults to -1
  248. */
  249. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  250. /**
  251. * Gets a boolean indicating if the observable has at least one observer
  252. * @returns true is the Observable has at least one Observer registered
  253. */
  254. hasObservers(): boolean;
  255. /**
  256. * Clear the list of observers
  257. */
  258. clear(): void;
  259. /**
  260. * Clone the current observable
  261. * @returns a new observable
  262. */
  263. clone(): Observable<T>;
  264. /**
  265. * Does this observable handles observer registered with a given mask
  266. * @param mask defines the mask to be tested
  267. * @return whether or not one observer registered with the given mask is handeled
  268. **/
  269. hasSpecificMask(mask?: number): boolean;
  270. }
  271. }
  272. declare module "babylonjs/Misc/domManagement" {
  273. /**
  274. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  275. * Babylon.js
  276. */
  277. export class DomManagement {
  278. /**
  279. * Checks if the window object exists
  280. * @returns true if the window object exists
  281. */
  282. static IsWindowObjectExist(): boolean;
  283. /**
  284. * Checks if the navigator object exists
  285. * @returns true if the navigator object exists
  286. */
  287. static IsNavigatorAvailable(): boolean;
  288. /**
  289. * Extracts text content from a DOM element hierarchy
  290. * @param element defines the root element
  291. * @returns a string
  292. */
  293. static GetDOMTextContent(element: HTMLElement): string;
  294. }
  295. }
  296. declare module "babylonjs/Misc/logger" {
  297. /**
  298. * Logger used througouht the application to allow configuration of
  299. * the log level required for the messages.
  300. */
  301. export class Logger {
  302. /**
  303. * No log
  304. */
  305. static readonly NoneLogLevel: number;
  306. /**
  307. * Only message logs
  308. */
  309. static readonly MessageLogLevel: number;
  310. /**
  311. * Only warning logs
  312. */
  313. static readonly WarningLogLevel: number;
  314. /**
  315. * Only error logs
  316. */
  317. static readonly ErrorLogLevel: number;
  318. /**
  319. * All logs
  320. */
  321. static readonly AllLogLevel: number;
  322. private static _LogCache;
  323. /**
  324. * Gets a value indicating the number of loading errors
  325. * @ignorenaming
  326. */
  327. static errorsCount: number;
  328. /**
  329. * Callback called when a new log is added
  330. */
  331. static OnNewCacheEntry: (entry: string) => void;
  332. private static _AddLogEntry;
  333. private static _FormatMessage;
  334. private static _LogDisabled;
  335. private static _LogEnabled;
  336. private static _WarnDisabled;
  337. private static _WarnEnabled;
  338. private static _ErrorDisabled;
  339. private static _ErrorEnabled;
  340. /**
  341. * Log a message to the console
  342. */
  343. static Log: (message: string) => void;
  344. /**
  345. * Write a warning message to the console
  346. */
  347. static Warn: (message: string) => void;
  348. /**
  349. * Write an error message to the console
  350. */
  351. static Error: (message: string) => void;
  352. /**
  353. * Gets current log cache (list of logs)
  354. */
  355. static get LogCache(): string;
  356. /**
  357. * Clears the log cache
  358. */
  359. static ClearLogCache(): void;
  360. /**
  361. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  362. */
  363. static set LogLevels(level: number);
  364. }
  365. }
  366. declare module "babylonjs/Misc/typeStore" {
  367. /** @hidden */
  368. export class _TypeStore {
  369. /** @hidden */
  370. static RegisteredTypes: {
  371. [key: string]: Object;
  372. };
  373. /** @hidden */
  374. static GetClass(fqdn: string): any;
  375. }
  376. }
  377. declare module "babylonjs/Misc/stringTools" {
  378. /**
  379. * Helper to manipulate strings
  380. */
  381. export class StringTools {
  382. /**
  383. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  384. * @param str Source string
  385. * @param suffix Suffix to search for in the source string
  386. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  387. */
  388. static EndsWith(str: string, suffix: string): boolean;
  389. /**
  390. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  391. * @param str Source string
  392. * @param suffix Suffix to search for in the source string
  393. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  394. */
  395. static StartsWith(str: string, suffix: string): boolean;
  396. /**
  397. * Decodes a buffer into a string
  398. * @param buffer The buffer to decode
  399. * @returns The decoded string
  400. */
  401. static Decode(buffer: Uint8Array | Uint16Array): string;
  402. /**
  403. * Encode a buffer to a base64 string
  404. * @param buffer defines the buffer to encode
  405. * @returns the encoded string
  406. */
  407. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  408. /**
  409. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  410. * @param num the number to convert and pad
  411. * @param length the expected length of the string
  412. * @returns the padded string
  413. */
  414. static PadNumber(num: number, length: number): string;
  415. }
  416. }
  417. declare module "babylonjs/Misc/deepCopier" {
  418. /**
  419. * Class containing a set of static utilities functions for deep copy.
  420. */
  421. export class DeepCopier {
  422. /**
  423. * Tries to copy an object by duplicating every property
  424. * @param source defines the source object
  425. * @param destination defines the target object
  426. * @param doNotCopyList defines a list of properties to avoid
  427. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  428. */
  429. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  430. }
  431. }
  432. declare module "babylonjs/Misc/precisionDate" {
  433. /**
  434. * Class containing a set of static utilities functions for precision date
  435. */
  436. export class PrecisionDate {
  437. /**
  438. * Gets either window.performance.now() if supported or Date.now() else
  439. */
  440. static get Now(): number;
  441. }
  442. }
  443. declare module "babylonjs/Misc/devTools" {
  444. /** @hidden */
  445. export class _DevTools {
  446. static WarnImport(name: string): string;
  447. }
  448. }
  449. declare module "babylonjs/Misc/interfaces/iWebRequest" {
  450. /**
  451. * Interface used to define the mechanism to get data from the network
  452. */
  453. export interface IWebRequest {
  454. /**
  455. * Returns client's response url
  456. */
  457. responseURL: string;
  458. /**
  459. * Returns client's status
  460. */
  461. status: number;
  462. /**
  463. * Returns client's status as a text
  464. */
  465. statusText: string;
  466. }
  467. }
  468. declare module "babylonjs/Misc/webRequest" {
  469. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  470. import { Nullable } from "babylonjs/types";
  471. /**
  472. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  473. */
  474. export class WebRequest implements IWebRequest {
  475. private _xhr;
  476. /**
  477. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  478. * i.e. when loading files, where the server/service expects an Authorization header
  479. */
  480. static CustomRequestHeaders: {
  481. [key: string]: string;
  482. };
  483. /**
  484. * Add callback functions in this array to update all the requests before they get sent to the network
  485. */
  486. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  487. private _injectCustomRequestHeaders;
  488. /**
  489. * Gets or sets a function to be called when loading progress changes
  490. */
  491. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  492. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  493. /**
  494. * Returns client's state
  495. */
  496. get readyState(): number;
  497. /**
  498. * Returns client's status
  499. */
  500. get status(): number;
  501. /**
  502. * Returns client's status as a text
  503. */
  504. get statusText(): string;
  505. /**
  506. * Returns client's response
  507. */
  508. get response(): any;
  509. /**
  510. * Returns client's response url
  511. */
  512. get responseURL(): string;
  513. /**
  514. * Returns client's response as text
  515. */
  516. get responseText(): string;
  517. /**
  518. * Gets or sets the expected response type
  519. */
  520. get responseType(): XMLHttpRequestResponseType;
  521. set responseType(value: XMLHttpRequestResponseType);
  522. /** @hidden */
  523. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  524. /** @hidden */
  525. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  526. /**
  527. * Cancels any network activity
  528. */
  529. abort(): void;
  530. /**
  531. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  532. * @param body defines an optional request body
  533. */
  534. send(body?: Document | BodyInit | null): void;
  535. /**
  536. * Sets the request method, request URL
  537. * @param method defines the method to use (GET, POST, etc..)
  538. * @param url defines the url to connect with
  539. */
  540. open(method: string, url: string): void;
  541. /**
  542. * Sets the value of a request header.
  543. * @param name The name of the header whose value is to be set
  544. * @param value The value to set as the body of the header
  545. */
  546. setRequestHeader(name: string, value: string): void;
  547. /**
  548. * Get the string containing the text of a particular header's value.
  549. * @param name The name of the header
  550. * @returns The string containing the text of the given header name
  551. */
  552. getResponseHeader(name: string): Nullable<string>;
  553. }
  554. }
  555. declare module "babylonjs/Misc/fileRequest" {
  556. import { Observable } from "babylonjs/Misc/observable";
  557. /**
  558. * File request interface
  559. */
  560. export interface IFileRequest {
  561. /**
  562. * Raised when the request is complete (success or error).
  563. */
  564. onCompleteObservable: Observable<IFileRequest>;
  565. /**
  566. * Aborts the request for a file.
  567. */
  568. abort: () => void;
  569. }
  570. }
  571. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  572. /**
  573. * Define options used to create a render target texture
  574. */
  575. export class RenderTargetCreationOptions {
  576. /**
  577. * Specifies is mipmaps must be generated
  578. */
  579. generateMipMaps?: boolean;
  580. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  581. generateDepthBuffer?: boolean;
  582. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  583. generateStencilBuffer?: boolean;
  584. /** Defines texture type (int by default) */
  585. type?: number;
  586. /** Defines sampling mode (trilinear by default) */
  587. samplingMode?: number;
  588. /** Defines format (RGBA by default) */
  589. format?: number;
  590. }
  591. }
  592. declare module "babylonjs/Engines/constants" {
  593. /** Defines the cross module used constants to avoid circular dependncies */
  594. export class Constants {
  595. /** Defines that alpha blending is disabled */
  596. static readonly ALPHA_DISABLE: number;
  597. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  598. static readonly ALPHA_ADD: number;
  599. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  600. static readonly ALPHA_COMBINE: number;
  601. /** Defines that alpha blending is DEST - SRC * DEST */
  602. static readonly ALPHA_SUBTRACT: number;
  603. /** Defines that alpha blending is SRC * DEST */
  604. static readonly ALPHA_MULTIPLY: number;
  605. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  606. static readonly ALPHA_MAXIMIZED: number;
  607. /** Defines that alpha blending is SRC + DEST */
  608. static readonly ALPHA_ONEONE: number;
  609. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  610. static readonly ALPHA_PREMULTIPLIED: number;
  611. /**
  612. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  613. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  614. */
  615. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  616. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  617. static readonly ALPHA_INTERPOLATE: number;
  618. /**
  619. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  620. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  621. */
  622. static readonly ALPHA_SCREENMODE: number;
  623. /**
  624. * Defines that alpha blending is SRC + DST
  625. * Alpha will be set to SRC ALPHA + DST ALPHA
  626. */
  627. static readonly ALPHA_ONEONE_ONEONE: number;
  628. /**
  629. * Defines that alpha blending is SRC * DST ALPHA + DST
  630. * Alpha will be set to 0
  631. */
  632. static readonly ALPHA_ALPHATOCOLOR: number;
  633. /**
  634. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  635. */
  636. static readonly ALPHA_REVERSEONEMINUS: number;
  637. /**
  638. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  639. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  640. */
  641. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  642. /**
  643. * Defines that alpha blending is SRC + DST
  644. * Alpha will be set to SRC ALPHA
  645. */
  646. static readonly ALPHA_ONEONE_ONEZERO: number;
  647. /**
  648. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  649. * Alpha will be set to DST ALPHA
  650. */
  651. static readonly ALPHA_EXCLUSION: number;
  652. /** Defines that alpha blending equation a SUM */
  653. static readonly ALPHA_EQUATION_ADD: number;
  654. /** Defines that alpha blending equation a SUBSTRACTION */
  655. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  656. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  657. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  658. /** Defines that alpha blending equation a MAX operation */
  659. static readonly ALPHA_EQUATION_MAX: number;
  660. /** Defines that alpha blending equation a MIN operation */
  661. static readonly ALPHA_EQUATION_MIN: number;
  662. /**
  663. * Defines that alpha blending equation a DARKEN operation:
  664. * It takes the min of the src and sums the alpha channels.
  665. */
  666. static readonly ALPHA_EQUATION_DARKEN: number;
  667. /** Defines that the ressource is not delayed*/
  668. static readonly DELAYLOADSTATE_NONE: number;
  669. /** Defines that the ressource was successfully delay loaded */
  670. static readonly DELAYLOADSTATE_LOADED: number;
  671. /** Defines that the ressource is currently delay loading */
  672. static readonly DELAYLOADSTATE_LOADING: number;
  673. /** Defines that the ressource is delayed and has not started loading */
  674. static readonly DELAYLOADSTATE_NOTLOADED: number;
  675. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  676. static readonly NEVER: number;
  677. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  678. static readonly ALWAYS: number;
  679. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  680. static readonly LESS: number;
  681. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  682. static readonly EQUAL: number;
  683. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than or equal to the stored value */
  684. static readonly LEQUAL: number;
  685. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  686. static readonly GREATER: number;
  687. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than or equal to the stored value */
  688. static readonly GEQUAL: number;
  689. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is not equal to the stored value */
  690. static readonly NOTEQUAL: number;
  691. /** Passed to stencilOperation to specify that stencil value must be kept */
  692. static readonly KEEP: number;
  693. /** Passed to stencilOperation to specify that stencil value must be replaced */
  694. static readonly REPLACE: number;
  695. /** Passed to stencilOperation to specify that stencil value must be incremented */
  696. static readonly INCR: number;
  697. /** Passed to stencilOperation to specify that stencil value must be decremented */
  698. static readonly DECR: number;
  699. /** Passed to stencilOperation to specify that stencil value must be inverted */
  700. static readonly INVERT: number;
  701. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  702. static readonly INCR_WRAP: number;
  703. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  704. static readonly DECR_WRAP: number;
  705. /** Texture is not repeating outside of 0..1 UVs */
  706. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  707. /** Texture is repeating outside of 0..1 UVs */
  708. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  709. /** Texture is repeating and mirrored */
  710. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  711. /** ALPHA */
  712. static readonly TEXTUREFORMAT_ALPHA: number;
  713. /** LUMINANCE */
  714. static readonly TEXTUREFORMAT_LUMINANCE: number;
  715. /** LUMINANCE_ALPHA */
  716. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  717. /** RGB */
  718. static readonly TEXTUREFORMAT_RGB: number;
  719. /** RGBA */
  720. static readonly TEXTUREFORMAT_RGBA: number;
  721. /** RED */
  722. static readonly TEXTUREFORMAT_RED: number;
  723. /** RED (2nd reference) */
  724. static readonly TEXTUREFORMAT_R: number;
  725. /** RG */
  726. static readonly TEXTUREFORMAT_RG: number;
  727. /** RED_INTEGER */
  728. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  729. /** RED_INTEGER (2nd reference) */
  730. static readonly TEXTUREFORMAT_R_INTEGER: number;
  731. /** RG_INTEGER */
  732. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  733. /** RGB_INTEGER */
  734. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  735. /** RGBA_INTEGER */
  736. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  737. /** UNSIGNED_BYTE */
  738. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  739. /** UNSIGNED_BYTE (2nd reference) */
  740. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  741. /** FLOAT */
  742. static readonly TEXTURETYPE_FLOAT: number;
  743. /** HALF_FLOAT */
  744. static readonly TEXTURETYPE_HALF_FLOAT: number;
  745. /** BYTE */
  746. static readonly TEXTURETYPE_BYTE: number;
  747. /** SHORT */
  748. static readonly TEXTURETYPE_SHORT: number;
  749. /** UNSIGNED_SHORT */
  750. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  751. /** INT */
  752. static readonly TEXTURETYPE_INT: number;
  753. /** UNSIGNED_INT */
  754. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  755. /** UNSIGNED_SHORT_4_4_4_4 */
  756. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  757. /** UNSIGNED_SHORT_5_5_5_1 */
  758. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  759. /** UNSIGNED_SHORT_5_6_5 */
  760. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  761. /** UNSIGNED_INT_2_10_10_10_REV */
  762. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  763. /** UNSIGNED_INT_24_8 */
  764. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  765. /** UNSIGNED_INT_10F_11F_11F_REV */
  766. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  767. /** UNSIGNED_INT_5_9_9_9_REV */
  768. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  769. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  770. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  771. /** nearest is mag = nearest and min = nearest and no mip */
  772. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  773. /** mag = nearest and min = nearest and mip = none */
  774. static readonly TEXTURE_NEAREST_NEAREST: number;
  775. /** Bilinear is mag = linear and min = linear and no mip */
  776. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  777. /** mag = linear and min = linear and mip = none */
  778. static readonly TEXTURE_LINEAR_LINEAR: number;
  779. /** Trilinear is mag = linear and min = linear and mip = linear */
  780. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  781. /** Trilinear is mag = linear and min = linear and mip = linear */
  782. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  783. /** mag = nearest and min = nearest and mip = nearest */
  784. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  785. /** mag = nearest and min = linear and mip = nearest */
  786. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  787. /** mag = nearest and min = linear and mip = linear */
  788. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  789. /** mag = nearest and min = linear and mip = none */
  790. static readonly TEXTURE_NEAREST_LINEAR: number;
  791. /** nearest is mag = nearest and min = nearest and mip = linear */
  792. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  793. /** mag = linear and min = nearest and mip = nearest */
  794. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  795. /** mag = linear and min = nearest and mip = linear */
  796. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  797. /** Bilinear is mag = linear and min = linear and mip = nearest */
  798. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  799. /** mag = linear and min = nearest and mip = none */
  800. static readonly TEXTURE_LINEAR_NEAREST: number;
  801. /** Explicit coordinates mode */
  802. static readonly TEXTURE_EXPLICIT_MODE: number;
  803. /** Spherical coordinates mode */
  804. static readonly TEXTURE_SPHERICAL_MODE: number;
  805. /** Planar coordinates mode */
  806. static readonly TEXTURE_PLANAR_MODE: number;
  807. /** Cubic coordinates mode */
  808. static readonly TEXTURE_CUBIC_MODE: number;
  809. /** Projection coordinates mode */
  810. static readonly TEXTURE_PROJECTION_MODE: number;
  811. /** Skybox coordinates mode */
  812. static readonly TEXTURE_SKYBOX_MODE: number;
  813. /** Inverse Cubic coordinates mode */
  814. static readonly TEXTURE_INVCUBIC_MODE: number;
  815. /** Equirectangular coordinates mode */
  816. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  817. /** Equirectangular Fixed coordinates mode */
  818. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  819. /** Equirectangular Fixed Mirrored coordinates mode */
  820. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  821. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  822. static readonly SCALEMODE_FLOOR: number;
  823. /** Defines that texture rescaling will look for the nearest power of 2 size */
  824. static readonly SCALEMODE_NEAREST: number;
  825. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  826. static readonly SCALEMODE_CEILING: number;
  827. /**
  828. * The dirty texture flag value
  829. */
  830. static readonly MATERIAL_TextureDirtyFlag: number;
  831. /**
  832. * The dirty light flag value
  833. */
  834. static readonly MATERIAL_LightDirtyFlag: number;
  835. /**
  836. * The dirty fresnel flag value
  837. */
  838. static readonly MATERIAL_FresnelDirtyFlag: number;
  839. /**
  840. * The dirty attribute flag value
  841. */
  842. static readonly MATERIAL_AttributesDirtyFlag: number;
  843. /**
  844. * The dirty misc flag value
  845. */
  846. static readonly MATERIAL_MiscDirtyFlag: number;
  847. /**
  848. * The all dirty flag value
  849. */
  850. static readonly MATERIAL_AllDirtyFlag: number;
  851. /**
  852. * Returns the triangle fill mode
  853. */
  854. static readonly MATERIAL_TriangleFillMode: number;
  855. /**
  856. * Returns the wireframe mode
  857. */
  858. static readonly MATERIAL_WireFrameFillMode: number;
  859. /**
  860. * Returns the point fill mode
  861. */
  862. static readonly MATERIAL_PointFillMode: number;
  863. /**
  864. * Returns the point list draw mode
  865. */
  866. static readonly MATERIAL_PointListDrawMode: number;
  867. /**
  868. * Returns the line list draw mode
  869. */
  870. static readonly MATERIAL_LineListDrawMode: number;
  871. /**
  872. * Returns the line loop draw mode
  873. */
  874. static readonly MATERIAL_LineLoopDrawMode: number;
  875. /**
  876. * Returns the line strip draw mode
  877. */
  878. static readonly MATERIAL_LineStripDrawMode: number;
  879. /**
  880. * Returns the triangle strip draw mode
  881. */
  882. static readonly MATERIAL_TriangleStripDrawMode: number;
  883. /**
  884. * Returns the triangle fan draw mode
  885. */
  886. static readonly MATERIAL_TriangleFanDrawMode: number;
  887. /**
  888. * Stores the clock-wise side orientation
  889. */
  890. static readonly MATERIAL_ClockWiseSideOrientation: number;
  891. /**
  892. * Stores the counter clock-wise side orientation
  893. */
  894. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  895. /**
  896. * Nothing
  897. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  898. */
  899. static readonly ACTION_NothingTrigger: number;
  900. /**
  901. * On pick
  902. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  903. */
  904. static readonly ACTION_OnPickTrigger: number;
  905. /**
  906. * On left pick
  907. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  908. */
  909. static readonly ACTION_OnLeftPickTrigger: number;
  910. /**
  911. * On right pick
  912. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  913. */
  914. static readonly ACTION_OnRightPickTrigger: number;
  915. /**
  916. * On center pick
  917. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  918. */
  919. static readonly ACTION_OnCenterPickTrigger: number;
  920. /**
  921. * On pick down
  922. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  923. */
  924. static readonly ACTION_OnPickDownTrigger: number;
  925. /**
  926. * On double pick
  927. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  928. */
  929. static readonly ACTION_OnDoublePickTrigger: number;
  930. /**
  931. * On pick up
  932. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  933. */
  934. static readonly ACTION_OnPickUpTrigger: number;
  935. /**
  936. * On pick out.
  937. * This trigger will only be raised if you also declared a OnPickDown
  938. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  939. */
  940. static readonly ACTION_OnPickOutTrigger: number;
  941. /**
  942. * On long press
  943. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  944. */
  945. static readonly ACTION_OnLongPressTrigger: number;
  946. /**
  947. * On pointer over
  948. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  949. */
  950. static readonly ACTION_OnPointerOverTrigger: number;
  951. /**
  952. * On pointer out
  953. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  954. */
  955. static readonly ACTION_OnPointerOutTrigger: number;
  956. /**
  957. * On every frame
  958. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  959. */
  960. static readonly ACTION_OnEveryFrameTrigger: number;
  961. /**
  962. * On intersection enter
  963. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  964. */
  965. static readonly ACTION_OnIntersectionEnterTrigger: number;
  966. /**
  967. * On intersection exit
  968. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  969. */
  970. static readonly ACTION_OnIntersectionExitTrigger: number;
  971. /**
  972. * On key down
  973. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  974. */
  975. static readonly ACTION_OnKeyDownTrigger: number;
  976. /**
  977. * On key up
  978. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  979. */
  980. static readonly ACTION_OnKeyUpTrigger: number;
  981. /**
  982. * Billboard mode will only apply to Y axis
  983. */
  984. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  985. /**
  986. * Billboard mode will apply to all axes
  987. */
  988. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  989. /**
  990. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  991. */
  992. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  993. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  994. * Test order :
  995. * Is the bounding sphere outside the frustum ?
  996. * If not, are the bounding box vertices outside the frustum ?
  997. * It not, then the cullable object is in the frustum.
  998. */
  999. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  1000. /** Culling strategy : Bounding Sphere Only.
  1001. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  1002. * It's also less accurate than the standard because some not visible objects can still be selected.
  1003. * Test : is the bounding sphere outside the frustum ?
  1004. * If not, then the cullable object is in the frustum.
  1005. */
  1006. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  1007. /** Culling strategy : Optimistic Inclusion.
  1008. * This in an inclusion test first, then the standard exclusion test.
  1009. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  1010. * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside.
  1011. * Anyway, it's as accurate as the standard strategy.
  1012. * Test :
  1013. * Is the cullable object bounding sphere center in the frustum ?
  1014. * If not, apply the default culling strategy.
  1015. */
  1016. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  1017. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  1018. * This in an inclusion test first, then the bounding sphere only exclusion test.
  1019. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  1020. * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it.
  1021. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  1022. * Test :
  1023. * Is the cullable object bounding sphere center in the frustum ?
  1024. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  1025. */
  1026. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  1027. /**
  1028. * No logging while loading
  1029. */
  1030. static readonly SCENELOADER_NO_LOGGING: number;
  1031. /**
  1032. * Minimal logging while loading
  1033. */
  1034. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  1035. /**
  1036. * Summary logging while loading
  1037. */
  1038. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  1039. /**
  1040. * Detailled logging while loading
  1041. */
  1042. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1043. }
  1044. }
  1045. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  1046. import { Nullable } from "babylonjs/types";
  1047. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  1048. /**
  1049. * This represents the required contract to create a new type of texture loader.
  1050. */
  1051. export interface IInternalTextureLoader {
  1052. /**
  1053. * Defines wether the loader supports cascade loading the different faces.
  1054. */
  1055. supportCascades: boolean;
  1056. /**
  1057. * This returns if the loader support the current file information.
  1058. * @param extension defines the file extension of the file being loaded
  1059. * @returns true if the loader can load the specified file
  1060. */
  1061. canLoad(extension: string): boolean;
  1062. /**
  1063. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  1064. * @param data contains the texture data
  1065. * @param texture defines the BabylonJS internal texture
  1066. * @param createPolynomials will be true if polynomials have been requested
  1067. * @param onLoad defines the callback to trigger once the texture is ready
  1068. * @param onError defines the callback to trigger in case of error
  1069. */
  1070. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  1071. /**
  1072. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  1073. * @param data contains the texture data
  1074. * @param texture defines the BabylonJS internal texture
  1075. * @param callback defines the method to call once ready to upload
  1076. */
  1077. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  1078. }
  1079. }
  1080. declare module "babylonjs/Engines/IPipelineContext" {
  1081. /**
  1082. * Class used to store and describe the pipeline context associated with an effect
  1083. */
  1084. export interface IPipelineContext {
  1085. /**
  1086. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1087. */
  1088. isAsync: boolean;
  1089. /**
  1090. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1091. */
  1092. isReady: boolean;
  1093. /** @hidden */
  1094. _getVertexShaderCode(): string | null;
  1095. /** @hidden */
  1096. _getFragmentShaderCode(): string | null;
  1097. /** @hidden */
  1098. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1099. }
  1100. }
  1101. declare module "babylonjs/Meshes/dataBuffer" {
  1102. /**
  1103. * Class used to store gfx data (like WebGLBuffer)
  1104. */
  1105. export class DataBuffer {
  1106. /**
  1107. * Gets or sets the number of objects referencing this buffer
  1108. */
  1109. references: number;
  1110. /** Gets or sets the size of the underlying buffer */
  1111. capacity: number;
  1112. /**
  1113. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1114. */
  1115. is32Bits: boolean;
  1116. /**
  1117. * Gets the underlying buffer
  1118. */
  1119. get underlyingResource(): any;
  1120. }
  1121. }
  1122. declare module "babylonjs/Engines/Processors/iShaderProcessor" {
  1123. /** @hidden */
  1124. export interface IShaderProcessor {
  1125. attributeProcessor?: (attribute: string) => string;
  1126. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1127. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1128. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1129. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1130. lineProcessor?: (line: string, isFragment: boolean) => string;
  1131. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1132. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1133. }
  1134. }
  1135. declare module "babylonjs/Engines/Processors/shaderProcessingOptions" {
  1136. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  1137. /** @hidden */
  1138. export interface ProcessingOptions {
  1139. defines: string[];
  1140. indexParameters: any;
  1141. isFragment: boolean;
  1142. shouldUseHighPrecisionShader: boolean;
  1143. supportsUniformBuffers: boolean;
  1144. shadersRepository: string;
  1145. includesShadersStore: {
  1146. [key: string]: string;
  1147. };
  1148. processor?: IShaderProcessor;
  1149. version: string;
  1150. platformName: string;
  1151. lookForClosingBracketForUniformBuffer?: boolean;
  1152. }
  1153. }
  1154. declare module "babylonjs/Engines/Processors/shaderCodeNode" {
  1155. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1156. /** @hidden */
  1157. export class ShaderCodeNode {
  1158. line: string;
  1159. children: ShaderCodeNode[];
  1160. additionalDefineKey?: string;
  1161. additionalDefineValue?: string;
  1162. isValid(preprocessors: {
  1163. [key: string]: string;
  1164. }): boolean;
  1165. process(preprocessors: {
  1166. [key: string]: string;
  1167. }, options: ProcessingOptions): string;
  1168. }
  1169. }
  1170. declare module "babylonjs/Engines/Processors/shaderCodeCursor" {
  1171. /** @hidden */
  1172. export class ShaderCodeCursor {
  1173. private _lines;
  1174. lineIndex: number;
  1175. get currentLine(): string;
  1176. get canRead(): boolean;
  1177. set lines(value: string[]);
  1178. }
  1179. }
  1180. declare module "babylonjs/Engines/Processors/shaderCodeConditionNode" {
  1181. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1182. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1183. /** @hidden */
  1184. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1185. process(preprocessors: {
  1186. [key: string]: string;
  1187. }, options: ProcessingOptions): string;
  1188. }
  1189. }
  1190. declare module "babylonjs/Engines/Processors/Expressions/shaderDefineExpression" {
  1191. /** @hidden */
  1192. export class ShaderDefineExpression {
  1193. isTrue(preprocessors: {
  1194. [key: string]: string;
  1195. }): boolean;
  1196. private static _OperatorPriority;
  1197. private static _Stack;
  1198. static postfixToInfix(postfix: string[]): string;
  1199. static infixToPostfix(infix: string): string[];
  1200. }
  1201. }
  1202. declare module "babylonjs/Engines/Processors/shaderCodeTestNode" {
  1203. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1204. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1205. /** @hidden */
  1206. export class ShaderCodeTestNode extends ShaderCodeNode {
  1207. testExpression: ShaderDefineExpression;
  1208. isValid(preprocessors: {
  1209. [key: string]: string;
  1210. }): boolean;
  1211. }
  1212. }
  1213. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator" {
  1214. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1215. /** @hidden */
  1216. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1217. define: string;
  1218. not: boolean;
  1219. constructor(define: string, not?: boolean);
  1220. isTrue(preprocessors: {
  1221. [key: string]: string;
  1222. }): boolean;
  1223. }
  1224. }
  1225. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator" {
  1226. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1227. /** @hidden */
  1228. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1229. leftOperand: ShaderDefineExpression;
  1230. rightOperand: ShaderDefineExpression;
  1231. isTrue(preprocessors: {
  1232. [key: string]: string;
  1233. }): boolean;
  1234. }
  1235. }
  1236. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator" {
  1237. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1238. /** @hidden */
  1239. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1240. leftOperand: ShaderDefineExpression;
  1241. rightOperand: ShaderDefineExpression;
  1242. isTrue(preprocessors: {
  1243. [key: string]: string;
  1244. }): boolean;
  1245. }
  1246. }
  1247. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator" {
  1248. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1249. /** @hidden */
  1250. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1251. define: string;
  1252. operand: string;
  1253. testValue: string;
  1254. constructor(define: string, operand: string, testValue: string);
  1255. isTrue(preprocessors: {
  1256. [key: string]: string;
  1257. }): boolean;
  1258. }
  1259. }
  1260. declare module "babylonjs/Offline/IOfflineProvider" {
  1261. /**
  1262. * Class used to enable access to offline support
  1263. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1264. */
  1265. export interface IOfflineProvider {
  1266. /**
  1267. * Gets a boolean indicating if scene must be saved in the database
  1268. */
  1269. enableSceneOffline: boolean;
  1270. /**
  1271. * Gets a boolean indicating if textures must be saved in the database
  1272. */
  1273. enableTexturesOffline: boolean;
  1274. /**
  1275. * Open the offline support and make it available
  1276. * @param successCallback defines the callback to call on success
  1277. * @param errorCallback defines the callback to call on error
  1278. */
  1279. open(successCallback: () => void, errorCallback: () => void): void;
  1280. /**
  1281. * Loads an image from the offline support
  1282. * @param url defines the url to load from
  1283. * @param image defines the target DOM image
  1284. */
  1285. loadImage(url: string, image: HTMLImageElement): void;
  1286. /**
  1287. * Loads a file from offline support
  1288. * @param url defines the URL to load from
  1289. * @param sceneLoaded defines a callback to call on success
  1290. * @param progressCallBack defines a callback to call when progress changed
  1291. * @param errorCallback defines a callback to call on error
  1292. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1293. */
  1294. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1295. }
  1296. }
  1297. declare module "babylonjs/Misc/filesInputStore" {
  1298. /**
  1299. * Class used to help managing file picking and drag'n'drop
  1300. * File Storage
  1301. */
  1302. export class FilesInputStore {
  1303. /**
  1304. * List of files ready to be loaded
  1305. */
  1306. static FilesToLoad: {
  1307. [key: string]: File;
  1308. };
  1309. }
  1310. }
  1311. declare module "babylonjs/Misc/retryStrategy" {
  1312. import { WebRequest } from "babylonjs/Misc/webRequest";
  1313. /**
  1314. * Class used to define a retry strategy when error happens while loading assets
  1315. */
  1316. export class RetryStrategy {
  1317. /**
  1318. * Function used to defines an exponential back off strategy
  1319. * @param maxRetries defines the maximum number of retries (3 by default)
  1320. * @param baseInterval defines the interval between retries
  1321. * @returns the strategy function to use
  1322. */
  1323. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1324. }
  1325. }
  1326. declare module "babylonjs/Misc/baseError" {
  1327. /**
  1328. * @ignore
  1329. * Application error to support additional information when loading a file
  1330. */
  1331. export abstract class BaseError extends Error {
  1332. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1333. }
  1334. }
  1335. declare module "babylonjs/Misc/fileTools" {
  1336. import { WebRequest } from "babylonjs/Misc/webRequest";
  1337. import { Nullable } from "babylonjs/types";
  1338. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1339. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1340. import { BaseError } from "babylonjs/Misc/baseError";
  1341. /** @ignore */
  1342. export class LoadFileError extends BaseError {
  1343. request?: WebRequest;
  1344. file?: File;
  1345. /**
  1346. * Creates a new LoadFileError
  1347. * @param message defines the message of the error
  1348. * @param request defines the optional web request
  1349. * @param file defines the optional file
  1350. */
  1351. constructor(message: string, object?: WebRequest | File);
  1352. }
  1353. /** @ignore */
  1354. export class RequestFileError extends BaseError {
  1355. request: WebRequest;
  1356. /**
  1357. * Creates a new LoadFileError
  1358. * @param message defines the message of the error
  1359. * @param request defines the optional web request
  1360. */
  1361. constructor(message: string, request: WebRequest);
  1362. }
  1363. /** @ignore */
  1364. export class ReadFileError extends BaseError {
  1365. file: File;
  1366. /**
  1367. * Creates a new ReadFileError
  1368. * @param message defines the message of the error
  1369. * @param file defines the optional file
  1370. */
  1371. constructor(message: string, file: File);
  1372. }
  1373. /**
  1374. * @hidden
  1375. */
  1376. export class FileTools {
  1377. /**
  1378. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1379. */
  1380. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1381. /**
  1382. * Gets or sets the base URL to use to load assets
  1383. */
  1384. static BaseUrl: string;
  1385. /**
  1386. * Default behaviour for cors in the application.
  1387. * It can be a string if the expected behavior is identical in the entire app.
  1388. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1389. */
  1390. static CorsBehavior: string | ((url: string | string[]) => string);
  1391. /**
  1392. * Gets or sets a function used to pre-process url before using them to load assets
  1393. */
  1394. static PreprocessUrl: (url: string) => string;
  1395. /**
  1396. * Removes unwanted characters from an url
  1397. * @param url defines the url to clean
  1398. * @returns the cleaned url
  1399. */
  1400. private static _CleanUrl;
  1401. /**
  1402. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1403. * @param url define the url we are trying
  1404. * @param element define the dom element where to configure the cors policy
  1405. */
  1406. static SetCorsBehavior(url: string | string[], element: {
  1407. crossOrigin: string | null;
  1408. }): void;
  1409. /**
  1410. * Loads an image as an HTMLImageElement.
  1411. * @param input url string, ArrayBuffer, or Blob to load
  1412. * @param onLoad callback called when the image successfully loads
  1413. * @param onError callback called when the image fails to load
  1414. * @param offlineProvider offline provider for caching
  1415. * @param mimeType optional mime type
  1416. * @returns the HTMLImageElement of the loaded image
  1417. */
  1418. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  1419. /**
  1420. * Reads a file from a File object
  1421. * @param file defines the file to load
  1422. * @param onSuccess defines the callback to call when data is loaded
  1423. * @param onProgress defines the callback to call during loading process
  1424. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1425. * @param onError defines the callback to call when an error occurs
  1426. * @returns a file request object
  1427. */
  1428. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1429. /**
  1430. * Loads a file from a url
  1431. * @param url url to load
  1432. * @param onSuccess callback called when the file successfully loads
  1433. * @param onProgress callback called while file is loading (if the server supports this mode)
  1434. * @param offlineProvider defines the offline provider for caching
  1435. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1436. * @param onError callback called when the file fails to load
  1437. * @returns a file request object
  1438. */
  1439. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1440. /**
  1441. * Loads a file
  1442. * @param url url to load
  1443. * @param onSuccess callback called when the file successfully loads
  1444. * @param onProgress callback called while file is loading (if the server supports this mode)
  1445. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1446. * @param onError callback called when the file fails to load
  1447. * @param onOpened callback called when the web request is opened
  1448. * @returns a file request object
  1449. */
  1450. static RequestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (event: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  1451. /**
  1452. * Checks if the loaded document was accessed via `file:`-Protocol.
  1453. * @returns boolean
  1454. */
  1455. static IsFileURL(): boolean;
  1456. }
  1457. }
  1458. declare module "babylonjs/Engines/Processors/shaderProcessor" {
  1459. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1460. import { WebRequest } from "babylonjs/Misc/webRequest";
  1461. import { LoadFileError } from "babylonjs/Misc/fileTools";
  1462. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1463. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1464. /** @hidden */
  1465. export class ShaderProcessor {
  1466. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1467. private static _ProcessPrecision;
  1468. private static _ExtractOperation;
  1469. private static _BuildSubExpression;
  1470. private static _BuildExpression;
  1471. private static _MoveCursorWithinIf;
  1472. private static _MoveCursor;
  1473. private static _EvaluatePreProcessors;
  1474. private static _PreparePreProcessors;
  1475. private static _ProcessShaderConversion;
  1476. private static _ProcessIncludes;
  1477. /**
  1478. * Loads a file from a url
  1479. * @param url url to load
  1480. * @param onSuccess callback called when the file successfully loads
  1481. * @param onProgress callback called while file is loading (if the server supports this mode)
  1482. * @param offlineProvider defines the offline provider for caching
  1483. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1484. * @param onError callback called when the file fails to load
  1485. * @returns a file request object
  1486. * @hidden
  1487. */
  1488. static _FileToolsLoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1489. }
  1490. }
  1491. declare module "babylonjs/Maths/math.like" {
  1492. import { float, int, DeepImmutable } from "babylonjs/types";
  1493. /**
  1494. * @hidden
  1495. */
  1496. export interface IColor4Like {
  1497. r: float;
  1498. g: float;
  1499. b: float;
  1500. a: float;
  1501. }
  1502. /**
  1503. * @hidden
  1504. */
  1505. export interface IColor3Like {
  1506. r: float;
  1507. g: float;
  1508. b: float;
  1509. }
  1510. /**
  1511. * @hidden
  1512. */
  1513. export interface IVector4Like {
  1514. x: float;
  1515. y: float;
  1516. z: float;
  1517. w: float;
  1518. }
  1519. /**
  1520. * @hidden
  1521. */
  1522. export interface IVector3Like {
  1523. x: float;
  1524. y: float;
  1525. z: float;
  1526. }
  1527. /**
  1528. * @hidden
  1529. */
  1530. export interface IVector2Like {
  1531. x: float;
  1532. y: float;
  1533. }
  1534. /**
  1535. * @hidden
  1536. */
  1537. export interface IMatrixLike {
  1538. toArray(): DeepImmutable<Float32Array>;
  1539. updateFlag: int;
  1540. }
  1541. /**
  1542. * @hidden
  1543. */
  1544. export interface IViewportLike {
  1545. x: float;
  1546. y: float;
  1547. width: float;
  1548. height: float;
  1549. }
  1550. /**
  1551. * @hidden
  1552. */
  1553. export interface IPlaneLike {
  1554. normal: IVector3Like;
  1555. d: float;
  1556. normalize(): void;
  1557. }
  1558. }
  1559. declare module "babylonjs/Materials/iEffectFallbacks" {
  1560. import { Effect } from "babylonjs/Materials/effect";
  1561. /**
  1562. * Interface used to define common properties for effect fallbacks
  1563. */
  1564. export interface IEffectFallbacks {
  1565. /**
  1566. * Removes the defines that should be removed when falling back.
  1567. * @param currentDefines defines the current define statements for the shader.
  1568. * @param effect defines the current effect we try to compile
  1569. * @returns The resulting defines with defines of the current rank removed.
  1570. */
  1571. reduce(currentDefines: string, effect: Effect): string;
  1572. /**
  1573. * Removes the fallback from the bound mesh.
  1574. */
  1575. unBindMesh(): void;
  1576. /**
  1577. * Checks to see if more fallbacks are still availible.
  1578. */
  1579. hasMoreFallbacks: boolean;
  1580. }
  1581. }
  1582. declare module "babylonjs/Misc/andOrNotEvaluator" {
  1583. /**
  1584. * Class used to evalaute queries containing `and` and `or` operators
  1585. */
  1586. export class AndOrNotEvaluator {
  1587. /**
  1588. * Evaluate a query
  1589. * @param query defines the query to evaluate
  1590. * @param evaluateCallback defines the callback used to filter result
  1591. * @returns true if the query matches
  1592. */
  1593. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1594. private static _HandleParenthesisContent;
  1595. private static _SimplifyNegation;
  1596. }
  1597. }
  1598. declare module "babylonjs/Misc/tags" {
  1599. /**
  1600. * Class used to store custom tags
  1601. */
  1602. export class Tags {
  1603. /**
  1604. * Adds support for tags on the given object
  1605. * @param obj defines the object to use
  1606. */
  1607. static EnableFor(obj: any): void;
  1608. /**
  1609. * Removes tags support
  1610. * @param obj defines the object to use
  1611. */
  1612. static DisableFor(obj: any): void;
  1613. /**
  1614. * Gets a boolean indicating if the given object has tags
  1615. * @param obj defines the object to use
  1616. * @returns a boolean
  1617. */
  1618. static HasTags(obj: any): boolean;
  1619. /**
  1620. * Gets the tags available on a given object
  1621. * @param obj defines the object to use
  1622. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1623. * @returns the tags
  1624. */
  1625. static GetTags(obj: any, asString?: boolean): any;
  1626. /**
  1627. * Adds tags to an object
  1628. * @param obj defines the object to use
  1629. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1630. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1631. */
  1632. static AddTagsTo(obj: any, tagsString: string): void;
  1633. /**
  1634. * @hidden
  1635. */
  1636. static _AddTagTo(obj: any, tag: string): void;
  1637. /**
  1638. * Removes specific tags from a specific object
  1639. * @param obj defines the object to use
  1640. * @param tagsString defines the tags to remove
  1641. */
  1642. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1643. /**
  1644. * @hidden
  1645. */
  1646. static _RemoveTagFrom(obj: any, tag: string): void;
  1647. /**
  1648. * Defines if tags hosted on an object match a given query
  1649. * @param obj defines the object to use
  1650. * @param tagsQuery defines the tag query
  1651. * @returns a boolean
  1652. */
  1653. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1654. }
  1655. }
  1656. declare module "babylonjs/Maths/math.scalar" {
  1657. /**
  1658. * Scalar computation library
  1659. */
  1660. export class Scalar {
  1661. /**
  1662. * Two pi constants convenient for computation.
  1663. */
  1664. static TwoPi: number;
  1665. /**
  1666. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1667. * @param a number
  1668. * @param b number
  1669. * @param epsilon (default = 1.401298E-45)
  1670. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1671. */
  1672. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1673. /**
  1674. * Returns a string : the upper case translation of the number i to hexadecimal.
  1675. * @param i number
  1676. * @returns the upper case translation of the number i to hexadecimal.
  1677. */
  1678. static ToHex(i: number): string;
  1679. /**
  1680. * Returns -1 if value is negative and +1 is value is positive.
  1681. * @param value the value
  1682. * @returns the value itself if it's equal to zero.
  1683. */
  1684. static Sign(value: number): number;
  1685. /**
  1686. * Returns the value itself if it's between min and max.
  1687. * Returns min if the value is lower than min.
  1688. * Returns max if the value is greater than max.
  1689. * @param value the value to clmap
  1690. * @param min the min value to clamp to (default: 0)
  1691. * @param max the max value to clamp to (default: 1)
  1692. * @returns the clamped value
  1693. */
  1694. static Clamp(value: number, min?: number, max?: number): number;
  1695. /**
  1696. * the log2 of value.
  1697. * @param value the value to compute log2 of
  1698. * @returns the log2 of value.
  1699. */
  1700. static Log2(value: number): number;
  1701. /**
  1702. * Loops the value, so that it is never larger than length and never smaller than 0.
  1703. *
  1704. * This is similar to the modulo operator but it works with floating point numbers.
  1705. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1706. * With t = 5 and length = 2.5, the result would be 0.0.
  1707. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1708. * @param value the value
  1709. * @param length the length
  1710. * @returns the looped value
  1711. */
  1712. static Repeat(value: number, length: number): number;
  1713. /**
  1714. * Normalize the value between 0.0 and 1.0 using min and max values
  1715. * @param value value to normalize
  1716. * @param min max to normalize between
  1717. * @param max min to normalize between
  1718. * @returns the normalized value
  1719. */
  1720. static Normalize(value: number, min: number, max: number): number;
  1721. /**
  1722. * Denormalize the value from 0.0 and 1.0 using min and max values
  1723. * @param normalized value to denormalize
  1724. * @param min max to denormalize between
  1725. * @param max min to denormalize between
  1726. * @returns the denormalized value
  1727. */
  1728. static Denormalize(normalized: number, min: number, max: number): number;
  1729. /**
  1730. * Calculates the shortest difference between two given angles given in degrees.
  1731. * @param current current angle in degrees
  1732. * @param target target angle in degrees
  1733. * @returns the delta
  1734. */
  1735. static DeltaAngle(current: number, target: number): number;
  1736. /**
  1737. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1738. * @param tx value
  1739. * @param length length
  1740. * @returns The returned value will move back and forth between 0 and length
  1741. */
  1742. static PingPong(tx: number, length: number): number;
  1743. /**
  1744. * Interpolates between min and max with smoothing at the limits.
  1745. *
  1746. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1747. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1748. * @param from from
  1749. * @param to to
  1750. * @param tx value
  1751. * @returns the smooth stepped value
  1752. */
  1753. static SmoothStep(from: number, to: number, tx: number): number;
  1754. /**
  1755. * Moves a value current towards target.
  1756. *
  1757. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1758. * Negative values of maxDelta pushes the value away from target.
  1759. * @param current current value
  1760. * @param target target value
  1761. * @param maxDelta max distance to move
  1762. * @returns resulting value
  1763. */
  1764. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1765. /**
  1766. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1767. *
  1768. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1769. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1770. * @param current current value
  1771. * @param target target value
  1772. * @param maxDelta max distance to move
  1773. * @returns resulting angle
  1774. */
  1775. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1776. /**
  1777. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1778. * @param start start value
  1779. * @param end target value
  1780. * @param amount amount to lerp between
  1781. * @returns the lerped value
  1782. */
  1783. static Lerp(start: number, end: number, amount: number): number;
  1784. /**
  1785. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1786. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1787. * @param start start value
  1788. * @param end target value
  1789. * @param amount amount to lerp between
  1790. * @returns the lerped value
  1791. */
  1792. static LerpAngle(start: number, end: number, amount: number): number;
  1793. /**
  1794. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1795. * @param a start value
  1796. * @param b target value
  1797. * @param value value between a and b
  1798. * @returns the inverseLerp value
  1799. */
  1800. static InverseLerp(a: number, b: number, value: number): number;
  1801. /**
  1802. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1803. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1804. * @param value1 spline value
  1805. * @param tangent1 spline value
  1806. * @param value2 spline value
  1807. * @param tangent2 spline value
  1808. * @param amount input value
  1809. * @returns hermite result
  1810. */
  1811. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1812. /**
  1813. * Returns a random float number between and min and max values
  1814. * @param min min value of random
  1815. * @param max max value of random
  1816. * @returns random value
  1817. */
  1818. static RandomRange(min: number, max: number): number;
  1819. /**
  1820. * This function returns percentage of a number in a given range.
  1821. *
  1822. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1823. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1824. * @param number to convert to percentage
  1825. * @param min min range
  1826. * @param max max range
  1827. * @returns the percentage
  1828. */
  1829. static RangeToPercent(number: number, min: number, max: number): number;
  1830. /**
  1831. * This function returns number that corresponds to the percentage in a given range.
  1832. *
  1833. * PercentToRange(0.34,0,100) will return 34.
  1834. * @param percent to convert to number
  1835. * @param min min range
  1836. * @param max max range
  1837. * @returns the number
  1838. */
  1839. static PercentToRange(percent: number, min: number, max: number): number;
  1840. /**
  1841. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1842. * @param angle The angle to normalize in radian.
  1843. * @return The converted angle.
  1844. */
  1845. static NormalizeRadians(angle: number): number;
  1846. }
  1847. }
  1848. declare module "babylonjs/Maths/math.constants" {
  1849. /**
  1850. * Constant used to convert a value to gamma space
  1851. * @ignorenaming
  1852. */
  1853. export const ToGammaSpace: number;
  1854. /**
  1855. * Constant used to convert a value to linear space
  1856. * @ignorenaming
  1857. */
  1858. export const ToLinearSpace = 2.2;
  1859. /**
  1860. * Constant used to define the minimal number value in Babylon.js
  1861. * @ignorenaming
  1862. */
  1863. let Epsilon: number;
  1864. export { Epsilon };
  1865. }
  1866. declare module "babylonjs/Maths/math.viewport" {
  1867. /**
  1868. * Class used to represent a viewport on screen
  1869. */
  1870. export class Viewport {
  1871. /** viewport left coordinate */
  1872. x: number;
  1873. /** viewport top coordinate */
  1874. y: number;
  1875. /**viewport width */
  1876. width: number;
  1877. /** viewport height */
  1878. height: number;
  1879. /**
  1880. * Creates a Viewport object located at (x, y) and sized (width, height)
  1881. * @param x defines viewport left coordinate
  1882. * @param y defines viewport top coordinate
  1883. * @param width defines the viewport width
  1884. * @param height defines the viewport height
  1885. */
  1886. constructor(
  1887. /** viewport left coordinate */
  1888. x: number,
  1889. /** viewport top coordinate */
  1890. y: number,
  1891. /**viewport width */
  1892. width: number,
  1893. /** viewport height */
  1894. height: number);
  1895. /**
  1896. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1897. * @param renderWidth defines the rendering width
  1898. * @param renderHeight defines the rendering height
  1899. * @returns a new Viewport
  1900. */
  1901. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1902. /**
  1903. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1904. * @param renderWidth defines the rendering width
  1905. * @param renderHeight defines the rendering height
  1906. * @param ref defines the target viewport
  1907. * @returns the current viewport
  1908. */
  1909. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1910. /**
  1911. * Returns a new Viewport copied from the current one
  1912. * @returns a new Viewport
  1913. */
  1914. clone(): Viewport;
  1915. }
  1916. }
  1917. declare module "babylonjs/Misc/arrayTools" {
  1918. /**
  1919. * Class containing a set of static utilities functions for arrays.
  1920. */
  1921. export class ArrayTools {
  1922. /**
  1923. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1924. * @param size the number of element to construct and put in the array
  1925. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1926. * @returns a new array filled with new objects
  1927. */
  1928. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1929. }
  1930. }
  1931. declare module "babylonjs/Maths/math.vector" {
  1932. import { Viewport } from "babylonjs/Maths/math.viewport";
  1933. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  1934. import { IPlaneLike } from "babylonjs/Maths/math.like";
  1935. /**
  1936. * Class representing a vector containing 2 coordinates
  1937. */
  1938. export class Vector2 {
  1939. /** defines the first coordinate */
  1940. x: number;
  1941. /** defines the second coordinate */
  1942. y: number;
  1943. /**
  1944. * Creates a new Vector2 from the given x and y coordinates
  1945. * @param x defines the first coordinate
  1946. * @param y defines the second coordinate
  1947. */
  1948. constructor(
  1949. /** defines the first coordinate */
  1950. x?: number,
  1951. /** defines the second coordinate */
  1952. y?: number);
  1953. /**
  1954. * Gets a string with the Vector2 coordinates
  1955. * @returns a string with the Vector2 coordinates
  1956. */
  1957. toString(): string;
  1958. /**
  1959. * Gets class name
  1960. * @returns the string "Vector2"
  1961. */
  1962. getClassName(): string;
  1963. /**
  1964. * Gets current vector hash code
  1965. * @returns the Vector2 hash code as a number
  1966. */
  1967. getHashCode(): number;
  1968. /**
  1969. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  1970. * @param array defines the source array
  1971. * @param index defines the offset in source array
  1972. * @returns the current Vector2
  1973. */
  1974. toArray(array: FloatArray, index?: number): Vector2;
  1975. /**
  1976. * Copy the current vector to an array
  1977. * @returns a new array with 2 elements: the Vector2 coordinates.
  1978. */
  1979. asArray(): number[];
  1980. /**
  1981. * Sets the Vector2 coordinates with the given Vector2 coordinates
  1982. * @param source defines the source Vector2
  1983. * @returns the current updated Vector2
  1984. */
  1985. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  1986. /**
  1987. * Sets the Vector2 coordinates with the given floats
  1988. * @param x defines the first coordinate
  1989. * @param y defines the second coordinate
  1990. * @returns the current updated Vector2
  1991. */
  1992. copyFromFloats(x: number, y: number): Vector2;
  1993. /**
  1994. * Sets the Vector2 coordinates with the given floats
  1995. * @param x defines the first coordinate
  1996. * @param y defines the second coordinate
  1997. * @returns the current updated Vector2
  1998. */
  1999. set(x: number, y: number): Vector2;
  2000. /**
  2001. * Add another vector with the current one
  2002. * @param otherVector defines the other vector
  2003. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  2004. */
  2005. add(otherVector: DeepImmutable<Vector2>): Vector2;
  2006. /**
  2007. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  2008. * @param otherVector defines the other vector
  2009. * @param result defines the target vector
  2010. * @returns the unmodified current Vector2
  2011. */
  2012. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2013. /**
  2014. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  2015. * @param otherVector defines the other vector
  2016. * @returns the current updated Vector2
  2017. */
  2018. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2019. /**
  2020. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  2021. * @param otherVector defines the other vector
  2022. * @returns a new Vector2
  2023. */
  2024. addVector3(otherVector: Vector3): Vector2;
  2025. /**
  2026. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  2027. * @param otherVector defines the other vector
  2028. * @returns a new Vector2
  2029. */
  2030. subtract(otherVector: Vector2): Vector2;
  2031. /**
  2032. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2033. * @param otherVector defines the other vector
  2034. * @param result defines the target vector
  2035. * @returns the unmodified current Vector2
  2036. */
  2037. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2038. /**
  2039. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2040. * @param otherVector defines the other vector
  2041. * @returns the current updated Vector2
  2042. */
  2043. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2044. /**
  2045. * Multiplies in place the current Vector2 coordinates by the given ones
  2046. * @param otherVector defines the other vector
  2047. * @returns the current updated Vector2
  2048. */
  2049. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2050. /**
  2051. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2052. * @param otherVector defines the other vector
  2053. * @returns a new Vector2
  2054. */
  2055. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2056. /**
  2057. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2058. * @param otherVector defines the other vector
  2059. * @param result defines the target vector
  2060. * @returns the unmodified current Vector2
  2061. */
  2062. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2063. /**
  2064. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2065. * @param x defines the first coordinate
  2066. * @param y defines the second coordinate
  2067. * @returns a new Vector2
  2068. */
  2069. multiplyByFloats(x: number, y: number): Vector2;
  2070. /**
  2071. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2072. * @param otherVector defines the other vector
  2073. * @returns a new Vector2
  2074. */
  2075. divide(otherVector: Vector2): Vector2;
  2076. /**
  2077. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2078. * @param otherVector defines the other vector
  2079. * @param result defines the target vector
  2080. * @returns the unmodified current Vector2
  2081. */
  2082. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2083. /**
  2084. * Divides the current Vector2 coordinates by the given ones
  2085. * @param otherVector defines the other vector
  2086. * @returns the current updated Vector2
  2087. */
  2088. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2089. /**
  2090. * Gets a new Vector2 with current Vector2 negated coordinates
  2091. * @returns a new Vector2
  2092. */
  2093. negate(): Vector2;
  2094. /**
  2095. * Negate this vector in place
  2096. * @returns this
  2097. */
  2098. negateInPlace(): Vector2;
  2099. /**
  2100. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  2101. * @param result defines the Vector3 object where to store the result
  2102. * @returns the current Vector2
  2103. */
  2104. negateToRef(result: Vector2): Vector2;
  2105. /**
  2106. * Multiply the Vector2 coordinates by scale
  2107. * @param scale defines the scaling factor
  2108. * @returns the current updated Vector2
  2109. */
  2110. scaleInPlace(scale: number): Vector2;
  2111. /**
  2112. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2113. * @param scale defines the scaling factor
  2114. * @returns a new Vector2
  2115. */
  2116. scale(scale: number): Vector2;
  2117. /**
  2118. * Scale the current Vector2 values by a factor to a given Vector2
  2119. * @param scale defines the scale factor
  2120. * @param result defines the Vector2 object where to store the result
  2121. * @returns the unmodified current Vector2
  2122. */
  2123. scaleToRef(scale: number, result: Vector2): Vector2;
  2124. /**
  2125. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2126. * @param scale defines the scale factor
  2127. * @param result defines the Vector2 object where to store the result
  2128. * @returns the unmodified current Vector2
  2129. */
  2130. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2131. /**
  2132. * Gets a boolean if two vectors are equals
  2133. * @param otherVector defines the other vector
  2134. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2135. */
  2136. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2137. /**
  2138. * Gets a boolean if two vectors are equals (using an epsilon value)
  2139. * @param otherVector defines the other vector
  2140. * @param epsilon defines the minimal distance to consider equality
  2141. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2142. */
  2143. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2144. /**
  2145. * Gets a new Vector2 from current Vector2 floored values
  2146. * @returns a new Vector2
  2147. */
  2148. floor(): Vector2;
  2149. /**
  2150. * Gets a new Vector2 from current Vector2 floored values
  2151. * @returns a new Vector2
  2152. */
  2153. fract(): Vector2;
  2154. /**
  2155. * Gets the length of the vector
  2156. * @returns the vector length (float)
  2157. */
  2158. length(): number;
  2159. /**
  2160. * Gets the vector squared length
  2161. * @returns the vector squared length (float)
  2162. */
  2163. lengthSquared(): number;
  2164. /**
  2165. * Normalize the vector
  2166. * @returns the current updated Vector2
  2167. */
  2168. normalize(): Vector2;
  2169. /**
  2170. * Gets a new Vector2 copied from the Vector2
  2171. * @returns a new Vector2
  2172. */
  2173. clone(): Vector2;
  2174. /**
  2175. * Gets a new Vector2(0, 0)
  2176. * @returns a new Vector2
  2177. */
  2178. static Zero(): Vector2;
  2179. /**
  2180. * Gets a new Vector2(1, 1)
  2181. * @returns a new Vector2
  2182. */
  2183. static One(): Vector2;
  2184. /**
  2185. * Gets a new Vector2 set from the given index element of the given array
  2186. * @param array defines the data source
  2187. * @param offset defines the offset in the data source
  2188. * @returns a new Vector2
  2189. */
  2190. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2191. /**
  2192. * Sets "result" from the given index element of the given array
  2193. * @param array defines the data source
  2194. * @param offset defines the offset in the data source
  2195. * @param result defines the target vector
  2196. */
  2197. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2198. /**
  2199. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2200. * @param value1 defines 1st point of control
  2201. * @param value2 defines 2nd point of control
  2202. * @param value3 defines 3rd point of control
  2203. * @param value4 defines 4th point of control
  2204. * @param amount defines the interpolation factor
  2205. * @returns a new Vector2
  2206. */
  2207. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2208. /**
  2209. * Returns a new Vector2 set with same the coordinates than "value" ones if the vector "value" is in the square defined by "min" and "max".
  2210. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2211. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2212. * @param value defines the value to clamp
  2213. * @param min defines the lower limit
  2214. * @param max defines the upper limit
  2215. * @returns a new Vector2
  2216. */
  2217. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2218. /**
  2219. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2220. * @param value1 defines the 1st control point
  2221. * @param tangent1 defines the outgoing tangent
  2222. * @param value2 defines the 2nd control point
  2223. * @param tangent2 defines the incoming tangent
  2224. * @param amount defines the interpolation factor
  2225. * @returns a new Vector2
  2226. */
  2227. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2228. /**
  2229. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2230. * @param start defines the start vector
  2231. * @param end defines the end vector
  2232. * @param amount defines the interpolation factor
  2233. * @returns a new Vector2
  2234. */
  2235. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2236. /**
  2237. * Gets the dot product of the vector "left" and the vector "right"
  2238. * @param left defines first vector
  2239. * @param right defines second vector
  2240. * @returns the dot product (float)
  2241. */
  2242. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2243. /**
  2244. * Returns a new Vector2 equal to the normalized given vector
  2245. * @param vector defines the vector to normalize
  2246. * @returns a new Vector2
  2247. */
  2248. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2249. /**
  2250. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2251. * @param left defines 1st vector
  2252. * @param right defines 2nd vector
  2253. * @returns a new Vector2
  2254. */
  2255. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2256. /**
  2257. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2258. * @param left defines 1st vector
  2259. * @param right defines 2nd vector
  2260. * @returns a new Vector2
  2261. */
  2262. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2263. /**
  2264. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2265. * @param vector defines the vector to transform
  2266. * @param transformation defines the matrix to apply
  2267. * @returns a new Vector2
  2268. */
  2269. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2270. /**
  2271. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2272. * @param vector defines the vector to transform
  2273. * @param transformation defines the matrix to apply
  2274. * @param result defines the target vector
  2275. */
  2276. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2277. /**
  2278. * Determines if a given vector is included in a triangle
  2279. * @param p defines the vector to test
  2280. * @param p0 defines 1st triangle point
  2281. * @param p1 defines 2nd triangle point
  2282. * @param p2 defines 3rd triangle point
  2283. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2284. */
  2285. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2286. /**
  2287. * Gets the distance between the vectors "value1" and "value2"
  2288. * @param value1 defines first vector
  2289. * @param value2 defines second vector
  2290. * @returns the distance between vectors
  2291. */
  2292. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2293. /**
  2294. * Returns the squared distance between the vectors "value1" and "value2"
  2295. * @param value1 defines first vector
  2296. * @param value2 defines second vector
  2297. * @returns the squared distance between vectors
  2298. */
  2299. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2300. /**
  2301. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2302. * @param value1 defines first vector
  2303. * @param value2 defines second vector
  2304. * @returns a new Vector2
  2305. */
  2306. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2307. /**
  2308. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2309. * @param p defines the middle point
  2310. * @param segA defines one point of the segment
  2311. * @param segB defines the other point of the segment
  2312. * @returns the shortest distance
  2313. */
  2314. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2315. }
  2316. /**
  2317. * Class used to store (x,y,z) vector representation
  2318. * A Vector3 is the main object used in 3D geometry
  2319. * It can represent etiher the coordinates of a point the space, either a direction
  2320. * Reminder: js uses a left handed forward facing system
  2321. */
  2322. export class Vector3 {
  2323. /**
  2324. * Defines the first coordinates (on X axis)
  2325. */
  2326. x: number;
  2327. /**
  2328. * Defines the second coordinates (on Y axis)
  2329. */
  2330. y: number;
  2331. /**
  2332. * Defines the third coordinates (on Z axis)
  2333. */
  2334. z: number;
  2335. private static _UpReadOnly;
  2336. private static _ZeroReadOnly;
  2337. /**
  2338. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2339. * @param x defines the first coordinates (on X axis)
  2340. * @param y defines the second coordinates (on Y axis)
  2341. * @param z defines the third coordinates (on Z axis)
  2342. */
  2343. constructor(
  2344. /**
  2345. * Defines the first coordinates (on X axis)
  2346. */
  2347. x?: number,
  2348. /**
  2349. * Defines the second coordinates (on Y axis)
  2350. */
  2351. y?: number,
  2352. /**
  2353. * Defines the third coordinates (on Z axis)
  2354. */
  2355. z?: number);
  2356. /**
  2357. * Creates a string representation of the Vector3
  2358. * @returns a string with the Vector3 coordinates.
  2359. */
  2360. toString(): string;
  2361. /**
  2362. * Gets the class name
  2363. * @returns the string "Vector3"
  2364. */
  2365. getClassName(): string;
  2366. /**
  2367. * Creates the Vector3 hash code
  2368. * @returns a number which tends to be unique between Vector3 instances
  2369. */
  2370. getHashCode(): number;
  2371. /**
  2372. * Creates an array containing three elements : the coordinates of the Vector3
  2373. * @returns a new array of numbers
  2374. */
  2375. asArray(): number[];
  2376. /**
  2377. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2378. * @param array defines the destination array
  2379. * @param index defines the offset in the destination array
  2380. * @returns the current Vector3
  2381. */
  2382. toArray(array: FloatArray, index?: number): Vector3;
  2383. /**
  2384. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2385. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2386. */
  2387. toQuaternion(): Quaternion;
  2388. /**
  2389. * Adds the given vector to the current Vector3
  2390. * @param otherVector defines the second operand
  2391. * @returns the current updated Vector3
  2392. */
  2393. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2394. /**
  2395. * Adds the given coordinates to the current Vector3
  2396. * @param x defines the x coordinate of the operand
  2397. * @param y defines the y coordinate of the operand
  2398. * @param z defines the z coordinate of the operand
  2399. * @returns the current updated Vector3
  2400. */
  2401. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2402. /**
  2403. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2404. * @param otherVector defines the second operand
  2405. * @returns the resulting Vector3
  2406. */
  2407. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2408. /**
  2409. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2410. * @param otherVector defines the second operand
  2411. * @param result defines the Vector3 object where to store the result
  2412. * @returns the current Vector3
  2413. */
  2414. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2415. /**
  2416. * Subtract the given vector from the current Vector3
  2417. * @param otherVector defines the second operand
  2418. * @returns the current updated Vector3
  2419. */
  2420. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2421. /**
  2422. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2423. * @param otherVector defines the second operand
  2424. * @returns the resulting Vector3
  2425. */
  2426. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2427. /**
  2428. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2429. * @param otherVector defines the second operand
  2430. * @param result defines the Vector3 object where to store the result
  2431. * @returns the current Vector3
  2432. */
  2433. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2434. /**
  2435. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2436. * @param x defines the x coordinate of the operand
  2437. * @param y defines the y coordinate of the operand
  2438. * @param z defines the z coordinate of the operand
  2439. * @returns the resulting Vector3
  2440. */
  2441. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2442. /**
  2443. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2444. * @param x defines the x coordinate of the operand
  2445. * @param y defines the y coordinate of the operand
  2446. * @param z defines the z coordinate of the operand
  2447. * @param result defines the Vector3 object where to store the result
  2448. * @returns the current Vector3
  2449. */
  2450. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2451. /**
  2452. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2453. * @returns a new Vector3
  2454. */
  2455. negate(): Vector3;
  2456. /**
  2457. * Negate this vector in place
  2458. * @returns this
  2459. */
  2460. negateInPlace(): Vector3;
  2461. /**
  2462. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  2463. * @param result defines the Vector3 object where to store the result
  2464. * @returns the current Vector3
  2465. */
  2466. negateToRef(result: Vector3): Vector3;
  2467. /**
  2468. * Multiplies the Vector3 coordinates by the float "scale"
  2469. * @param scale defines the multiplier factor
  2470. * @returns the current updated Vector3
  2471. */
  2472. scaleInPlace(scale: number): Vector3;
  2473. /**
  2474. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2475. * @param scale defines the multiplier factor
  2476. * @returns a new Vector3
  2477. */
  2478. scale(scale: number): Vector3;
  2479. /**
  2480. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2481. * @param scale defines the multiplier factor
  2482. * @param result defines the Vector3 object where to store the result
  2483. * @returns the current Vector3
  2484. */
  2485. scaleToRef(scale: number, result: Vector3): Vector3;
  2486. /**
  2487. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2488. * @param scale defines the scale factor
  2489. * @param result defines the Vector3 object where to store the result
  2490. * @returns the unmodified current Vector3
  2491. */
  2492. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2493. /**
  2494. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2495. * @param otherVector defines the second operand
  2496. * @returns true if both vectors are equals
  2497. */
  2498. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2499. /**
  2500. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2501. * @param otherVector defines the second operand
  2502. * @param epsilon defines the minimal distance to define values as equals
  2503. * @returns true if both vectors are distant less than epsilon
  2504. */
  2505. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2506. /**
  2507. * Returns true if the current Vector3 coordinates equals the given floats
  2508. * @param x defines the x coordinate of the operand
  2509. * @param y defines the y coordinate of the operand
  2510. * @param z defines the z coordinate of the operand
  2511. * @returns true if both vectors are equals
  2512. */
  2513. equalsToFloats(x: number, y: number, z: number): boolean;
  2514. /**
  2515. * Multiplies the current Vector3 coordinates by the given ones
  2516. * @param otherVector defines the second operand
  2517. * @returns the current updated Vector3
  2518. */
  2519. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2520. /**
  2521. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2522. * @param otherVector defines the second operand
  2523. * @returns the new Vector3
  2524. */
  2525. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2526. /**
  2527. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2528. * @param otherVector defines the second operand
  2529. * @param result defines the Vector3 object where to store the result
  2530. * @returns the current Vector3
  2531. */
  2532. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2533. /**
  2534. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2535. * @param x defines the x coordinate of the operand
  2536. * @param y defines the y coordinate of the operand
  2537. * @param z defines the z coordinate of the operand
  2538. * @returns the new Vector3
  2539. */
  2540. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2541. /**
  2542. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2543. * @param otherVector defines the second operand
  2544. * @returns the new Vector3
  2545. */
  2546. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2547. /**
  2548. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2549. * @param otherVector defines the second operand
  2550. * @param result defines the Vector3 object where to store the result
  2551. * @returns the current Vector3
  2552. */
  2553. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2554. /**
  2555. * Divides the current Vector3 coordinates by the given ones.
  2556. * @param otherVector defines the second operand
  2557. * @returns the current updated Vector3
  2558. */
  2559. divideInPlace(otherVector: Vector3): Vector3;
  2560. /**
  2561. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2562. * @param other defines the second operand
  2563. * @returns the current updated Vector3
  2564. */
  2565. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2566. /**
  2567. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2568. * @param other defines the second operand
  2569. * @returns the current updated Vector3
  2570. */
  2571. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2572. /**
  2573. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2574. * @param x defines the x coordinate of the operand
  2575. * @param y defines the y coordinate of the operand
  2576. * @param z defines the z coordinate of the operand
  2577. * @returns the current updated Vector3
  2578. */
  2579. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2580. /**
  2581. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2582. * @param x defines the x coordinate of the operand
  2583. * @param y defines the y coordinate of the operand
  2584. * @param z defines the z coordinate of the operand
  2585. * @returns the current updated Vector3
  2586. */
  2587. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2588. /**
  2589. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2590. * Check if is non uniform within a certain amount of decimal places to account for this
  2591. * @param epsilon the amount the values can differ
  2592. * @returns if the the vector is non uniform to a certain number of decimal places
  2593. */
  2594. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2595. /**
  2596. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2597. */
  2598. get isNonUniform(): boolean;
  2599. /**
  2600. * Gets a new Vector3 from current Vector3 floored values
  2601. * @returns a new Vector3
  2602. */
  2603. floor(): Vector3;
  2604. /**
  2605. * Gets a new Vector3 from current Vector3 floored values
  2606. * @returns a new Vector3
  2607. */
  2608. fract(): Vector3;
  2609. /**
  2610. * Gets the length of the Vector3
  2611. * @returns the length of the Vector3
  2612. */
  2613. length(): number;
  2614. /**
  2615. * Gets the squared length of the Vector3
  2616. * @returns squared length of the Vector3
  2617. */
  2618. lengthSquared(): number;
  2619. /**
  2620. * Normalize the current Vector3.
  2621. * Please note that this is an in place operation.
  2622. * @returns the current updated Vector3
  2623. */
  2624. normalize(): Vector3;
  2625. /**
  2626. * Reorders the x y z properties of the vector in place
  2627. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2628. * @returns the current updated vector
  2629. */
  2630. reorderInPlace(order: string): this;
  2631. /**
  2632. * Rotates the vector around 0,0,0 by a quaternion
  2633. * @param quaternion the rotation quaternion
  2634. * @param result vector to store the result
  2635. * @returns the resulting vector
  2636. */
  2637. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2638. /**
  2639. * Rotates a vector around a given point
  2640. * @param quaternion the rotation quaternion
  2641. * @param point the point to rotate around
  2642. * @param result vector to store the result
  2643. * @returns the resulting vector
  2644. */
  2645. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2646. /**
  2647. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2648. * The cross product is then orthogonal to both current and "other"
  2649. * @param other defines the right operand
  2650. * @returns the cross product
  2651. */
  2652. cross(other: Vector3): Vector3;
  2653. /**
  2654. * Normalize the current Vector3 with the given input length.
  2655. * Please note that this is an in place operation.
  2656. * @param len the length of the vector
  2657. * @returns the current updated Vector3
  2658. */
  2659. normalizeFromLength(len: number): Vector3;
  2660. /**
  2661. * Normalize the current Vector3 to a new vector
  2662. * @returns the new Vector3
  2663. */
  2664. normalizeToNew(): Vector3;
  2665. /**
  2666. * Normalize the current Vector3 to the reference
  2667. * @param reference define the Vector3 to update
  2668. * @returns the updated Vector3
  2669. */
  2670. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  2671. /**
  2672. * Creates a new Vector3 copied from the current Vector3
  2673. * @returns the new Vector3
  2674. */
  2675. clone(): Vector3;
  2676. /**
  2677. * Copies the given vector coordinates to the current Vector3 ones
  2678. * @param source defines the source Vector3
  2679. * @returns the current updated Vector3
  2680. */
  2681. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2682. /**
  2683. * Copies the given floats to the current Vector3 coordinates
  2684. * @param x defines the x coordinate of the operand
  2685. * @param y defines the y coordinate of the operand
  2686. * @param z defines the z coordinate of the operand
  2687. * @returns the current updated Vector3
  2688. */
  2689. copyFromFloats(x: number, y: number, z: number): Vector3;
  2690. /**
  2691. * Copies the given floats to the current Vector3 coordinates
  2692. * @param x defines the x coordinate of the operand
  2693. * @param y defines the y coordinate of the operand
  2694. * @param z defines the z coordinate of the operand
  2695. * @returns the current updated Vector3
  2696. */
  2697. set(x: number, y: number, z: number): Vector3;
  2698. /**
  2699. * Copies the given float to the current Vector3 coordinates
  2700. * @param v defines the x, y and z coordinates of the operand
  2701. * @returns the current updated Vector3
  2702. */
  2703. setAll(v: number): Vector3;
  2704. /**
  2705. * Get the clip factor between two vectors
  2706. * @param vector0 defines the first operand
  2707. * @param vector1 defines the second operand
  2708. * @param axis defines the axis to use
  2709. * @param size defines the size along the axis
  2710. * @returns the clip factor
  2711. */
  2712. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2713. /**
  2714. * Get angle between two vectors
  2715. * @param vector0 angle between vector0 and vector1
  2716. * @param vector1 angle between vector0 and vector1
  2717. * @param normal direction of the normal
  2718. * @return the angle between vector0 and vector1
  2719. */
  2720. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2721. /**
  2722. * Returns a new Vector3 set from the index "offset" of the given array
  2723. * @param array defines the source array
  2724. * @param offset defines the offset in the source array
  2725. * @returns the new Vector3
  2726. */
  2727. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2728. /**
  2729. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2730. * @param array defines the source array
  2731. * @param offset defines the offset in the source array
  2732. * @returns the new Vector3
  2733. * @deprecated Please use FromArray instead.
  2734. */
  2735. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2736. /**
  2737. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2738. * @param array defines the source array
  2739. * @param offset defines the offset in the source array
  2740. * @param result defines the Vector3 where to store the result
  2741. */
  2742. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2743. /**
  2744. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2745. * @param array defines the source array
  2746. * @param offset defines the offset in the source array
  2747. * @param result defines the Vector3 where to store the result
  2748. * @deprecated Please use FromArrayToRef instead.
  2749. */
  2750. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2751. /**
  2752. * Sets the given vector "result" with the given floats.
  2753. * @param x defines the x coordinate of the source
  2754. * @param y defines the y coordinate of the source
  2755. * @param z defines the z coordinate of the source
  2756. * @param result defines the Vector3 where to store the result
  2757. */
  2758. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2759. /**
  2760. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2761. * @returns a new empty Vector3
  2762. */
  2763. static Zero(): Vector3;
  2764. /**
  2765. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2766. * @returns a new unit Vector3
  2767. */
  2768. static One(): Vector3;
  2769. /**
  2770. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2771. * @returns a new up Vector3
  2772. */
  2773. static Up(): Vector3;
  2774. /**
  2775. * Gets a up Vector3 that must not be updated
  2776. */
  2777. static get UpReadOnly(): DeepImmutable<Vector3>;
  2778. /**
  2779. * Gets a zero Vector3 that must not be updated
  2780. */
  2781. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  2782. /**
  2783. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2784. * @returns a new down Vector3
  2785. */
  2786. static Down(): Vector3;
  2787. /**
  2788. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2789. * @returns a new forward Vector3
  2790. */
  2791. static Forward(): Vector3;
  2792. /**
  2793. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2794. * @returns a new forward Vector3
  2795. */
  2796. static Backward(): Vector3;
  2797. /**
  2798. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2799. * @returns a new right Vector3
  2800. */
  2801. static Right(): Vector3;
  2802. /**
  2803. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2804. * @returns a new left Vector3
  2805. */
  2806. static Left(): Vector3;
  2807. /**
  2808. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2809. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2810. * @param vector defines the Vector3 to transform
  2811. * @param transformation defines the transformation matrix
  2812. * @returns the transformed Vector3
  2813. */
  2814. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2815. /**
  2816. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2817. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2818. * @param vector defines the Vector3 to transform
  2819. * @param transformation defines the transformation matrix
  2820. * @param result defines the Vector3 where to store the result
  2821. */
  2822. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2823. /**
  2824. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2825. * This method computes tranformed coordinates only, not transformed direction vectors
  2826. * @param x define the x coordinate of the source vector
  2827. * @param y define the y coordinate of the source vector
  2828. * @param z define the z coordinate of the source vector
  2829. * @param transformation defines the transformation matrix
  2830. * @param result defines the Vector3 where to store the result
  2831. */
  2832. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2833. /**
  2834. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2835. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2836. * @param vector defines the Vector3 to transform
  2837. * @param transformation defines the transformation matrix
  2838. * @returns the new Vector3
  2839. */
  2840. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2841. /**
  2842. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2843. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2844. * @param vector defines the Vector3 to transform
  2845. * @param transformation defines the transformation matrix
  2846. * @param result defines the Vector3 where to store the result
  2847. */
  2848. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2849. /**
  2850. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2851. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2852. * @param x define the x coordinate of the source vector
  2853. * @param y define the y coordinate of the source vector
  2854. * @param z define the z coordinate of the source vector
  2855. * @param transformation defines the transformation matrix
  2856. * @param result defines the Vector3 where to store the result
  2857. */
  2858. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2859. /**
  2860. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2861. * @param value1 defines the first control point
  2862. * @param value2 defines the second control point
  2863. * @param value3 defines the third control point
  2864. * @param value4 defines the fourth control point
  2865. * @param amount defines the amount on the spline to use
  2866. * @returns the new Vector3
  2867. */
  2868. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  2869. /**
  2870. * Returns a new Vector3 set with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  2871. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2872. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2873. * @param value defines the current value
  2874. * @param min defines the lower range value
  2875. * @param max defines the upper range value
  2876. * @returns the new Vector3
  2877. */
  2878. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  2879. /**
  2880. * Sets the given vector "result" with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  2881. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2882. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2883. * @param value defines the current value
  2884. * @param min defines the lower range value
  2885. * @param max defines the upper range value
  2886. * @param result defines the Vector3 where to store the result
  2887. */
  2888. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  2889. /**
  2890. * Checks if a given vector is inside a specific range
  2891. * @param v defines the vector to test
  2892. * @param min defines the minimum range
  2893. * @param max defines the maximum range
  2894. */
  2895. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  2896. /**
  2897. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  2898. * @param value1 defines the first control point
  2899. * @param tangent1 defines the first tangent vector
  2900. * @param value2 defines the second control point
  2901. * @param tangent2 defines the second tangent vector
  2902. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  2903. * @returns the new Vector3
  2904. */
  2905. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  2906. /**
  2907. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  2908. * @param start defines the start value
  2909. * @param end defines the end value
  2910. * @param amount max defines amount between both (between 0 and 1)
  2911. * @returns the new Vector3
  2912. */
  2913. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  2914. /**
  2915. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  2916. * @param start defines the start value
  2917. * @param end defines the end value
  2918. * @param amount max defines amount between both (between 0 and 1)
  2919. * @param result defines the Vector3 where to store the result
  2920. */
  2921. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  2922. /**
  2923. * Returns the dot product (float) between the vectors "left" and "right"
  2924. * @param left defines the left operand
  2925. * @param right defines the right operand
  2926. * @returns the dot product
  2927. */
  2928. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  2929. /**
  2930. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  2931. * The cross product is then orthogonal to both "left" and "right"
  2932. * @param left defines the left operand
  2933. * @param right defines the right operand
  2934. * @returns the cross product
  2935. */
  2936. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2937. /**
  2938. * Sets the given vector "result" with the cross product of "left" and "right"
  2939. * The cross product is then orthogonal to both "left" and "right"
  2940. * @param left defines the left operand
  2941. * @param right defines the right operand
  2942. * @param result defines the Vector3 where to store the result
  2943. */
  2944. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  2945. /**
  2946. * Returns a new Vector3 as the normalization of the given vector
  2947. * @param vector defines the Vector3 to normalize
  2948. * @returns the new Vector3
  2949. */
  2950. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  2951. /**
  2952. * Sets the given vector "result" with the normalization of the given first vector
  2953. * @param vector defines the Vector3 to normalize
  2954. * @param result defines the Vector3 where to store the result
  2955. */
  2956. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  2957. /**
  2958. * Project a Vector3 onto screen space
  2959. * @param vector defines the Vector3 to project
  2960. * @param world defines the world matrix to use
  2961. * @param transform defines the transform (view x projection) matrix to use
  2962. * @param viewport defines the screen viewport to use
  2963. * @returns the new Vector3
  2964. */
  2965. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  2966. /** @hidden */
  2967. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  2968. /**
  2969. * Unproject from screen space to object space
  2970. * @param source defines the screen space Vector3 to use
  2971. * @param viewportWidth defines the current width of the viewport
  2972. * @param viewportHeight defines the current height of the viewport
  2973. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2974. * @param transform defines the transform (view x projection) matrix to use
  2975. * @returns the new Vector3
  2976. */
  2977. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  2978. /**
  2979. * Unproject from screen space to object space
  2980. * @param source defines the screen space Vector3 to use
  2981. * @param viewportWidth defines the current width of the viewport
  2982. * @param viewportHeight defines the current height of the viewport
  2983. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2984. * @param view defines the view matrix to use
  2985. * @param projection defines the projection matrix to use
  2986. * @returns the new Vector3
  2987. */
  2988. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  2989. /**
  2990. * Unproject from screen space to object space
  2991. * @param source defines the screen space Vector3 to use
  2992. * @param viewportWidth defines the current width of the viewport
  2993. * @param viewportHeight defines the current height of the viewport
  2994. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2995. * @param view defines the view matrix to use
  2996. * @param projection defines the projection matrix to use
  2997. * @param result defines the Vector3 where to store the result
  2998. */
  2999. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3000. /**
  3001. * Unproject from screen space to object space
  3002. * @param sourceX defines the screen space x coordinate to use
  3003. * @param sourceY defines the screen space y coordinate to use
  3004. * @param sourceZ defines the screen space z coordinate to use
  3005. * @param viewportWidth defines the current width of the viewport
  3006. * @param viewportHeight defines the current height of the viewport
  3007. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3008. * @param view defines the view matrix to use
  3009. * @param projection defines the projection matrix to use
  3010. * @param result defines the Vector3 where to store the result
  3011. */
  3012. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3013. /**
  3014. * Gets the minimal coordinate values between two Vector3
  3015. * @param left defines the first operand
  3016. * @param right defines the second operand
  3017. * @returns the new Vector3
  3018. */
  3019. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3020. /**
  3021. * Gets the maximal coordinate values between two Vector3
  3022. * @param left defines the first operand
  3023. * @param right defines the second operand
  3024. * @returns the new Vector3
  3025. */
  3026. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3027. /**
  3028. * Returns the distance between the vectors "value1" and "value2"
  3029. * @param value1 defines the first operand
  3030. * @param value2 defines the second operand
  3031. * @returns the distance
  3032. */
  3033. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3034. /**
  3035. * Returns the squared distance between the vectors "value1" and "value2"
  3036. * @param value1 defines the first operand
  3037. * @param value2 defines the second operand
  3038. * @returns the squared distance
  3039. */
  3040. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3041. /**
  3042. * Returns a new Vector3 located at the center between "value1" and "value2"
  3043. * @param value1 defines the first operand
  3044. * @param value2 defines the second operand
  3045. * @returns the new Vector3
  3046. */
  3047. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3048. /**
  3049. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3050. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3051. * to something in order to rotate it from its local system to the given target system
  3052. * Note: axis1, axis2 and axis3 are normalized during this operation
  3053. * @param axis1 defines the first axis
  3054. * @param axis2 defines the second axis
  3055. * @param axis3 defines the third axis
  3056. * @returns a new Vector3
  3057. */
  3058. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3059. /**
  3060. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3061. * @param axis1 defines the first axis
  3062. * @param axis2 defines the second axis
  3063. * @param axis3 defines the third axis
  3064. * @param ref defines the Vector3 where to store the result
  3065. */
  3066. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3067. }
  3068. /**
  3069. * Vector4 class created for EulerAngle class conversion to Quaternion
  3070. */
  3071. export class Vector4 {
  3072. /** x value of the vector */
  3073. x: number;
  3074. /** y value of the vector */
  3075. y: number;
  3076. /** z value of the vector */
  3077. z: number;
  3078. /** w value of the vector */
  3079. w: number;
  3080. /**
  3081. * Creates a Vector4 object from the given floats.
  3082. * @param x x value of the vector
  3083. * @param y y value of the vector
  3084. * @param z z value of the vector
  3085. * @param w w value of the vector
  3086. */
  3087. constructor(
  3088. /** x value of the vector */
  3089. x: number,
  3090. /** y value of the vector */
  3091. y: number,
  3092. /** z value of the vector */
  3093. z: number,
  3094. /** w value of the vector */
  3095. w: number);
  3096. /**
  3097. * Returns the string with the Vector4 coordinates.
  3098. * @returns a string containing all the vector values
  3099. */
  3100. toString(): string;
  3101. /**
  3102. * Returns the string "Vector4".
  3103. * @returns "Vector4"
  3104. */
  3105. getClassName(): string;
  3106. /**
  3107. * Returns the Vector4 hash code.
  3108. * @returns a unique hash code
  3109. */
  3110. getHashCode(): number;
  3111. /**
  3112. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3113. * @returns the resulting array
  3114. */
  3115. asArray(): number[];
  3116. /**
  3117. * Populates the given array from the given index with the Vector4 coordinates.
  3118. * @param array array to populate
  3119. * @param index index of the array to start at (default: 0)
  3120. * @returns the Vector4.
  3121. */
  3122. toArray(array: FloatArray, index?: number): Vector4;
  3123. /**
  3124. * Adds the given vector to the current Vector4.
  3125. * @param otherVector the vector to add
  3126. * @returns the updated Vector4.
  3127. */
  3128. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3129. /**
  3130. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3131. * @param otherVector the vector to add
  3132. * @returns the resulting vector
  3133. */
  3134. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3135. /**
  3136. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3137. * @param otherVector the vector to add
  3138. * @param result the vector to store the result
  3139. * @returns the current Vector4.
  3140. */
  3141. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3142. /**
  3143. * Subtract in place the given vector from the current Vector4.
  3144. * @param otherVector the vector to subtract
  3145. * @returns the updated Vector4.
  3146. */
  3147. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3148. /**
  3149. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3150. * @param otherVector the vector to add
  3151. * @returns the new vector with the result
  3152. */
  3153. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3154. /**
  3155. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3156. * @param otherVector the vector to subtract
  3157. * @param result the vector to store the result
  3158. * @returns the current Vector4.
  3159. */
  3160. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3161. /**
  3162. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3163. */
  3164. /**
  3165. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3166. * @param x value to subtract
  3167. * @param y value to subtract
  3168. * @param z value to subtract
  3169. * @param w value to subtract
  3170. * @returns new vector containing the result
  3171. */
  3172. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3173. /**
  3174. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3175. * @param x value to subtract
  3176. * @param y value to subtract
  3177. * @param z value to subtract
  3178. * @param w value to subtract
  3179. * @param result the vector to store the result in
  3180. * @returns the current Vector4.
  3181. */
  3182. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3183. /**
  3184. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3185. * @returns a new vector with the negated values
  3186. */
  3187. negate(): Vector4;
  3188. /**
  3189. * Negate this vector in place
  3190. * @returns this
  3191. */
  3192. negateInPlace(): Vector4;
  3193. /**
  3194. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  3195. * @param result defines the Vector3 object where to store the result
  3196. * @returns the current Vector4
  3197. */
  3198. negateToRef(result: Vector4): Vector4;
  3199. /**
  3200. * Multiplies the current Vector4 coordinates by scale (float).
  3201. * @param scale the number to scale with
  3202. * @returns the updated Vector4.
  3203. */
  3204. scaleInPlace(scale: number): Vector4;
  3205. /**
  3206. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3207. * @param scale the number to scale with
  3208. * @returns a new vector with the result
  3209. */
  3210. scale(scale: number): Vector4;
  3211. /**
  3212. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3213. * @param scale the number to scale with
  3214. * @param result a vector to store the result in
  3215. * @returns the current Vector4.
  3216. */
  3217. scaleToRef(scale: number, result: Vector4): Vector4;
  3218. /**
  3219. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3220. * @param scale defines the scale factor
  3221. * @param result defines the Vector4 object where to store the result
  3222. * @returns the unmodified current Vector4
  3223. */
  3224. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3225. /**
  3226. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3227. * @param otherVector the vector to compare against
  3228. * @returns true if they are equal
  3229. */
  3230. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3231. /**
  3232. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3233. * @param otherVector vector to compare against
  3234. * @param epsilon (Default: very small number)
  3235. * @returns true if they are equal
  3236. */
  3237. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3238. /**
  3239. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3240. * @param x x value to compare against
  3241. * @param y y value to compare against
  3242. * @param z z value to compare against
  3243. * @param w w value to compare against
  3244. * @returns true if equal
  3245. */
  3246. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3247. /**
  3248. * Multiplies in place the current Vector4 by the given one.
  3249. * @param otherVector vector to multiple with
  3250. * @returns the updated Vector4.
  3251. */
  3252. multiplyInPlace(otherVector: Vector4): Vector4;
  3253. /**
  3254. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3255. * @param otherVector vector to multiple with
  3256. * @returns resulting new vector
  3257. */
  3258. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3259. /**
  3260. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3261. * @param otherVector vector to multiple with
  3262. * @param result vector to store the result
  3263. * @returns the current Vector4.
  3264. */
  3265. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3266. /**
  3267. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3268. * @param x x value multiply with
  3269. * @param y y value multiply with
  3270. * @param z z value multiply with
  3271. * @param w w value multiply with
  3272. * @returns resulting new vector
  3273. */
  3274. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3275. /**
  3276. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3277. * @param otherVector vector to devide with
  3278. * @returns resulting new vector
  3279. */
  3280. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3281. /**
  3282. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3283. * @param otherVector vector to devide with
  3284. * @param result vector to store the result
  3285. * @returns the current Vector4.
  3286. */
  3287. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3288. /**
  3289. * Divides the current Vector3 coordinates by the given ones.
  3290. * @param otherVector vector to devide with
  3291. * @returns the updated Vector3.
  3292. */
  3293. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3294. /**
  3295. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3296. * @param other defines the second operand
  3297. * @returns the current updated Vector4
  3298. */
  3299. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3300. /**
  3301. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3302. * @param other defines the second operand
  3303. * @returns the current updated Vector4
  3304. */
  3305. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3306. /**
  3307. * Gets a new Vector4 from current Vector4 floored values
  3308. * @returns a new Vector4
  3309. */
  3310. floor(): Vector4;
  3311. /**
  3312. * Gets a new Vector4 from current Vector3 floored values
  3313. * @returns a new Vector4
  3314. */
  3315. fract(): Vector4;
  3316. /**
  3317. * Returns the Vector4 length (float).
  3318. * @returns the length
  3319. */
  3320. length(): number;
  3321. /**
  3322. * Returns the Vector4 squared length (float).
  3323. * @returns the length squared
  3324. */
  3325. lengthSquared(): number;
  3326. /**
  3327. * Normalizes in place the Vector4.
  3328. * @returns the updated Vector4.
  3329. */
  3330. normalize(): Vector4;
  3331. /**
  3332. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3333. * @returns this converted to a new vector3
  3334. */
  3335. toVector3(): Vector3;
  3336. /**
  3337. * Returns a new Vector4 copied from the current one.
  3338. * @returns the new cloned vector
  3339. */
  3340. clone(): Vector4;
  3341. /**
  3342. * Updates the current Vector4 with the given one coordinates.
  3343. * @param source the source vector to copy from
  3344. * @returns the updated Vector4.
  3345. */
  3346. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3347. /**
  3348. * Updates the current Vector4 coordinates with the given floats.
  3349. * @param x float to copy from
  3350. * @param y float to copy from
  3351. * @param z float to copy from
  3352. * @param w float to copy from
  3353. * @returns the updated Vector4.
  3354. */
  3355. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3356. /**
  3357. * Updates the current Vector4 coordinates with the given floats.
  3358. * @param x float to set from
  3359. * @param y float to set from
  3360. * @param z float to set from
  3361. * @param w float to set from
  3362. * @returns the updated Vector4.
  3363. */
  3364. set(x: number, y: number, z: number, w: number): Vector4;
  3365. /**
  3366. * Copies the given float to the current Vector3 coordinates
  3367. * @param v defines the x, y, z and w coordinates of the operand
  3368. * @returns the current updated Vector3
  3369. */
  3370. setAll(v: number): Vector4;
  3371. /**
  3372. * Returns a new Vector4 set from the starting index of the given array.
  3373. * @param array the array to pull values from
  3374. * @param offset the offset into the array to start at
  3375. * @returns the new vector
  3376. */
  3377. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3378. /**
  3379. * Updates the given vector "result" from the starting index of the given array.
  3380. * @param array the array to pull values from
  3381. * @param offset the offset into the array to start at
  3382. * @param result the vector to store the result in
  3383. */
  3384. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3385. /**
  3386. * Updates the given vector "result" from the starting index of the given Float32Array.
  3387. * @param array the array to pull values from
  3388. * @param offset the offset into the array to start at
  3389. * @param result the vector to store the result in
  3390. */
  3391. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3392. /**
  3393. * Updates the given vector "result" coordinates from the given floats.
  3394. * @param x float to set from
  3395. * @param y float to set from
  3396. * @param z float to set from
  3397. * @param w float to set from
  3398. * @param result the vector to the floats in
  3399. */
  3400. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3401. /**
  3402. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3403. * @returns the new vector
  3404. */
  3405. static Zero(): Vector4;
  3406. /**
  3407. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3408. * @returns the new vector
  3409. */
  3410. static One(): Vector4;
  3411. /**
  3412. * Returns a new normalized Vector4 from the given one.
  3413. * @param vector the vector to normalize
  3414. * @returns the vector
  3415. */
  3416. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3417. /**
  3418. * Updates the given vector "result" from the normalization of the given one.
  3419. * @param vector the vector to normalize
  3420. * @param result the vector to store the result in
  3421. */
  3422. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3423. /**
  3424. * Returns a vector with the minimum values from the left and right vectors
  3425. * @param left left vector to minimize
  3426. * @param right right vector to minimize
  3427. * @returns a new vector with the minimum of the left and right vector values
  3428. */
  3429. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3430. /**
  3431. * Returns a vector with the maximum values from the left and right vectors
  3432. * @param left left vector to maximize
  3433. * @param right right vector to maximize
  3434. * @returns a new vector with the maximum of the left and right vector values
  3435. */
  3436. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3437. /**
  3438. * Returns the distance (float) between the vectors "value1" and "value2".
  3439. * @param value1 value to calulate the distance between
  3440. * @param value2 value to calulate the distance between
  3441. * @return the distance between the two vectors
  3442. */
  3443. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3444. /**
  3445. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3446. * @param value1 value to calulate the distance between
  3447. * @param value2 value to calulate the distance between
  3448. * @return the distance between the two vectors squared
  3449. */
  3450. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3451. /**
  3452. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3453. * @param value1 value to calulate the center between
  3454. * @param value2 value to calulate the center between
  3455. * @return the center between the two vectors
  3456. */
  3457. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3458. /**
  3459. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3460. * This methods computes transformed normalized direction vectors only.
  3461. * @param vector the vector to transform
  3462. * @param transformation the transformation matrix to apply
  3463. * @returns the new vector
  3464. */
  3465. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3466. /**
  3467. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3468. * This methods computes transformed normalized direction vectors only.
  3469. * @param vector the vector to transform
  3470. * @param transformation the transformation matrix to apply
  3471. * @param result the vector to store the result in
  3472. */
  3473. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3474. /**
  3475. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3476. * This methods computes transformed normalized direction vectors only.
  3477. * @param x value to transform
  3478. * @param y value to transform
  3479. * @param z value to transform
  3480. * @param w value to transform
  3481. * @param transformation the transformation matrix to apply
  3482. * @param result the vector to store the results in
  3483. */
  3484. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3485. /**
  3486. * Creates a new Vector4 from a Vector3
  3487. * @param source defines the source data
  3488. * @param w defines the 4th component (default is 0)
  3489. * @returns a new Vector4
  3490. */
  3491. static FromVector3(source: Vector3, w?: number): Vector4;
  3492. }
  3493. /**
  3494. * Class used to store quaternion data
  3495. * @see https://en.wikipedia.org/wiki/Quaternion
  3496. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  3497. */
  3498. export class Quaternion {
  3499. /** defines the first component (0 by default) */
  3500. x: number;
  3501. /** defines the second component (0 by default) */
  3502. y: number;
  3503. /** defines the third component (0 by default) */
  3504. z: number;
  3505. /** defines the fourth component (1.0 by default) */
  3506. w: number;
  3507. /**
  3508. * Creates a new Quaternion from the given floats
  3509. * @param x defines the first component (0 by default)
  3510. * @param y defines the second component (0 by default)
  3511. * @param z defines the third component (0 by default)
  3512. * @param w defines the fourth component (1.0 by default)
  3513. */
  3514. constructor(
  3515. /** defines the first component (0 by default) */
  3516. x?: number,
  3517. /** defines the second component (0 by default) */
  3518. y?: number,
  3519. /** defines the third component (0 by default) */
  3520. z?: number,
  3521. /** defines the fourth component (1.0 by default) */
  3522. w?: number);
  3523. /**
  3524. * Gets a string representation for the current quaternion
  3525. * @returns a string with the Quaternion coordinates
  3526. */
  3527. toString(): string;
  3528. /**
  3529. * Gets the class name of the quaternion
  3530. * @returns the string "Quaternion"
  3531. */
  3532. getClassName(): string;
  3533. /**
  3534. * Gets a hash code for this quaternion
  3535. * @returns the quaternion hash code
  3536. */
  3537. getHashCode(): number;
  3538. /**
  3539. * Copy the quaternion to an array
  3540. * @returns a new array populated with 4 elements from the quaternion coordinates
  3541. */
  3542. asArray(): number[];
  3543. /**
  3544. * Check if two quaternions are equals
  3545. * @param otherQuaternion defines the second operand
  3546. * @return true if the current quaternion and the given one coordinates are strictly equals
  3547. */
  3548. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3549. /**
  3550. * Gets a boolean if two quaternions are equals (using an epsilon value)
  3551. * @param otherQuaternion defines the other quaternion
  3552. * @param epsilon defines the minimal distance to consider equality
  3553. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  3554. */
  3555. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  3556. /**
  3557. * Clone the current quaternion
  3558. * @returns a new quaternion copied from the current one
  3559. */
  3560. clone(): Quaternion;
  3561. /**
  3562. * Copy a quaternion to the current one
  3563. * @param other defines the other quaternion
  3564. * @returns the updated current quaternion
  3565. */
  3566. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3567. /**
  3568. * Updates the current quaternion with the given float coordinates
  3569. * @param x defines the x coordinate
  3570. * @param y defines the y coordinate
  3571. * @param z defines the z coordinate
  3572. * @param w defines the w coordinate
  3573. * @returns the updated current quaternion
  3574. */
  3575. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3576. /**
  3577. * Updates the current quaternion from the given float coordinates
  3578. * @param x defines the x coordinate
  3579. * @param y defines the y coordinate
  3580. * @param z defines the z coordinate
  3581. * @param w defines the w coordinate
  3582. * @returns the updated current quaternion
  3583. */
  3584. set(x: number, y: number, z: number, w: number): Quaternion;
  3585. /**
  3586. * Adds two quaternions
  3587. * @param other defines the second operand
  3588. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3589. */
  3590. add(other: DeepImmutable<Quaternion>): Quaternion;
  3591. /**
  3592. * Add a quaternion to the current one
  3593. * @param other defines the quaternion to add
  3594. * @returns the current quaternion
  3595. */
  3596. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3597. /**
  3598. * Subtract two quaternions
  3599. * @param other defines the second operand
  3600. * @returns a new quaternion as the subtraction result of the given one from the current one
  3601. */
  3602. subtract(other: Quaternion): Quaternion;
  3603. /**
  3604. * Multiplies the current quaternion by a scale factor
  3605. * @param value defines the scale factor
  3606. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3607. */
  3608. scale(value: number): Quaternion;
  3609. /**
  3610. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3611. * @param scale defines the scale factor
  3612. * @param result defines the Quaternion object where to store the result
  3613. * @returns the unmodified current quaternion
  3614. */
  3615. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3616. /**
  3617. * Multiplies in place the current quaternion by a scale factor
  3618. * @param value defines the scale factor
  3619. * @returns the current modified quaternion
  3620. */
  3621. scaleInPlace(value: number): Quaternion;
  3622. /**
  3623. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3624. * @param scale defines the scale factor
  3625. * @param result defines the Quaternion object where to store the result
  3626. * @returns the unmodified current quaternion
  3627. */
  3628. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3629. /**
  3630. * Multiplies two quaternions
  3631. * @param q1 defines the second operand
  3632. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3633. */
  3634. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3635. /**
  3636. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3637. * @param q1 defines the second operand
  3638. * @param result defines the target quaternion
  3639. * @returns the current quaternion
  3640. */
  3641. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3642. /**
  3643. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3644. * @param q1 defines the second operand
  3645. * @returns the currentupdated quaternion
  3646. */
  3647. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3648. /**
  3649. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3650. * @param ref defines the target quaternion
  3651. * @returns the current quaternion
  3652. */
  3653. conjugateToRef(ref: Quaternion): Quaternion;
  3654. /**
  3655. * Conjugates in place (1-q) the current quaternion
  3656. * @returns the current updated quaternion
  3657. */
  3658. conjugateInPlace(): Quaternion;
  3659. /**
  3660. * Conjugates in place (1-q) the current quaternion
  3661. * @returns a new quaternion
  3662. */
  3663. conjugate(): Quaternion;
  3664. /**
  3665. * Gets length of current quaternion
  3666. * @returns the quaternion length (float)
  3667. */
  3668. length(): number;
  3669. /**
  3670. * Normalize in place the current quaternion
  3671. * @returns the current updated quaternion
  3672. */
  3673. normalize(): Quaternion;
  3674. /**
  3675. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3676. * @param order is a reserved parameter and is ignore for now
  3677. * @returns a new Vector3 containing the Euler angles
  3678. */
  3679. toEulerAngles(order?: string): Vector3;
  3680. /**
  3681. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3682. * @param result defines the vector which will be filled with the Euler angles
  3683. * @param order is a reserved parameter and is ignore for now
  3684. * @returns the current unchanged quaternion
  3685. */
  3686. toEulerAnglesToRef(result: Vector3): Quaternion;
  3687. /**
  3688. * Updates the given rotation matrix with the current quaternion values
  3689. * @param result defines the target matrix
  3690. * @returns the current unchanged quaternion
  3691. */
  3692. toRotationMatrix(result: Matrix): Quaternion;
  3693. /**
  3694. * Updates the current quaternion from the given rotation matrix values
  3695. * @param matrix defines the source matrix
  3696. * @returns the current updated quaternion
  3697. */
  3698. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3699. /**
  3700. * Creates a new quaternion from a rotation matrix
  3701. * @param matrix defines the source matrix
  3702. * @returns a new quaternion created from the given rotation matrix values
  3703. */
  3704. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3705. /**
  3706. * Updates the given quaternion with the given rotation matrix values
  3707. * @param matrix defines the source matrix
  3708. * @param result defines the target quaternion
  3709. */
  3710. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3711. /**
  3712. * Returns the dot product (float) between the quaternions "left" and "right"
  3713. * @param left defines the left operand
  3714. * @param right defines the right operand
  3715. * @returns the dot product
  3716. */
  3717. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3718. /**
  3719. * Checks if the two quaternions are close to each other
  3720. * @param quat0 defines the first quaternion to check
  3721. * @param quat1 defines the second quaternion to check
  3722. * @returns true if the two quaternions are close to each other
  3723. */
  3724. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3725. /**
  3726. * Creates an empty quaternion
  3727. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3728. */
  3729. static Zero(): Quaternion;
  3730. /**
  3731. * Inverse a given quaternion
  3732. * @param q defines the source quaternion
  3733. * @returns a new quaternion as the inverted current quaternion
  3734. */
  3735. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3736. /**
  3737. * Inverse a given quaternion
  3738. * @param q defines the source quaternion
  3739. * @param result the quaternion the result will be stored in
  3740. * @returns the result quaternion
  3741. */
  3742. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3743. /**
  3744. * Creates an identity quaternion
  3745. * @returns the identity quaternion
  3746. */
  3747. static Identity(): Quaternion;
  3748. /**
  3749. * Gets a boolean indicating if the given quaternion is identity
  3750. * @param quaternion defines the quaternion to check
  3751. * @returns true if the quaternion is identity
  3752. */
  3753. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3754. /**
  3755. * Creates a quaternion from a rotation around an axis
  3756. * @param axis defines the axis to use
  3757. * @param angle defines the angle to use
  3758. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3759. */
  3760. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3761. /**
  3762. * Creates a rotation around an axis and stores it into the given quaternion
  3763. * @param axis defines the axis to use
  3764. * @param angle defines the angle to use
  3765. * @param result defines the target quaternion
  3766. * @returns the target quaternion
  3767. */
  3768. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3769. /**
  3770. * Creates a new quaternion from data stored into an array
  3771. * @param array defines the data source
  3772. * @param offset defines the offset in the source array where the data starts
  3773. * @returns a new quaternion
  3774. */
  3775. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3776. /**
  3777. * Updates the given quaternion "result" from the starting index of the given array.
  3778. * @param array the array to pull values from
  3779. * @param offset the offset into the array to start at
  3780. * @param result the quaternion to store the result in
  3781. */
  3782. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  3783. /**
  3784. * Create a quaternion from Euler rotation angles
  3785. * @param x Pitch
  3786. * @param y Yaw
  3787. * @param z Roll
  3788. * @returns the new Quaternion
  3789. */
  3790. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3791. /**
  3792. * Updates a quaternion from Euler rotation angles
  3793. * @param x Pitch
  3794. * @param y Yaw
  3795. * @param z Roll
  3796. * @param result the quaternion to store the result
  3797. * @returns the updated quaternion
  3798. */
  3799. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3800. /**
  3801. * Create a quaternion from Euler rotation vector
  3802. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3803. * @returns the new Quaternion
  3804. */
  3805. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3806. /**
  3807. * Updates a quaternion from Euler rotation vector
  3808. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3809. * @param result the quaternion to store the result
  3810. * @returns the updated quaternion
  3811. */
  3812. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3813. /**
  3814. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3815. * @param yaw defines the rotation around Y axis
  3816. * @param pitch defines the rotation around X axis
  3817. * @param roll defines the rotation around Z axis
  3818. * @returns the new quaternion
  3819. */
  3820. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3821. /**
  3822. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3823. * @param yaw defines the rotation around Y axis
  3824. * @param pitch defines the rotation around X axis
  3825. * @param roll defines the rotation around Z axis
  3826. * @param result defines the target quaternion
  3827. */
  3828. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3829. /**
  3830. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3831. * @param alpha defines the rotation around first axis
  3832. * @param beta defines the rotation around second axis
  3833. * @param gamma defines the rotation around third axis
  3834. * @returns the new quaternion
  3835. */
  3836. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3837. /**
  3838. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3839. * @param alpha defines the rotation around first axis
  3840. * @param beta defines the rotation around second axis
  3841. * @param gamma defines the rotation around third axis
  3842. * @param result defines the target quaternion
  3843. */
  3844. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3845. /**
  3846. * Creates a new quaternion containing the rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation)
  3847. * @param axis1 defines the first axis
  3848. * @param axis2 defines the second axis
  3849. * @param axis3 defines the third axis
  3850. * @returns the new quaternion
  3851. */
  3852. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3853. /**
  3854. * Creates a rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation) and stores it in the target quaternion
  3855. * @param axis1 defines the first axis
  3856. * @param axis2 defines the second axis
  3857. * @param axis3 defines the third axis
  3858. * @param ref defines the target quaternion
  3859. */
  3860. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  3861. /**
  3862. * Interpolates between two quaternions
  3863. * @param left defines first quaternion
  3864. * @param right defines second quaternion
  3865. * @param amount defines the gradient to use
  3866. * @returns the new interpolated quaternion
  3867. */
  3868. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3869. /**
  3870. * Interpolates between two quaternions and stores it into a target quaternion
  3871. * @param left defines first quaternion
  3872. * @param right defines second quaternion
  3873. * @param amount defines the gradient to use
  3874. * @param result defines the target quaternion
  3875. */
  3876. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  3877. /**
  3878. * Interpolate between two quaternions using Hermite interpolation
  3879. * @param value1 defines first quaternion
  3880. * @param tangent1 defines the incoming tangent
  3881. * @param value2 defines second quaternion
  3882. * @param tangent2 defines the outgoing tangent
  3883. * @param amount defines the target quaternion
  3884. * @returns the new interpolated quaternion
  3885. */
  3886. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3887. }
  3888. /**
  3889. * Class used to store matrix data (4x4)
  3890. */
  3891. export class Matrix {
  3892. private static _updateFlagSeed;
  3893. private static _identityReadOnly;
  3894. private _isIdentity;
  3895. private _isIdentityDirty;
  3896. private _isIdentity3x2;
  3897. private _isIdentity3x2Dirty;
  3898. /**
  3899. * Gets the update flag of the matrix which is an unique number for the matrix.
  3900. * It will be incremented every time the matrix data change.
  3901. * You can use it to speed the comparison between two versions of the same matrix.
  3902. */
  3903. updateFlag: number;
  3904. private readonly _m;
  3905. /**
  3906. * Gets the internal data of the matrix
  3907. */
  3908. get m(): DeepImmutable<Float32Array>;
  3909. /** @hidden */
  3910. _markAsUpdated(): void;
  3911. /** @hidden */
  3912. private _updateIdentityStatus;
  3913. /**
  3914. * Creates an empty matrix (filled with zeros)
  3915. */
  3916. constructor();
  3917. /**
  3918. * Check if the current matrix is identity
  3919. * @returns true is the matrix is the identity matrix
  3920. */
  3921. isIdentity(): boolean;
  3922. /**
  3923. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  3924. * @returns true is the matrix is the identity matrix
  3925. */
  3926. isIdentityAs3x2(): boolean;
  3927. /**
  3928. * Gets the determinant of the matrix
  3929. * @returns the matrix determinant
  3930. */
  3931. determinant(): number;
  3932. /**
  3933. * Returns the matrix as a Float32Array
  3934. * @returns the matrix underlying array
  3935. */
  3936. toArray(): DeepImmutable<Float32Array>;
  3937. /**
  3938. * Returns the matrix as a Float32Array
  3939. * @returns the matrix underlying array.
  3940. */
  3941. asArray(): DeepImmutable<Float32Array>;
  3942. /**
  3943. * Inverts the current matrix in place
  3944. * @returns the current inverted matrix
  3945. */
  3946. invert(): Matrix;
  3947. /**
  3948. * Sets all the matrix elements to zero
  3949. * @returns the current matrix
  3950. */
  3951. reset(): Matrix;
  3952. /**
  3953. * Adds the current matrix with a second one
  3954. * @param other defines the matrix to add
  3955. * @returns a new matrix as the addition of the current matrix and the given one
  3956. */
  3957. add(other: DeepImmutable<Matrix>): Matrix;
  3958. /**
  3959. * Sets the given matrix "result" to the addition of the current matrix and the given one
  3960. * @param other defines the matrix to add
  3961. * @param result defines the target matrix
  3962. * @returns the current matrix
  3963. */
  3964. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3965. /**
  3966. * Adds in place the given matrix to the current matrix
  3967. * @param other defines the second operand
  3968. * @returns the current updated matrix
  3969. */
  3970. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  3971. /**
  3972. * Sets the given matrix to the current inverted Matrix
  3973. * @param other defines the target matrix
  3974. * @returns the unmodified current matrix
  3975. */
  3976. invertToRef(other: Matrix): Matrix;
  3977. /**
  3978. * add a value at the specified position in the current Matrix
  3979. * @param index the index of the value within the matrix. between 0 and 15.
  3980. * @param value the value to be added
  3981. * @returns the current updated matrix
  3982. */
  3983. addAtIndex(index: number, value: number): Matrix;
  3984. /**
  3985. * mutiply the specified position in the current Matrix by a value
  3986. * @param index the index of the value within the matrix. between 0 and 15.
  3987. * @param value the value to be added
  3988. * @returns the current updated matrix
  3989. */
  3990. multiplyAtIndex(index: number, value: number): Matrix;
  3991. /**
  3992. * Inserts the translation vector (using 3 floats) in the current matrix
  3993. * @param x defines the 1st component of the translation
  3994. * @param y defines the 2nd component of the translation
  3995. * @param z defines the 3rd component of the translation
  3996. * @returns the current updated matrix
  3997. */
  3998. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3999. /**
  4000. * Adds the translation vector (using 3 floats) in the current matrix
  4001. * @param x defines the 1st component of the translation
  4002. * @param y defines the 2nd component of the translation
  4003. * @param z defines the 3rd component of the translation
  4004. * @returns the current updated matrix
  4005. */
  4006. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4007. /**
  4008. * Inserts the translation vector in the current matrix
  4009. * @param vector3 defines the translation to insert
  4010. * @returns the current updated matrix
  4011. */
  4012. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  4013. /**
  4014. * Gets the translation value of the current matrix
  4015. * @returns a new Vector3 as the extracted translation from the matrix
  4016. */
  4017. getTranslation(): Vector3;
  4018. /**
  4019. * Fill a Vector3 with the extracted translation from the matrix
  4020. * @param result defines the Vector3 where to store the translation
  4021. * @returns the current matrix
  4022. */
  4023. getTranslationToRef(result: Vector3): Matrix;
  4024. /**
  4025. * Remove rotation and scaling part from the matrix
  4026. * @returns the updated matrix
  4027. */
  4028. removeRotationAndScaling(): Matrix;
  4029. /**
  4030. * Multiply two matrices
  4031. * @param other defines the second operand
  4032. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  4033. */
  4034. multiply(other: DeepImmutable<Matrix>): Matrix;
  4035. /**
  4036. * Copy the current matrix from the given one
  4037. * @param other defines the source matrix
  4038. * @returns the current updated matrix
  4039. */
  4040. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  4041. /**
  4042. * Populates the given array from the starting index with the current matrix values
  4043. * @param array defines the target array
  4044. * @param offset defines the offset in the target array where to start storing values
  4045. * @returns the current matrix
  4046. */
  4047. copyToArray(array: Float32Array, offset?: number): Matrix;
  4048. /**
  4049. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4050. * @param other defines the second operand
  4051. * @param result defines the matrix where to store the multiplication
  4052. * @returns the current matrix
  4053. */
  4054. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4055. /**
  4056. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4057. * @param other defines the second operand
  4058. * @param result defines the array where to store the multiplication
  4059. * @param offset defines the offset in the target array where to start storing values
  4060. * @returns the current matrix
  4061. */
  4062. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  4063. /**
  4064. * Check equality between this matrix and a second one
  4065. * @param value defines the second matrix to compare
  4066. * @returns true is the current matrix and the given one values are strictly equal
  4067. */
  4068. equals(value: DeepImmutable<Matrix>): boolean;
  4069. /**
  4070. * Clone the current matrix
  4071. * @returns a new matrix from the current matrix
  4072. */
  4073. clone(): Matrix;
  4074. /**
  4075. * Returns the name of the current matrix class
  4076. * @returns the string "Matrix"
  4077. */
  4078. getClassName(): string;
  4079. /**
  4080. * Gets the hash code of the current matrix
  4081. * @returns the hash code
  4082. */
  4083. getHashCode(): number;
  4084. /**
  4085. * Decomposes the current Matrix into a translation, rotation and scaling components
  4086. * @param scale defines the scale vector3 given as a reference to update
  4087. * @param rotation defines the rotation quaternion given as a reference to update
  4088. * @param translation defines the translation vector3 given as a reference to update
  4089. * @returns true if operation was successful
  4090. */
  4091. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4092. /**
  4093. * Gets specific row of the matrix
  4094. * @param index defines the number of the row to get
  4095. * @returns the index-th row of the current matrix as a new Vector4
  4096. */
  4097. getRow(index: number): Nullable<Vector4>;
  4098. /**
  4099. * Sets the index-th row of the current matrix to the vector4 values
  4100. * @param index defines the number of the row to set
  4101. * @param row defines the target vector4
  4102. * @returns the updated current matrix
  4103. */
  4104. setRow(index: number, row: Vector4): Matrix;
  4105. /**
  4106. * Compute the transpose of the matrix
  4107. * @returns the new transposed matrix
  4108. */
  4109. transpose(): Matrix;
  4110. /**
  4111. * Compute the transpose of the matrix and store it in a given matrix
  4112. * @param result defines the target matrix
  4113. * @returns the current matrix
  4114. */
  4115. transposeToRef(result: Matrix): Matrix;
  4116. /**
  4117. * Sets the index-th row of the current matrix with the given 4 x float values
  4118. * @param index defines the row index
  4119. * @param x defines the x component to set
  4120. * @param y defines the y component to set
  4121. * @param z defines the z component to set
  4122. * @param w defines the w component to set
  4123. * @returns the updated current matrix
  4124. */
  4125. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4126. /**
  4127. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4128. * @param scale defines the scale factor
  4129. * @returns a new matrix
  4130. */
  4131. scale(scale: number): Matrix;
  4132. /**
  4133. * Scale the current matrix values by a factor to a given result matrix
  4134. * @param scale defines the scale factor
  4135. * @param result defines the matrix to store the result
  4136. * @returns the current matrix
  4137. */
  4138. scaleToRef(scale: number, result: Matrix): Matrix;
  4139. /**
  4140. * Scale the current matrix values by a factor and add the result to a given matrix
  4141. * @param scale defines the scale factor
  4142. * @param result defines the Matrix to store the result
  4143. * @returns the current matrix
  4144. */
  4145. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4146. /**
  4147. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4148. * @param ref matrix to store the result
  4149. */
  4150. toNormalMatrix(ref: Matrix): void;
  4151. /**
  4152. * Gets only rotation part of the current matrix
  4153. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4154. */
  4155. getRotationMatrix(): Matrix;
  4156. /**
  4157. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4158. * @param result defines the target matrix to store data to
  4159. * @returns the current matrix
  4160. */
  4161. getRotationMatrixToRef(result: Matrix): Matrix;
  4162. /**
  4163. * Toggles model matrix from being right handed to left handed in place and vice versa
  4164. */
  4165. toggleModelMatrixHandInPlace(): void;
  4166. /**
  4167. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4168. */
  4169. toggleProjectionMatrixHandInPlace(): void;
  4170. /**
  4171. * Creates a matrix from an array
  4172. * @param array defines the source array
  4173. * @param offset defines an offset in the source array
  4174. * @returns a new Matrix set from the starting index of the given array
  4175. */
  4176. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4177. /**
  4178. * Copy the content of an array into a given matrix
  4179. * @param array defines the source array
  4180. * @param offset defines an offset in the source array
  4181. * @param result defines the target matrix
  4182. */
  4183. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4184. /**
  4185. * Stores an array into a matrix after having multiplied each component by a given factor
  4186. * @param array defines the source array
  4187. * @param offset defines the offset in the source array
  4188. * @param scale defines the scaling factor
  4189. * @param result defines the target matrix
  4190. */
  4191. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  4192. /**
  4193. * Gets an identity matrix that must not be updated
  4194. */
  4195. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  4196. /**
  4197. * Stores a list of values (16) inside a given matrix
  4198. * @param initialM11 defines 1st value of 1st row
  4199. * @param initialM12 defines 2nd value of 1st row
  4200. * @param initialM13 defines 3rd value of 1st row
  4201. * @param initialM14 defines 4th value of 1st row
  4202. * @param initialM21 defines 1st value of 2nd row
  4203. * @param initialM22 defines 2nd value of 2nd row
  4204. * @param initialM23 defines 3rd value of 2nd row
  4205. * @param initialM24 defines 4th value of 2nd row
  4206. * @param initialM31 defines 1st value of 3rd row
  4207. * @param initialM32 defines 2nd value of 3rd row
  4208. * @param initialM33 defines 3rd value of 3rd row
  4209. * @param initialM34 defines 4th value of 3rd row
  4210. * @param initialM41 defines 1st value of 4th row
  4211. * @param initialM42 defines 2nd value of 4th row
  4212. * @param initialM43 defines 3rd value of 4th row
  4213. * @param initialM44 defines 4th value of 4th row
  4214. * @param result defines the target matrix
  4215. */
  4216. static FromValuesToRef(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number, result: Matrix): void;
  4217. /**
  4218. * Creates new matrix from a list of values (16)
  4219. * @param initialM11 defines 1st value of 1st row
  4220. * @param initialM12 defines 2nd value of 1st row
  4221. * @param initialM13 defines 3rd value of 1st row
  4222. * @param initialM14 defines 4th value of 1st row
  4223. * @param initialM21 defines 1st value of 2nd row
  4224. * @param initialM22 defines 2nd value of 2nd row
  4225. * @param initialM23 defines 3rd value of 2nd row
  4226. * @param initialM24 defines 4th value of 2nd row
  4227. * @param initialM31 defines 1st value of 3rd row
  4228. * @param initialM32 defines 2nd value of 3rd row
  4229. * @param initialM33 defines 3rd value of 3rd row
  4230. * @param initialM34 defines 4th value of 3rd row
  4231. * @param initialM41 defines 1st value of 4th row
  4232. * @param initialM42 defines 2nd value of 4th row
  4233. * @param initialM43 defines 3rd value of 4th row
  4234. * @param initialM44 defines 4th value of 4th row
  4235. * @returns the new matrix
  4236. */
  4237. static FromValues(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number): Matrix;
  4238. /**
  4239. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4240. * @param scale defines the scale vector3
  4241. * @param rotation defines the rotation quaternion
  4242. * @param translation defines the translation vector3
  4243. * @returns a new matrix
  4244. */
  4245. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4246. /**
  4247. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4248. * @param scale defines the scale vector3
  4249. * @param rotation defines the rotation quaternion
  4250. * @param translation defines the translation vector3
  4251. * @param result defines the target matrix
  4252. */
  4253. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4254. /**
  4255. * Creates a new identity matrix
  4256. * @returns a new identity matrix
  4257. */
  4258. static Identity(): Matrix;
  4259. /**
  4260. * Creates a new identity matrix and stores the result in a given matrix
  4261. * @param result defines the target matrix
  4262. */
  4263. static IdentityToRef(result: Matrix): void;
  4264. /**
  4265. * Creates a new zero matrix
  4266. * @returns a new zero matrix
  4267. */
  4268. static Zero(): Matrix;
  4269. /**
  4270. * Creates a new rotation matrix for "angle" radians around the X axis
  4271. * @param angle defines the angle (in radians) to use
  4272. * @return the new matrix
  4273. */
  4274. static RotationX(angle: number): Matrix;
  4275. /**
  4276. * Creates a new matrix as the invert of a given matrix
  4277. * @param source defines the source matrix
  4278. * @returns the new matrix
  4279. */
  4280. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4281. /**
  4282. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4283. * @param angle defines the angle (in radians) to use
  4284. * @param result defines the target matrix
  4285. */
  4286. static RotationXToRef(angle: number, result: Matrix): void;
  4287. /**
  4288. * Creates a new rotation matrix for "angle" radians around the Y axis
  4289. * @param angle defines the angle (in radians) to use
  4290. * @return the new matrix
  4291. */
  4292. static RotationY(angle: number): Matrix;
  4293. /**
  4294. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4295. * @param angle defines the angle (in radians) to use
  4296. * @param result defines the target matrix
  4297. */
  4298. static RotationYToRef(angle: number, result: Matrix): void;
  4299. /**
  4300. * Creates a new rotation matrix for "angle" radians around the Z axis
  4301. * @param angle defines the angle (in radians) to use
  4302. * @return the new matrix
  4303. */
  4304. static RotationZ(angle: number): Matrix;
  4305. /**
  4306. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4307. * @param angle defines the angle (in radians) to use
  4308. * @param result defines the target matrix
  4309. */
  4310. static RotationZToRef(angle: number, result: Matrix): void;
  4311. /**
  4312. * Creates a new rotation matrix for "angle" radians around the given axis
  4313. * @param axis defines the axis to use
  4314. * @param angle defines the angle (in radians) to use
  4315. * @return the new matrix
  4316. */
  4317. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4318. /**
  4319. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4320. * @param axis defines the axis to use
  4321. * @param angle defines the angle (in radians) to use
  4322. * @param result defines the target matrix
  4323. */
  4324. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4325. /**
  4326. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4327. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4328. * @param from defines the vector to align
  4329. * @param to defines the vector to align to
  4330. * @param result defines the target matrix
  4331. */
  4332. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4333. /**
  4334. * Creates a rotation matrix
  4335. * @param yaw defines the yaw angle in radians (Y axis)
  4336. * @param pitch defines the pitch angle in radians (X axis)
  4337. * @param roll defines the roll angle in radians (X axis)
  4338. * @returns the new rotation matrix
  4339. */
  4340. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4341. /**
  4342. * Creates a rotation matrix and stores it in a given matrix
  4343. * @param yaw defines the yaw angle in radians (Y axis)
  4344. * @param pitch defines the pitch angle in radians (X axis)
  4345. * @param roll defines the roll angle in radians (X axis)
  4346. * @param result defines the target matrix
  4347. */
  4348. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4349. /**
  4350. * Creates a scaling matrix
  4351. * @param x defines the scale factor on X axis
  4352. * @param y defines the scale factor on Y axis
  4353. * @param z defines the scale factor on Z axis
  4354. * @returns the new matrix
  4355. */
  4356. static Scaling(x: number, y: number, z: number): Matrix;
  4357. /**
  4358. * Creates a scaling matrix and stores it in a given matrix
  4359. * @param x defines the scale factor on X axis
  4360. * @param y defines the scale factor on Y axis
  4361. * @param z defines the scale factor on Z axis
  4362. * @param result defines the target matrix
  4363. */
  4364. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4365. /**
  4366. * Creates a translation matrix
  4367. * @param x defines the translation on X axis
  4368. * @param y defines the translation on Y axis
  4369. * @param z defines the translationon Z axis
  4370. * @returns the new matrix
  4371. */
  4372. static Translation(x: number, y: number, z: number): Matrix;
  4373. /**
  4374. * Creates a translation matrix and stores it in a given matrix
  4375. * @param x defines the translation on X axis
  4376. * @param y defines the translation on Y axis
  4377. * @param z defines the translationon Z axis
  4378. * @param result defines the target matrix
  4379. */
  4380. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4381. /**
  4382. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4383. * @param startValue defines the start value
  4384. * @param endValue defines the end value
  4385. * @param gradient defines the gradient factor
  4386. * @returns the new matrix
  4387. */
  4388. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4389. /**
  4390. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4391. * @param startValue defines the start value
  4392. * @param endValue defines the end value
  4393. * @param gradient defines the gradient factor
  4394. * @param result defines the Matrix object where to store data
  4395. */
  4396. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4397. /**
  4398. * Builds a new matrix whose values are computed by:
  4399. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4400. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4401. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4402. * @param startValue defines the first matrix
  4403. * @param endValue defines the second matrix
  4404. * @param gradient defines the gradient between the two matrices
  4405. * @returns the new matrix
  4406. */
  4407. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4408. /**
  4409. * Update a matrix to values which are computed by:
  4410. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4411. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4412. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4413. * @param startValue defines the first matrix
  4414. * @param endValue defines the second matrix
  4415. * @param gradient defines the gradient between the two matrices
  4416. * @param result defines the target matrix
  4417. */
  4418. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4419. /**
  4420. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  4421. * This function works in left handed mode
  4422. * @param eye defines the final position of the entity
  4423. * @param target defines where the entity should look at
  4424. * @param up defines the up vector for the entity
  4425. * @returns the new matrix
  4426. */
  4427. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4428. /**
  4429. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  4430. * This function works in left handed mode
  4431. * @param eye defines the final position of the entity
  4432. * @param target defines where the entity should look at
  4433. * @param up defines the up vector for the entity
  4434. * @param result defines the target matrix
  4435. */
  4436. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4437. /**
  4438. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  4439. * This function works in right handed mode
  4440. * @param eye defines the final position of the entity
  4441. * @param target defines where the entity should look at
  4442. * @param up defines the up vector for the entity
  4443. * @returns the new matrix
  4444. */
  4445. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4446. /**
  4447. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  4448. * This function works in right handed mode
  4449. * @param eye defines the final position of the entity
  4450. * @param target defines where the entity should look at
  4451. * @param up defines the up vector for the entity
  4452. * @param result defines the target matrix
  4453. */
  4454. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4455. /**
  4456. * Create a left-handed orthographic projection matrix
  4457. * @param width defines the viewport width
  4458. * @param height defines the viewport height
  4459. * @param znear defines the near clip plane
  4460. * @param zfar defines the far clip plane
  4461. * @returns a new matrix as a left-handed orthographic projection matrix
  4462. */
  4463. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4464. /**
  4465. * Store a left-handed orthographic projection to a given matrix
  4466. * @param width defines the viewport width
  4467. * @param height defines the viewport height
  4468. * @param znear defines the near clip plane
  4469. * @param zfar defines the far clip plane
  4470. * @param result defines the target matrix
  4471. */
  4472. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4473. /**
  4474. * Create a left-handed orthographic projection matrix
  4475. * @param left defines the viewport left coordinate
  4476. * @param right defines the viewport right coordinate
  4477. * @param bottom defines the viewport bottom coordinate
  4478. * @param top defines the viewport top coordinate
  4479. * @param znear defines the near clip plane
  4480. * @param zfar defines the far clip plane
  4481. * @returns a new matrix as a left-handed orthographic projection matrix
  4482. */
  4483. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4484. /**
  4485. * Stores a left-handed orthographic projection into a given matrix
  4486. * @param left defines the viewport left coordinate
  4487. * @param right defines the viewport right coordinate
  4488. * @param bottom defines the viewport bottom coordinate
  4489. * @param top defines the viewport top coordinate
  4490. * @param znear defines the near clip plane
  4491. * @param zfar defines the far clip plane
  4492. * @param result defines the target matrix
  4493. */
  4494. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4495. /**
  4496. * Creates a right-handed orthographic projection matrix
  4497. * @param left defines the viewport left coordinate
  4498. * @param right defines the viewport right coordinate
  4499. * @param bottom defines the viewport bottom coordinate
  4500. * @param top defines the viewport top coordinate
  4501. * @param znear defines the near clip plane
  4502. * @param zfar defines the far clip plane
  4503. * @returns a new matrix as a right-handed orthographic projection matrix
  4504. */
  4505. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4506. /**
  4507. * Stores a right-handed orthographic projection into a given matrix
  4508. * @param left defines the viewport left coordinate
  4509. * @param right defines the viewport right coordinate
  4510. * @param bottom defines the viewport bottom coordinate
  4511. * @param top defines the viewport top coordinate
  4512. * @param znear defines the near clip plane
  4513. * @param zfar defines the far clip plane
  4514. * @param result defines the target matrix
  4515. */
  4516. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4517. /**
  4518. * Creates a left-handed perspective projection matrix
  4519. * @param width defines the viewport width
  4520. * @param height defines the viewport height
  4521. * @param znear defines the near clip plane
  4522. * @param zfar defines the far clip plane
  4523. * @returns a new matrix as a left-handed perspective projection matrix
  4524. */
  4525. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4526. /**
  4527. * Creates a left-handed perspective projection matrix
  4528. * @param fov defines the horizontal field of view
  4529. * @param aspect defines the aspect ratio
  4530. * @param znear defines the near clip plane
  4531. * @param zfar defines the far clip plane
  4532. * @returns a new matrix as a left-handed perspective projection matrix
  4533. */
  4534. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4535. /**
  4536. * Stores a left-handed perspective projection into a given matrix
  4537. * @param fov defines the horizontal field of view
  4538. * @param aspect defines the aspect ratio
  4539. * @param znear defines the near clip plane
  4540. * @param zfar defines the far clip plane
  4541. * @param result defines the target matrix
  4542. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4543. */
  4544. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4545. /**
  4546. * Stores a left-handed perspective projection into a given matrix with depth reversed
  4547. * @param fov defines the horizontal field of view
  4548. * @param aspect defines the aspect ratio
  4549. * @param znear defines the near clip plane
  4550. * @param zfar not used as infinity is used as far clip
  4551. * @param result defines the target matrix
  4552. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4553. */
  4554. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4555. /**
  4556. * Creates a right-handed perspective projection matrix
  4557. * @param fov defines the horizontal field of view
  4558. * @param aspect defines the aspect ratio
  4559. * @param znear defines the near clip plane
  4560. * @param zfar defines the far clip plane
  4561. * @returns a new matrix as a right-handed perspective projection matrix
  4562. */
  4563. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4564. /**
  4565. * Stores a right-handed perspective projection into a given matrix
  4566. * @param fov defines the horizontal field of view
  4567. * @param aspect defines the aspect ratio
  4568. * @param znear defines the near clip plane
  4569. * @param zfar defines the far clip plane
  4570. * @param result defines the target matrix
  4571. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4572. */
  4573. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4574. /**
  4575. * Stores a right-handed perspective projection into a given matrix
  4576. * @param fov defines the horizontal field of view
  4577. * @param aspect defines the aspect ratio
  4578. * @param znear defines the near clip plane
  4579. * @param zfar not used as infinity is used as far clip
  4580. * @param result defines the target matrix
  4581. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4582. */
  4583. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4584. /**
  4585. * Stores a perspective projection for WebVR info a given matrix
  4586. * @param fov defines the field of view
  4587. * @param znear defines the near clip plane
  4588. * @param zfar defines the far clip plane
  4589. * @param result defines the target matrix
  4590. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4591. */
  4592. static PerspectiveFovWebVRToRef(fov: {
  4593. upDegrees: number;
  4594. downDegrees: number;
  4595. leftDegrees: number;
  4596. rightDegrees: number;
  4597. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4598. /**
  4599. * Computes a complete transformation matrix
  4600. * @param viewport defines the viewport to use
  4601. * @param world defines the world matrix
  4602. * @param view defines the view matrix
  4603. * @param projection defines the projection matrix
  4604. * @param zmin defines the near clip plane
  4605. * @param zmax defines the far clip plane
  4606. * @returns the transformation matrix
  4607. */
  4608. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4609. /**
  4610. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4611. * @param matrix defines the matrix to use
  4612. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4613. */
  4614. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  4615. /**
  4616. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4617. * @param matrix defines the matrix to use
  4618. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4619. */
  4620. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  4621. /**
  4622. * Compute the transpose of a given matrix
  4623. * @param matrix defines the matrix to transpose
  4624. * @returns the new matrix
  4625. */
  4626. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4627. /**
  4628. * Compute the transpose of a matrix and store it in a target matrix
  4629. * @param matrix defines the matrix to transpose
  4630. * @param result defines the target matrix
  4631. */
  4632. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4633. /**
  4634. * Computes a reflection matrix from a plane
  4635. * @param plane defines the reflection plane
  4636. * @returns a new matrix
  4637. */
  4638. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4639. /**
  4640. * Computes a reflection matrix from a plane
  4641. * @param plane defines the reflection plane
  4642. * @param result defines the target matrix
  4643. */
  4644. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4645. /**
  4646. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4647. * @param xaxis defines the value of the 1st axis
  4648. * @param yaxis defines the value of the 2nd axis
  4649. * @param zaxis defines the value of the 3rd axis
  4650. * @param result defines the target matrix
  4651. */
  4652. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4653. /**
  4654. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4655. * @param quat defines the quaternion to use
  4656. * @param result defines the target matrix
  4657. */
  4658. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4659. }
  4660. /**
  4661. * @hidden
  4662. */
  4663. export class TmpVectors {
  4664. static Vector2: Vector2[];
  4665. static Vector3: Vector3[];
  4666. static Vector4: Vector4[];
  4667. static Quaternion: Quaternion[];
  4668. static Matrix: Matrix[];
  4669. }
  4670. }
  4671. declare module "babylonjs/Maths/math.path" {
  4672. import { DeepImmutable, Nullable } from "babylonjs/types";
  4673. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  4674. /**
  4675. * Defines potential orientation for back face culling
  4676. */
  4677. export enum Orientation {
  4678. /**
  4679. * Clockwise
  4680. */
  4681. CW = 0,
  4682. /** Counter clockwise */
  4683. CCW = 1
  4684. }
  4685. /** Class used to represent a Bezier curve */
  4686. export class BezierCurve {
  4687. /**
  4688. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4689. * @param t defines the time
  4690. * @param x1 defines the left coordinate on X axis
  4691. * @param y1 defines the left coordinate on Y axis
  4692. * @param x2 defines the right coordinate on X axis
  4693. * @param y2 defines the right coordinate on Y axis
  4694. * @returns the interpolated value
  4695. */
  4696. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4697. }
  4698. /**
  4699. * Defines angle representation
  4700. */
  4701. export class Angle {
  4702. private _radians;
  4703. /**
  4704. * Creates an Angle object of "radians" radians (float).
  4705. * @param radians the angle in radians
  4706. */
  4707. constructor(radians: number);
  4708. /**
  4709. * Get value in degrees
  4710. * @returns the Angle value in degrees (float)
  4711. */
  4712. degrees(): number;
  4713. /**
  4714. * Get value in radians
  4715. * @returns the Angle value in radians (float)
  4716. */
  4717. radians(): number;
  4718. /**
  4719. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  4720. * @param a defines first vector
  4721. * @param b defines second vector
  4722. * @returns a new Angle
  4723. */
  4724. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4725. /**
  4726. * Gets a new Angle object from the given float in radians
  4727. * @param radians defines the angle value in radians
  4728. * @returns a new Angle
  4729. */
  4730. static FromRadians(radians: number): Angle;
  4731. /**
  4732. * Gets a new Angle object from the given float in degrees
  4733. * @param degrees defines the angle value in degrees
  4734. * @returns a new Angle
  4735. */
  4736. static FromDegrees(degrees: number): Angle;
  4737. }
  4738. /**
  4739. * This represents an arc in a 2d space.
  4740. */
  4741. export class Arc2 {
  4742. /** Defines the start point of the arc */
  4743. startPoint: Vector2;
  4744. /** Defines the mid point of the arc */
  4745. midPoint: Vector2;
  4746. /** Defines the end point of the arc */
  4747. endPoint: Vector2;
  4748. /**
  4749. * Defines the center point of the arc.
  4750. */
  4751. centerPoint: Vector2;
  4752. /**
  4753. * Defines the radius of the arc.
  4754. */
  4755. radius: number;
  4756. /**
  4757. * Defines the angle of the arc (from mid point to end point).
  4758. */
  4759. angle: Angle;
  4760. /**
  4761. * Defines the start angle of the arc (from start point to middle point).
  4762. */
  4763. startAngle: Angle;
  4764. /**
  4765. * Defines the orientation of the arc (clock wise/counter clock wise).
  4766. */
  4767. orientation: Orientation;
  4768. /**
  4769. * Creates an Arc object from the three given points : start, middle and end.
  4770. * @param startPoint Defines the start point of the arc
  4771. * @param midPoint Defines the midlle point of the arc
  4772. * @param endPoint Defines the end point of the arc
  4773. */
  4774. constructor(
  4775. /** Defines the start point of the arc */
  4776. startPoint: Vector2,
  4777. /** Defines the mid point of the arc */
  4778. midPoint: Vector2,
  4779. /** Defines the end point of the arc */
  4780. endPoint: Vector2);
  4781. }
  4782. /**
  4783. * Represents a 2D path made up of multiple 2D points
  4784. */
  4785. export class Path2 {
  4786. private _points;
  4787. private _length;
  4788. /**
  4789. * If the path start and end point are the same
  4790. */
  4791. closed: boolean;
  4792. /**
  4793. * Creates a Path2 object from the starting 2D coordinates x and y.
  4794. * @param x the starting points x value
  4795. * @param y the starting points y value
  4796. */
  4797. constructor(x: number, y: number);
  4798. /**
  4799. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4800. * @param x the added points x value
  4801. * @param y the added points y value
  4802. * @returns the updated Path2.
  4803. */
  4804. addLineTo(x: number, y: number): Path2;
  4805. /**
  4806. * Adds _numberOfSegments_ segments according to the arc definition (middle point coordinates, end point coordinates, the arc start point being the current Path2 last point) to the current Path2.
  4807. * @param midX middle point x value
  4808. * @param midY middle point y value
  4809. * @param endX end point x value
  4810. * @param endY end point y value
  4811. * @param numberOfSegments (default: 36)
  4812. * @returns the updated Path2.
  4813. */
  4814. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  4815. /**
  4816. * Closes the Path2.
  4817. * @returns the Path2.
  4818. */
  4819. close(): Path2;
  4820. /**
  4821. * Gets the sum of the distance between each sequential point in the path
  4822. * @returns the Path2 total length (float).
  4823. */
  4824. length(): number;
  4825. /**
  4826. * Gets the points which construct the path
  4827. * @returns the Path2 internal array of points.
  4828. */
  4829. getPoints(): Vector2[];
  4830. /**
  4831. * Retreives the point at the distance aways from the starting point
  4832. * @param normalizedLengthPosition the length along the path to retreive the point from
  4833. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  4834. */
  4835. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  4836. /**
  4837. * Creates a new path starting from an x and y position
  4838. * @param x starting x value
  4839. * @param y starting y value
  4840. * @returns a new Path2 starting at the coordinates (x, y).
  4841. */
  4842. static StartingAt(x: number, y: number): Path2;
  4843. }
  4844. /**
  4845. * Represents a 3D path made up of multiple 3D points
  4846. */
  4847. export class Path3D {
  4848. /**
  4849. * an array of Vector3, the curve axis of the Path3D
  4850. */
  4851. path: Vector3[];
  4852. private _curve;
  4853. private _distances;
  4854. private _tangents;
  4855. private _normals;
  4856. private _binormals;
  4857. private _raw;
  4858. private _alignTangentsWithPath;
  4859. private readonly _pointAtData;
  4860. /**
  4861. * new Path3D(path, normal, raw)
  4862. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  4863. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  4864. * @param path an array of Vector3, the curve axis of the Path3D
  4865. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  4866. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  4867. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  4868. */
  4869. constructor(
  4870. /**
  4871. * an array of Vector3, the curve axis of the Path3D
  4872. */
  4873. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  4874. /**
  4875. * Returns the Path3D array of successive Vector3 designing its curve.
  4876. * @returns the Path3D array of successive Vector3 designing its curve.
  4877. */
  4878. getCurve(): Vector3[];
  4879. /**
  4880. * Returns the Path3D array of successive Vector3 designing its curve.
  4881. * @returns the Path3D array of successive Vector3 designing its curve.
  4882. */
  4883. getPoints(): Vector3[];
  4884. /**
  4885. * @returns the computed length (float) of the path.
  4886. */
  4887. length(): number;
  4888. /**
  4889. * Returns an array populated with tangent vectors on each Path3D curve point.
  4890. * @returns an array populated with tangent vectors on each Path3D curve point.
  4891. */
  4892. getTangents(): Vector3[];
  4893. /**
  4894. * Returns an array populated with normal vectors on each Path3D curve point.
  4895. * @returns an array populated with normal vectors on each Path3D curve point.
  4896. */
  4897. getNormals(): Vector3[];
  4898. /**
  4899. * Returns an array populated with binormal vectors on each Path3D curve point.
  4900. * @returns an array populated with binormal vectors on each Path3D curve point.
  4901. */
  4902. getBinormals(): Vector3[];
  4903. /**
  4904. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4905. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4906. */
  4907. getDistances(): number[];
  4908. /**
  4909. * Returns an interpolated point along this path
  4910. * @param position the position of the point along this path, from 0.0 to 1.0
  4911. * @returns a new Vector3 as the point
  4912. */
  4913. getPointAt(position: number): Vector3;
  4914. /**
  4915. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  4916. * @param position the position of the point along this path, from 0.0 to 1.0
  4917. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  4918. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  4919. */
  4920. getTangentAt(position: number, interpolated?: boolean): Vector3;
  4921. /**
  4922. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  4923. * @param position the position of the point along this path, from 0.0 to 1.0
  4924. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  4925. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  4926. */
  4927. getNormalAt(position: number, interpolated?: boolean): Vector3;
  4928. /**
  4929. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  4930. * @param position the position of the point along this path, from 0.0 to 1.0
  4931. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  4932. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  4933. */
  4934. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  4935. /**
  4936. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  4937. * @param position the position of the point along this path, from 0.0 to 1.0
  4938. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  4939. */
  4940. getDistanceAt(position: number): number;
  4941. /**
  4942. * Returns the array index of the previous point of an interpolated point along this path
  4943. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  4944. * @returns the array index
  4945. */
  4946. getPreviousPointIndexAt(position: number): number;
  4947. /**
  4948. * Returns the position of an interpolated point relative to the two path points it lies between, from 0.0 (point A) to 1.0 (point B)
  4949. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  4950. * @returns the sub position
  4951. */
  4952. getSubPositionAt(position: number): number;
  4953. /**
  4954. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  4955. * @param target the vector of which to get the closest position to
  4956. * @returns the position of the closest virtual point on this path to the target vector
  4957. */
  4958. getClosestPositionTo(target: Vector3): number;
  4959. /**
  4960. * Returns a sub path (slice) of this path
  4961. * @param start the position of the fist path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  4962. * @param end the position of the last path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  4963. * @returns a sub path (slice) of this path
  4964. */
  4965. slice(start?: number, end?: number): Path3D;
  4966. /**
  4967. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4968. * @param path path which all values are copied into the curves points
  4969. * @param firstNormal which should be projected onto the curve
  4970. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  4971. * @returns the same object updated.
  4972. */
  4973. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  4974. private _compute;
  4975. private _getFirstNonNullVector;
  4976. private _getLastNonNullVector;
  4977. private _normalVector;
  4978. /**
  4979. * Updates the point at data for an interpolated point along this curve
  4980. * @param position the position of the point along this curve, from 0.0 to 1.0
  4981. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  4982. * @returns the (updated) point at data
  4983. */
  4984. private _updatePointAtData;
  4985. /**
  4986. * Updates the point at data from the specified parameters
  4987. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  4988. * @param point the interpolated point
  4989. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  4990. */
  4991. private _setPointAtData;
  4992. /**
  4993. * Updates the point at interpolation matrix for the tangents, normals and binormals
  4994. */
  4995. private _updateInterpolationMatrix;
  4996. }
  4997. /**
  4998. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4999. * A Curve3 is designed from a series of successive Vector3.
  5000. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  5001. */
  5002. export class Curve3 {
  5003. private _points;
  5004. private _length;
  5005. /**
  5006. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  5007. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  5008. * @param v1 (Vector3) the control point
  5009. * @param v2 (Vector3) the end point of the Quadratic Bezier
  5010. * @param nbPoints (integer) the wanted number of points in the curve
  5011. * @returns the created Curve3
  5012. */
  5013. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5014. /**
  5015. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  5016. * @param v0 (Vector3) the origin point of the Cubic Bezier
  5017. * @param v1 (Vector3) the first control point
  5018. * @param v2 (Vector3) the second control point
  5019. * @param v3 (Vector3) the end point of the Cubic Bezier
  5020. * @param nbPoints (integer) the wanted number of points in the curve
  5021. * @returns the created Curve3
  5022. */
  5023. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5024. /**
  5025. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  5026. * @param p1 (Vector3) the origin point of the Hermite Spline
  5027. * @param t1 (Vector3) the tangent vector at the origin point
  5028. * @param p2 (Vector3) the end point of the Hermite Spline
  5029. * @param t2 (Vector3) the tangent vector at the end point
  5030. * @param nbPoints (integer) the wanted number of points in the curve
  5031. * @returns the created Curve3
  5032. */
  5033. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5034. /**
  5035. * Returns a Curve3 object along a CatmullRom Spline curve :
  5036. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5037. * @param nbPoints (integer) the wanted number of points between each curve control points
  5038. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5039. * @returns the created Curve3
  5040. */
  5041. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5042. /**
  5043. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5044. * A Curve3 is designed from a series of successive Vector3.
  5045. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5046. * @param points points which make up the curve
  5047. */
  5048. constructor(points: Vector3[]);
  5049. /**
  5050. * @returns the Curve3 stored array of successive Vector3
  5051. */
  5052. getPoints(): Vector3[];
  5053. /**
  5054. * @returns the computed length (float) of the curve.
  5055. */
  5056. length(): number;
  5057. /**
  5058. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5059. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5060. * curveA and curveB keep unchanged.
  5061. * @param curve the curve to continue from this curve
  5062. * @returns the newly constructed curve
  5063. */
  5064. continue(curve: DeepImmutable<Curve3>): Curve3;
  5065. private _computeLength;
  5066. }
  5067. }
  5068. declare module "babylonjs/Animations/easing" {
  5069. /**
  5070. * This represents the main contract an easing function should follow.
  5071. * Easing functions are used throughout the animation system.
  5072. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5073. */
  5074. export interface IEasingFunction {
  5075. /**
  5076. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5077. * of the easing function.
  5078. * The link below provides some of the most common examples of easing functions.
  5079. * @see https://easings.net/
  5080. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5081. * @returns the corresponding value on the curve defined by the easing function
  5082. */
  5083. ease(gradient: number): number;
  5084. }
  5085. /**
  5086. * Base class used for every default easing function.
  5087. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5088. */
  5089. export class EasingFunction implements IEasingFunction {
  5090. /**
  5091. * Interpolation follows the mathematical formula associated with the easing function.
  5092. */
  5093. static readonly EASINGMODE_EASEIN: number;
  5094. /**
  5095. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5096. */
  5097. static readonly EASINGMODE_EASEOUT: number;
  5098. /**
  5099. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5100. */
  5101. static readonly EASINGMODE_EASEINOUT: number;
  5102. private _easingMode;
  5103. /**
  5104. * Sets the easing mode of the current function.
  5105. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5106. */
  5107. setEasingMode(easingMode: number): void;
  5108. /**
  5109. * Gets the current easing mode.
  5110. * @returns the easing mode
  5111. */
  5112. getEasingMode(): number;
  5113. /**
  5114. * @hidden
  5115. */
  5116. easeInCore(gradient: number): number;
  5117. /**
  5118. * Given an input gradient between 0 and 1, this returns the corresponding value
  5119. * of the easing function.
  5120. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5121. * @returns the corresponding value on the curve defined by the easing function
  5122. */
  5123. ease(gradient: number): number;
  5124. }
  5125. /**
  5126. * Easing function with a circle shape (see link below).
  5127. * @see https://easings.net/#easeInCirc
  5128. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5129. */
  5130. export class CircleEase extends EasingFunction implements IEasingFunction {
  5131. /** @hidden */
  5132. easeInCore(gradient: number): number;
  5133. }
  5134. /**
  5135. * Easing function with a ease back shape (see link below).
  5136. * @see https://easings.net/#easeInBack
  5137. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5138. */
  5139. export class BackEase extends EasingFunction implements IEasingFunction {
  5140. /** Defines the amplitude of the function */
  5141. amplitude: number;
  5142. /**
  5143. * Instantiates a back ease easing
  5144. * @see https://easings.net/#easeInBack
  5145. * @param amplitude Defines the amplitude of the function
  5146. */
  5147. constructor(
  5148. /** Defines the amplitude of the function */
  5149. amplitude?: number);
  5150. /** @hidden */
  5151. easeInCore(gradient: number): number;
  5152. }
  5153. /**
  5154. * Easing function with a bouncing shape (see link below).
  5155. * @see https://easings.net/#easeInBounce
  5156. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5157. */
  5158. export class BounceEase extends EasingFunction implements IEasingFunction {
  5159. /** Defines the number of bounces */
  5160. bounces: number;
  5161. /** Defines the amplitude of the bounce */
  5162. bounciness: number;
  5163. /**
  5164. * Instantiates a bounce easing
  5165. * @see https://easings.net/#easeInBounce
  5166. * @param bounces Defines the number of bounces
  5167. * @param bounciness Defines the amplitude of the bounce
  5168. */
  5169. constructor(
  5170. /** Defines the number of bounces */
  5171. bounces?: number,
  5172. /** Defines the amplitude of the bounce */
  5173. bounciness?: number);
  5174. /** @hidden */
  5175. easeInCore(gradient: number): number;
  5176. }
  5177. /**
  5178. * Easing function with a power of 3 shape (see link below).
  5179. * @see https://easings.net/#easeInCubic
  5180. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5181. */
  5182. export class CubicEase extends EasingFunction implements IEasingFunction {
  5183. /** @hidden */
  5184. easeInCore(gradient: number): number;
  5185. }
  5186. /**
  5187. * Easing function with an elastic shape (see link below).
  5188. * @see https://easings.net/#easeInElastic
  5189. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5190. */
  5191. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5192. /** Defines the number of oscillations*/
  5193. oscillations: number;
  5194. /** Defines the amplitude of the oscillations*/
  5195. springiness: number;
  5196. /**
  5197. * Instantiates an elastic easing function
  5198. * @see https://easings.net/#easeInElastic
  5199. * @param oscillations Defines the number of oscillations
  5200. * @param springiness Defines the amplitude of the oscillations
  5201. */
  5202. constructor(
  5203. /** Defines the number of oscillations*/
  5204. oscillations?: number,
  5205. /** Defines the amplitude of the oscillations*/
  5206. springiness?: number);
  5207. /** @hidden */
  5208. easeInCore(gradient: number): number;
  5209. }
  5210. /**
  5211. * Easing function with an exponential shape (see link below).
  5212. * @see https://easings.net/#easeInExpo
  5213. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5214. */
  5215. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5216. /** Defines the exponent of the function */
  5217. exponent: number;
  5218. /**
  5219. * Instantiates an exponential easing function
  5220. * @see https://easings.net/#easeInExpo
  5221. * @param exponent Defines the exponent of the function
  5222. */
  5223. constructor(
  5224. /** Defines the exponent of the function */
  5225. exponent?: number);
  5226. /** @hidden */
  5227. easeInCore(gradient: number): number;
  5228. }
  5229. /**
  5230. * Easing function with a power shape (see link below).
  5231. * @see https://easings.net/#easeInQuad
  5232. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5233. */
  5234. export class PowerEase extends EasingFunction implements IEasingFunction {
  5235. /** Defines the power of the function */
  5236. power: number;
  5237. /**
  5238. * Instantiates an power base easing function
  5239. * @see https://easings.net/#easeInQuad
  5240. * @param power Defines the power of the function
  5241. */
  5242. constructor(
  5243. /** Defines the power of the function */
  5244. power?: number);
  5245. /** @hidden */
  5246. easeInCore(gradient: number): number;
  5247. }
  5248. /**
  5249. * Easing function with a power of 2 shape (see link below).
  5250. * @see https://easings.net/#easeInQuad
  5251. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5252. */
  5253. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5254. /** @hidden */
  5255. easeInCore(gradient: number): number;
  5256. }
  5257. /**
  5258. * Easing function with a power of 4 shape (see link below).
  5259. * @see https://easings.net/#easeInQuart
  5260. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5261. */
  5262. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5263. /** @hidden */
  5264. easeInCore(gradient: number): number;
  5265. }
  5266. /**
  5267. * Easing function with a power of 5 shape (see link below).
  5268. * @see https://easings.net/#easeInQuint
  5269. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5270. */
  5271. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5272. /** @hidden */
  5273. easeInCore(gradient: number): number;
  5274. }
  5275. /**
  5276. * Easing function with a sin shape (see link below).
  5277. * @see https://easings.net/#easeInSine
  5278. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5279. */
  5280. export class SineEase extends EasingFunction implements IEasingFunction {
  5281. /** @hidden */
  5282. easeInCore(gradient: number): number;
  5283. }
  5284. /**
  5285. * Easing function with a bezier shape (see link below).
  5286. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5287. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5288. */
  5289. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5290. /** Defines the x component of the start tangent in the bezier curve */
  5291. x1: number;
  5292. /** Defines the y component of the start tangent in the bezier curve */
  5293. y1: number;
  5294. /** Defines the x component of the end tangent in the bezier curve */
  5295. x2: number;
  5296. /** Defines the y component of the end tangent in the bezier curve */
  5297. y2: number;
  5298. /**
  5299. * Instantiates a bezier function
  5300. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5301. * @param x1 Defines the x component of the start tangent in the bezier curve
  5302. * @param y1 Defines the y component of the start tangent in the bezier curve
  5303. * @param x2 Defines the x component of the end tangent in the bezier curve
  5304. * @param y2 Defines the y component of the end tangent in the bezier curve
  5305. */
  5306. constructor(
  5307. /** Defines the x component of the start tangent in the bezier curve */
  5308. x1?: number,
  5309. /** Defines the y component of the start tangent in the bezier curve */
  5310. y1?: number,
  5311. /** Defines the x component of the end tangent in the bezier curve */
  5312. x2?: number,
  5313. /** Defines the y component of the end tangent in the bezier curve */
  5314. y2?: number);
  5315. /** @hidden */
  5316. easeInCore(gradient: number): number;
  5317. }
  5318. }
  5319. declare module "babylonjs/Maths/math.color" {
  5320. import { DeepImmutable, FloatArray } from "babylonjs/types";
  5321. /**
  5322. * Class used to hold a RBG color
  5323. */
  5324. export class Color3 {
  5325. /**
  5326. * Defines the red component (between 0 and 1, default is 0)
  5327. */
  5328. r: number;
  5329. /**
  5330. * Defines the green component (between 0 and 1, default is 0)
  5331. */
  5332. g: number;
  5333. /**
  5334. * Defines the blue component (between 0 and 1, default is 0)
  5335. */
  5336. b: number;
  5337. /**
  5338. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5339. * @param r defines the red component (between 0 and 1, default is 0)
  5340. * @param g defines the green component (between 0 and 1, default is 0)
  5341. * @param b defines the blue component (between 0 and 1, default is 0)
  5342. */
  5343. constructor(
  5344. /**
  5345. * Defines the red component (between 0 and 1, default is 0)
  5346. */
  5347. r?: number,
  5348. /**
  5349. * Defines the green component (between 0 and 1, default is 0)
  5350. */
  5351. g?: number,
  5352. /**
  5353. * Defines the blue component (between 0 and 1, default is 0)
  5354. */
  5355. b?: number);
  5356. /**
  5357. * Creates a string with the Color3 current values
  5358. * @returns the string representation of the Color3 object
  5359. */
  5360. toString(): string;
  5361. /**
  5362. * Returns the string "Color3"
  5363. * @returns "Color3"
  5364. */
  5365. getClassName(): string;
  5366. /**
  5367. * Compute the Color3 hash code
  5368. * @returns an unique number that can be used to hash Color3 objects
  5369. */
  5370. getHashCode(): number;
  5371. /**
  5372. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5373. * @param array defines the array where to store the r,g,b components
  5374. * @param index defines an optional index in the target array to define where to start storing values
  5375. * @returns the current Color3 object
  5376. */
  5377. toArray(array: FloatArray, index?: number): Color3;
  5378. /**
  5379. * Returns a new Color4 object from the current Color3 and the given alpha
  5380. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5381. * @returns a new Color4 object
  5382. */
  5383. toColor4(alpha?: number): Color4;
  5384. /**
  5385. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5386. * @returns the new array
  5387. */
  5388. asArray(): number[];
  5389. /**
  5390. * Returns the luminance value
  5391. * @returns a float value
  5392. */
  5393. toLuminance(): number;
  5394. /**
  5395. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5396. * @param otherColor defines the second operand
  5397. * @returns the new Color3 object
  5398. */
  5399. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5400. /**
  5401. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5402. * @param otherColor defines the second operand
  5403. * @param result defines the Color3 object where to store the result
  5404. * @returns the current Color3
  5405. */
  5406. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5407. /**
  5408. * Determines equality between Color3 objects
  5409. * @param otherColor defines the second operand
  5410. * @returns true if the rgb values are equal to the given ones
  5411. */
  5412. equals(otherColor: DeepImmutable<Color3>): boolean;
  5413. /**
  5414. * Determines equality between the current Color3 object and a set of r,b,g values
  5415. * @param r defines the red component to check
  5416. * @param g defines the green component to check
  5417. * @param b defines the blue component to check
  5418. * @returns true if the rgb values are equal to the given ones
  5419. */
  5420. equalsFloats(r: number, g: number, b: number): boolean;
  5421. /**
  5422. * Multiplies in place each rgb value by scale
  5423. * @param scale defines the scaling factor
  5424. * @returns the updated Color3
  5425. */
  5426. scale(scale: number): Color3;
  5427. /**
  5428. * Multiplies the rgb values by scale and stores the result into "result"
  5429. * @param scale defines the scaling factor
  5430. * @param result defines the Color3 object where to store the result
  5431. * @returns the unmodified current Color3
  5432. */
  5433. scaleToRef(scale: number, result: Color3): Color3;
  5434. /**
  5435. * Scale the current Color3 values by a factor and add the result to a given Color3
  5436. * @param scale defines the scale factor
  5437. * @param result defines color to store the result into
  5438. * @returns the unmodified current Color3
  5439. */
  5440. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5441. /**
  5442. * Clamps the rgb values by the min and max values and stores the result into "result"
  5443. * @param min defines minimum clamping value (default is 0)
  5444. * @param max defines maximum clamping value (default is 1)
  5445. * @param result defines color to store the result into
  5446. * @returns the original Color3
  5447. */
  5448. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5449. /**
  5450. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5451. * @param otherColor defines the second operand
  5452. * @returns the new Color3
  5453. */
  5454. add(otherColor: DeepImmutable<Color3>): Color3;
  5455. /**
  5456. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5457. * @param otherColor defines the second operand
  5458. * @param result defines Color3 object to store the result into
  5459. * @returns the unmodified current Color3
  5460. */
  5461. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5462. /**
  5463. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5464. * @param otherColor defines the second operand
  5465. * @returns the new Color3
  5466. */
  5467. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5468. /**
  5469. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5470. * @param otherColor defines the second operand
  5471. * @param result defines Color3 object to store the result into
  5472. * @returns the unmodified current Color3
  5473. */
  5474. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5475. /**
  5476. * Copy the current object
  5477. * @returns a new Color3 copied the current one
  5478. */
  5479. clone(): Color3;
  5480. /**
  5481. * Copies the rgb values from the source in the current Color3
  5482. * @param source defines the source Color3 object
  5483. * @returns the updated Color3 object
  5484. */
  5485. copyFrom(source: DeepImmutable<Color3>): Color3;
  5486. /**
  5487. * Updates the Color3 rgb values from the given floats
  5488. * @param r defines the red component to read from
  5489. * @param g defines the green component to read from
  5490. * @param b defines the blue component to read from
  5491. * @returns the current Color3 object
  5492. */
  5493. copyFromFloats(r: number, g: number, b: number): Color3;
  5494. /**
  5495. * Updates the Color3 rgb values from the given floats
  5496. * @param r defines the red component to read from
  5497. * @param g defines the green component to read from
  5498. * @param b defines the blue component to read from
  5499. * @returns the current Color3 object
  5500. */
  5501. set(r: number, g: number, b: number): Color3;
  5502. /**
  5503. * Compute the Color3 hexadecimal code as a string
  5504. * @returns a string containing the hexadecimal representation of the Color3 object
  5505. */
  5506. toHexString(): string;
  5507. /**
  5508. * Computes a new Color3 converted from the current one to linear space
  5509. * @returns a new Color3 object
  5510. */
  5511. toLinearSpace(): Color3;
  5512. /**
  5513. * Converts current color in rgb space to HSV values
  5514. * @returns a new color3 representing the HSV values
  5515. */
  5516. toHSV(): Color3;
  5517. /**
  5518. * Converts current color in rgb space to HSV values
  5519. * @param result defines the Color3 where to store the HSV values
  5520. */
  5521. toHSVToRef(result: Color3): void;
  5522. /**
  5523. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5524. * @param convertedColor defines the Color3 object where to store the linear space version
  5525. * @returns the unmodified Color3
  5526. */
  5527. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5528. /**
  5529. * Computes a new Color3 converted from the current one to gamma space
  5530. * @returns a new Color3 object
  5531. */
  5532. toGammaSpace(): Color3;
  5533. /**
  5534. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5535. * @param convertedColor defines the Color3 object where to store the gamma space version
  5536. * @returns the unmodified Color3
  5537. */
  5538. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5539. private static _BlackReadOnly;
  5540. /**
  5541. * Convert Hue, saturation and value to a Color3 (RGB)
  5542. * @param hue defines the hue
  5543. * @param saturation defines the saturation
  5544. * @param value defines the value
  5545. * @param result defines the Color3 where to store the RGB values
  5546. */
  5547. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5548. /**
  5549. * Creates a new Color3 from the string containing valid hexadecimal values
  5550. * @param hex defines a string containing valid hexadecimal values
  5551. * @returns a new Color3 object
  5552. */
  5553. static FromHexString(hex: string): Color3;
  5554. /**
  5555. * Creates a new Color3 from the starting index of the given array
  5556. * @param array defines the source array
  5557. * @param offset defines an offset in the source array
  5558. * @returns a new Color3 object
  5559. */
  5560. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5561. /**
  5562. * Creates a new Color3 from integer values (< 256)
  5563. * @param r defines the red component to read from (value between 0 and 255)
  5564. * @param g defines the green component to read from (value between 0 and 255)
  5565. * @param b defines the blue component to read from (value between 0 and 255)
  5566. * @returns a new Color3 object
  5567. */
  5568. static FromInts(r: number, g: number, b: number): Color3;
  5569. /**
  5570. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5571. * @param start defines the start Color3 value
  5572. * @param end defines the end Color3 value
  5573. * @param amount defines the gradient value between start and end
  5574. * @returns a new Color3 object
  5575. */
  5576. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5577. /**
  5578. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5579. * @param left defines the start value
  5580. * @param right defines the end value
  5581. * @param amount defines the gradient factor
  5582. * @param result defines the Color3 object where to store the result
  5583. */
  5584. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5585. /**
  5586. * Returns a Color3 value containing a red color
  5587. * @returns a new Color3 object
  5588. */
  5589. static Red(): Color3;
  5590. /**
  5591. * Returns a Color3 value containing a green color
  5592. * @returns a new Color3 object
  5593. */
  5594. static Green(): Color3;
  5595. /**
  5596. * Returns a Color3 value containing a blue color
  5597. * @returns a new Color3 object
  5598. */
  5599. static Blue(): Color3;
  5600. /**
  5601. * Returns a Color3 value containing a black color
  5602. * @returns a new Color3 object
  5603. */
  5604. static Black(): Color3;
  5605. /**
  5606. * Gets a Color3 value containing a black color that must not be updated
  5607. */
  5608. static get BlackReadOnly(): DeepImmutable<Color3>;
  5609. /**
  5610. * Returns a Color3 value containing a white color
  5611. * @returns a new Color3 object
  5612. */
  5613. static White(): Color3;
  5614. /**
  5615. * Returns a Color3 value containing a purple color
  5616. * @returns a new Color3 object
  5617. */
  5618. static Purple(): Color3;
  5619. /**
  5620. * Returns a Color3 value containing a magenta color
  5621. * @returns a new Color3 object
  5622. */
  5623. static Magenta(): Color3;
  5624. /**
  5625. * Returns a Color3 value containing a yellow color
  5626. * @returns a new Color3 object
  5627. */
  5628. static Yellow(): Color3;
  5629. /**
  5630. * Returns a Color3 value containing a gray color
  5631. * @returns a new Color3 object
  5632. */
  5633. static Gray(): Color3;
  5634. /**
  5635. * Returns a Color3 value containing a teal color
  5636. * @returns a new Color3 object
  5637. */
  5638. static Teal(): Color3;
  5639. /**
  5640. * Returns a Color3 value containing a random color
  5641. * @returns a new Color3 object
  5642. */
  5643. static Random(): Color3;
  5644. }
  5645. /**
  5646. * Class used to hold a RBGA color
  5647. */
  5648. export class Color4 {
  5649. /**
  5650. * Defines the red component (between 0 and 1, default is 0)
  5651. */
  5652. r: number;
  5653. /**
  5654. * Defines the green component (between 0 and 1, default is 0)
  5655. */
  5656. g: number;
  5657. /**
  5658. * Defines the blue component (between 0 and 1, default is 0)
  5659. */
  5660. b: number;
  5661. /**
  5662. * Defines the alpha component (between 0 and 1, default is 1)
  5663. */
  5664. a: number;
  5665. /**
  5666. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5667. * @param r defines the red component (between 0 and 1, default is 0)
  5668. * @param g defines the green component (between 0 and 1, default is 0)
  5669. * @param b defines the blue component (between 0 and 1, default is 0)
  5670. * @param a defines the alpha component (between 0 and 1, default is 1)
  5671. */
  5672. constructor(
  5673. /**
  5674. * Defines the red component (between 0 and 1, default is 0)
  5675. */
  5676. r?: number,
  5677. /**
  5678. * Defines the green component (between 0 and 1, default is 0)
  5679. */
  5680. g?: number,
  5681. /**
  5682. * Defines the blue component (between 0 and 1, default is 0)
  5683. */
  5684. b?: number,
  5685. /**
  5686. * Defines the alpha component (between 0 and 1, default is 1)
  5687. */
  5688. a?: number);
  5689. /**
  5690. * Adds in place the given Color4 values to the current Color4 object
  5691. * @param right defines the second operand
  5692. * @returns the current updated Color4 object
  5693. */
  5694. addInPlace(right: DeepImmutable<Color4>): Color4;
  5695. /**
  5696. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5697. * @returns the new array
  5698. */
  5699. asArray(): number[];
  5700. /**
  5701. * Stores from the starting index in the given array the Color4 successive values
  5702. * @param array defines the array where to store the r,g,b components
  5703. * @param index defines an optional index in the target array to define where to start storing values
  5704. * @returns the current Color4 object
  5705. */
  5706. toArray(array: number[], index?: number): Color4;
  5707. /**
  5708. * Determines equality between Color4 objects
  5709. * @param otherColor defines the second operand
  5710. * @returns true if the rgba values are equal to the given ones
  5711. */
  5712. equals(otherColor: DeepImmutable<Color4>): boolean;
  5713. /**
  5714. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5715. * @param right defines the second operand
  5716. * @returns a new Color4 object
  5717. */
  5718. add(right: DeepImmutable<Color4>): Color4;
  5719. /**
  5720. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5721. * @param right defines the second operand
  5722. * @returns a new Color4 object
  5723. */
  5724. subtract(right: DeepImmutable<Color4>): Color4;
  5725. /**
  5726. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5727. * @param right defines the second operand
  5728. * @param result defines the Color4 object where to store the result
  5729. * @returns the current Color4 object
  5730. */
  5731. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5732. /**
  5733. * Creates a new Color4 with the current Color4 values multiplied by scale
  5734. * @param scale defines the scaling factor to apply
  5735. * @returns a new Color4 object
  5736. */
  5737. scale(scale: number): Color4;
  5738. /**
  5739. * Multiplies the current Color4 values by scale and stores the result in "result"
  5740. * @param scale defines the scaling factor to apply
  5741. * @param result defines the Color4 object where to store the result
  5742. * @returns the current unmodified Color4
  5743. */
  5744. scaleToRef(scale: number, result: Color4): Color4;
  5745. /**
  5746. * Scale the current Color4 values by a factor and add the result to a given Color4
  5747. * @param scale defines the scale factor
  5748. * @param result defines the Color4 object where to store the result
  5749. * @returns the unmodified current Color4
  5750. */
  5751. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5752. /**
  5753. * Clamps the rgb values by the min and max values and stores the result into "result"
  5754. * @param min defines minimum clamping value (default is 0)
  5755. * @param max defines maximum clamping value (default is 1)
  5756. * @param result defines color to store the result into.
  5757. * @returns the cuurent Color4
  5758. */
  5759. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5760. /**
  5761. * Multipy an Color4 value by another and return a new Color4 object
  5762. * @param color defines the Color4 value to multiply by
  5763. * @returns a new Color4 object
  5764. */
  5765. multiply(color: Color4): Color4;
  5766. /**
  5767. * Multipy a Color4 value by another and push the result in a reference value
  5768. * @param color defines the Color4 value to multiply by
  5769. * @param result defines the Color4 to fill the result in
  5770. * @returns the result Color4
  5771. */
  5772. multiplyToRef(color: Color4, result: Color4): Color4;
  5773. /**
  5774. * Creates a string with the Color4 current values
  5775. * @returns the string representation of the Color4 object
  5776. */
  5777. toString(): string;
  5778. /**
  5779. * Returns the string "Color4"
  5780. * @returns "Color4"
  5781. */
  5782. getClassName(): string;
  5783. /**
  5784. * Compute the Color4 hash code
  5785. * @returns an unique number that can be used to hash Color4 objects
  5786. */
  5787. getHashCode(): number;
  5788. /**
  5789. * Creates a new Color4 copied from the current one
  5790. * @returns a new Color4 object
  5791. */
  5792. clone(): Color4;
  5793. /**
  5794. * Copies the given Color4 values into the current one
  5795. * @param source defines the source Color4 object
  5796. * @returns the current updated Color4 object
  5797. */
  5798. copyFrom(source: Color4): Color4;
  5799. /**
  5800. * Copies the given float values into the current one
  5801. * @param r defines the red component to read from
  5802. * @param g defines the green component to read from
  5803. * @param b defines the blue component to read from
  5804. * @param a defines the alpha component to read from
  5805. * @returns the current updated Color4 object
  5806. */
  5807. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5808. /**
  5809. * Copies the given float values into the current one
  5810. * @param r defines the red component to read from
  5811. * @param g defines the green component to read from
  5812. * @param b defines the blue component to read from
  5813. * @param a defines the alpha component to read from
  5814. * @returns the current updated Color4 object
  5815. */
  5816. set(r: number, g: number, b: number, a: number): Color4;
  5817. /**
  5818. * Compute the Color4 hexadecimal code as a string
  5819. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  5820. * @returns a string containing the hexadecimal representation of the Color4 object
  5821. */
  5822. toHexString(returnAsColor3?: boolean): string;
  5823. /**
  5824. * Computes a new Color4 converted from the current one to linear space
  5825. * @returns a new Color4 object
  5826. */
  5827. toLinearSpace(): Color4;
  5828. /**
  5829. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5830. * @param convertedColor defines the Color4 object where to store the linear space version
  5831. * @returns the unmodified Color4
  5832. */
  5833. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5834. /**
  5835. * Computes a new Color4 converted from the current one to gamma space
  5836. * @returns a new Color4 object
  5837. */
  5838. toGammaSpace(): Color4;
  5839. /**
  5840. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5841. * @param convertedColor defines the Color4 object where to store the gamma space version
  5842. * @returns the unmodified Color4
  5843. */
  5844. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5845. /**
  5846. * Creates a new Color4 from the string containing valid hexadecimal values
  5847. * @param hex defines a string containing valid hexadecimal values
  5848. * @returns a new Color4 object
  5849. */
  5850. static FromHexString(hex: string): Color4;
  5851. /**
  5852. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5853. * @param left defines the start value
  5854. * @param right defines the end value
  5855. * @param amount defines the gradient factor
  5856. * @returns a new Color4 object
  5857. */
  5858. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5859. /**
  5860. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5861. * @param left defines the start value
  5862. * @param right defines the end value
  5863. * @param amount defines the gradient factor
  5864. * @param result defines the Color4 object where to store data
  5865. */
  5866. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5867. /**
  5868. * Creates a new Color4 from a Color3 and an alpha value
  5869. * @param color3 defines the source Color3 to read from
  5870. * @param alpha defines the alpha component (1.0 by default)
  5871. * @returns a new Color4 object
  5872. */
  5873. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5874. /**
  5875. * Creates a new Color4 from the starting index element of the given array
  5876. * @param array defines the source array to read from
  5877. * @param offset defines the offset in the source array
  5878. * @returns a new Color4 object
  5879. */
  5880. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5881. /**
  5882. * Creates a new Color3 from integer values (< 256)
  5883. * @param r defines the red component to read from (value between 0 and 255)
  5884. * @param g defines the green component to read from (value between 0 and 255)
  5885. * @param b defines the blue component to read from (value between 0 and 255)
  5886. * @param a defines the alpha component to read from (value between 0 and 255)
  5887. * @returns a new Color3 object
  5888. */
  5889. static FromInts(r: number, g: number, b: number, a: number): Color4;
  5890. /**
  5891. * Check the content of a given array and convert it to an array containing RGBA data
  5892. * If the original array was already containing count * 4 values then it is returned directly
  5893. * @param colors defines the array to check
  5894. * @param count defines the number of RGBA data to expect
  5895. * @returns an array containing count * 4 values (RGBA)
  5896. */
  5897. static CheckColors4(colors: number[], count: number): number[];
  5898. }
  5899. /**
  5900. * @hidden
  5901. */
  5902. export class TmpColors {
  5903. static Color3: Color3[];
  5904. static Color4: Color4[];
  5905. }
  5906. }
  5907. declare module "babylonjs/Animations/animationKey" {
  5908. /**
  5909. * Defines an interface which represents an animation key frame
  5910. */
  5911. export interface IAnimationKey {
  5912. /**
  5913. * Frame of the key frame
  5914. */
  5915. frame: number;
  5916. /**
  5917. * Value at the specifies key frame
  5918. */
  5919. value: any;
  5920. /**
  5921. * The input tangent for the cubic hermite spline
  5922. */
  5923. inTangent?: any;
  5924. /**
  5925. * The output tangent for the cubic hermite spline
  5926. */
  5927. outTangent?: any;
  5928. /**
  5929. * The animation interpolation type
  5930. */
  5931. interpolation?: AnimationKeyInterpolation;
  5932. }
  5933. /**
  5934. * Enum for the animation key frame interpolation type
  5935. */
  5936. export enum AnimationKeyInterpolation {
  5937. /**
  5938. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  5939. */
  5940. STEP = 1
  5941. }
  5942. }
  5943. declare module "babylonjs/Animations/animationRange" {
  5944. /**
  5945. * Represents the range of an animation
  5946. */
  5947. export class AnimationRange {
  5948. /**The name of the animation range**/
  5949. name: string;
  5950. /**The starting frame of the animation */
  5951. from: number;
  5952. /**The ending frame of the animation*/
  5953. to: number;
  5954. /**
  5955. * Initializes the range of an animation
  5956. * @param name The name of the animation range
  5957. * @param from The starting frame of the animation
  5958. * @param to The ending frame of the animation
  5959. */
  5960. constructor(
  5961. /**The name of the animation range**/
  5962. name: string,
  5963. /**The starting frame of the animation */
  5964. from: number,
  5965. /**The ending frame of the animation*/
  5966. to: number);
  5967. /**
  5968. * Makes a copy of the animation range
  5969. * @returns A copy of the animation range
  5970. */
  5971. clone(): AnimationRange;
  5972. }
  5973. }
  5974. declare module "babylonjs/Animations/animationEvent" {
  5975. /**
  5976. * Composed of a frame, and an action function
  5977. */
  5978. export class AnimationEvent {
  5979. /** The frame for which the event is triggered **/
  5980. frame: number;
  5981. /** The event to perform when triggered **/
  5982. action: (currentFrame: number) => void;
  5983. /** Specifies if the event should be triggered only once**/
  5984. onlyOnce?: boolean | undefined;
  5985. /**
  5986. * Specifies if the animation event is done
  5987. */
  5988. isDone: boolean;
  5989. /**
  5990. * Initializes the animation event
  5991. * @param frame The frame for which the event is triggered
  5992. * @param action The event to perform when triggered
  5993. * @param onlyOnce Specifies if the event should be triggered only once
  5994. */
  5995. constructor(
  5996. /** The frame for which the event is triggered **/
  5997. frame: number,
  5998. /** The event to perform when triggered **/
  5999. action: (currentFrame: number) => void,
  6000. /** Specifies if the event should be triggered only once**/
  6001. onlyOnce?: boolean | undefined);
  6002. /** @hidden */
  6003. _clone(): AnimationEvent;
  6004. }
  6005. }
  6006. declare module "babylonjs/Behaviors/behavior" {
  6007. import { Nullable } from "babylonjs/types";
  6008. /**
  6009. * Interface used to define a behavior
  6010. */
  6011. export interface Behavior<T> {
  6012. /** gets or sets behavior's name */
  6013. name: string;
  6014. /**
  6015. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6016. */
  6017. init(): void;
  6018. /**
  6019. * Called when the behavior is attached to a target
  6020. * @param target defines the target where the behavior is attached to
  6021. */
  6022. attach(target: T): void;
  6023. /**
  6024. * Called when the behavior is detached from its target
  6025. */
  6026. detach(): void;
  6027. }
  6028. /**
  6029. * Interface implemented by classes supporting behaviors
  6030. */
  6031. export interface IBehaviorAware<T> {
  6032. /**
  6033. * Attach a behavior
  6034. * @param behavior defines the behavior to attach
  6035. * @returns the current host
  6036. */
  6037. addBehavior(behavior: Behavior<T>): T;
  6038. /**
  6039. * Remove a behavior from the current object
  6040. * @param behavior defines the behavior to detach
  6041. * @returns the current host
  6042. */
  6043. removeBehavior(behavior: Behavior<T>): T;
  6044. /**
  6045. * Gets a behavior using its name to search
  6046. * @param name defines the name to search
  6047. * @returns the behavior or null if not found
  6048. */
  6049. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6050. }
  6051. }
  6052. declare module "babylonjs/Misc/smartArray" {
  6053. /**
  6054. * Defines an array and its length.
  6055. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6056. */
  6057. export interface ISmartArrayLike<T> {
  6058. /**
  6059. * The data of the array.
  6060. */
  6061. data: Array<T>;
  6062. /**
  6063. * The active length of the array.
  6064. */
  6065. length: number;
  6066. }
  6067. /**
  6068. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6069. */
  6070. export class SmartArray<T> implements ISmartArrayLike<T> {
  6071. /**
  6072. * The full set of data from the array.
  6073. */
  6074. data: Array<T>;
  6075. /**
  6076. * The active length of the array.
  6077. */
  6078. length: number;
  6079. protected _id: number;
  6080. /**
  6081. * Instantiates a Smart Array.
  6082. * @param capacity defines the default capacity of the array.
  6083. */
  6084. constructor(capacity: number);
  6085. /**
  6086. * Pushes a value at the end of the active data.
  6087. * @param value defines the object to push in the array.
  6088. */
  6089. push(value: T): void;
  6090. /**
  6091. * Iterates over the active data and apply the lambda to them.
  6092. * @param func defines the action to apply on each value.
  6093. */
  6094. forEach(func: (content: T) => void): void;
  6095. /**
  6096. * Sorts the full sets of data.
  6097. * @param compareFn defines the comparison function to apply.
  6098. */
  6099. sort(compareFn: (a: T, b: T) => number): void;
  6100. /**
  6101. * Resets the active data to an empty array.
  6102. */
  6103. reset(): void;
  6104. /**
  6105. * Releases all the data from the array as well as the array.
  6106. */
  6107. dispose(): void;
  6108. /**
  6109. * Concats the active data with a given array.
  6110. * @param array defines the data to concatenate with.
  6111. */
  6112. concat(array: any): void;
  6113. /**
  6114. * Returns the position of a value in the active data.
  6115. * @param value defines the value to find the index for
  6116. * @returns the index if found in the active data otherwise -1
  6117. */
  6118. indexOf(value: T): number;
  6119. /**
  6120. * Returns whether an element is part of the active data.
  6121. * @param value defines the value to look for
  6122. * @returns true if found in the active data otherwise false
  6123. */
  6124. contains(value: T): boolean;
  6125. private static _GlobalId;
  6126. }
  6127. /**
  6128. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6129. * The data in this array can only be present once
  6130. */
  6131. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6132. private _duplicateId;
  6133. /**
  6134. * Pushes a value at the end of the active data.
  6135. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6136. * @param value defines the object to push in the array.
  6137. */
  6138. push(value: T): void;
  6139. /**
  6140. * Pushes a value at the end of the active data.
  6141. * If the data is already present, it won t be added again
  6142. * @param value defines the object to push in the array.
  6143. * @returns true if added false if it was already present
  6144. */
  6145. pushNoDuplicate(value: T): boolean;
  6146. /**
  6147. * Resets the active data to an empty array.
  6148. */
  6149. reset(): void;
  6150. /**
  6151. * Concats the active data with a given array.
  6152. * This ensures no dupplicate will be present in the result.
  6153. * @param array defines the data to concatenate with.
  6154. */
  6155. concatWithNoDuplicate(array: any): void;
  6156. }
  6157. }
  6158. declare module "babylonjs/Cameras/cameraInputsManager" {
  6159. import { Nullable } from "babylonjs/types";
  6160. import { Camera } from "babylonjs/Cameras/camera";
  6161. /**
  6162. * @ignore
  6163. * This is a list of all the different input types that are available in the application.
  6164. * Fo instance: ArcRotateCameraGamepadInput...
  6165. */
  6166. export var CameraInputTypes: {};
  6167. /**
  6168. * This is the contract to implement in order to create a new input class.
  6169. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6170. */
  6171. export interface ICameraInput<TCamera extends Camera> {
  6172. /**
  6173. * Defines the camera the input is attached to.
  6174. */
  6175. camera: Nullable<TCamera>;
  6176. /**
  6177. * Gets the class name of the current intput.
  6178. * @returns the class name
  6179. */
  6180. getClassName(): string;
  6181. /**
  6182. * Get the friendly name associated with the input class.
  6183. * @returns the input friendly name
  6184. */
  6185. getSimpleName(): string;
  6186. /**
  6187. * Attach the input controls to a specific dom element to get the input from.
  6188. * @param element Defines the element the controls should be listened from
  6189. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6190. */
  6191. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6192. /**
  6193. * Detach the current controls from the specified dom element.
  6194. * @param element Defines the element to stop listening the inputs from
  6195. */
  6196. detachControl(element: Nullable<HTMLElement>): void;
  6197. /**
  6198. * Update the current camera state depending on the inputs that have been used this frame.
  6199. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6200. */
  6201. checkInputs?: () => void;
  6202. }
  6203. /**
  6204. * Represents a map of input types to input instance or input index to input instance.
  6205. */
  6206. export interface CameraInputsMap<TCamera extends Camera> {
  6207. /**
  6208. * Accessor to the input by input type.
  6209. */
  6210. [name: string]: ICameraInput<TCamera>;
  6211. /**
  6212. * Accessor to the input by input index.
  6213. */
  6214. [idx: number]: ICameraInput<TCamera>;
  6215. }
  6216. /**
  6217. * This represents the input manager used within a camera.
  6218. * It helps dealing with all the different kind of input attached to a camera.
  6219. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6220. */
  6221. export class CameraInputsManager<TCamera extends Camera> {
  6222. /**
  6223. * Defines the list of inputs attahed to the camera.
  6224. */
  6225. attached: CameraInputsMap<TCamera>;
  6226. /**
  6227. * Defines the dom element the camera is collecting inputs from.
  6228. * This is null if the controls have not been attached.
  6229. */
  6230. attachedElement: Nullable<HTMLElement>;
  6231. /**
  6232. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6233. */
  6234. noPreventDefault: boolean;
  6235. /**
  6236. * Defined the camera the input manager belongs to.
  6237. */
  6238. camera: TCamera;
  6239. /**
  6240. * Update the current camera state depending on the inputs that have been used this frame.
  6241. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6242. */
  6243. checkInputs: () => void;
  6244. /**
  6245. * Instantiate a new Camera Input Manager.
  6246. * @param camera Defines the camera the input manager blongs to
  6247. */
  6248. constructor(camera: TCamera);
  6249. /**
  6250. * Add an input method to a camera
  6251. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6252. * @param input camera input method
  6253. */
  6254. add(input: ICameraInput<TCamera>): void;
  6255. /**
  6256. * Remove a specific input method from a camera
  6257. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6258. * @param inputToRemove camera input method
  6259. */
  6260. remove(inputToRemove: ICameraInput<TCamera>): void;
  6261. /**
  6262. * Remove a specific input type from a camera
  6263. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6264. * @param inputType the type of the input to remove
  6265. */
  6266. removeByType(inputType: string): void;
  6267. private _addCheckInputs;
  6268. /**
  6269. * Attach the input controls to the currently attached dom element to listen the events from.
  6270. * @param input Defines the input to attach
  6271. */
  6272. attachInput(input: ICameraInput<TCamera>): void;
  6273. /**
  6274. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6275. * @param element Defines the dom element to collect the events from
  6276. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6277. */
  6278. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6279. /**
  6280. * Detach the current manager inputs controls from a specific dom element.
  6281. * @param element Defines the dom element to collect the events from
  6282. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6283. */
  6284. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6285. /**
  6286. * Rebuild the dynamic inputCheck function from the current list of
  6287. * defined inputs in the manager.
  6288. */
  6289. rebuildInputCheck(): void;
  6290. /**
  6291. * Remove all attached input methods from a camera
  6292. */
  6293. clear(): void;
  6294. /**
  6295. * Serialize the current input manager attached to a camera.
  6296. * This ensures than once parsed,
  6297. * the input associated to the camera will be identical to the current ones
  6298. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6299. */
  6300. serialize(serializedCamera: any): void;
  6301. /**
  6302. * Parses an input manager serialized JSON to restore the previous list of inputs
  6303. * and states associated to a camera.
  6304. * @param parsedCamera Defines the JSON to parse
  6305. */
  6306. parse(parsedCamera: any): void;
  6307. }
  6308. }
  6309. declare module "babylonjs/Meshes/buffer" {
  6310. import { Nullable, DataArray } from "babylonjs/types";
  6311. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  6312. /**
  6313. * Class used to store data that will be store in GPU memory
  6314. */
  6315. export class Buffer {
  6316. private _engine;
  6317. private _buffer;
  6318. /** @hidden */
  6319. _data: Nullable<DataArray>;
  6320. private _updatable;
  6321. private _instanced;
  6322. private _divisor;
  6323. /**
  6324. * Gets the byte stride.
  6325. */
  6326. readonly byteStride: number;
  6327. /**
  6328. * Constructor
  6329. * @param engine the engine
  6330. * @param data the data to use for this buffer
  6331. * @param updatable whether the data is updatable
  6332. * @param stride the stride (optional)
  6333. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6334. * @param instanced whether the buffer is instanced (optional)
  6335. * @param useBytes set to true if the stride in in bytes (optional)
  6336. * @param divisor sets an optional divisor for instances (1 by default)
  6337. */
  6338. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6339. /**
  6340. * Create a new VertexBuffer based on the current buffer
  6341. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6342. * @param offset defines offset in the buffer (0 by default)
  6343. * @param size defines the size in floats of attributes (position is 3 for instance)
  6344. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6345. * @param instanced defines if the vertex buffer contains indexed data
  6346. * @param useBytes defines if the offset and stride are in bytes *
  6347. * @param divisor sets an optional divisor for instances (1 by default)
  6348. * @returns the new vertex buffer
  6349. */
  6350. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6351. /**
  6352. * Gets a boolean indicating if the Buffer is updatable?
  6353. * @returns true if the buffer is updatable
  6354. */
  6355. isUpdatable(): boolean;
  6356. /**
  6357. * Gets current buffer's data
  6358. * @returns a DataArray or null
  6359. */
  6360. getData(): Nullable<DataArray>;
  6361. /**
  6362. * Gets underlying native buffer
  6363. * @returns underlying native buffer
  6364. */
  6365. getBuffer(): Nullable<DataBuffer>;
  6366. /**
  6367. * Gets the stride in float32 units (i.e. byte stride / 4).
  6368. * May not be an integer if the byte stride is not divisible by 4.
  6369. * @returns the stride in float32 units
  6370. * @deprecated Please use byteStride instead.
  6371. */
  6372. getStrideSize(): number;
  6373. /**
  6374. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6375. * @param data defines the data to store
  6376. */
  6377. create(data?: Nullable<DataArray>): void;
  6378. /** @hidden */
  6379. _rebuild(): void;
  6380. /**
  6381. * Update current buffer data
  6382. * @param data defines the data to store
  6383. */
  6384. update(data: DataArray): void;
  6385. /**
  6386. * Updates the data directly.
  6387. * @param data the new data
  6388. * @param offset the new offset
  6389. * @param vertexCount the vertex count (optional)
  6390. * @param useBytes set to true if the offset is in bytes
  6391. */
  6392. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6393. /**
  6394. * Release all resources
  6395. */
  6396. dispose(): void;
  6397. }
  6398. /**
  6399. * Specialized buffer used to store vertex data
  6400. */
  6401. export class VertexBuffer {
  6402. /** @hidden */
  6403. _buffer: Buffer;
  6404. private _kind;
  6405. private _size;
  6406. private _ownsBuffer;
  6407. private _instanced;
  6408. private _instanceDivisor;
  6409. /**
  6410. * The byte type.
  6411. */
  6412. static readonly BYTE: number;
  6413. /**
  6414. * The unsigned byte type.
  6415. */
  6416. static readonly UNSIGNED_BYTE: number;
  6417. /**
  6418. * The short type.
  6419. */
  6420. static readonly SHORT: number;
  6421. /**
  6422. * The unsigned short type.
  6423. */
  6424. static readonly UNSIGNED_SHORT: number;
  6425. /**
  6426. * The integer type.
  6427. */
  6428. static readonly INT: number;
  6429. /**
  6430. * The unsigned integer type.
  6431. */
  6432. static readonly UNSIGNED_INT: number;
  6433. /**
  6434. * The float type.
  6435. */
  6436. static readonly FLOAT: number;
  6437. /**
  6438. * Gets or sets the instance divisor when in instanced mode
  6439. */
  6440. get instanceDivisor(): number;
  6441. set instanceDivisor(value: number);
  6442. /**
  6443. * Gets the byte stride.
  6444. */
  6445. readonly byteStride: number;
  6446. /**
  6447. * Gets the byte offset.
  6448. */
  6449. readonly byteOffset: number;
  6450. /**
  6451. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6452. */
  6453. readonly normalized: boolean;
  6454. /**
  6455. * Gets the data type of each component in the array.
  6456. */
  6457. readonly type: number;
  6458. /**
  6459. * Constructor
  6460. * @param engine the engine
  6461. * @param data the data to use for this vertex buffer
  6462. * @param kind the vertex buffer kind
  6463. * @param updatable whether the data is updatable
  6464. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6465. * @param stride the stride (optional)
  6466. * @param instanced whether the buffer is instanced (optional)
  6467. * @param offset the offset of the data (optional)
  6468. * @param size the number of components (optional)
  6469. * @param type the type of the component (optional)
  6470. * @param normalized whether the data contains normalized data (optional)
  6471. * @param useBytes set to true if stride and offset are in bytes (optional)
  6472. * @param divisor defines the instance divisor to use (1 by default)
  6473. */
  6474. constructor(engine: any, data: DataArray | Buffer, kind: string, updatable: boolean, postponeInternalCreation?: boolean, stride?: number, instanced?: boolean, offset?: number, size?: number, type?: number, normalized?: boolean, useBytes?: boolean, divisor?: number);
  6475. /** @hidden */
  6476. _rebuild(): void;
  6477. /**
  6478. * Returns the kind of the VertexBuffer (string)
  6479. * @returns a string
  6480. */
  6481. getKind(): string;
  6482. /**
  6483. * Gets a boolean indicating if the VertexBuffer is updatable?
  6484. * @returns true if the buffer is updatable
  6485. */
  6486. isUpdatable(): boolean;
  6487. /**
  6488. * Gets current buffer's data
  6489. * @returns a DataArray or null
  6490. */
  6491. getData(): Nullable<DataArray>;
  6492. /**
  6493. * Gets underlying native buffer
  6494. * @returns underlying native buffer
  6495. */
  6496. getBuffer(): Nullable<DataBuffer>;
  6497. /**
  6498. * Gets the stride in float32 units (i.e. byte stride / 4).
  6499. * May not be an integer if the byte stride is not divisible by 4.
  6500. * @returns the stride in float32 units
  6501. * @deprecated Please use byteStride instead.
  6502. */
  6503. getStrideSize(): number;
  6504. /**
  6505. * Returns the offset as a multiple of the type byte length.
  6506. * @returns the offset in bytes
  6507. * @deprecated Please use byteOffset instead.
  6508. */
  6509. getOffset(): number;
  6510. /**
  6511. * Returns the number of components per vertex attribute (integer)
  6512. * @returns the size in float
  6513. */
  6514. getSize(): number;
  6515. /**
  6516. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6517. * @returns true if this buffer is instanced
  6518. */
  6519. getIsInstanced(): boolean;
  6520. /**
  6521. * Returns the instancing divisor, zero for non-instanced (integer).
  6522. * @returns a number
  6523. */
  6524. getInstanceDivisor(): number;
  6525. /**
  6526. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6527. * @param data defines the data to store
  6528. */
  6529. create(data?: DataArray): void;
  6530. /**
  6531. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6532. * This function will create a new buffer if the current one is not updatable
  6533. * @param data defines the data to store
  6534. */
  6535. update(data: DataArray): void;
  6536. /**
  6537. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6538. * Returns the directly updated WebGLBuffer.
  6539. * @param data the new data
  6540. * @param offset the new offset
  6541. * @param useBytes set to true if the offset is in bytes
  6542. */
  6543. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6544. /**
  6545. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6546. */
  6547. dispose(): void;
  6548. /**
  6549. * Enumerates each value of this vertex buffer as numbers.
  6550. * @param count the number of values to enumerate
  6551. * @param callback the callback function called for each value
  6552. */
  6553. forEach(count: number, callback: (value: number, index: number) => void): void;
  6554. /**
  6555. * Positions
  6556. */
  6557. static readonly PositionKind: string;
  6558. /**
  6559. * Normals
  6560. */
  6561. static readonly NormalKind: string;
  6562. /**
  6563. * Tangents
  6564. */
  6565. static readonly TangentKind: string;
  6566. /**
  6567. * Texture coordinates
  6568. */
  6569. static readonly UVKind: string;
  6570. /**
  6571. * Texture coordinates 2
  6572. */
  6573. static readonly UV2Kind: string;
  6574. /**
  6575. * Texture coordinates 3
  6576. */
  6577. static readonly UV3Kind: string;
  6578. /**
  6579. * Texture coordinates 4
  6580. */
  6581. static readonly UV4Kind: string;
  6582. /**
  6583. * Texture coordinates 5
  6584. */
  6585. static readonly UV5Kind: string;
  6586. /**
  6587. * Texture coordinates 6
  6588. */
  6589. static readonly UV6Kind: string;
  6590. /**
  6591. * Colors
  6592. */
  6593. static readonly ColorKind: string;
  6594. /**
  6595. * Matrix indices (for bones)
  6596. */
  6597. static readonly MatricesIndicesKind: string;
  6598. /**
  6599. * Matrix weights (for bones)
  6600. */
  6601. static readonly MatricesWeightsKind: string;
  6602. /**
  6603. * Additional matrix indices (for bones)
  6604. */
  6605. static readonly MatricesIndicesExtraKind: string;
  6606. /**
  6607. * Additional matrix weights (for bones)
  6608. */
  6609. static readonly MatricesWeightsExtraKind: string;
  6610. /**
  6611. * Deduces the stride given a kind.
  6612. * @param kind The kind string to deduce
  6613. * @returns The deduced stride
  6614. */
  6615. static DeduceStride(kind: string): number;
  6616. /**
  6617. * Gets the byte length of the given type.
  6618. * @param type the type
  6619. * @returns the number of bytes
  6620. */
  6621. static GetTypeByteLength(type: number): number;
  6622. /**
  6623. * Enumerates each value of the given parameters as numbers.
  6624. * @param data the data to enumerate
  6625. * @param byteOffset the byte offset of the data
  6626. * @param byteStride the byte stride of the data
  6627. * @param componentCount the number of components per element
  6628. * @param componentType the type of the component
  6629. * @param count the number of values to enumerate
  6630. * @param normalized whether the data is normalized
  6631. * @param callback the callback function called for each value
  6632. */
  6633. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6634. private static _GetFloatValue;
  6635. }
  6636. }
  6637. declare module "babylonjs/Collisions/intersectionInfo" {
  6638. import { Nullable } from "babylonjs/types";
  6639. /**
  6640. * @hidden
  6641. */
  6642. export class IntersectionInfo {
  6643. bu: Nullable<number>;
  6644. bv: Nullable<number>;
  6645. distance: number;
  6646. faceId: number;
  6647. subMeshId: number;
  6648. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6649. }
  6650. }
  6651. declare module "babylonjs/Maths/math.plane" {
  6652. import { DeepImmutable } from "babylonjs/types";
  6653. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  6654. /**
  6655. * Represens a plane by the equation ax + by + cz + d = 0
  6656. */
  6657. export class Plane {
  6658. private static _TmpMatrix;
  6659. /**
  6660. * Normal of the plane (a,b,c)
  6661. */
  6662. normal: Vector3;
  6663. /**
  6664. * d component of the plane
  6665. */
  6666. d: number;
  6667. /**
  6668. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6669. * @param a a component of the plane
  6670. * @param b b component of the plane
  6671. * @param c c component of the plane
  6672. * @param d d component of the plane
  6673. */
  6674. constructor(a: number, b: number, c: number, d: number);
  6675. /**
  6676. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6677. */
  6678. asArray(): number[];
  6679. /**
  6680. * @returns a new plane copied from the current Plane.
  6681. */
  6682. clone(): Plane;
  6683. /**
  6684. * @returns the string "Plane".
  6685. */
  6686. getClassName(): string;
  6687. /**
  6688. * @returns the Plane hash code.
  6689. */
  6690. getHashCode(): number;
  6691. /**
  6692. * Normalize the current Plane in place.
  6693. * @returns the updated Plane.
  6694. */
  6695. normalize(): Plane;
  6696. /**
  6697. * Applies a transformation the plane and returns the result
  6698. * @param transformation the transformation matrix to be applied to the plane
  6699. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6700. */
  6701. transform(transformation: DeepImmutable<Matrix>): Plane;
  6702. /**
  6703. * Calcualtte the dot product between the point and the plane normal
  6704. * @param point point to calculate the dot product with
  6705. * @returns the dot product (float) of the point coordinates and the plane normal.
  6706. */
  6707. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6708. /**
  6709. * Updates the current Plane from the plane defined by the three given points.
  6710. * @param point1 one of the points used to contruct the plane
  6711. * @param point2 one of the points used to contruct the plane
  6712. * @param point3 one of the points used to contruct the plane
  6713. * @returns the updated Plane.
  6714. */
  6715. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6716. /**
  6717. * Checks if the plane is facing a given direction
  6718. * @param direction the direction to check if the plane is facing
  6719. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6720. * @returns True is the vector "direction" is the same side than the plane normal.
  6721. */
  6722. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6723. /**
  6724. * Calculates the distance to a point
  6725. * @param point point to calculate distance to
  6726. * @returns the signed distance (float) from the given point to the Plane.
  6727. */
  6728. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6729. /**
  6730. * Creates a plane from an array
  6731. * @param array the array to create a plane from
  6732. * @returns a new Plane from the given array.
  6733. */
  6734. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6735. /**
  6736. * Creates a plane from three points
  6737. * @param point1 point used to create the plane
  6738. * @param point2 point used to create the plane
  6739. * @param point3 point used to create the plane
  6740. * @returns a new Plane defined by the three given points.
  6741. */
  6742. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6743. /**
  6744. * Creates a plane from an origin point and a normal
  6745. * @param origin origin of the plane to be constructed
  6746. * @param normal normal of the plane to be constructed
  6747. * @returns a new Plane the normal vector to this plane at the given origin point.
  6748. * Note : the vector "normal" is updated because normalized.
  6749. */
  6750. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6751. /**
  6752. * Calculates the distance from a plane and a point
  6753. * @param origin origin of the plane to be constructed
  6754. * @param normal normal of the plane to be constructed
  6755. * @param point point to calculate distance to
  6756. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  6757. */
  6758. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  6759. }
  6760. }
  6761. declare module "babylonjs/Culling/boundingSphere" {
  6762. import { DeepImmutable } from "babylonjs/types";
  6763. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6764. import { Plane } from "babylonjs/Maths/math.plane";
  6765. /**
  6766. * Class used to store bounding sphere information
  6767. */
  6768. export class BoundingSphere {
  6769. /**
  6770. * Gets the center of the bounding sphere in local space
  6771. */
  6772. readonly center: Vector3;
  6773. /**
  6774. * Radius of the bounding sphere in local space
  6775. */
  6776. radius: number;
  6777. /**
  6778. * Gets the center of the bounding sphere in world space
  6779. */
  6780. readonly centerWorld: Vector3;
  6781. /**
  6782. * Radius of the bounding sphere in world space
  6783. */
  6784. radiusWorld: number;
  6785. /**
  6786. * Gets the minimum vector in local space
  6787. */
  6788. readonly minimum: Vector3;
  6789. /**
  6790. * Gets the maximum vector in local space
  6791. */
  6792. readonly maximum: Vector3;
  6793. private _worldMatrix;
  6794. private static readonly TmpVector3;
  6795. /**
  6796. * Creates a new bounding sphere
  6797. * @param min defines the minimum vector (in local space)
  6798. * @param max defines the maximum vector (in local space)
  6799. * @param worldMatrix defines the new world matrix
  6800. */
  6801. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6802. /**
  6803. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6804. * @param min defines the new minimum vector (in local space)
  6805. * @param max defines the new maximum vector (in local space)
  6806. * @param worldMatrix defines the new world matrix
  6807. */
  6808. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6809. /**
  6810. * Scale the current bounding sphere by applying a scale factor
  6811. * @param factor defines the scale factor to apply
  6812. * @returns the current bounding box
  6813. */
  6814. scale(factor: number): BoundingSphere;
  6815. /**
  6816. * Gets the world matrix of the bounding box
  6817. * @returns a matrix
  6818. */
  6819. getWorldMatrix(): DeepImmutable<Matrix>;
  6820. /** @hidden */
  6821. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6822. /**
  6823. * Tests if the bounding sphere is intersecting the frustum planes
  6824. * @param frustumPlanes defines the frustum planes to test
  6825. * @returns true if there is an intersection
  6826. */
  6827. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6828. /**
  6829. * Tests if the bounding sphere center is in between the frustum planes.
  6830. * Used for optimistic fast inclusion.
  6831. * @param frustumPlanes defines the frustum planes to test
  6832. * @returns true if the sphere center is in between the frustum planes
  6833. */
  6834. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6835. /**
  6836. * Tests if a point is inside the bounding sphere
  6837. * @param point defines the point to test
  6838. * @returns true if the point is inside the bounding sphere
  6839. */
  6840. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6841. /**
  6842. * Checks if two sphere intersct
  6843. * @param sphere0 sphere 0
  6844. * @param sphere1 sphere 1
  6845. * @returns true if the speres intersect
  6846. */
  6847. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6848. }
  6849. }
  6850. declare module "babylonjs/Culling/boundingBox" {
  6851. import { DeepImmutable } from "babylonjs/types";
  6852. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6853. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  6854. import { ICullable } from "babylonjs/Culling/boundingInfo";
  6855. import { Plane } from "babylonjs/Maths/math.plane";
  6856. /**
  6857. * Class used to store bounding box information
  6858. */
  6859. export class BoundingBox implements ICullable {
  6860. /**
  6861. * Gets the 8 vectors representing the bounding box in local space
  6862. */
  6863. readonly vectors: Vector3[];
  6864. /**
  6865. * Gets the center of the bounding box in local space
  6866. */
  6867. readonly center: Vector3;
  6868. /**
  6869. * Gets the center of the bounding box in world space
  6870. */
  6871. readonly centerWorld: Vector3;
  6872. /**
  6873. * Gets the extend size in local space
  6874. */
  6875. readonly extendSize: Vector3;
  6876. /**
  6877. * Gets the extend size in world space
  6878. */
  6879. readonly extendSizeWorld: Vector3;
  6880. /**
  6881. * Gets the OBB (object bounding box) directions
  6882. */
  6883. readonly directions: Vector3[];
  6884. /**
  6885. * Gets the 8 vectors representing the bounding box in world space
  6886. */
  6887. readonly vectorsWorld: Vector3[];
  6888. /**
  6889. * Gets the minimum vector in world space
  6890. */
  6891. readonly minimumWorld: Vector3;
  6892. /**
  6893. * Gets the maximum vector in world space
  6894. */
  6895. readonly maximumWorld: Vector3;
  6896. /**
  6897. * Gets the minimum vector in local space
  6898. */
  6899. readonly minimum: Vector3;
  6900. /**
  6901. * Gets the maximum vector in local space
  6902. */
  6903. readonly maximum: Vector3;
  6904. private _worldMatrix;
  6905. private static readonly TmpVector3;
  6906. /**
  6907. * @hidden
  6908. */
  6909. _tag: number;
  6910. /**
  6911. * Creates a new bounding box
  6912. * @param min defines the minimum vector (in local space)
  6913. * @param max defines the maximum vector (in local space)
  6914. * @param worldMatrix defines the new world matrix
  6915. */
  6916. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6917. /**
  6918. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6919. * @param min defines the new minimum vector (in local space)
  6920. * @param max defines the new maximum vector (in local space)
  6921. * @param worldMatrix defines the new world matrix
  6922. */
  6923. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6924. /**
  6925. * Scale the current bounding box by applying a scale factor
  6926. * @param factor defines the scale factor to apply
  6927. * @returns the current bounding box
  6928. */
  6929. scale(factor: number): BoundingBox;
  6930. /**
  6931. * Gets the world matrix of the bounding box
  6932. * @returns a matrix
  6933. */
  6934. getWorldMatrix(): DeepImmutable<Matrix>;
  6935. /** @hidden */
  6936. _update(world: DeepImmutable<Matrix>): void;
  6937. /**
  6938. * Tests if the bounding box is intersecting the frustum planes
  6939. * @param frustumPlanes defines the frustum planes to test
  6940. * @returns true if there is an intersection
  6941. */
  6942. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6943. /**
  6944. * Tests if the bounding box is entirely inside the frustum planes
  6945. * @param frustumPlanes defines the frustum planes to test
  6946. * @returns true if there is an inclusion
  6947. */
  6948. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6949. /**
  6950. * Tests if a point is inside the bounding box
  6951. * @param point defines the point to test
  6952. * @returns true if the point is inside the bounding box
  6953. */
  6954. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6955. /**
  6956. * Tests if the bounding box intersects with a bounding sphere
  6957. * @param sphere defines the sphere to test
  6958. * @returns true if there is an intersection
  6959. */
  6960. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6961. /**
  6962. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6963. * @param min defines the min vector to use
  6964. * @param max defines the max vector to use
  6965. * @returns true if there is an intersection
  6966. */
  6967. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6968. /**
  6969. * Tests if two bounding boxes are intersections
  6970. * @param box0 defines the first box to test
  6971. * @param box1 defines the second box to test
  6972. * @returns true if there is an intersection
  6973. */
  6974. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  6975. /**
  6976. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  6977. * @param minPoint defines the minimum vector of the bounding box
  6978. * @param maxPoint defines the maximum vector of the bounding box
  6979. * @param sphereCenter defines the sphere center
  6980. * @param sphereRadius defines the sphere radius
  6981. * @returns true if there is an intersection
  6982. */
  6983. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  6984. /**
  6985. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  6986. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6987. * @param frustumPlanes defines the frustum planes to test
  6988. * @return true if there is an inclusion
  6989. */
  6990. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6991. /**
  6992. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  6993. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6994. * @param frustumPlanes defines the frustum planes to test
  6995. * @return true if there is an intersection
  6996. */
  6997. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6998. }
  6999. }
  7000. declare module "babylonjs/Collisions/collider" {
  7001. import { Nullable, IndicesArray } from "babylonjs/types";
  7002. import { Vector3 } from "babylonjs/Maths/math.vector";
  7003. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7004. import { Plane } from "babylonjs/Maths/math.plane";
  7005. /** @hidden */
  7006. export class Collider {
  7007. /** Define if a collision was found */
  7008. collisionFound: boolean;
  7009. /**
  7010. * Define last intersection point in local space
  7011. */
  7012. intersectionPoint: Vector3;
  7013. /**
  7014. * Define last collided mesh
  7015. */
  7016. collidedMesh: Nullable<AbstractMesh>;
  7017. private _collisionPoint;
  7018. private _planeIntersectionPoint;
  7019. private _tempVector;
  7020. private _tempVector2;
  7021. private _tempVector3;
  7022. private _tempVector4;
  7023. private _edge;
  7024. private _baseToVertex;
  7025. private _destinationPoint;
  7026. private _slidePlaneNormal;
  7027. private _displacementVector;
  7028. /** @hidden */
  7029. _radius: Vector3;
  7030. /** @hidden */
  7031. _retry: number;
  7032. private _velocity;
  7033. private _basePoint;
  7034. private _epsilon;
  7035. /** @hidden */
  7036. _velocityWorldLength: number;
  7037. /** @hidden */
  7038. _basePointWorld: Vector3;
  7039. private _velocityWorld;
  7040. private _normalizedVelocity;
  7041. /** @hidden */
  7042. _initialVelocity: Vector3;
  7043. /** @hidden */
  7044. _initialPosition: Vector3;
  7045. private _nearestDistance;
  7046. private _collisionMask;
  7047. get collisionMask(): number;
  7048. set collisionMask(mask: number);
  7049. /**
  7050. * Gets the plane normal used to compute the sliding response (in local space)
  7051. */
  7052. get slidePlaneNormal(): Vector3;
  7053. /** @hidden */
  7054. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7055. /** @hidden */
  7056. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7057. /** @hidden */
  7058. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7059. /** @hidden */
  7060. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7061. /** @hidden */
  7062. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7063. /** @hidden */
  7064. _getResponse(pos: Vector3, vel: Vector3): void;
  7065. }
  7066. }
  7067. declare module "babylonjs/Culling/boundingInfo" {
  7068. import { DeepImmutable } from "babylonjs/types";
  7069. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7070. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7071. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7072. import { Plane } from "babylonjs/Maths/math.plane";
  7073. import { Collider } from "babylonjs/Collisions/collider";
  7074. /**
  7075. * Interface for cullable objects
  7076. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7077. */
  7078. export interface ICullable {
  7079. /**
  7080. * Checks if the object or part of the object is in the frustum
  7081. * @param frustumPlanes Camera near/planes
  7082. * @returns true if the object is in frustum otherwise false
  7083. */
  7084. isInFrustum(frustumPlanes: Plane[]): boolean;
  7085. /**
  7086. * Checks if a cullable object (mesh...) is in the camera frustum
  7087. * Unlike isInFrustum this cheks the full bounding box
  7088. * @param frustumPlanes Camera near/planes
  7089. * @returns true if the object is in frustum otherwise false
  7090. */
  7091. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7092. }
  7093. /**
  7094. * Info for a bounding data of a mesh
  7095. */
  7096. export class BoundingInfo implements ICullable {
  7097. /**
  7098. * Bounding box for the mesh
  7099. */
  7100. readonly boundingBox: BoundingBox;
  7101. /**
  7102. * Bounding sphere for the mesh
  7103. */
  7104. readonly boundingSphere: BoundingSphere;
  7105. private _isLocked;
  7106. private static readonly TmpVector3;
  7107. /**
  7108. * Constructs bounding info
  7109. * @param minimum min vector of the bounding box/sphere
  7110. * @param maximum max vector of the bounding box/sphere
  7111. * @param worldMatrix defines the new world matrix
  7112. */
  7113. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7114. /**
  7115. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7116. * @param min defines the new minimum vector (in local space)
  7117. * @param max defines the new maximum vector (in local space)
  7118. * @param worldMatrix defines the new world matrix
  7119. */
  7120. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7121. /**
  7122. * min vector of the bounding box/sphere
  7123. */
  7124. get minimum(): Vector3;
  7125. /**
  7126. * max vector of the bounding box/sphere
  7127. */
  7128. get maximum(): Vector3;
  7129. /**
  7130. * If the info is locked and won't be updated to avoid perf overhead
  7131. */
  7132. get isLocked(): boolean;
  7133. set isLocked(value: boolean);
  7134. /**
  7135. * Updates the bounding sphere and box
  7136. * @param world world matrix to be used to update
  7137. */
  7138. update(world: DeepImmutable<Matrix>): void;
  7139. /**
  7140. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7141. * @param center New center of the bounding info
  7142. * @param extend New extend of the bounding info
  7143. * @returns the current bounding info
  7144. */
  7145. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7146. /**
  7147. * Scale the current bounding info by applying a scale factor
  7148. * @param factor defines the scale factor to apply
  7149. * @returns the current bounding info
  7150. */
  7151. scale(factor: number): BoundingInfo;
  7152. /**
  7153. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7154. * @param frustumPlanes defines the frustum to test
  7155. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7156. * @returns true if the bounding info is in the frustum planes
  7157. */
  7158. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7159. /**
  7160. * Gets the world distance between the min and max points of the bounding box
  7161. */
  7162. get diagonalLength(): number;
  7163. /**
  7164. * Checks if a cullable object (mesh...) is in the camera frustum
  7165. * Unlike isInFrustum this cheks the full bounding box
  7166. * @param frustumPlanes Camera near/planes
  7167. * @returns true if the object is in frustum otherwise false
  7168. */
  7169. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7170. /** @hidden */
  7171. _checkCollision(collider: Collider): boolean;
  7172. /**
  7173. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7174. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7175. * @param point the point to check intersection with
  7176. * @returns if the point intersects
  7177. */
  7178. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7179. /**
  7180. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7181. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7182. * @param boundingInfo the bounding info to check intersection with
  7183. * @param precise if the intersection should be done using OBB
  7184. * @returns if the bounding info intersects
  7185. */
  7186. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7187. }
  7188. }
  7189. declare module "babylonjs/Maths/math.functions" {
  7190. import { FloatArray, Nullable, IndicesArray } from "babylonjs/types";
  7191. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  7192. /**
  7193. * Extracts minimum and maximum values from a list of indexed positions
  7194. * @param positions defines the positions to use
  7195. * @param indices defines the indices to the positions
  7196. * @param indexStart defines the start index
  7197. * @param indexCount defines the end index
  7198. * @param bias defines bias value to add to the result
  7199. * @return minimum and maximum values
  7200. */
  7201. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7202. minimum: Vector3;
  7203. maximum: Vector3;
  7204. };
  7205. /**
  7206. * Extracts minimum and maximum values from a list of positions
  7207. * @param positions defines the positions to use
  7208. * @param start defines the start index in the positions array
  7209. * @param count defines the number of positions to handle
  7210. * @param bias defines bias value to add to the result
  7211. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7212. * @return minimum and maximum values
  7213. */
  7214. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7215. minimum: Vector3;
  7216. maximum: Vector3;
  7217. };
  7218. }
  7219. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  7220. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7221. /** @hidden */
  7222. export class WebGLDataBuffer extends DataBuffer {
  7223. private _buffer;
  7224. constructor(resource: WebGLBuffer);
  7225. get underlyingResource(): any;
  7226. }
  7227. }
  7228. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  7229. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7230. import { Nullable } from "babylonjs/types";
  7231. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7232. /** @hidden */
  7233. export class WebGLPipelineContext implements IPipelineContext {
  7234. engine: ThinEngine;
  7235. program: Nullable<WebGLProgram>;
  7236. context?: WebGLRenderingContext;
  7237. vertexShader?: WebGLShader;
  7238. fragmentShader?: WebGLShader;
  7239. isParallelCompiled: boolean;
  7240. onCompiled?: () => void;
  7241. transformFeedback?: WebGLTransformFeedback | null;
  7242. vertexCompilationError: Nullable<string>;
  7243. fragmentCompilationError: Nullable<string>;
  7244. programLinkError: Nullable<string>;
  7245. programValidationError: Nullable<string>;
  7246. get isAsync(): boolean;
  7247. get isReady(): boolean;
  7248. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7249. _getVertexShaderCode(): string | null;
  7250. _getFragmentShaderCode(): string | null;
  7251. }
  7252. }
  7253. declare module "babylonjs/Engines/Extensions/engine.uniformBuffer" {
  7254. import { FloatArray, Nullable } from "babylonjs/types";
  7255. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7256. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7257. module "babylonjs/Engines/thinEngine" {
  7258. interface ThinEngine {
  7259. /**
  7260. * Create an uniform buffer
  7261. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7262. * @param elements defines the content of the uniform buffer
  7263. * @returns the webGL uniform buffer
  7264. */
  7265. createUniformBuffer(elements: FloatArray): DataBuffer;
  7266. /**
  7267. * Create a dynamic uniform buffer
  7268. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7269. * @param elements defines the content of the uniform buffer
  7270. * @returns the webGL uniform buffer
  7271. */
  7272. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7273. /**
  7274. * Update an existing uniform buffer
  7275. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7276. * @param uniformBuffer defines the target uniform buffer
  7277. * @param elements defines the content to update
  7278. * @param offset defines the offset in the uniform buffer where update should start
  7279. * @param count defines the size of the data to update
  7280. */
  7281. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7282. /**
  7283. * Bind an uniform buffer to the current webGL context
  7284. * @param buffer defines the buffer to bind
  7285. */
  7286. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7287. /**
  7288. * Bind a buffer to the current webGL context at a given location
  7289. * @param buffer defines the buffer to bind
  7290. * @param location defines the index where to bind the buffer
  7291. */
  7292. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7293. /**
  7294. * Bind a specific block at a given index in a specific shader program
  7295. * @param pipelineContext defines the pipeline context to use
  7296. * @param blockName defines the block name
  7297. * @param index defines the index where to bind the block
  7298. */
  7299. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7300. }
  7301. }
  7302. }
  7303. declare module "babylonjs/Materials/uniformBuffer" {
  7304. import { Nullable, FloatArray } from "babylonjs/types";
  7305. import { Matrix, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  7306. import { Engine } from "babylonjs/Engines/engine";
  7307. import { Effect } from "babylonjs/Materials/effect";
  7308. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7309. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7310. import { Color3 } from "babylonjs/Maths/math.color";
  7311. import "babylonjs/Engines/Extensions/engine.uniformBuffer";
  7312. /**
  7313. * Uniform buffer objects.
  7314. *
  7315. * Handles blocks of uniform on the GPU.
  7316. *
  7317. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7318. *
  7319. * For more information, please refer to :
  7320. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7321. */
  7322. export class UniformBuffer {
  7323. private _engine;
  7324. private _buffer;
  7325. private _data;
  7326. private _bufferData;
  7327. private _dynamic?;
  7328. private _uniformLocations;
  7329. private _uniformSizes;
  7330. private _uniformLocationPointer;
  7331. private _needSync;
  7332. private _noUBO;
  7333. private _currentEffect;
  7334. /** @hidden */
  7335. _alreadyBound: boolean;
  7336. private static _MAX_UNIFORM_SIZE;
  7337. private static _tempBuffer;
  7338. /**
  7339. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7340. * This is dynamic to allow compat with webgl 1 and 2.
  7341. * You will need to pass the name of the uniform as well as the value.
  7342. */
  7343. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7344. /**
  7345. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7346. * This is dynamic to allow compat with webgl 1 and 2.
  7347. * You will need to pass the name of the uniform as well as the value.
  7348. */
  7349. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7350. /**
  7351. * Lambda to Update a single float in a uniform buffer.
  7352. * This is dynamic to allow compat with webgl 1 and 2.
  7353. * You will need to pass the name of the uniform as well as the value.
  7354. */
  7355. updateFloat: (name: string, x: number) => void;
  7356. /**
  7357. * Lambda to Update a vec2 of float in a uniform buffer.
  7358. * This is dynamic to allow compat with webgl 1 and 2.
  7359. * You will need to pass the name of the uniform as well as the value.
  7360. */
  7361. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7362. /**
  7363. * Lambda to Update a vec3 of float in a uniform buffer.
  7364. * This is dynamic to allow compat with webgl 1 and 2.
  7365. * You will need to pass the name of the uniform as well as the value.
  7366. */
  7367. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7368. /**
  7369. * Lambda to Update a vec4 of float in a uniform buffer.
  7370. * This is dynamic to allow compat with webgl 1 and 2.
  7371. * You will need to pass the name of the uniform as well as the value.
  7372. */
  7373. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7374. /**
  7375. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7376. * This is dynamic to allow compat with webgl 1 and 2.
  7377. * You will need to pass the name of the uniform as well as the value.
  7378. */
  7379. updateMatrix: (name: string, mat: Matrix) => void;
  7380. /**
  7381. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7382. * This is dynamic to allow compat with webgl 1 and 2.
  7383. * You will need to pass the name of the uniform as well as the value.
  7384. */
  7385. updateVector3: (name: string, vector: Vector3) => void;
  7386. /**
  7387. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7388. * This is dynamic to allow compat with webgl 1 and 2.
  7389. * You will need to pass the name of the uniform as well as the value.
  7390. */
  7391. updateVector4: (name: string, vector: Vector4) => void;
  7392. /**
  7393. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7394. * This is dynamic to allow compat with webgl 1 and 2.
  7395. * You will need to pass the name of the uniform as well as the value.
  7396. */
  7397. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7398. /**
  7399. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7400. * This is dynamic to allow compat with webgl 1 and 2.
  7401. * You will need to pass the name of the uniform as well as the value.
  7402. */
  7403. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7404. /**
  7405. * Instantiates a new Uniform buffer objects.
  7406. *
  7407. * Handles blocks of uniform on the GPU.
  7408. *
  7409. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7410. *
  7411. * For more information, please refer to :
  7412. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7413. * @param engine Define the engine the buffer is associated with
  7414. * @param data Define the data contained in the buffer
  7415. * @param dynamic Define if the buffer is updatable
  7416. */
  7417. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7418. /**
  7419. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7420. * or just falling back on setUniformXXX calls.
  7421. */
  7422. get useUbo(): boolean;
  7423. /**
  7424. * Indicates if the WebGL underlying uniform buffer is in sync
  7425. * with the javascript cache data.
  7426. */
  7427. get isSync(): boolean;
  7428. /**
  7429. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7430. * Also, a dynamic UniformBuffer will disable cache verification and always
  7431. * update the underlying WebGL uniform buffer to the GPU.
  7432. * @returns if Dynamic, otherwise false
  7433. */
  7434. isDynamic(): boolean;
  7435. /**
  7436. * The data cache on JS side.
  7437. * @returns the underlying data as a float array
  7438. */
  7439. getData(): Float32Array;
  7440. /**
  7441. * The underlying WebGL Uniform buffer.
  7442. * @returns the webgl buffer
  7443. */
  7444. getBuffer(): Nullable<DataBuffer>;
  7445. /**
  7446. * std140 layout specifies how to align data within an UBO structure.
  7447. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7448. * for specs.
  7449. */
  7450. private _fillAlignment;
  7451. /**
  7452. * Adds an uniform in the buffer.
  7453. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7454. * for the layout to be correct !
  7455. * @param name Name of the uniform, as used in the uniform block in the shader.
  7456. * @param size Data size, or data directly.
  7457. */
  7458. addUniform(name: string, size: number | number[]): void;
  7459. /**
  7460. * Adds a Matrix 4x4 to the uniform buffer.
  7461. * @param name Name of the uniform, as used in the uniform block in the shader.
  7462. * @param mat A 4x4 matrix.
  7463. */
  7464. addMatrix(name: string, mat: Matrix): void;
  7465. /**
  7466. * Adds a vec2 to the uniform buffer.
  7467. * @param name Name of the uniform, as used in the uniform block in the shader.
  7468. * @param x Define the x component value of the vec2
  7469. * @param y Define the y component value of the vec2
  7470. */
  7471. addFloat2(name: string, x: number, y: number): void;
  7472. /**
  7473. * Adds a vec3 to the uniform buffer.
  7474. * @param name Name of the uniform, as used in the uniform block in the shader.
  7475. * @param x Define the x component value of the vec3
  7476. * @param y Define the y component value of the vec3
  7477. * @param z Define the z component value of the vec3
  7478. */
  7479. addFloat3(name: string, x: number, y: number, z: number): void;
  7480. /**
  7481. * Adds a vec3 to the uniform buffer.
  7482. * @param name Name of the uniform, as used in the uniform block in the shader.
  7483. * @param color Define the vec3 from a Color
  7484. */
  7485. addColor3(name: string, color: Color3): void;
  7486. /**
  7487. * Adds a vec4 to the uniform buffer.
  7488. * @param name Name of the uniform, as used in the uniform block in the shader.
  7489. * @param color Define the rgb components from a Color
  7490. * @param alpha Define the a component of the vec4
  7491. */
  7492. addColor4(name: string, color: Color3, alpha: number): void;
  7493. /**
  7494. * Adds a vec3 to the uniform buffer.
  7495. * @param name Name of the uniform, as used in the uniform block in the shader.
  7496. * @param vector Define the vec3 components from a Vector
  7497. */
  7498. addVector3(name: string, vector: Vector3): void;
  7499. /**
  7500. * Adds a Matrix 3x3 to the uniform buffer.
  7501. * @param name Name of the uniform, as used in the uniform block in the shader.
  7502. */
  7503. addMatrix3x3(name: string): void;
  7504. /**
  7505. * Adds a Matrix 2x2 to the uniform buffer.
  7506. * @param name Name of the uniform, as used in the uniform block in the shader.
  7507. */
  7508. addMatrix2x2(name: string): void;
  7509. /**
  7510. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7511. */
  7512. create(): void;
  7513. /** @hidden */
  7514. _rebuild(): void;
  7515. /**
  7516. * Updates the WebGL Uniform Buffer on the GPU.
  7517. * If the `dynamic` flag is set to true, no cache comparison is done.
  7518. * Otherwise, the buffer will be updated only if the cache differs.
  7519. */
  7520. update(): void;
  7521. /**
  7522. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7523. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7524. * @param data Define the flattened data
  7525. * @param size Define the size of the data.
  7526. */
  7527. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7528. private _valueCache;
  7529. private _cacheMatrix;
  7530. private _updateMatrix3x3ForUniform;
  7531. private _updateMatrix3x3ForEffect;
  7532. private _updateMatrix2x2ForEffect;
  7533. private _updateMatrix2x2ForUniform;
  7534. private _updateFloatForEffect;
  7535. private _updateFloatForUniform;
  7536. private _updateFloat2ForEffect;
  7537. private _updateFloat2ForUniform;
  7538. private _updateFloat3ForEffect;
  7539. private _updateFloat3ForUniform;
  7540. private _updateFloat4ForEffect;
  7541. private _updateFloat4ForUniform;
  7542. private _updateMatrixForEffect;
  7543. private _updateMatrixForUniform;
  7544. private _updateVector3ForEffect;
  7545. private _updateVector3ForUniform;
  7546. private _updateVector4ForEffect;
  7547. private _updateVector4ForUniform;
  7548. private _updateColor3ForEffect;
  7549. private _updateColor3ForUniform;
  7550. private _updateColor4ForEffect;
  7551. private _updateColor4ForUniform;
  7552. /**
  7553. * Sets a sampler uniform on the effect.
  7554. * @param name Define the name of the sampler.
  7555. * @param texture Define the texture to set in the sampler
  7556. */
  7557. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7558. /**
  7559. * Directly updates the value of the uniform in the cache AND on the GPU.
  7560. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7561. * @param data Define the flattened data
  7562. */
  7563. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7564. /**
  7565. * Binds this uniform buffer to an effect.
  7566. * @param effect Define the effect to bind the buffer to
  7567. * @param name Name of the uniform block in the shader.
  7568. */
  7569. bindToEffect(effect: Effect, name: string): void;
  7570. /**
  7571. * Disposes the uniform buffer.
  7572. */
  7573. dispose(): void;
  7574. }
  7575. }
  7576. declare module "babylonjs/Misc/iInspectable" {
  7577. /**
  7578. * Enum that determines the text-wrapping mode to use.
  7579. */
  7580. export enum InspectableType {
  7581. /**
  7582. * Checkbox for booleans
  7583. */
  7584. Checkbox = 0,
  7585. /**
  7586. * Sliders for numbers
  7587. */
  7588. Slider = 1,
  7589. /**
  7590. * Vector3
  7591. */
  7592. Vector3 = 2,
  7593. /**
  7594. * Quaternions
  7595. */
  7596. Quaternion = 3,
  7597. /**
  7598. * Color3
  7599. */
  7600. Color3 = 4,
  7601. /**
  7602. * String
  7603. */
  7604. String = 5
  7605. }
  7606. /**
  7607. * Interface used to define custom inspectable properties.
  7608. * This interface is used by the inspector to display custom property grids
  7609. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7610. */
  7611. export interface IInspectable {
  7612. /**
  7613. * Gets the label to display
  7614. */
  7615. label: string;
  7616. /**
  7617. * Gets the name of the property to edit
  7618. */
  7619. propertyName: string;
  7620. /**
  7621. * Gets the type of the editor to use
  7622. */
  7623. type: InspectableType;
  7624. /**
  7625. * Gets the minimum value of the property when using in "slider" mode
  7626. */
  7627. min?: number;
  7628. /**
  7629. * Gets the maximum value of the property when using in "slider" mode
  7630. */
  7631. max?: number;
  7632. /**
  7633. * Gets the setp to use when using in "slider" mode
  7634. */
  7635. step?: number;
  7636. }
  7637. }
  7638. declare module "babylonjs/Misc/timingTools" {
  7639. /**
  7640. * Class used to provide helper for timing
  7641. */
  7642. export class TimingTools {
  7643. /**
  7644. * Polyfill for setImmediate
  7645. * @param action defines the action to execute after the current execution block
  7646. */
  7647. static SetImmediate(action: () => void): void;
  7648. }
  7649. }
  7650. declare module "babylonjs/Misc/instantiationTools" {
  7651. /**
  7652. * Class used to enable instatition of objects by class name
  7653. */
  7654. export class InstantiationTools {
  7655. /**
  7656. * Use this object to register external classes like custom textures or material
  7657. * to allow the laoders to instantiate them
  7658. */
  7659. static RegisteredExternalClasses: {
  7660. [key: string]: Object;
  7661. };
  7662. /**
  7663. * Tries to instantiate a new object from a given class name
  7664. * @param className defines the class name to instantiate
  7665. * @returns the new object or null if the system was not able to do the instantiation
  7666. */
  7667. static Instantiate(className: string): any;
  7668. }
  7669. }
  7670. declare module "babylonjs/Engines/depthTextureCreationOptions" {
  7671. /**
  7672. * Define options used to create a depth texture
  7673. */
  7674. export class DepthTextureCreationOptions {
  7675. /** Specifies whether or not a stencil should be allocated in the texture */
  7676. generateStencil?: boolean;
  7677. /** Specifies whether or not bilinear filtering is enable on the texture */
  7678. bilinearFiltering?: boolean;
  7679. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7680. comparisonFunction?: number;
  7681. /** Specifies if the created texture is a cube texture */
  7682. isCube?: boolean;
  7683. }
  7684. }
  7685. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  7686. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7687. import { Nullable } from "babylonjs/types";
  7688. import { Scene } from "babylonjs/scene";
  7689. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  7690. module "babylonjs/Engines/thinEngine" {
  7691. interface ThinEngine {
  7692. /**
  7693. * Creates a depth stencil cube texture.
  7694. * This is only available in WebGL 2.
  7695. * @param size The size of face edge in the cube texture.
  7696. * @param options The options defining the cube texture.
  7697. * @returns The cube texture
  7698. */
  7699. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7700. /**
  7701. * Creates a cube texture
  7702. * @param rootUrl defines the url where the files to load is located
  7703. * @param scene defines the current scene
  7704. * @param files defines the list of files to load (1 per face)
  7705. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7706. * @param onLoad defines an optional callback raised when the texture is loaded
  7707. * @param onError defines an optional callback raised if there is an issue to load the texture
  7708. * @param format defines the format of the data
  7709. * @param forcedExtension defines the extension to use to pick the right loader
  7710. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7711. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7712. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7713. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7714. * @returns the cube texture as an InternalTexture
  7715. */
  7716. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean | undefined, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number, fallback: Nullable<InternalTexture>): InternalTexture;
  7717. /**
  7718. * Creates a cube texture
  7719. * @param rootUrl defines the url where the files to load is located
  7720. * @param scene defines the current scene
  7721. * @param files defines the list of files to load (1 per face)
  7722. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7723. * @param onLoad defines an optional callback raised when the texture is loaded
  7724. * @param onError defines an optional callback raised if there is an issue to load the texture
  7725. * @param format defines the format of the data
  7726. * @param forcedExtension defines the extension to use to pick the right loader
  7727. * @returns the cube texture as an InternalTexture
  7728. */
  7729. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any): InternalTexture;
  7730. /**
  7731. * Creates a cube texture
  7732. * @param rootUrl defines the url where the files to load is located
  7733. * @param scene defines the current scene
  7734. * @param files defines the list of files to load (1 per face)
  7735. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7736. * @param onLoad defines an optional callback raised when the texture is loaded
  7737. * @param onError defines an optional callback raised if there is an issue to load the texture
  7738. * @param format defines the format of the data
  7739. * @param forcedExtension defines the extension to use to pick the right loader
  7740. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7741. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7742. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7743. * @returns the cube texture as an InternalTexture
  7744. */
  7745. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number): InternalTexture;
  7746. /** @hidden */
  7747. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7748. /** @hidden */
  7749. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7750. /** @hidden */
  7751. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7752. /** @hidden */
  7753. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7754. /**
  7755. * @hidden
  7756. */
  7757. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7758. }
  7759. }
  7760. }
  7761. declare module "babylonjs/Materials/Textures/cubeTexture" {
  7762. import { Nullable } from "babylonjs/types";
  7763. import { Scene } from "babylonjs/scene";
  7764. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7765. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7766. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  7767. import { Observable } from "babylonjs/Misc/observable";
  7768. /**
  7769. * Class for creating a cube texture
  7770. */
  7771. export class CubeTexture extends BaseTexture {
  7772. private _delayedOnLoad;
  7773. /**
  7774. * Observable triggered once the texture has been loaded.
  7775. */
  7776. onLoadObservable: Observable<CubeTexture>;
  7777. /**
  7778. * The url of the texture
  7779. */
  7780. url: string;
  7781. /**
  7782. * Gets or sets the center of the bounding box associated with the cube texture.
  7783. * It must define where the camera used to render the texture was set
  7784. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7785. */
  7786. boundingBoxPosition: Vector3;
  7787. private _boundingBoxSize;
  7788. /**
  7789. * Gets or sets the size of the bounding box associated with the cube texture
  7790. * When defined, the cubemap will switch to local mode
  7791. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7792. * @example https://www.babylonjs-playground.com/#RNASML
  7793. */
  7794. set boundingBoxSize(value: Vector3);
  7795. /**
  7796. * Returns the bounding box size
  7797. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7798. */
  7799. get boundingBoxSize(): Vector3;
  7800. protected _rotationY: number;
  7801. /**
  7802. * Sets texture matrix rotation angle around Y axis in radians.
  7803. */
  7804. set rotationY(value: number);
  7805. /**
  7806. * Gets texture matrix rotation angle around Y axis radians.
  7807. */
  7808. get rotationY(): number;
  7809. /**
  7810. * Are mip maps generated for this texture or not.
  7811. */
  7812. get noMipmap(): boolean;
  7813. private _noMipmap;
  7814. private _files;
  7815. protected _forcedExtension: Nullable<string>;
  7816. private _extensions;
  7817. private _textureMatrix;
  7818. private _format;
  7819. private _createPolynomials;
  7820. /** @hidden */
  7821. _prefiltered: boolean;
  7822. /**
  7823. * Creates a cube texture from an array of image urls
  7824. * @param files defines an array of image urls
  7825. * @param scene defines the hosting scene
  7826. * @param noMipmap specifies if mip maps are not used
  7827. * @returns a cube texture
  7828. */
  7829. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7830. /**
  7831. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7832. * @param url defines the url of the prefiltered texture
  7833. * @param scene defines the scene the texture is attached to
  7834. * @param forcedExtension defines the extension of the file if different from the url
  7835. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7836. * @return the prefiltered texture
  7837. */
  7838. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7839. /**
  7840. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7841. * as prefiltered data.
  7842. * @param rootUrl defines the url of the texture or the root name of the six images
  7843. * @param scene defines the scene the texture is attached to
  7844. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7845. * @param noMipmap defines if mipmaps should be created or not
  7846. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7847. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7848. * @param onError defines a callback triggered in case of error during load
  7849. * @param format defines the internal format to use for the texture once loaded
  7850. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7851. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7852. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7853. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7854. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7855. * @return the cube texture
  7856. */
  7857. constructor(rootUrl: string, scene: Scene, extensions?: Nullable<string[]>, noMipmap?: boolean, files?: Nullable<string[]>, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, prefiltered?: boolean, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number);
  7858. /**
  7859. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7860. */
  7861. get isPrefiltered(): boolean;
  7862. /**
  7863. * Get the current class name of the texture useful for serialization or dynamic coding.
  7864. * @returns "CubeTexture"
  7865. */
  7866. getClassName(): string;
  7867. /**
  7868. * Update the url (and optional buffer) of this texture if url was null during construction.
  7869. * @param url the url of the texture
  7870. * @param forcedExtension defines the extension to use
  7871. * @param onLoad callback called when the texture is loaded (defaults to null)
  7872. * @param prefiltered Defines whether the updated texture is prefiltered or not
  7873. */
  7874. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  7875. /**
  7876. * Delays loading of the cube texture
  7877. * @param forcedExtension defines the extension to use
  7878. */
  7879. delayLoad(forcedExtension?: string): void;
  7880. /**
  7881. * Returns the reflection texture matrix
  7882. * @returns the reflection texture matrix
  7883. */
  7884. getReflectionTextureMatrix(): Matrix;
  7885. /**
  7886. * Sets the reflection texture matrix
  7887. * @param value Reflection texture matrix
  7888. */
  7889. setReflectionTextureMatrix(value: Matrix): void;
  7890. /**
  7891. * Parses text to create a cube texture
  7892. * @param parsedTexture define the serialized text to read from
  7893. * @param scene defines the hosting scene
  7894. * @param rootUrl defines the root url of the cube texture
  7895. * @returns a cube texture
  7896. */
  7897. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7898. /**
  7899. * Makes a clone, or deep copy, of the cube texture
  7900. * @returns a new cube texture
  7901. */
  7902. clone(): CubeTexture;
  7903. }
  7904. }
  7905. declare module "babylonjs/Materials/materialDefines" {
  7906. /**
  7907. * Manages the defines for the Material
  7908. */
  7909. export class MaterialDefines {
  7910. /** @hidden */
  7911. protected _keys: string[];
  7912. private _isDirty;
  7913. /** @hidden */
  7914. _renderId: number;
  7915. /** @hidden */
  7916. _areLightsDirty: boolean;
  7917. /** @hidden */
  7918. _areLightsDisposed: boolean;
  7919. /** @hidden */
  7920. _areAttributesDirty: boolean;
  7921. /** @hidden */
  7922. _areTexturesDirty: boolean;
  7923. /** @hidden */
  7924. _areFresnelDirty: boolean;
  7925. /** @hidden */
  7926. _areMiscDirty: boolean;
  7927. /** @hidden */
  7928. _areImageProcessingDirty: boolean;
  7929. /** @hidden */
  7930. _normals: boolean;
  7931. /** @hidden */
  7932. _uvs: boolean;
  7933. /** @hidden */
  7934. _needNormals: boolean;
  7935. /** @hidden */
  7936. _needUVs: boolean;
  7937. [id: string]: any;
  7938. /**
  7939. * Specifies if the material needs to be re-calculated
  7940. */
  7941. get isDirty(): boolean;
  7942. /**
  7943. * Marks the material to indicate that it has been re-calculated
  7944. */
  7945. markAsProcessed(): void;
  7946. /**
  7947. * Marks the material to indicate that it needs to be re-calculated
  7948. */
  7949. markAsUnprocessed(): void;
  7950. /**
  7951. * Marks the material to indicate all of its defines need to be re-calculated
  7952. */
  7953. markAllAsDirty(): void;
  7954. /**
  7955. * Marks the material to indicate that image processing needs to be re-calculated
  7956. */
  7957. markAsImageProcessingDirty(): void;
  7958. /**
  7959. * Marks the material to indicate the lights need to be re-calculated
  7960. * @param disposed Defines whether the light is dirty due to dispose or not
  7961. */
  7962. markAsLightDirty(disposed?: boolean): void;
  7963. /**
  7964. * Marks the attribute state as changed
  7965. */
  7966. markAsAttributesDirty(): void;
  7967. /**
  7968. * Marks the texture state as changed
  7969. */
  7970. markAsTexturesDirty(): void;
  7971. /**
  7972. * Marks the fresnel state as changed
  7973. */
  7974. markAsFresnelDirty(): void;
  7975. /**
  7976. * Marks the misc state as changed
  7977. */
  7978. markAsMiscDirty(): void;
  7979. /**
  7980. * Rebuilds the material defines
  7981. */
  7982. rebuild(): void;
  7983. /**
  7984. * Specifies if two material defines are equal
  7985. * @param other - A material define instance to compare to
  7986. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7987. */
  7988. isEqual(other: MaterialDefines): boolean;
  7989. /**
  7990. * Clones this instance's defines to another instance
  7991. * @param other - material defines to clone values to
  7992. */
  7993. cloneTo(other: MaterialDefines): void;
  7994. /**
  7995. * Resets the material define values
  7996. */
  7997. reset(): void;
  7998. /**
  7999. * Converts the material define values to a string
  8000. * @returns - String of material define information
  8001. */
  8002. toString(): string;
  8003. }
  8004. }
  8005. declare module "babylonjs/Materials/colorCurves" {
  8006. import { Effect } from "babylonjs/Materials/effect";
  8007. /**
  8008. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  8009. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  8010. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  8011. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  8012. */
  8013. export class ColorCurves {
  8014. private _dirty;
  8015. private _tempColor;
  8016. private _globalCurve;
  8017. private _highlightsCurve;
  8018. private _midtonesCurve;
  8019. private _shadowsCurve;
  8020. private _positiveCurve;
  8021. private _negativeCurve;
  8022. private _globalHue;
  8023. private _globalDensity;
  8024. private _globalSaturation;
  8025. private _globalExposure;
  8026. /**
  8027. * Gets the global Hue value.
  8028. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8029. */
  8030. get globalHue(): number;
  8031. /**
  8032. * Sets the global Hue value.
  8033. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8034. */
  8035. set globalHue(value: number);
  8036. /**
  8037. * Gets the global Density value.
  8038. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8039. * Values less than zero provide a filter of opposite hue.
  8040. */
  8041. get globalDensity(): number;
  8042. /**
  8043. * Sets the global Density value.
  8044. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8045. * Values less than zero provide a filter of opposite hue.
  8046. */
  8047. set globalDensity(value: number);
  8048. /**
  8049. * Gets the global Saturation value.
  8050. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8051. */
  8052. get globalSaturation(): number;
  8053. /**
  8054. * Sets the global Saturation value.
  8055. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8056. */
  8057. set globalSaturation(value: number);
  8058. /**
  8059. * Gets the global Exposure value.
  8060. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8061. */
  8062. get globalExposure(): number;
  8063. /**
  8064. * Sets the global Exposure value.
  8065. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8066. */
  8067. set globalExposure(value: number);
  8068. private _highlightsHue;
  8069. private _highlightsDensity;
  8070. private _highlightsSaturation;
  8071. private _highlightsExposure;
  8072. /**
  8073. * Gets the highlights Hue value.
  8074. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8075. */
  8076. get highlightsHue(): number;
  8077. /**
  8078. * Sets the highlights Hue value.
  8079. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8080. */
  8081. set highlightsHue(value: number);
  8082. /**
  8083. * Gets the highlights Density value.
  8084. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8085. * Values less than zero provide a filter of opposite hue.
  8086. */
  8087. get highlightsDensity(): number;
  8088. /**
  8089. * Sets the highlights Density value.
  8090. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8091. * Values less than zero provide a filter of opposite hue.
  8092. */
  8093. set highlightsDensity(value: number);
  8094. /**
  8095. * Gets the highlights Saturation value.
  8096. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8097. */
  8098. get highlightsSaturation(): number;
  8099. /**
  8100. * Sets the highlights Saturation value.
  8101. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8102. */
  8103. set highlightsSaturation(value: number);
  8104. /**
  8105. * Gets the highlights Exposure value.
  8106. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8107. */
  8108. get highlightsExposure(): number;
  8109. /**
  8110. * Sets the highlights Exposure value.
  8111. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8112. */
  8113. set highlightsExposure(value: number);
  8114. private _midtonesHue;
  8115. private _midtonesDensity;
  8116. private _midtonesSaturation;
  8117. private _midtonesExposure;
  8118. /**
  8119. * Gets the midtones Hue value.
  8120. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8121. */
  8122. get midtonesHue(): number;
  8123. /**
  8124. * Sets the midtones Hue value.
  8125. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8126. */
  8127. set midtonesHue(value: number);
  8128. /**
  8129. * Gets the midtones Density value.
  8130. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8131. * Values less than zero provide a filter of opposite hue.
  8132. */
  8133. get midtonesDensity(): number;
  8134. /**
  8135. * Sets the midtones Density value.
  8136. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8137. * Values less than zero provide a filter of opposite hue.
  8138. */
  8139. set midtonesDensity(value: number);
  8140. /**
  8141. * Gets the midtones Saturation value.
  8142. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8143. */
  8144. get midtonesSaturation(): number;
  8145. /**
  8146. * Sets the midtones Saturation value.
  8147. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8148. */
  8149. set midtonesSaturation(value: number);
  8150. /**
  8151. * Gets the midtones Exposure value.
  8152. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8153. */
  8154. get midtonesExposure(): number;
  8155. /**
  8156. * Sets the midtones Exposure value.
  8157. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8158. */
  8159. set midtonesExposure(value: number);
  8160. private _shadowsHue;
  8161. private _shadowsDensity;
  8162. private _shadowsSaturation;
  8163. private _shadowsExposure;
  8164. /**
  8165. * Gets the shadows Hue value.
  8166. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8167. */
  8168. get shadowsHue(): number;
  8169. /**
  8170. * Sets the shadows Hue value.
  8171. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8172. */
  8173. set shadowsHue(value: number);
  8174. /**
  8175. * Gets the shadows Density value.
  8176. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8177. * Values less than zero provide a filter of opposite hue.
  8178. */
  8179. get shadowsDensity(): number;
  8180. /**
  8181. * Sets the shadows Density value.
  8182. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8183. * Values less than zero provide a filter of opposite hue.
  8184. */
  8185. set shadowsDensity(value: number);
  8186. /**
  8187. * Gets the shadows Saturation value.
  8188. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8189. */
  8190. get shadowsSaturation(): number;
  8191. /**
  8192. * Sets the shadows Saturation value.
  8193. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8194. */
  8195. set shadowsSaturation(value: number);
  8196. /**
  8197. * Gets the shadows Exposure value.
  8198. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8199. */
  8200. get shadowsExposure(): number;
  8201. /**
  8202. * Sets the shadows Exposure value.
  8203. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8204. */
  8205. set shadowsExposure(value: number);
  8206. /**
  8207. * Returns the class name
  8208. * @returns The class name
  8209. */
  8210. getClassName(): string;
  8211. /**
  8212. * Binds the color curves to the shader.
  8213. * @param colorCurves The color curve to bind
  8214. * @param effect The effect to bind to
  8215. * @param positiveUniform The positive uniform shader parameter
  8216. * @param neutralUniform The neutral uniform shader parameter
  8217. * @param negativeUniform The negative uniform shader parameter
  8218. */
  8219. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8220. /**
  8221. * Prepare the list of uniforms associated with the ColorCurves effects.
  8222. * @param uniformsList The list of uniforms used in the effect
  8223. */
  8224. static PrepareUniforms(uniformsList: string[]): void;
  8225. /**
  8226. * Returns color grading data based on a hue, density, saturation and exposure value.
  8227. * @param filterHue The hue of the color filter.
  8228. * @param filterDensity The density of the color filter.
  8229. * @param saturation The saturation.
  8230. * @param exposure The exposure.
  8231. * @param result The result data container.
  8232. */
  8233. private getColorGradingDataToRef;
  8234. /**
  8235. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8236. * @param value The input slider value in range [-100,100].
  8237. * @returns Adjusted value.
  8238. */
  8239. private static applyColorGradingSliderNonlinear;
  8240. /**
  8241. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8242. * @param hue The hue (H) input.
  8243. * @param saturation The saturation (S) input.
  8244. * @param brightness The brightness (B) input.
  8245. * @result An RGBA color represented as Vector4.
  8246. */
  8247. private static fromHSBToRef;
  8248. /**
  8249. * Returns a value clamped between min and max
  8250. * @param value The value to clamp
  8251. * @param min The minimum of value
  8252. * @param max The maximum of value
  8253. * @returns The clamped value.
  8254. */
  8255. private static clamp;
  8256. /**
  8257. * Clones the current color curve instance.
  8258. * @return The cloned curves
  8259. */
  8260. clone(): ColorCurves;
  8261. /**
  8262. * Serializes the current color curve instance to a json representation.
  8263. * @return a JSON representation
  8264. */
  8265. serialize(): any;
  8266. /**
  8267. * Parses the color curve from a json representation.
  8268. * @param source the JSON source to parse
  8269. * @return The parsed curves
  8270. */
  8271. static Parse(source: any): ColorCurves;
  8272. }
  8273. }
  8274. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  8275. import { Observable } from "babylonjs/Misc/observable";
  8276. import { Nullable } from "babylonjs/types";
  8277. import { Color4 } from "babylonjs/Maths/math.color";
  8278. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8279. import { Effect } from "babylonjs/Materials/effect";
  8280. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8281. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  8282. /**
  8283. * Interface to follow in your material defines to integrate easily the
  8284. * Image proccessing functions.
  8285. * @hidden
  8286. */
  8287. export interface IImageProcessingConfigurationDefines {
  8288. IMAGEPROCESSING: boolean;
  8289. VIGNETTE: boolean;
  8290. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8291. VIGNETTEBLENDMODEOPAQUE: boolean;
  8292. TONEMAPPING: boolean;
  8293. TONEMAPPING_ACES: boolean;
  8294. CONTRAST: boolean;
  8295. EXPOSURE: boolean;
  8296. COLORCURVES: boolean;
  8297. COLORGRADING: boolean;
  8298. COLORGRADING3D: boolean;
  8299. SAMPLER3DGREENDEPTH: boolean;
  8300. SAMPLER3DBGRMAP: boolean;
  8301. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8302. }
  8303. /**
  8304. * @hidden
  8305. */
  8306. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8307. IMAGEPROCESSING: boolean;
  8308. VIGNETTE: boolean;
  8309. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8310. VIGNETTEBLENDMODEOPAQUE: boolean;
  8311. TONEMAPPING: boolean;
  8312. TONEMAPPING_ACES: boolean;
  8313. CONTRAST: boolean;
  8314. COLORCURVES: boolean;
  8315. COLORGRADING: boolean;
  8316. COLORGRADING3D: boolean;
  8317. SAMPLER3DGREENDEPTH: boolean;
  8318. SAMPLER3DBGRMAP: boolean;
  8319. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8320. EXPOSURE: boolean;
  8321. constructor();
  8322. }
  8323. /**
  8324. * This groups together the common properties used for image processing either in direct forward pass
  8325. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8326. * or not.
  8327. */
  8328. export class ImageProcessingConfiguration {
  8329. /**
  8330. * Default tone mapping applied in BabylonJS.
  8331. */
  8332. static readonly TONEMAPPING_STANDARD: number;
  8333. /**
  8334. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8335. * to other engines rendering to increase portability.
  8336. */
  8337. static readonly TONEMAPPING_ACES: number;
  8338. /**
  8339. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8340. */
  8341. colorCurves: Nullable<ColorCurves>;
  8342. private _colorCurvesEnabled;
  8343. /**
  8344. * Gets wether the color curves effect is enabled.
  8345. */
  8346. get colorCurvesEnabled(): boolean;
  8347. /**
  8348. * Sets wether the color curves effect is enabled.
  8349. */
  8350. set colorCurvesEnabled(value: boolean);
  8351. private _colorGradingTexture;
  8352. /**
  8353. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8354. */
  8355. get colorGradingTexture(): Nullable<BaseTexture>;
  8356. /**
  8357. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8358. */
  8359. set colorGradingTexture(value: Nullable<BaseTexture>);
  8360. private _colorGradingEnabled;
  8361. /**
  8362. * Gets wether the color grading effect is enabled.
  8363. */
  8364. get colorGradingEnabled(): boolean;
  8365. /**
  8366. * Sets wether the color grading effect is enabled.
  8367. */
  8368. set colorGradingEnabled(value: boolean);
  8369. private _colorGradingWithGreenDepth;
  8370. /**
  8371. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8372. */
  8373. get colorGradingWithGreenDepth(): boolean;
  8374. /**
  8375. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8376. */
  8377. set colorGradingWithGreenDepth(value: boolean);
  8378. private _colorGradingBGR;
  8379. /**
  8380. * Gets wether the color grading texture contains BGR values.
  8381. */
  8382. get colorGradingBGR(): boolean;
  8383. /**
  8384. * Sets wether the color grading texture contains BGR values.
  8385. */
  8386. set colorGradingBGR(value: boolean);
  8387. /** @hidden */
  8388. _exposure: number;
  8389. /**
  8390. * Gets the Exposure used in the effect.
  8391. */
  8392. get exposure(): number;
  8393. /**
  8394. * Sets the Exposure used in the effect.
  8395. */
  8396. set exposure(value: number);
  8397. private _toneMappingEnabled;
  8398. /**
  8399. * Gets wether the tone mapping effect is enabled.
  8400. */
  8401. get toneMappingEnabled(): boolean;
  8402. /**
  8403. * Sets wether the tone mapping effect is enabled.
  8404. */
  8405. set toneMappingEnabled(value: boolean);
  8406. private _toneMappingType;
  8407. /**
  8408. * Gets the type of tone mapping effect.
  8409. */
  8410. get toneMappingType(): number;
  8411. /**
  8412. * Sets the type of tone mapping effect used in BabylonJS.
  8413. */
  8414. set toneMappingType(value: number);
  8415. protected _contrast: number;
  8416. /**
  8417. * Gets the contrast used in the effect.
  8418. */
  8419. get contrast(): number;
  8420. /**
  8421. * Sets the contrast used in the effect.
  8422. */
  8423. set contrast(value: number);
  8424. /**
  8425. * Vignette stretch size.
  8426. */
  8427. vignetteStretch: number;
  8428. /**
  8429. * Vignette centre X Offset.
  8430. */
  8431. vignetteCentreX: number;
  8432. /**
  8433. * Vignette centre Y Offset.
  8434. */
  8435. vignetteCentreY: number;
  8436. /**
  8437. * Vignette weight or intensity of the vignette effect.
  8438. */
  8439. vignetteWeight: number;
  8440. /**
  8441. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8442. * if vignetteEnabled is set to true.
  8443. */
  8444. vignetteColor: Color4;
  8445. /**
  8446. * Camera field of view used by the Vignette effect.
  8447. */
  8448. vignetteCameraFov: number;
  8449. private _vignetteBlendMode;
  8450. /**
  8451. * Gets the vignette blend mode allowing different kind of effect.
  8452. */
  8453. get vignetteBlendMode(): number;
  8454. /**
  8455. * Sets the vignette blend mode allowing different kind of effect.
  8456. */
  8457. set vignetteBlendMode(value: number);
  8458. private _vignetteEnabled;
  8459. /**
  8460. * Gets wether the vignette effect is enabled.
  8461. */
  8462. get vignetteEnabled(): boolean;
  8463. /**
  8464. * Sets wether the vignette effect is enabled.
  8465. */
  8466. set vignetteEnabled(value: boolean);
  8467. private _applyByPostProcess;
  8468. /**
  8469. * Gets wether the image processing is applied through a post process or not.
  8470. */
  8471. get applyByPostProcess(): boolean;
  8472. /**
  8473. * Sets wether the image processing is applied through a post process or not.
  8474. */
  8475. set applyByPostProcess(value: boolean);
  8476. private _isEnabled;
  8477. /**
  8478. * Gets wether the image processing is enabled or not.
  8479. */
  8480. get isEnabled(): boolean;
  8481. /**
  8482. * Sets wether the image processing is enabled or not.
  8483. */
  8484. set isEnabled(value: boolean);
  8485. /**
  8486. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8487. */
  8488. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8489. /**
  8490. * Method called each time the image processing information changes requires to recompile the effect.
  8491. */
  8492. protected _updateParameters(): void;
  8493. /**
  8494. * Gets the current class name.
  8495. * @return "ImageProcessingConfiguration"
  8496. */
  8497. getClassName(): string;
  8498. /**
  8499. * Prepare the list of uniforms associated with the Image Processing effects.
  8500. * @param uniforms The list of uniforms used in the effect
  8501. * @param defines the list of defines currently in use
  8502. */
  8503. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8504. /**
  8505. * Prepare the list of samplers associated with the Image Processing effects.
  8506. * @param samplersList The list of uniforms used in the effect
  8507. * @param defines the list of defines currently in use
  8508. */
  8509. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8510. /**
  8511. * Prepare the list of defines associated to the shader.
  8512. * @param defines the list of defines to complete
  8513. * @param forPostProcess Define if we are currently in post process mode or not
  8514. */
  8515. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8516. /**
  8517. * Returns true if all the image processing information are ready.
  8518. * @returns True if ready, otherwise, false
  8519. */
  8520. isReady(): boolean;
  8521. /**
  8522. * Binds the image processing to the shader.
  8523. * @param effect The effect to bind to
  8524. * @param overrideAspectRatio Override the aspect ratio of the effect
  8525. */
  8526. bind(effect: Effect, overrideAspectRatio?: number): void;
  8527. /**
  8528. * Clones the current image processing instance.
  8529. * @return The cloned image processing
  8530. */
  8531. clone(): ImageProcessingConfiguration;
  8532. /**
  8533. * Serializes the current image processing instance to a json representation.
  8534. * @return a JSON representation
  8535. */
  8536. serialize(): any;
  8537. /**
  8538. * Parses the image processing from a json representation.
  8539. * @param source the JSON source to parse
  8540. * @return The parsed image processing
  8541. */
  8542. static Parse(source: any): ImageProcessingConfiguration;
  8543. private static _VIGNETTEMODE_MULTIPLY;
  8544. private static _VIGNETTEMODE_OPAQUE;
  8545. /**
  8546. * Used to apply the vignette as a mix with the pixel color.
  8547. */
  8548. static get VIGNETTEMODE_MULTIPLY(): number;
  8549. /**
  8550. * Used to apply the vignette as a replacement of the pixel color.
  8551. */
  8552. static get VIGNETTEMODE_OPAQUE(): number;
  8553. }
  8554. }
  8555. declare module "babylonjs/Shaders/postprocess.vertex" {
  8556. /** @hidden */
  8557. export var postprocessVertexShader: {
  8558. name: string;
  8559. shader: string;
  8560. };
  8561. }
  8562. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  8563. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  8564. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  8565. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  8566. module "babylonjs/Engines/thinEngine" {
  8567. interface ThinEngine {
  8568. /**
  8569. * Creates a new render target texture
  8570. * @param size defines the size of the texture
  8571. * @param options defines the options used to create the texture
  8572. * @returns a new render target texture stored in an InternalTexture
  8573. */
  8574. createRenderTargetTexture(size: number | {
  8575. width: number;
  8576. height: number;
  8577. layers?: number;
  8578. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8579. /**
  8580. * Creates a depth stencil texture.
  8581. * This is only available in WebGL 2 or with the depth texture extension available.
  8582. * @param size The size of face edge in the texture.
  8583. * @param options The options defining the texture.
  8584. * @returns The texture
  8585. */
  8586. createDepthStencilTexture(size: number | {
  8587. width: number;
  8588. height: number;
  8589. layers?: number;
  8590. }, options: DepthTextureCreationOptions): InternalTexture;
  8591. /** @hidden */
  8592. _createDepthStencilTexture(size: number | {
  8593. width: number;
  8594. height: number;
  8595. layers?: number;
  8596. }, options: DepthTextureCreationOptions): InternalTexture;
  8597. }
  8598. }
  8599. }
  8600. declare module "babylonjs/Maths/math.axis" {
  8601. import { Vector3 } from "babylonjs/Maths/math.vector";
  8602. /** Defines supported spaces */
  8603. export enum Space {
  8604. /** Local (object) space */
  8605. LOCAL = 0,
  8606. /** World space */
  8607. WORLD = 1,
  8608. /** Bone space */
  8609. BONE = 2
  8610. }
  8611. /** Defines the 3 main axes */
  8612. export class Axis {
  8613. /** X axis */
  8614. static X: Vector3;
  8615. /** Y axis */
  8616. static Y: Vector3;
  8617. /** Z axis */
  8618. static Z: Vector3;
  8619. }
  8620. }
  8621. declare module "babylonjs/Cameras/targetCamera" {
  8622. import { Nullable } from "babylonjs/types";
  8623. import { Camera } from "babylonjs/Cameras/camera";
  8624. import { Scene } from "babylonjs/scene";
  8625. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  8626. /**
  8627. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8628. * This is the base of the follow, arc rotate cameras and Free camera
  8629. * @see http://doc.babylonjs.com/features/cameras
  8630. */
  8631. export class TargetCamera extends Camera {
  8632. private static _RigCamTransformMatrix;
  8633. private static _TargetTransformMatrix;
  8634. private static _TargetFocalPoint;
  8635. /**
  8636. * Define the current direction the camera is moving to
  8637. */
  8638. cameraDirection: Vector3;
  8639. /**
  8640. * Define the current rotation the camera is rotating to
  8641. */
  8642. cameraRotation: Vector2;
  8643. /**
  8644. * When set, the up vector of the camera will be updated by the rotation of the camera
  8645. */
  8646. updateUpVectorFromRotation: boolean;
  8647. private _tmpQuaternion;
  8648. /**
  8649. * Define the current rotation of the camera
  8650. */
  8651. rotation: Vector3;
  8652. /**
  8653. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8654. */
  8655. rotationQuaternion: Quaternion;
  8656. /**
  8657. * Define the current speed of the camera
  8658. */
  8659. speed: number;
  8660. /**
  8661. * Add constraint to the camera to prevent it to move freely in all directions and
  8662. * around all axis.
  8663. */
  8664. noRotationConstraint: boolean;
  8665. /**
  8666. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  8667. * panning
  8668. */
  8669. invertRotation: boolean;
  8670. /**
  8671. * Speed multiplier for inverse camera panning
  8672. */
  8673. inverseRotationSpeed: number;
  8674. /**
  8675. * Define the current target of the camera as an object or a position.
  8676. */
  8677. lockedTarget: any;
  8678. /** @hidden */
  8679. _currentTarget: Vector3;
  8680. /** @hidden */
  8681. _initialFocalDistance: number;
  8682. /** @hidden */
  8683. _viewMatrix: Matrix;
  8684. /** @hidden */
  8685. _camMatrix: Matrix;
  8686. /** @hidden */
  8687. _cameraTransformMatrix: Matrix;
  8688. /** @hidden */
  8689. _cameraRotationMatrix: Matrix;
  8690. /** @hidden */
  8691. _referencePoint: Vector3;
  8692. /** @hidden */
  8693. _transformedReferencePoint: Vector3;
  8694. protected _globalCurrentTarget: Vector3;
  8695. protected _globalCurrentUpVector: Vector3;
  8696. /** @hidden */
  8697. _reset: () => void;
  8698. private _defaultUp;
  8699. /**
  8700. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8701. * This is the base of the follow, arc rotate cameras and Free camera
  8702. * @see http://doc.babylonjs.com/features/cameras
  8703. * @param name Defines the name of the camera in the scene
  8704. * @param position Defines the start position of the camera in the scene
  8705. * @param scene Defines the scene the camera belongs to
  8706. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8707. */
  8708. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8709. /**
  8710. * Gets the position in front of the camera at a given distance.
  8711. * @param distance The distance from the camera we want the position to be
  8712. * @returns the position
  8713. */
  8714. getFrontPosition(distance: number): Vector3;
  8715. /** @hidden */
  8716. _getLockedTargetPosition(): Nullable<Vector3>;
  8717. private _storedPosition;
  8718. private _storedRotation;
  8719. private _storedRotationQuaternion;
  8720. /**
  8721. * Store current camera state of the camera (fov, position, rotation, etc..)
  8722. * @returns the camera
  8723. */
  8724. storeState(): Camera;
  8725. /**
  8726. * Restored camera state. You must call storeState() first
  8727. * @returns whether it was successful or not
  8728. * @hidden
  8729. */
  8730. _restoreStateValues(): boolean;
  8731. /** @hidden */
  8732. _initCache(): void;
  8733. /** @hidden */
  8734. _updateCache(ignoreParentClass?: boolean): void;
  8735. /** @hidden */
  8736. _isSynchronizedViewMatrix(): boolean;
  8737. /** @hidden */
  8738. _computeLocalCameraSpeed(): number;
  8739. /**
  8740. * Defines the target the camera should look at.
  8741. * @param target Defines the new target as a Vector or a mesh
  8742. */
  8743. setTarget(target: Vector3): void;
  8744. /**
  8745. * Return the current target position of the camera. This value is expressed in local space.
  8746. * @returns the target position
  8747. */
  8748. getTarget(): Vector3;
  8749. /** @hidden */
  8750. _decideIfNeedsToMove(): boolean;
  8751. /** @hidden */
  8752. _updatePosition(): void;
  8753. /** @hidden */
  8754. _checkInputs(): void;
  8755. protected _updateCameraRotationMatrix(): void;
  8756. /**
  8757. * Update the up vector to apply the rotation of the camera (So if you changed the camera rotation.z this will let you update the up vector as well)
  8758. * @returns the current camera
  8759. */
  8760. private _rotateUpVectorWithCameraRotationMatrix;
  8761. private _cachedRotationZ;
  8762. private _cachedQuaternionRotationZ;
  8763. /** @hidden */
  8764. _getViewMatrix(): Matrix;
  8765. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8766. /**
  8767. * @hidden
  8768. */
  8769. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8770. /**
  8771. * @hidden
  8772. */
  8773. _updateRigCameras(): void;
  8774. private _getRigCamPositionAndTarget;
  8775. /**
  8776. * Gets the current object class name.
  8777. * @return the class name
  8778. */
  8779. getClassName(): string;
  8780. }
  8781. }
  8782. declare module "babylonjs/Events/keyboardEvents" {
  8783. /**
  8784. * Gather the list of keyboard event types as constants.
  8785. */
  8786. export class KeyboardEventTypes {
  8787. /**
  8788. * The keydown event is fired when a key becomes active (pressed).
  8789. */
  8790. static readonly KEYDOWN: number;
  8791. /**
  8792. * The keyup event is fired when a key has been released.
  8793. */
  8794. static readonly KEYUP: number;
  8795. }
  8796. /**
  8797. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8798. */
  8799. export class KeyboardInfo {
  8800. /**
  8801. * Defines the type of event (KeyboardEventTypes)
  8802. */
  8803. type: number;
  8804. /**
  8805. * Defines the related dom event
  8806. */
  8807. event: KeyboardEvent;
  8808. /**
  8809. * Instantiates a new keyboard info.
  8810. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8811. * @param type Defines the type of event (KeyboardEventTypes)
  8812. * @param event Defines the related dom event
  8813. */
  8814. constructor(
  8815. /**
  8816. * Defines the type of event (KeyboardEventTypes)
  8817. */
  8818. type: number,
  8819. /**
  8820. * Defines the related dom event
  8821. */
  8822. event: KeyboardEvent);
  8823. }
  8824. /**
  8825. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8826. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8827. */
  8828. export class KeyboardInfoPre extends KeyboardInfo {
  8829. /**
  8830. * Defines the type of event (KeyboardEventTypes)
  8831. */
  8832. type: number;
  8833. /**
  8834. * Defines the related dom event
  8835. */
  8836. event: KeyboardEvent;
  8837. /**
  8838. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8839. */
  8840. skipOnPointerObservable: boolean;
  8841. /**
  8842. * Instantiates a new keyboard pre info.
  8843. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8844. * @param type Defines the type of event (KeyboardEventTypes)
  8845. * @param event Defines the related dom event
  8846. */
  8847. constructor(
  8848. /**
  8849. * Defines the type of event (KeyboardEventTypes)
  8850. */
  8851. type: number,
  8852. /**
  8853. * Defines the related dom event
  8854. */
  8855. event: KeyboardEvent);
  8856. }
  8857. }
  8858. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  8859. import { Nullable } from "babylonjs/types";
  8860. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  8861. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  8862. /**
  8863. * Manage the keyboard inputs to control the movement of a free camera.
  8864. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8865. */
  8866. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8867. /**
  8868. * Defines the camera the input is attached to.
  8869. */
  8870. camera: FreeCamera;
  8871. /**
  8872. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8873. */
  8874. keysUp: number[];
  8875. /**
  8876. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  8877. */
  8878. keysUpward: number[];
  8879. /**
  8880. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8881. */
  8882. keysDown: number[];
  8883. /**
  8884. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  8885. */
  8886. keysDownward: number[];
  8887. /**
  8888. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8889. */
  8890. keysLeft: number[];
  8891. /**
  8892. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8893. */
  8894. keysRight: number[];
  8895. private _keys;
  8896. private _onCanvasBlurObserver;
  8897. private _onKeyboardObserver;
  8898. private _engine;
  8899. private _scene;
  8900. /**
  8901. * Attach the input controls to a specific dom element to get the input from.
  8902. * @param element Defines the element the controls should be listened from
  8903. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8904. */
  8905. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8906. /**
  8907. * Detach the current controls from the specified dom element.
  8908. * @param element Defines the element to stop listening the inputs from
  8909. */
  8910. detachControl(element: Nullable<HTMLElement>): void;
  8911. /**
  8912. * Update the current camera state depending on the inputs that have been used this frame.
  8913. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8914. */
  8915. checkInputs(): void;
  8916. /**
  8917. * Gets the class name of the current intput.
  8918. * @returns the class name
  8919. */
  8920. getClassName(): string;
  8921. /** @hidden */
  8922. _onLostFocus(): void;
  8923. /**
  8924. * Get the friendly name associated with the input class.
  8925. * @returns the input friendly name
  8926. */
  8927. getSimpleName(): string;
  8928. }
  8929. }
  8930. declare module "babylonjs/Lights/shadowLight" {
  8931. import { Camera } from "babylonjs/Cameras/camera";
  8932. import { Scene } from "babylonjs/scene";
  8933. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  8934. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8935. import { Light } from "babylonjs/Lights/light";
  8936. /**
  8937. * Interface describing all the common properties and methods a shadow light needs to implement.
  8938. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8939. * as well as binding the different shadow properties to the effects.
  8940. */
  8941. export interface IShadowLight extends Light {
  8942. /**
  8943. * The light id in the scene (used in scene.findLighById for instance)
  8944. */
  8945. id: string;
  8946. /**
  8947. * The position the shdow will be casted from.
  8948. */
  8949. position: Vector3;
  8950. /**
  8951. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8952. */
  8953. direction: Vector3;
  8954. /**
  8955. * The transformed position. Position of the light in world space taking parenting in account.
  8956. */
  8957. transformedPosition: Vector3;
  8958. /**
  8959. * The transformed direction. Direction of the light in world space taking parenting in account.
  8960. */
  8961. transformedDirection: Vector3;
  8962. /**
  8963. * The friendly name of the light in the scene.
  8964. */
  8965. name: string;
  8966. /**
  8967. * Defines the shadow projection clipping minimum z value.
  8968. */
  8969. shadowMinZ: number;
  8970. /**
  8971. * Defines the shadow projection clipping maximum z value.
  8972. */
  8973. shadowMaxZ: number;
  8974. /**
  8975. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8976. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8977. */
  8978. computeTransformedInformation(): boolean;
  8979. /**
  8980. * Gets the scene the light belongs to.
  8981. * @returns The scene
  8982. */
  8983. getScene(): Scene;
  8984. /**
  8985. * Callback defining a custom Projection Matrix Builder.
  8986. * This can be used to override the default projection matrix computation.
  8987. */
  8988. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8989. /**
  8990. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8991. * @param matrix The materix to updated with the projection information
  8992. * @param viewMatrix The transform matrix of the light
  8993. * @param renderList The list of mesh to render in the map
  8994. * @returns The current light
  8995. */
  8996. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8997. /**
  8998. * Gets the current depth scale used in ESM.
  8999. * @returns The scale
  9000. */
  9001. getDepthScale(): number;
  9002. /**
  9003. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9004. * @returns true if a cube texture needs to be use
  9005. */
  9006. needCube(): boolean;
  9007. /**
  9008. * Detects if the projection matrix requires to be recomputed this frame.
  9009. * @returns true if it requires to be recomputed otherwise, false.
  9010. */
  9011. needProjectionMatrixCompute(): boolean;
  9012. /**
  9013. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9014. */
  9015. forceProjectionMatrixCompute(): void;
  9016. /**
  9017. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9018. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9019. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9020. */
  9021. getShadowDirection(faceIndex?: number): Vector3;
  9022. /**
  9023. * Gets the minZ used for shadow according to both the scene and the light.
  9024. * @param activeCamera The camera we are returning the min for
  9025. * @returns the depth min z
  9026. */
  9027. getDepthMinZ(activeCamera: Camera): number;
  9028. /**
  9029. * Gets the maxZ used for shadow according to both the scene and the light.
  9030. * @param activeCamera The camera we are returning the max for
  9031. * @returns the depth max z
  9032. */
  9033. getDepthMaxZ(activeCamera: Camera): number;
  9034. }
  9035. /**
  9036. * Base implementation IShadowLight
  9037. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  9038. */
  9039. export abstract class ShadowLight extends Light implements IShadowLight {
  9040. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9041. protected _position: Vector3;
  9042. protected _setPosition(value: Vector3): void;
  9043. /**
  9044. * Sets the position the shadow will be casted from. Also use as the light position for both
  9045. * point and spot lights.
  9046. */
  9047. get position(): Vector3;
  9048. /**
  9049. * Sets the position the shadow will be casted from. Also use as the light position for both
  9050. * point and spot lights.
  9051. */
  9052. set position(value: Vector3);
  9053. protected _direction: Vector3;
  9054. protected _setDirection(value: Vector3): void;
  9055. /**
  9056. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9057. * Also use as the light direction on spot and directional lights.
  9058. */
  9059. get direction(): Vector3;
  9060. /**
  9061. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9062. * Also use as the light direction on spot and directional lights.
  9063. */
  9064. set direction(value: Vector3);
  9065. protected _shadowMinZ: number;
  9066. /**
  9067. * Gets the shadow projection clipping minimum z value.
  9068. */
  9069. get shadowMinZ(): number;
  9070. /**
  9071. * Sets the shadow projection clipping minimum z value.
  9072. */
  9073. set shadowMinZ(value: number);
  9074. protected _shadowMaxZ: number;
  9075. /**
  9076. * Sets the shadow projection clipping maximum z value.
  9077. */
  9078. get shadowMaxZ(): number;
  9079. /**
  9080. * Gets the shadow projection clipping maximum z value.
  9081. */
  9082. set shadowMaxZ(value: number);
  9083. /**
  9084. * Callback defining a custom Projection Matrix Builder.
  9085. * This can be used to override the default projection matrix computation.
  9086. */
  9087. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9088. /**
  9089. * The transformed position. Position of the light in world space taking parenting in account.
  9090. */
  9091. transformedPosition: Vector3;
  9092. /**
  9093. * The transformed direction. Direction of the light in world space taking parenting in account.
  9094. */
  9095. transformedDirection: Vector3;
  9096. private _needProjectionMatrixCompute;
  9097. /**
  9098. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9099. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9100. */
  9101. computeTransformedInformation(): boolean;
  9102. /**
  9103. * Return the depth scale used for the shadow map.
  9104. * @returns the depth scale.
  9105. */
  9106. getDepthScale(): number;
  9107. /**
  9108. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9109. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9110. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9111. */
  9112. getShadowDirection(faceIndex?: number): Vector3;
  9113. /**
  9114. * Returns the ShadowLight absolute position in the World.
  9115. * @returns the position vector in world space
  9116. */
  9117. getAbsolutePosition(): Vector3;
  9118. /**
  9119. * Sets the ShadowLight direction toward the passed target.
  9120. * @param target The point to target in local space
  9121. * @returns the updated ShadowLight direction
  9122. */
  9123. setDirectionToTarget(target: Vector3): Vector3;
  9124. /**
  9125. * Returns the light rotation in euler definition.
  9126. * @returns the x y z rotation in local space.
  9127. */
  9128. getRotation(): Vector3;
  9129. /**
  9130. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9131. * @returns true if a cube texture needs to be use
  9132. */
  9133. needCube(): boolean;
  9134. /**
  9135. * Detects if the projection matrix requires to be recomputed this frame.
  9136. * @returns true if it requires to be recomputed otherwise, false.
  9137. */
  9138. needProjectionMatrixCompute(): boolean;
  9139. /**
  9140. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9141. */
  9142. forceProjectionMatrixCompute(): void;
  9143. /** @hidden */
  9144. _initCache(): void;
  9145. /** @hidden */
  9146. _isSynchronized(): boolean;
  9147. /**
  9148. * Computes the world matrix of the node
  9149. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9150. * @returns the world matrix
  9151. */
  9152. computeWorldMatrix(force?: boolean): Matrix;
  9153. /**
  9154. * Gets the minZ used for shadow according to both the scene and the light.
  9155. * @param activeCamera The camera we are returning the min for
  9156. * @returns the depth min z
  9157. */
  9158. getDepthMinZ(activeCamera: Camera): number;
  9159. /**
  9160. * Gets the maxZ used for shadow according to both the scene and the light.
  9161. * @param activeCamera The camera we are returning the max for
  9162. * @returns the depth max z
  9163. */
  9164. getDepthMaxZ(activeCamera: Camera): number;
  9165. /**
  9166. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9167. * @param matrix The materix to updated with the projection information
  9168. * @param viewMatrix The transform matrix of the light
  9169. * @param renderList The list of mesh to render in the map
  9170. * @returns The current light
  9171. */
  9172. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9173. }
  9174. }
  9175. declare module "babylonjs/Materials/effectFallbacks" {
  9176. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  9177. import { Effect } from "babylonjs/Materials/effect";
  9178. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9179. /**
  9180. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9181. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9182. */
  9183. export class EffectFallbacks implements IEffectFallbacks {
  9184. private _defines;
  9185. private _currentRank;
  9186. private _maxRank;
  9187. private _mesh;
  9188. /**
  9189. * Removes the fallback from the bound mesh.
  9190. */
  9191. unBindMesh(): void;
  9192. /**
  9193. * Adds a fallback on the specified property.
  9194. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9195. * @param define The name of the define in the shader
  9196. */
  9197. addFallback(rank: number, define: string): void;
  9198. /**
  9199. * Sets the mesh to use CPU skinning when needing to fallback.
  9200. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9201. * @param mesh The mesh to use the fallbacks.
  9202. */
  9203. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9204. /**
  9205. * Checks to see if more fallbacks are still availible.
  9206. */
  9207. get hasMoreFallbacks(): boolean;
  9208. /**
  9209. * Removes the defines that should be removed when falling back.
  9210. * @param currentDefines defines the current define statements for the shader.
  9211. * @param effect defines the current effect we try to compile
  9212. * @returns The resulting defines with defines of the current rank removed.
  9213. */
  9214. reduce(currentDefines: string, effect: Effect): string;
  9215. }
  9216. }
  9217. declare module "babylonjs/Materials/materialHelper" {
  9218. import { Nullable } from "babylonjs/types";
  9219. import { Scene } from "babylonjs/scene";
  9220. import { Engine } from "babylonjs/Engines/engine";
  9221. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9222. import { Light } from "babylonjs/Lights/light";
  9223. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9224. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  9225. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  9226. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9227. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  9228. /**
  9229. * "Static Class" containing the most commonly used helper while dealing with material for
  9230. * rendering purpose.
  9231. *
  9232. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9233. *
  9234. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9235. */
  9236. export class MaterialHelper {
  9237. /**
  9238. * Bind the current view position to an effect.
  9239. * @param effect The effect to be bound
  9240. * @param scene The scene the eyes position is used from
  9241. */
  9242. static BindEyePosition(effect: Effect, scene: Scene): void;
  9243. /**
  9244. * Helps preparing the defines values about the UVs in used in the effect.
  9245. * UVs are shared as much as we can accross channels in the shaders.
  9246. * @param texture The texture we are preparing the UVs for
  9247. * @param defines The defines to update
  9248. * @param key The channel key "diffuse", "specular"... used in the shader
  9249. */
  9250. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9251. /**
  9252. * Binds a texture matrix value to its corrsponding uniform
  9253. * @param texture The texture to bind the matrix for
  9254. * @param uniformBuffer The uniform buffer receivin the data
  9255. * @param key The channel key "diffuse", "specular"... used in the shader
  9256. */
  9257. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9258. /**
  9259. * Gets the current status of the fog (should it be enabled?)
  9260. * @param mesh defines the mesh to evaluate for fog support
  9261. * @param scene defines the hosting scene
  9262. * @returns true if fog must be enabled
  9263. */
  9264. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  9265. /**
  9266. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9267. * @param mesh defines the current mesh
  9268. * @param scene defines the current scene
  9269. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9270. * @param pointsCloud defines if point cloud rendering has to be turned on
  9271. * @param fogEnabled defines if fog has to be turned on
  9272. * @param alphaTest defines if alpha testing has to be turned on
  9273. * @param defines defines the current list of defines
  9274. */
  9275. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9276. /**
  9277. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9278. * @param scene defines the current scene
  9279. * @param engine defines the current engine
  9280. * @param defines specifies the list of active defines
  9281. * @param useInstances defines if instances have to be turned on
  9282. * @param useClipPlane defines if clip plane have to be turned on
  9283. */
  9284. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9285. /**
  9286. * Prepares the defines for bones
  9287. * @param mesh The mesh containing the geometry data we will draw
  9288. * @param defines The defines to update
  9289. */
  9290. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  9291. /**
  9292. * Prepares the defines for morph targets
  9293. * @param mesh The mesh containing the geometry data we will draw
  9294. * @param defines The defines to update
  9295. */
  9296. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  9297. /**
  9298. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9299. * @param mesh The mesh containing the geometry data we will draw
  9300. * @param defines The defines to update
  9301. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9302. * @param useBones Precise whether bones should be used or not (override mesh info)
  9303. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9304. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9305. * @returns false if defines are considered not dirty and have not been checked
  9306. */
  9307. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9308. /**
  9309. * Prepares the defines related to multiview
  9310. * @param scene The scene we are intending to draw
  9311. * @param defines The defines to update
  9312. */
  9313. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9314. /**
  9315. * Prepares the defines related to the light information passed in parameter
  9316. * @param scene The scene we are intending to draw
  9317. * @param mesh The mesh the effect is compiling for
  9318. * @param light The light the effect is compiling for
  9319. * @param lightIndex The index of the light
  9320. * @param defines The defines to update
  9321. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9322. * @param state Defines the current state regarding what is needed (normals, etc...)
  9323. */
  9324. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  9325. needNormals: boolean;
  9326. needRebuild: boolean;
  9327. shadowEnabled: boolean;
  9328. specularEnabled: boolean;
  9329. lightmapMode: boolean;
  9330. }): void;
  9331. /**
  9332. * Prepares the defines related to the light information passed in parameter
  9333. * @param scene The scene we are intending to draw
  9334. * @param mesh The mesh the effect is compiling for
  9335. * @param defines The defines to update
  9336. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9337. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9338. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9339. * @returns true if normals will be required for the rest of the effect
  9340. */
  9341. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9342. /**
  9343. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  9344. * @param lightIndex defines the light index
  9345. * @param uniformsList The uniform list
  9346. * @param samplersList The sampler list
  9347. * @param projectedLightTexture defines if projected texture must be used
  9348. * @param uniformBuffersList defines an optional list of uniform buffers
  9349. */
  9350. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  9351. /**
  9352. * Prepares the uniforms and samplers list to be used in the effect
  9353. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9354. * @param samplersList The sampler list
  9355. * @param defines The defines helping in the list generation
  9356. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9357. */
  9358. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9359. /**
  9360. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9361. * @param defines The defines to update while falling back
  9362. * @param fallbacks The authorized effect fallbacks
  9363. * @param maxSimultaneousLights The maximum number of lights allowed
  9364. * @param rank the current rank of the Effect
  9365. * @returns The newly affected rank
  9366. */
  9367. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9368. private static _TmpMorphInfluencers;
  9369. /**
  9370. * Prepares the list of attributes required for morph targets according to the effect defines.
  9371. * @param attribs The current list of supported attribs
  9372. * @param mesh The mesh to prepare the morph targets attributes for
  9373. * @param influencers The number of influencers
  9374. */
  9375. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  9376. /**
  9377. * Prepares the list of attributes required for morph targets according to the effect defines.
  9378. * @param attribs The current list of supported attribs
  9379. * @param mesh The mesh to prepare the morph targets attributes for
  9380. * @param defines The current Defines of the effect
  9381. */
  9382. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9383. /**
  9384. * Prepares the list of attributes required for bones according to the effect defines.
  9385. * @param attribs The current list of supported attribs
  9386. * @param mesh The mesh to prepare the bones attributes for
  9387. * @param defines The current Defines of the effect
  9388. * @param fallbacks The current efffect fallback strategy
  9389. */
  9390. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9391. /**
  9392. * Check and prepare the list of attributes required for instances according to the effect defines.
  9393. * @param attribs The current list of supported attribs
  9394. * @param defines The current MaterialDefines of the effect
  9395. */
  9396. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  9397. /**
  9398. * Add the list of attributes required for instances to the attribs array.
  9399. * @param attribs The current list of supported attribs
  9400. */
  9401. static PushAttributesForInstances(attribs: string[]): void;
  9402. /**
  9403. * Binds the light information to the effect.
  9404. * @param light The light containing the generator
  9405. * @param effect The effect we are binding the data to
  9406. * @param lightIndex The light index in the effect used to render
  9407. */
  9408. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9409. /**
  9410. * Binds the lights information from the scene to the effect for the given mesh.
  9411. * @param light Light to bind
  9412. * @param lightIndex Light index
  9413. * @param scene The scene where the light belongs to
  9414. * @param effect The effect we are binding the data to
  9415. * @param useSpecular Defines if specular is supported
  9416. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9417. */
  9418. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  9419. /**
  9420. * Binds the lights information from the scene to the effect for the given mesh.
  9421. * @param scene The scene the lights belongs to
  9422. * @param mesh The mesh we are binding the information to render
  9423. * @param effect The effect we are binding the data to
  9424. * @param defines The generated defines for the effect
  9425. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9426. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9427. */
  9428. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  9429. private static _tempFogColor;
  9430. /**
  9431. * Binds the fog information from the scene to the effect for the given mesh.
  9432. * @param scene The scene the lights belongs to
  9433. * @param mesh The mesh we are binding the information to render
  9434. * @param effect The effect we are binding the data to
  9435. * @param linearSpace Defines if the fog effect is applied in linear space
  9436. */
  9437. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9438. /**
  9439. * Binds the bones information from the mesh to the effect.
  9440. * @param mesh The mesh we are binding the information to render
  9441. * @param effect The effect we are binding the data to
  9442. */
  9443. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9444. /**
  9445. * Binds the morph targets information from the mesh to the effect.
  9446. * @param abstractMesh The mesh we are binding the information to render
  9447. * @param effect The effect we are binding the data to
  9448. */
  9449. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9450. /**
  9451. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9452. * @param defines The generated defines used in the effect
  9453. * @param effect The effect we are binding the data to
  9454. * @param scene The scene we are willing to render with logarithmic scale for
  9455. */
  9456. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9457. /**
  9458. * Binds the clip plane information from the scene to the effect.
  9459. * @param scene The scene the clip plane information are extracted from
  9460. * @param effect The effect we are binding the data to
  9461. */
  9462. static BindClipPlane(effect: Effect, scene: Scene): void;
  9463. }
  9464. }
  9465. declare module "babylonjs/Shaders/ShadersInclude/packingFunctions" {
  9466. /** @hidden */
  9467. export var packingFunctions: {
  9468. name: string;
  9469. shader: string;
  9470. };
  9471. }
  9472. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  9473. /** @hidden */
  9474. export var clipPlaneFragmentDeclaration: {
  9475. name: string;
  9476. shader: string;
  9477. };
  9478. }
  9479. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  9480. /** @hidden */
  9481. export var clipPlaneFragment: {
  9482. name: string;
  9483. shader: string;
  9484. };
  9485. }
  9486. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9487. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  9488. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  9489. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  9490. /** @hidden */
  9491. export var shadowMapPixelShader: {
  9492. name: string;
  9493. shader: string;
  9494. };
  9495. }
  9496. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9497. /** @hidden */
  9498. export var bonesDeclaration: {
  9499. name: string;
  9500. shader: string;
  9501. };
  9502. }
  9503. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9504. /** @hidden */
  9505. export var morphTargetsVertexGlobalDeclaration: {
  9506. name: string;
  9507. shader: string;
  9508. };
  9509. }
  9510. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9511. /** @hidden */
  9512. export var morphTargetsVertexDeclaration: {
  9513. name: string;
  9514. shader: string;
  9515. };
  9516. }
  9517. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9518. /** @hidden */
  9519. export var instancesDeclaration: {
  9520. name: string;
  9521. shader: string;
  9522. };
  9523. }
  9524. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9525. /** @hidden */
  9526. export var helperFunctions: {
  9527. name: string;
  9528. shader: string;
  9529. };
  9530. }
  9531. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  9532. /** @hidden */
  9533. export var clipPlaneVertexDeclaration: {
  9534. name: string;
  9535. shader: string;
  9536. };
  9537. }
  9538. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9539. /** @hidden */
  9540. export var morphTargetsVertex: {
  9541. name: string;
  9542. shader: string;
  9543. };
  9544. }
  9545. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9546. /** @hidden */
  9547. export var instancesVertex: {
  9548. name: string;
  9549. shader: string;
  9550. };
  9551. }
  9552. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9553. /** @hidden */
  9554. export var bonesVertex: {
  9555. name: string;
  9556. shader: string;
  9557. };
  9558. }
  9559. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  9560. /** @hidden */
  9561. export var clipPlaneVertex: {
  9562. name: string;
  9563. shader: string;
  9564. };
  9565. }
  9566. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9567. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9568. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9569. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9570. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9571. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9572. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  9573. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9574. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9575. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9576. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  9577. /** @hidden */
  9578. export var shadowMapVertexShader: {
  9579. name: string;
  9580. shader: string;
  9581. };
  9582. }
  9583. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9584. /** @hidden */
  9585. export var depthBoxBlurPixelShader: {
  9586. name: string;
  9587. shader: string;
  9588. };
  9589. }
  9590. declare module "babylonjs/Culling/ray" {
  9591. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  9592. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  9593. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9594. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  9595. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  9596. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  9597. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  9598. import { Plane } from "babylonjs/Maths/math.plane";
  9599. /**
  9600. * Class representing a ray with position and direction
  9601. */
  9602. export class Ray {
  9603. /** origin point */
  9604. origin: Vector3;
  9605. /** direction */
  9606. direction: Vector3;
  9607. /** length of the ray */
  9608. length: number;
  9609. private static readonly TmpVector3;
  9610. private _tmpRay;
  9611. /**
  9612. * Creates a new ray
  9613. * @param origin origin point
  9614. * @param direction direction
  9615. * @param length length of the ray
  9616. */
  9617. constructor(
  9618. /** origin point */
  9619. origin: Vector3,
  9620. /** direction */
  9621. direction: Vector3,
  9622. /** length of the ray */
  9623. length?: number);
  9624. /**
  9625. * Checks if the ray intersects a box
  9626. * @param minimum bound of the box
  9627. * @param maximum bound of the box
  9628. * @param intersectionTreshold extra extend to be added to the box in all direction
  9629. * @returns if the box was hit
  9630. */
  9631. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  9632. /**
  9633. * Checks if the ray intersects a box
  9634. * @param box the bounding box to check
  9635. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  9636. * @returns if the box was hit
  9637. */
  9638. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  9639. /**
  9640. * If the ray hits a sphere
  9641. * @param sphere the bounding sphere to check
  9642. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  9643. * @returns true if it hits the sphere
  9644. */
  9645. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  9646. /**
  9647. * If the ray hits a triange
  9648. * @param vertex0 triangle vertex
  9649. * @param vertex1 triangle vertex
  9650. * @param vertex2 triangle vertex
  9651. * @returns intersection information if hit
  9652. */
  9653. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  9654. /**
  9655. * Checks if ray intersects a plane
  9656. * @param plane the plane to check
  9657. * @returns the distance away it was hit
  9658. */
  9659. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  9660. /**
  9661. * Calculate the intercept of a ray on a given axis
  9662. * @param axis to check 'x' | 'y' | 'z'
  9663. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  9664. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  9665. */
  9666. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  9667. /**
  9668. * Checks if ray intersects a mesh
  9669. * @param mesh the mesh to check
  9670. * @param fastCheck if only the bounding box should checked
  9671. * @returns picking info of the intersecton
  9672. */
  9673. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  9674. /**
  9675. * Checks if ray intersects a mesh
  9676. * @param meshes the meshes to check
  9677. * @param fastCheck if only the bounding box should checked
  9678. * @param results array to store result in
  9679. * @returns Array of picking infos
  9680. */
  9681. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  9682. private _comparePickingInfo;
  9683. private static smallnum;
  9684. private static rayl;
  9685. /**
  9686. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  9687. * @param sega the first point of the segment to test the intersection against
  9688. * @param segb the second point of the segment to test the intersection against
  9689. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  9690. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  9691. */
  9692. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  9693. /**
  9694. * Update the ray from viewport position
  9695. * @param x position
  9696. * @param y y position
  9697. * @param viewportWidth viewport width
  9698. * @param viewportHeight viewport height
  9699. * @param world world matrix
  9700. * @param view view matrix
  9701. * @param projection projection matrix
  9702. * @returns this ray updated
  9703. */
  9704. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  9705. /**
  9706. * Creates a ray with origin and direction of 0,0,0
  9707. * @returns the new ray
  9708. */
  9709. static Zero(): Ray;
  9710. /**
  9711. * Creates a new ray from screen space and viewport
  9712. * @param x position
  9713. * @param y y position
  9714. * @param viewportWidth viewport width
  9715. * @param viewportHeight viewport height
  9716. * @param world world matrix
  9717. * @param view view matrix
  9718. * @param projection projection matrix
  9719. * @returns new ray
  9720. */
  9721. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  9722. /**
  9723. * Function will create a new transformed ray starting from origin and ending at the end point. Ray's length will be set, and ray will be
  9724. * transformed to the given world matrix.
  9725. * @param origin The origin point
  9726. * @param end The end point
  9727. * @param world a matrix to transform the ray to. Default is the identity matrix.
  9728. * @returns the new ray
  9729. */
  9730. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  9731. /**
  9732. * Transforms a ray by a matrix
  9733. * @param ray ray to transform
  9734. * @param matrix matrix to apply
  9735. * @returns the resulting new ray
  9736. */
  9737. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  9738. /**
  9739. * Transforms a ray by a matrix
  9740. * @param ray ray to transform
  9741. * @param matrix matrix to apply
  9742. * @param result ray to store result in
  9743. */
  9744. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  9745. /**
  9746. * Unproject a ray from screen space to object space
  9747. * @param sourceX defines the screen space x coordinate to use
  9748. * @param sourceY defines the screen space y coordinate to use
  9749. * @param viewportWidth defines the current width of the viewport
  9750. * @param viewportHeight defines the current height of the viewport
  9751. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  9752. * @param view defines the view matrix to use
  9753. * @param projection defines the projection matrix to use
  9754. */
  9755. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  9756. }
  9757. /**
  9758. * Type used to define predicate used to select faces when a mesh intersection is detected
  9759. */
  9760. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  9761. module "babylonjs/scene" {
  9762. interface Scene {
  9763. /** @hidden */
  9764. _tempPickingRay: Nullable<Ray>;
  9765. /** @hidden */
  9766. _cachedRayForTransform: Ray;
  9767. /** @hidden */
  9768. _pickWithRayInverseMatrix: Matrix;
  9769. /** @hidden */
  9770. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  9771. /** @hidden */
  9772. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  9773. }
  9774. }
  9775. }
  9776. declare module "babylonjs/sceneComponent" {
  9777. import { Scene } from "babylonjs/scene";
  9778. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9779. import { SubMesh } from "babylonjs/Meshes/subMesh";
  9780. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  9781. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  9782. import { Nullable } from "babylonjs/types";
  9783. import { Camera } from "babylonjs/Cameras/camera";
  9784. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  9785. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  9786. import { AbstractScene } from "babylonjs/abstractScene";
  9787. import { Mesh } from "babylonjs/Meshes/mesh";
  9788. /**
  9789. * Groups all the scene component constants in one place to ease maintenance.
  9790. * @hidden
  9791. */
  9792. export class SceneComponentConstants {
  9793. static readonly NAME_EFFECTLAYER: string;
  9794. static readonly NAME_LAYER: string;
  9795. static readonly NAME_LENSFLARESYSTEM: string;
  9796. static readonly NAME_BOUNDINGBOXRENDERER: string;
  9797. static readonly NAME_PARTICLESYSTEM: string;
  9798. static readonly NAME_GAMEPAD: string;
  9799. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  9800. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  9801. static readonly NAME_DEPTHRENDERER: string;
  9802. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  9803. static readonly NAME_SPRITE: string;
  9804. static readonly NAME_OUTLINERENDERER: string;
  9805. static readonly NAME_PROCEDURALTEXTURE: string;
  9806. static readonly NAME_SHADOWGENERATOR: string;
  9807. static readonly NAME_OCTREE: string;
  9808. static readonly NAME_PHYSICSENGINE: string;
  9809. static readonly NAME_AUDIO: string;
  9810. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  9811. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  9812. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  9813. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  9814. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  9815. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  9816. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  9817. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  9818. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  9819. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  9820. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  9821. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  9822. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  9823. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  9824. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  9825. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  9826. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  9827. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  9828. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  9829. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  9830. static readonly STEP_AFTERRENDER_AUDIO: number;
  9831. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  9832. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  9833. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  9834. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  9835. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  9836. static readonly STEP_POINTERMOVE_SPRITE: number;
  9837. static readonly STEP_POINTERDOWN_SPRITE: number;
  9838. static readonly STEP_POINTERUP_SPRITE: number;
  9839. }
  9840. /**
  9841. * This represents a scene component.
  9842. *
  9843. * This is used to decouple the dependency the scene is having on the different workloads like
  9844. * layers, post processes...
  9845. */
  9846. export interface ISceneComponent {
  9847. /**
  9848. * The name of the component. Each component must have a unique name.
  9849. */
  9850. name: string;
  9851. /**
  9852. * The scene the component belongs to.
  9853. */
  9854. scene: Scene;
  9855. /**
  9856. * Register the component to one instance of a scene.
  9857. */
  9858. register(): void;
  9859. /**
  9860. * Rebuilds the elements related to this component in case of
  9861. * context lost for instance.
  9862. */
  9863. rebuild(): void;
  9864. /**
  9865. * Disposes the component and the associated ressources.
  9866. */
  9867. dispose(): void;
  9868. }
  9869. /**
  9870. * This represents a SERIALIZABLE scene component.
  9871. *
  9872. * This extends Scene Component to add Serialization methods on top.
  9873. */
  9874. export interface ISceneSerializableComponent extends ISceneComponent {
  9875. /**
  9876. * Adds all the elements from the container to the scene
  9877. * @param container the container holding the elements
  9878. */
  9879. addFromContainer(container: AbstractScene): void;
  9880. /**
  9881. * Removes all the elements in the container from the scene
  9882. * @param container contains the elements to remove
  9883. * @param dispose if the removed element should be disposed (default: false)
  9884. */
  9885. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  9886. /**
  9887. * Serializes the component data to the specified json object
  9888. * @param serializationObject The object to serialize to
  9889. */
  9890. serialize(serializationObject: any): void;
  9891. }
  9892. /**
  9893. * Strong typing of a Mesh related stage step action
  9894. */
  9895. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  9896. /**
  9897. * Strong typing of a Evaluate Sub Mesh related stage step action
  9898. */
  9899. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  9900. /**
  9901. * Strong typing of a Active Mesh related stage step action
  9902. */
  9903. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  9904. /**
  9905. * Strong typing of a Camera related stage step action
  9906. */
  9907. export type CameraStageAction = (camera: Camera) => void;
  9908. /**
  9909. * Strong typing of a Camera Frame buffer related stage step action
  9910. */
  9911. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  9912. /**
  9913. * Strong typing of a Render Target related stage step action
  9914. */
  9915. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  9916. /**
  9917. * Strong typing of a RenderingGroup related stage step action
  9918. */
  9919. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  9920. /**
  9921. * Strong typing of a Mesh Render related stage step action
  9922. */
  9923. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  9924. /**
  9925. * Strong typing of a simple stage step action
  9926. */
  9927. export type SimpleStageAction = () => void;
  9928. /**
  9929. * Strong typing of a render target action.
  9930. */
  9931. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  9932. /**
  9933. * Strong typing of a pointer move action.
  9934. */
  9935. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  9936. /**
  9937. * Strong typing of a pointer up/down action.
  9938. */
  9939. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  9940. /**
  9941. * Representation of a stage in the scene (Basically a list of ordered steps)
  9942. * @hidden
  9943. */
  9944. export class Stage<T extends Function> extends Array<{
  9945. index: number;
  9946. component: ISceneComponent;
  9947. action: T;
  9948. }> {
  9949. /**
  9950. * Hide ctor from the rest of the world.
  9951. * @param items The items to add.
  9952. */
  9953. private constructor();
  9954. /**
  9955. * Creates a new Stage.
  9956. * @returns A new instance of a Stage
  9957. */
  9958. static Create<T extends Function>(): Stage<T>;
  9959. /**
  9960. * Registers a step in an ordered way in the targeted stage.
  9961. * @param index Defines the position to register the step in
  9962. * @param component Defines the component attached to the step
  9963. * @param action Defines the action to launch during the step
  9964. */
  9965. registerStep(index: number, component: ISceneComponent, action: T): void;
  9966. /**
  9967. * Clears all the steps from the stage.
  9968. */
  9969. clear(): void;
  9970. }
  9971. }
  9972. declare module "babylonjs/Sprites/spriteSceneComponent" {
  9973. import { Nullable } from "babylonjs/types";
  9974. import { Observable } from "babylonjs/Misc/observable";
  9975. import { Scene } from "babylonjs/scene";
  9976. import { Sprite } from "babylonjs/Sprites/sprite";
  9977. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  9978. import { Ray } from "babylonjs/Culling/ray";
  9979. import { Camera } from "babylonjs/Cameras/camera";
  9980. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  9981. import { ISceneComponent } from "babylonjs/sceneComponent";
  9982. module "babylonjs/scene" {
  9983. interface Scene {
  9984. /** @hidden */
  9985. _pointerOverSprite: Nullable<Sprite>;
  9986. /** @hidden */
  9987. _pickedDownSprite: Nullable<Sprite>;
  9988. /** @hidden */
  9989. _tempSpritePickingRay: Nullable<Ray>;
  9990. /**
  9991. * All of the sprite managers added to this scene
  9992. * @see http://doc.babylonjs.com/babylon101/sprites
  9993. */
  9994. spriteManagers: Array<ISpriteManager>;
  9995. /**
  9996. * An event triggered when sprites rendering is about to start
  9997. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  9998. */
  9999. onBeforeSpritesRenderingObservable: Observable<Scene>;
  10000. /**
  10001. * An event triggered when sprites rendering is done
  10002. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  10003. */
  10004. onAfterSpritesRenderingObservable: Observable<Scene>;
  10005. /** @hidden */
  10006. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10007. /** Launch a ray to try to pick a sprite in the scene
  10008. * @param x position on screen
  10009. * @param y position on screen
  10010. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  10011. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  10012. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10013. * @returns a PickingInfo
  10014. */
  10015. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10016. /** Use the given ray to pick a sprite in the scene
  10017. * @param ray The ray (in world space) to use to pick meshes
  10018. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  10019. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  10020. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10021. * @returns a PickingInfo
  10022. */
  10023. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10024. /** @hidden */
  10025. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10026. /** Launch a ray to try to pick sprites in the scene
  10027. * @param x position on screen
  10028. * @param y position on screen
  10029. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  10030. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10031. * @returns a PickingInfo array
  10032. */
  10033. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10034. /** Use the given ray to pick sprites in the scene
  10035. * @param ray The ray (in world space) to use to pick meshes
  10036. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  10037. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10038. * @returns a PickingInfo array
  10039. */
  10040. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10041. /**
  10042. * Force the sprite under the pointer
  10043. * @param sprite defines the sprite to use
  10044. */
  10045. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  10046. /**
  10047. * Gets the sprite under the pointer
  10048. * @returns a Sprite or null if no sprite is under the pointer
  10049. */
  10050. getPointerOverSprite(): Nullable<Sprite>;
  10051. }
  10052. }
  10053. /**
  10054. * Defines the sprite scene component responsible to manage sprites
  10055. * in a given scene.
  10056. */
  10057. export class SpriteSceneComponent implements ISceneComponent {
  10058. /**
  10059. * The component name helpfull to identify the component in the list of scene components.
  10060. */
  10061. readonly name: string;
  10062. /**
  10063. * The scene the component belongs to.
  10064. */
  10065. scene: Scene;
  10066. /** @hidden */
  10067. private _spritePredicate;
  10068. /**
  10069. * Creates a new instance of the component for the given scene
  10070. * @param scene Defines the scene to register the component in
  10071. */
  10072. constructor(scene: Scene);
  10073. /**
  10074. * Registers the component in a given scene
  10075. */
  10076. register(): void;
  10077. /**
  10078. * Rebuilds the elements related to this component in case of
  10079. * context lost for instance.
  10080. */
  10081. rebuild(): void;
  10082. /**
  10083. * Disposes the component and the associated ressources.
  10084. */
  10085. dispose(): void;
  10086. private _pickSpriteButKeepRay;
  10087. private _pointerMove;
  10088. private _pointerDown;
  10089. private _pointerUp;
  10090. }
  10091. }
  10092. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  10093. /** @hidden */
  10094. export var fogFragmentDeclaration: {
  10095. name: string;
  10096. shader: string;
  10097. };
  10098. }
  10099. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  10100. /** @hidden */
  10101. export var fogFragment: {
  10102. name: string;
  10103. shader: string;
  10104. };
  10105. }
  10106. declare module "babylonjs/Shaders/sprites.fragment" {
  10107. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  10108. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  10109. /** @hidden */
  10110. export var spritesPixelShader: {
  10111. name: string;
  10112. shader: string;
  10113. };
  10114. }
  10115. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  10116. /** @hidden */
  10117. export var fogVertexDeclaration: {
  10118. name: string;
  10119. shader: string;
  10120. };
  10121. }
  10122. declare module "babylonjs/Shaders/sprites.vertex" {
  10123. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  10124. /** @hidden */
  10125. export var spritesVertexShader: {
  10126. name: string;
  10127. shader: string;
  10128. };
  10129. }
  10130. declare module "babylonjs/Sprites/spriteManager" {
  10131. import { IDisposable, Scene } from "babylonjs/scene";
  10132. import { Nullable } from "babylonjs/types";
  10133. import { Observable } from "babylonjs/Misc/observable";
  10134. import { Sprite } from "babylonjs/Sprites/sprite";
  10135. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10136. import { Camera } from "babylonjs/Cameras/camera";
  10137. import { Texture } from "babylonjs/Materials/Textures/texture";
  10138. import "babylonjs/Shaders/sprites.fragment";
  10139. import "babylonjs/Shaders/sprites.vertex";
  10140. import { Ray } from "babylonjs/Culling/ray";
  10141. /**
  10142. * Defines the minimum interface to fullfil in order to be a sprite manager.
  10143. */
  10144. export interface ISpriteManager extends IDisposable {
  10145. /**
  10146. * Restricts the camera to viewing objects with the same layerMask.
  10147. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  10148. */
  10149. layerMask: number;
  10150. /**
  10151. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  10152. */
  10153. isPickable: boolean;
  10154. /**
  10155. * Specifies the rendering group id for this mesh (0 by default)
  10156. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  10157. */
  10158. renderingGroupId: number;
  10159. /**
  10160. * Defines the list of sprites managed by the manager.
  10161. */
  10162. sprites: Array<Sprite>;
  10163. /**
  10164. * Tests the intersection of a sprite with a specific ray.
  10165. * @param ray The ray we are sending to test the collision
  10166. * @param camera The camera space we are sending rays in
  10167. * @param predicate A predicate allowing excluding sprites from the list of object to test
  10168. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  10169. * @returns picking info or null.
  10170. */
  10171. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  10172. /**
  10173. * Intersects the sprites with a ray
  10174. * @param ray defines the ray to intersect with
  10175. * @param camera defines the current active camera
  10176. * @param predicate defines a predicate used to select candidate sprites
  10177. * @returns null if no hit or a PickingInfo array
  10178. */
  10179. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  10180. /**
  10181. * Renders the list of sprites on screen.
  10182. */
  10183. render(): void;
  10184. }
  10185. /**
  10186. * Class used to manage multiple sprites on the same spritesheet
  10187. * @see http://doc.babylonjs.com/babylon101/sprites
  10188. */
  10189. export class SpriteManager implements ISpriteManager {
  10190. /** defines the manager's name */
  10191. name: string;
  10192. /** Gets the list of sprites */
  10193. sprites: Sprite[];
  10194. /** Gets or sets the rendering group id (0 by default) */
  10195. renderingGroupId: number;
  10196. /** Gets or sets camera layer mask */
  10197. layerMask: number;
  10198. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  10199. fogEnabled: boolean;
  10200. /** Gets or sets a boolean indicating if the sprites are pickable */
  10201. isPickable: boolean;
  10202. /** Defines the default width of a cell in the spritesheet */
  10203. cellWidth: number;
  10204. /** Defines the default height of a cell in the spritesheet */
  10205. cellHeight: number;
  10206. /** Associative array from JSON sprite data file */
  10207. private _cellData;
  10208. /** Array of sprite names from JSON sprite data file */
  10209. private _spriteMap;
  10210. /** True when packed cell data from JSON file is ready*/
  10211. private _packedAndReady;
  10212. /**
  10213. * An event triggered when the manager is disposed.
  10214. */
  10215. onDisposeObservable: Observable<SpriteManager>;
  10216. private _onDisposeObserver;
  10217. /**
  10218. * Callback called when the manager is disposed
  10219. */
  10220. set onDispose(callback: () => void);
  10221. private _capacity;
  10222. private _fromPacked;
  10223. private _spriteTexture;
  10224. private _epsilon;
  10225. private _scene;
  10226. private _vertexData;
  10227. private _buffer;
  10228. private _vertexBuffers;
  10229. private _indexBuffer;
  10230. private _effectBase;
  10231. private _effectFog;
  10232. /**
  10233. * Gets or sets the spritesheet texture
  10234. */
  10235. get texture(): Texture;
  10236. set texture(value: Texture);
  10237. private _blendMode;
  10238. /**
  10239. * Blend mode use to render the particle, it can be any of
  10240. * the static Constants.ALPHA_x properties provided in this class.
  10241. * Default value is Constants.ALPHA_COMBINE
  10242. */
  10243. get blendMode(): number;
  10244. set blendMode(blendMode: number);
  10245. /** Disables writing to the depth buffer when rendering the sprites.
  10246. * It can be handy to disable depth writing when using textures without alpha channel
  10247. * and setting some specific blend modes.
  10248. */
  10249. disableDepthWrite: boolean;
  10250. /**
  10251. * Creates a new sprite manager
  10252. * @param name defines the manager's name
  10253. * @param imgUrl defines the sprite sheet url
  10254. * @param capacity defines the maximum allowed number of sprites
  10255. * @param cellSize defines the size of a sprite cell
  10256. * @param scene defines the hosting scene
  10257. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  10258. * @param samplingMode defines the smapling mode to use with spritesheet
  10259. * @param fromPacked set to false; do not alter
  10260. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  10261. */
  10262. constructor(
  10263. /** defines the manager's name */
  10264. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  10265. private _makePacked;
  10266. private _appendSpriteVertex;
  10267. /**
  10268. * Intersects the sprites with a ray
  10269. * @param ray defines the ray to intersect with
  10270. * @param camera defines the current active camera
  10271. * @param predicate defines a predicate used to select candidate sprites
  10272. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  10273. * @returns null if no hit or a PickingInfo
  10274. */
  10275. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  10276. /**
  10277. * Intersects the sprites with a ray
  10278. * @param ray defines the ray to intersect with
  10279. * @param camera defines the current active camera
  10280. * @param predicate defines a predicate used to select candidate sprites
  10281. * @returns null if no hit or a PickingInfo array
  10282. */
  10283. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  10284. /**
  10285. * Render all child sprites
  10286. */
  10287. render(): void;
  10288. /**
  10289. * Release associated resources
  10290. */
  10291. dispose(): void;
  10292. }
  10293. }
  10294. declare module "babylonjs/Misc/gradients" {
  10295. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  10296. /** Interface used by value gradients (color, factor, ...) */
  10297. export interface IValueGradient {
  10298. /**
  10299. * Gets or sets the gradient value (between 0 and 1)
  10300. */
  10301. gradient: number;
  10302. }
  10303. /** Class used to store color4 gradient */
  10304. export class ColorGradient implements IValueGradient {
  10305. /**
  10306. * Gets or sets the gradient value (between 0 and 1)
  10307. */
  10308. gradient: number;
  10309. /**
  10310. * Gets or sets first associated color
  10311. */
  10312. color1: Color4;
  10313. /**
  10314. * Gets or sets second associated color
  10315. */
  10316. color2?: Color4 | undefined;
  10317. /**
  10318. * Creates a new color4 gradient
  10319. * @param gradient gets or sets the gradient value (between 0 and 1)
  10320. * @param color1 gets or sets first associated color
  10321. * @param color2 gets or sets first second color
  10322. */
  10323. constructor(
  10324. /**
  10325. * Gets or sets the gradient value (between 0 and 1)
  10326. */
  10327. gradient: number,
  10328. /**
  10329. * Gets or sets first associated color
  10330. */
  10331. color1: Color4,
  10332. /**
  10333. * Gets or sets second associated color
  10334. */
  10335. color2?: Color4 | undefined);
  10336. /**
  10337. * Will get a color picked randomly between color1 and color2.
  10338. * If color2 is undefined then color1 will be used
  10339. * @param result defines the target Color4 to store the result in
  10340. */
  10341. getColorToRef(result: Color4): void;
  10342. }
  10343. /** Class used to store color 3 gradient */
  10344. export class Color3Gradient implements IValueGradient {
  10345. /**
  10346. * Gets or sets the gradient value (between 0 and 1)
  10347. */
  10348. gradient: number;
  10349. /**
  10350. * Gets or sets the associated color
  10351. */
  10352. color: Color3;
  10353. /**
  10354. * Creates a new color3 gradient
  10355. * @param gradient gets or sets the gradient value (between 0 and 1)
  10356. * @param color gets or sets associated color
  10357. */
  10358. constructor(
  10359. /**
  10360. * Gets or sets the gradient value (between 0 and 1)
  10361. */
  10362. gradient: number,
  10363. /**
  10364. * Gets or sets the associated color
  10365. */
  10366. color: Color3);
  10367. }
  10368. /** Class used to store factor gradient */
  10369. export class FactorGradient implements IValueGradient {
  10370. /**
  10371. * Gets or sets the gradient value (between 0 and 1)
  10372. */
  10373. gradient: number;
  10374. /**
  10375. * Gets or sets first associated factor
  10376. */
  10377. factor1: number;
  10378. /**
  10379. * Gets or sets second associated factor
  10380. */
  10381. factor2?: number | undefined;
  10382. /**
  10383. * Creates a new factor gradient
  10384. * @param gradient gets or sets the gradient value (between 0 and 1)
  10385. * @param factor1 gets or sets first associated factor
  10386. * @param factor2 gets or sets second associated factor
  10387. */
  10388. constructor(
  10389. /**
  10390. * Gets or sets the gradient value (between 0 and 1)
  10391. */
  10392. gradient: number,
  10393. /**
  10394. * Gets or sets first associated factor
  10395. */
  10396. factor1: number,
  10397. /**
  10398. * Gets or sets second associated factor
  10399. */
  10400. factor2?: number | undefined);
  10401. /**
  10402. * Will get a number picked randomly between factor1 and factor2.
  10403. * If factor2 is undefined then factor1 will be used
  10404. * @returns the picked number
  10405. */
  10406. getFactor(): number;
  10407. }
  10408. /**
  10409. * Helper used to simplify some generic gradient tasks
  10410. */
  10411. export class GradientHelper {
  10412. /**
  10413. * Gets the current gradient from an array of IValueGradient
  10414. * @param ratio defines the current ratio to get
  10415. * @param gradients defines the array of IValueGradient
  10416. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  10417. */
  10418. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  10419. }
  10420. }
  10421. declare module "babylonjs/Maths/math.size" {
  10422. /**
  10423. * Interface for the size containing width and height
  10424. */
  10425. export interface ISize {
  10426. /**
  10427. * Width
  10428. */
  10429. width: number;
  10430. /**
  10431. * Heighht
  10432. */
  10433. height: number;
  10434. }
  10435. /**
  10436. * Size containing widht and height
  10437. */
  10438. export class Size implements ISize {
  10439. /**
  10440. * Width
  10441. */
  10442. width: number;
  10443. /**
  10444. * Height
  10445. */
  10446. height: number;
  10447. /**
  10448. * Creates a Size object from the given width and height (floats).
  10449. * @param width width of the new size
  10450. * @param height height of the new size
  10451. */
  10452. constructor(width: number, height: number);
  10453. /**
  10454. * Returns a string with the Size width and height
  10455. * @returns a string with the Size width and height
  10456. */
  10457. toString(): string;
  10458. /**
  10459. * "Size"
  10460. * @returns the string "Size"
  10461. */
  10462. getClassName(): string;
  10463. /**
  10464. * Returns the Size hash code.
  10465. * @returns a hash code for a unique width and height
  10466. */
  10467. getHashCode(): number;
  10468. /**
  10469. * Updates the current size from the given one.
  10470. * @param src the given size
  10471. */
  10472. copyFrom(src: Size): void;
  10473. /**
  10474. * Updates in place the current Size from the given floats.
  10475. * @param width width of the new size
  10476. * @param height height of the new size
  10477. * @returns the updated Size.
  10478. */
  10479. copyFromFloats(width: number, height: number): Size;
  10480. /**
  10481. * Updates in place the current Size from the given floats.
  10482. * @param width width to set
  10483. * @param height height to set
  10484. * @returns the updated Size.
  10485. */
  10486. set(width: number, height: number): Size;
  10487. /**
  10488. * Multiplies the width and height by numbers
  10489. * @param w factor to multiple the width by
  10490. * @param h factor to multiple the height by
  10491. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  10492. */
  10493. multiplyByFloats(w: number, h: number): Size;
  10494. /**
  10495. * Clones the size
  10496. * @returns a new Size copied from the given one.
  10497. */
  10498. clone(): Size;
  10499. /**
  10500. * True if the current Size and the given one width and height are strictly equal.
  10501. * @param other the other size to compare against
  10502. * @returns True if the current Size and the given one width and height are strictly equal.
  10503. */
  10504. equals(other: Size): boolean;
  10505. /**
  10506. * The surface of the Size : width * height (float).
  10507. */
  10508. get surface(): number;
  10509. /**
  10510. * Create a new size of zero
  10511. * @returns a new Size set to (0.0, 0.0)
  10512. */
  10513. static Zero(): Size;
  10514. /**
  10515. * Sums the width and height of two sizes
  10516. * @param otherSize size to add to this size
  10517. * @returns a new Size set as the addition result of the current Size and the given one.
  10518. */
  10519. add(otherSize: Size): Size;
  10520. /**
  10521. * Subtracts the width and height of two
  10522. * @param otherSize size to subtract to this size
  10523. * @returns a new Size set as the subtraction result of the given one from the current Size.
  10524. */
  10525. subtract(otherSize: Size): Size;
  10526. /**
  10527. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  10528. * @param start starting size to lerp between
  10529. * @param end end size to lerp between
  10530. * @param amount amount to lerp between the start and end values
  10531. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  10532. */
  10533. static Lerp(start: Size, end: Size, amount: number): Size;
  10534. }
  10535. }
  10536. declare module "babylonjs/Engines/Extensions/engine.dynamicTexture" {
  10537. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  10538. import { Nullable } from "babylonjs/types";
  10539. module "babylonjs/Engines/thinEngine" {
  10540. interface ThinEngine {
  10541. /**
  10542. * Creates a dynamic texture
  10543. * @param width defines the width of the texture
  10544. * @param height defines the height of the texture
  10545. * @param generateMipMaps defines if the engine should generate the mip levels
  10546. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  10547. * @returns the dynamic texture inside an InternalTexture
  10548. */
  10549. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  10550. /**
  10551. * Update the content of a dynamic texture
  10552. * @param texture defines the texture to update
  10553. * @param canvas defines the canvas containing the source
  10554. * @param invertY defines if data must be stored with Y axis inverted
  10555. * @param premulAlpha defines if alpha is stored as premultiplied
  10556. * @param format defines the format of the data
  10557. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  10558. */
  10559. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  10560. }
  10561. }
  10562. }
  10563. declare module "babylonjs/Misc/canvasGenerator" {
  10564. /**
  10565. * Helper class used to generate a canvas to manipulate images
  10566. */
  10567. export class CanvasGenerator {
  10568. /**
  10569. * Create a new canvas (or offscreen canvas depending on the context)
  10570. * @param width defines the expected width
  10571. * @param height defines the expected height
  10572. * @return a new canvas or offscreen canvas
  10573. */
  10574. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  10575. }
  10576. }
  10577. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  10578. import { Scene } from "babylonjs/scene";
  10579. import { Texture } from "babylonjs/Materials/Textures/texture";
  10580. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  10581. /**
  10582. * A class extending Texture allowing drawing on a texture
  10583. * @see http://doc.babylonjs.com/how_to/dynamictexture
  10584. */
  10585. export class DynamicTexture extends Texture {
  10586. private _generateMipMaps;
  10587. private _canvas;
  10588. private _context;
  10589. private _engine;
  10590. /**
  10591. * Creates a DynamicTexture
  10592. * @param name defines the name of the texture
  10593. * @param options provides 3 alternatives for width and height of texture, a canvas, object with width and height properties, number for both width and height
  10594. * @param scene defines the scene where you want the texture
  10595. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  10596. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  10597. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  10598. */
  10599. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  10600. /**
  10601. * Get the current class name of the texture useful for serialization or dynamic coding.
  10602. * @returns "DynamicTexture"
  10603. */
  10604. getClassName(): string;
  10605. /**
  10606. * Gets the current state of canRescale
  10607. */
  10608. get canRescale(): boolean;
  10609. private _recreate;
  10610. /**
  10611. * Scales the texture
  10612. * @param ratio the scale factor to apply to both width and height
  10613. */
  10614. scale(ratio: number): void;
  10615. /**
  10616. * Resizes the texture
  10617. * @param width the new width
  10618. * @param height the new height
  10619. */
  10620. scaleTo(width: number, height: number): void;
  10621. /**
  10622. * Gets the context of the canvas used by the texture
  10623. * @returns the canvas context of the dynamic texture
  10624. */
  10625. getContext(): CanvasRenderingContext2D;
  10626. /**
  10627. * Clears the texture
  10628. */
  10629. clear(): void;
  10630. /**
  10631. * Updates the texture
  10632. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  10633. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  10634. */
  10635. update(invertY?: boolean, premulAlpha?: boolean): void;
  10636. /**
  10637. * Draws text onto the texture
  10638. * @param text defines the text to be drawn
  10639. * @param x defines the placement of the text from the left
  10640. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  10641. * @param font defines the font to be used with font-style, font-size, font-name
  10642. * @param color defines the color used for the text
  10643. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  10644. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  10645. * @param update defines whether texture is immediately update (default is true)
  10646. */
  10647. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  10648. /**
  10649. * Clones the texture
  10650. * @returns the clone of the texture.
  10651. */
  10652. clone(): DynamicTexture;
  10653. /**
  10654. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  10655. * @returns a serialized dynamic texture object
  10656. */
  10657. serialize(): any;
  10658. /** @hidden */
  10659. _rebuild(): void;
  10660. }
  10661. }
  10662. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  10663. import { Nullable } from "babylonjs/types";
  10664. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  10665. import { Scene } from "babylonjs/scene";
  10666. module "babylonjs/Engines/engine" {
  10667. interface Engine {
  10668. /**
  10669. * Creates a raw texture
  10670. * @param data defines the data to store in the texture
  10671. * @param width defines the width of the texture
  10672. * @param height defines the height of the texture
  10673. * @param format defines the format of the data
  10674. * @param generateMipMaps defines if the engine should generate the mip levels
  10675. * @param invertY defines if data must be stored with Y axis inverted
  10676. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  10677. * @param compression defines the compression used (null by default)
  10678. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10679. * @returns the raw texture inside an InternalTexture
  10680. */
  10681. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  10682. /**
  10683. * Update a raw texture
  10684. * @param texture defines the texture to update
  10685. * @param data defines the data to store in the texture
  10686. * @param format defines the format of the data
  10687. * @param invertY defines if data must be stored with Y axis inverted
  10688. */
  10689. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10690. /**
  10691. * Update a raw texture
  10692. * @param texture defines the texture to update
  10693. * @param data defines the data to store in the texture
  10694. * @param format defines the format of the data
  10695. * @param invertY defines if data must be stored with Y axis inverted
  10696. * @param compression defines the compression used (null by default)
  10697. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10698. */
  10699. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  10700. /**
  10701. * Creates a new raw cube texture
  10702. * @param data defines the array of data to use to create each face
  10703. * @param size defines the size of the textures
  10704. * @param format defines the format of the data
  10705. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10706. * @param generateMipMaps defines if the engine should generate the mip levels
  10707. * @param invertY defines if data must be stored with Y axis inverted
  10708. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10709. * @param compression defines the compression used (null by default)
  10710. * @returns the cube texture as an InternalTexture
  10711. */
  10712. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  10713. /**
  10714. * Update a raw cube texture
  10715. * @param texture defines the texture to udpdate
  10716. * @param data defines the data to store
  10717. * @param format defines the data format
  10718. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10719. * @param invertY defines if data must be stored with Y axis inverted
  10720. */
  10721. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  10722. /**
  10723. * Update a raw cube texture
  10724. * @param texture defines the texture to udpdate
  10725. * @param data defines the data to store
  10726. * @param format defines the data format
  10727. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10728. * @param invertY defines if data must be stored with Y axis inverted
  10729. * @param compression defines the compression used (null by default)
  10730. */
  10731. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  10732. /**
  10733. * Update a raw cube texture
  10734. * @param texture defines the texture to udpdate
  10735. * @param data defines the data to store
  10736. * @param format defines the data format
  10737. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10738. * @param invertY defines if data must be stored with Y axis inverted
  10739. * @param compression defines the compression used (null by default)
  10740. * @param level defines which level of the texture to update
  10741. */
  10742. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  10743. /**
  10744. * Creates a new raw cube texture from a specified url
  10745. * @param url defines the url where the data is located
  10746. * @param scene defines the current scene
  10747. * @param size defines the size of the textures
  10748. * @param format defines the format of the data
  10749. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10750. * @param noMipmap defines if the engine should avoid generating the mip levels
  10751. * @param callback defines a callback used to extract texture data from loaded data
  10752. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  10753. * @param onLoad defines a callback called when texture is loaded
  10754. * @param onError defines a callback called if there is an error
  10755. * @returns the cube texture as an InternalTexture
  10756. */
  10757. createRawCubeTextureFromUrl(url: string, scene: Scene, size: number, format: number, type: number, noMipmap: boolean, callback: (ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[]>, mipmapGenerator: Nullable<((faces: ArrayBufferView[]) => ArrayBufferView[][])>, onLoad: Nullable<() => void>, onError: Nullable<(message?: string, exception?: any) => void>): InternalTexture;
  10758. /**
  10759. * Creates a new raw cube texture from a specified url
  10760. * @param url defines the url where the data is located
  10761. * @param scene defines the current scene
  10762. * @param size defines the size of the textures
  10763. * @param format defines the format of the data
  10764. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10765. * @param noMipmap defines if the engine should avoid generating the mip levels
  10766. * @param callback defines a callback used to extract texture data from loaded data
  10767. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  10768. * @param onLoad defines a callback called when texture is loaded
  10769. * @param onError defines a callback called if there is an error
  10770. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10771. * @param invertY defines if data must be stored with Y axis inverted
  10772. * @returns the cube texture as an InternalTexture
  10773. */
  10774. createRawCubeTextureFromUrl(url: string, scene: Scene, size: number, format: number, type: number, noMipmap: boolean, callback: (ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[]>, mipmapGenerator: Nullable<((faces: ArrayBufferView[]) => ArrayBufferView[][])>, onLoad: Nullable<() => void>, onError: Nullable<(message?: string, exception?: any) => void>, samplingMode: number, invertY: boolean): InternalTexture;
  10775. /**
  10776. * Creates a new raw 3D texture
  10777. * @param data defines the data used to create the texture
  10778. * @param width defines the width of the texture
  10779. * @param height defines the height of the texture
  10780. * @param depth defines the depth of the texture
  10781. * @param format defines the format of the texture
  10782. * @param generateMipMaps defines if the engine must generate mip levels
  10783. * @param invertY defines if data must be stored with Y axis inverted
  10784. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10785. * @param compression defines the compressed used (can be null)
  10786. * @param textureType defines the compressed used (can be null)
  10787. * @returns a new raw 3D texture (stored in an InternalTexture)
  10788. */
  10789. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  10790. /**
  10791. * Update a raw 3D texture
  10792. * @param texture defines the texture to update
  10793. * @param data defines the data to store
  10794. * @param format defines the data format
  10795. * @param invertY defines if data must be stored with Y axis inverted
  10796. */
  10797. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10798. /**
  10799. * Update a raw 3D texture
  10800. * @param texture defines the texture to update
  10801. * @param data defines the data to store
  10802. * @param format defines the data format
  10803. * @param invertY defines if data must be stored with Y axis inverted
  10804. * @param compression defines the used compression (can be null)
  10805. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  10806. */
  10807. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  10808. /**
  10809. * Creates a new raw 2D array texture
  10810. * @param data defines the data used to create the texture
  10811. * @param width defines the width of the texture
  10812. * @param height defines the height of the texture
  10813. * @param depth defines the number of layers of the texture
  10814. * @param format defines the format of the texture
  10815. * @param generateMipMaps defines if the engine must generate mip levels
  10816. * @param invertY defines if data must be stored with Y axis inverted
  10817. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10818. * @param compression defines the compressed used (can be null)
  10819. * @param textureType defines the compressed used (can be null)
  10820. * @returns a new raw 2D array texture (stored in an InternalTexture)
  10821. */
  10822. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  10823. /**
  10824. * Update a raw 2D array texture
  10825. * @param texture defines the texture to update
  10826. * @param data defines the data to store
  10827. * @param format defines the data format
  10828. * @param invertY defines if data must be stored with Y axis inverted
  10829. */
  10830. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10831. /**
  10832. * Update a raw 2D array texture
  10833. * @param texture defines the texture to update
  10834. * @param data defines the data to store
  10835. * @param format defines the data format
  10836. * @param invertY defines if data must be stored with Y axis inverted
  10837. * @param compression defines the used compression (can be null)
  10838. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  10839. */
  10840. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  10841. }
  10842. }
  10843. }
  10844. declare module "babylonjs/Materials/Textures/rawTexture" {
  10845. import { Scene } from "babylonjs/scene";
  10846. import { Texture } from "babylonjs/Materials/Textures/texture";
  10847. import "babylonjs/Engines/Extensions/engine.rawTexture";
  10848. /**
  10849. * Raw texture can help creating a texture directly from an array of data.
  10850. * This can be super useful if you either get the data from an uncompressed source or
  10851. * if you wish to create your texture pixel by pixel.
  10852. */
  10853. export class RawTexture extends Texture {
  10854. /**
  10855. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10856. */
  10857. format: number;
  10858. private _engine;
  10859. /**
  10860. * Instantiates a new RawTexture.
  10861. * Raw texture can help creating a texture directly from an array of data.
  10862. * This can be super useful if you either get the data from an uncompressed source or
  10863. * if you wish to create your texture pixel by pixel.
  10864. * @param data define the array of data to use to create the texture
  10865. * @param width define the width of the texture
  10866. * @param height define the height of the texture
  10867. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10868. * @param scene define the scene the texture belongs to
  10869. * @param generateMipMaps define whether mip maps should be generated or not
  10870. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10871. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10872. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10873. */
  10874. constructor(data: ArrayBufferView, width: number, height: number,
  10875. /**
  10876. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10877. */
  10878. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  10879. /**
  10880. * Updates the texture underlying data.
  10881. * @param data Define the new data of the texture
  10882. */
  10883. update(data: ArrayBufferView): void;
  10884. /**
  10885. * Creates a luminance texture from some data.
  10886. * @param data Define the texture data
  10887. * @param width Define the width of the texture
  10888. * @param height Define the height of the texture
  10889. * @param scene Define the scene the texture belongs to
  10890. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10891. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10892. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10893. * @returns the luminance texture
  10894. */
  10895. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10896. /**
  10897. * Creates a luminance alpha texture from some data.
  10898. * @param data Define the texture data
  10899. * @param width Define the width of the texture
  10900. * @param height Define the height of the texture
  10901. * @param scene Define the scene the texture belongs to
  10902. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10903. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10904. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10905. * @returns the luminance alpha texture
  10906. */
  10907. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10908. /**
  10909. * Creates an alpha texture from some data.
  10910. * @param data Define the texture data
  10911. * @param width Define the width of the texture
  10912. * @param height Define the height of the texture
  10913. * @param scene Define the scene the texture belongs to
  10914. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10915. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10916. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10917. * @returns the alpha texture
  10918. */
  10919. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10920. /**
  10921. * Creates a RGB texture from some data.
  10922. * @param data Define the texture data
  10923. * @param width Define the width of the texture
  10924. * @param height Define the height of the texture
  10925. * @param scene Define the scene the texture belongs to
  10926. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10927. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10928. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10929. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10930. * @returns the RGB alpha texture
  10931. */
  10932. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  10933. /**
  10934. * Creates a RGBA texture from some data.
  10935. * @param data Define the texture data
  10936. * @param width Define the width of the texture
  10937. * @param height Define the height of the texture
  10938. * @param scene Define the scene the texture belongs to
  10939. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10940. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10941. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10942. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10943. * @returns the RGBA texture
  10944. */
  10945. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  10946. /**
  10947. * Creates a R texture from some data.
  10948. * @param data Define the texture data
  10949. * @param width Define the width of the texture
  10950. * @param height Define the height of the texture
  10951. * @param scene Define the scene the texture belongs to
  10952. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10953. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10954. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10955. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10956. * @returns the R texture
  10957. */
  10958. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  10959. }
  10960. }
  10961. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  10962. import { Scene } from "babylonjs/scene";
  10963. import { ISceneComponent } from "babylonjs/sceneComponent";
  10964. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  10965. module "babylonjs/abstractScene" {
  10966. interface AbstractScene {
  10967. /**
  10968. * The list of procedural textures added to the scene
  10969. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  10970. */
  10971. proceduralTextures: Array<ProceduralTexture>;
  10972. }
  10973. }
  10974. /**
  10975. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  10976. * in a given scene.
  10977. */
  10978. export class ProceduralTextureSceneComponent implements ISceneComponent {
  10979. /**
  10980. * The component name helpfull to identify the component in the list of scene components.
  10981. */
  10982. readonly name: string;
  10983. /**
  10984. * The scene the component belongs to.
  10985. */
  10986. scene: Scene;
  10987. /**
  10988. * Creates a new instance of the component for the given scene
  10989. * @param scene Defines the scene to register the component in
  10990. */
  10991. constructor(scene: Scene);
  10992. /**
  10993. * Registers the component in a given scene
  10994. */
  10995. register(): void;
  10996. /**
  10997. * Rebuilds the elements related to this component in case of
  10998. * context lost for instance.
  10999. */
  11000. rebuild(): void;
  11001. /**
  11002. * Disposes the component and the associated ressources.
  11003. */
  11004. dispose(): void;
  11005. private _beforeClear;
  11006. }
  11007. }
  11008. declare module "babylonjs/Engines/Extensions/engine.renderTargetCube" {
  11009. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  11010. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  11011. module "babylonjs/Engines/thinEngine" {
  11012. interface ThinEngine {
  11013. /**
  11014. * Creates a new render target cube texture
  11015. * @param size defines the size of the texture
  11016. * @param options defines the options used to create the texture
  11017. * @returns a new render target cube texture stored in an InternalTexture
  11018. */
  11019. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  11020. }
  11021. }
  11022. }
  11023. declare module "babylonjs/Shaders/procedural.vertex" {
  11024. /** @hidden */
  11025. export var proceduralVertexShader: {
  11026. name: string;
  11027. shader: string;
  11028. };
  11029. }
  11030. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  11031. import { Observable } from "babylonjs/Misc/observable";
  11032. import { Nullable } from "babylonjs/types";
  11033. import { Scene } from "babylonjs/scene";
  11034. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  11035. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  11036. import { Effect } from "babylonjs/Materials/effect";
  11037. import { Texture } from "babylonjs/Materials/Textures/texture";
  11038. import "babylonjs/Engines/Extensions/engine.renderTarget";
  11039. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  11040. import "babylonjs/Shaders/procedural.vertex";
  11041. /**
  11042. * Procedural texturing is a way to programmatically create a texture. There are 2 types of procedural textures: code-only, and code that references some classic 2D images, sometimes calmpler' images.
  11043. * This is the base class of any Procedural texture and contains most of the shareable code.
  11044. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11045. */
  11046. export class ProceduralTexture extends Texture {
  11047. isCube: boolean;
  11048. /**
  11049. * Define if the texture is enabled or not (disabled texture will not render)
  11050. */
  11051. isEnabled: boolean;
  11052. /**
  11053. * Define if the texture must be cleared before rendering (default is true)
  11054. */
  11055. autoClear: boolean;
  11056. /**
  11057. * Callback called when the texture is generated
  11058. */
  11059. onGenerated: () => void;
  11060. /**
  11061. * Event raised when the texture is generated
  11062. */
  11063. onGeneratedObservable: Observable<ProceduralTexture>;
  11064. /** @hidden */
  11065. _generateMipMaps: boolean;
  11066. /** @hidden **/
  11067. _effect: Effect;
  11068. /** @hidden */
  11069. _textures: {
  11070. [key: string]: Texture;
  11071. };
  11072. /** @hidden */
  11073. protected _fallbackTexture: Nullable<Texture>;
  11074. private _size;
  11075. private _currentRefreshId;
  11076. private _frameId;
  11077. private _refreshRate;
  11078. private _vertexBuffers;
  11079. private _indexBuffer;
  11080. private _uniforms;
  11081. private _samplers;
  11082. private _fragment;
  11083. private _floats;
  11084. private _ints;
  11085. private _floatsArrays;
  11086. private _colors3;
  11087. private _colors4;
  11088. private _vectors2;
  11089. private _vectors3;
  11090. private _matrices;
  11091. private _fallbackTextureUsed;
  11092. private _engine;
  11093. private _cachedDefines;
  11094. private _contentUpdateId;
  11095. private _contentData;
  11096. /**
  11097. * Instantiates a new procedural texture.
  11098. * Procedural texturing is a way to programmatically create a texture. There are 2 types of procedural textures: code-only, and code that references some classic 2D images, sometimes called 'refMaps' or 'sampler' images.
  11099. * This is the base class of any Procedural texture and contains most of the shareable code.
  11100. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11101. * @param name Define the name of the texture
  11102. * @param size Define the size of the texture to create
  11103. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  11104. * @param scene Define the scene the texture belongs to
  11105. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  11106. * @param generateMipMaps Define if the texture should creates mip maps or not
  11107. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  11108. */
  11109. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  11110. /**
  11111. * The effect that is created when initializing the post process.
  11112. * @returns The created effect corresponding the the postprocess.
  11113. */
  11114. getEffect(): Effect;
  11115. /**
  11116. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  11117. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  11118. */
  11119. getContent(): Nullable<ArrayBufferView>;
  11120. private _createIndexBuffer;
  11121. /** @hidden */
  11122. _rebuild(): void;
  11123. /**
  11124. * Resets the texture in order to recreate its associated resources.
  11125. * This can be called in case of context loss
  11126. */
  11127. reset(): void;
  11128. protected _getDefines(): string;
  11129. /**
  11130. * Is the texture ready to be used ? (rendered at least once)
  11131. * @returns true if ready, otherwise, false.
  11132. */
  11133. isReady(): boolean;
  11134. /**
  11135. * Resets the refresh counter of the texture and start bak from scratch.
  11136. * Could be useful to regenerate the texture if it is setup to render only once.
  11137. */
  11138. resetRefreshCounter(): void;
  11139. /**
  11140. * Set the fragment shader to use in order to render the texture.
  11141. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  11142. */
  11143. setFragment(fragment: any): void;
  11144. /**
  11145. * Define the refresh rate of the texture or the rendering frequency.
  11146. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  11147. */
  11148. get refreshRate(): number;
  11149. set refreshRate(value: number);
  11150. /** @hidden */
  11151. _shouldRender(): boolean;
  11152. /**
  11153. * Get the size the texture is rendering at.
  11154. * @returns the size (texture is always squared)
  11155. */
  11156. getRenderSize(): number;
  11157. /**
  11158. * Resize the texture to new value.
  11159. * @param size Define the new size the texture should have
  11160. * @param generateMipMaps Define whether the new texture should create mip maps
  11161. */
  11162. resize(size: number, generateMipMaps: boolean): void;
  11163. private _checkUniform;
  11164. /**
  11165. * Set a texture in the shader program used to render.
  11166. * @param name Define the name of the uniform samplers as defined in the shader
  11167. * @param texture Define the texture to bind to this sampler
  11168. * @return the texture itself allowing "fluent" like uniform updates
  11169. */
  11170. setTexture(name: string, texture: Texture): ProceduralTexture;
  11171. /**
  11172. * Set a float in the shader.
  11173. * @param name Define the name of the uniform as defined in the shader
  11174. * @param value Define the value to give to the uniform
  11175. * @return the texture itself allowing "fluent" like uniform updates
  11176. */
  11177. setFloat(name: string, value: number): ProceduralTexture;
  11178. /**
  11179. * Set a int in the shader.
  11180. * @param name Define the name of the uniform as defined in the shader
  11181. * @param value Define the value to give to the uniform
  11182. * @return the texture itself allowing "fluent" like uniform updates
  11183. */
  11184. setInt(name: string, value: number): ProceduralTexture;
  11185. /**
  11186. * Set an array of floats in the shader.
  11187. * @param name Define the name of the uniform as defined in the shader
  11188. * @param value Define the value to give to the uniform
  11189. * @return the texture itself allowing "fluent" like uniform updates
  11190. */
  11191. setFloats(name: string, value: number[]): ProceduralTexture;
  11192. /**
  11193. * Set a vec3 in the shader from a Color3.
  11194. * @param name Define the name of the uniform as defined in the shader
  11195. * @param value Define the value to give to the uniform
  11196. * @return the texture itself allowing "fluent" like uniform updates
  11197. */
  11198. setColor3(name: string, value: Color3): ProceduralTexture;
  11199. /**
  11200. * Set a vec4 in the shader from a Color4.
  11201. * @param name Define the name of the uniform as defined in the shader
  11202. * @param value Define the value to give to the uniform
  11203. * @return the texture itself allowing "fluent" like uniform updates
  11204. */
  11205. setColor4(name: string, value: Color4): ProceduralTexture;
  11206. /**
  11207. * Set a vec2 in the shader from a Vector2.
  11208. * @param name Define the name of the uniform as defined in the shader
  11209. * @param value Define the value to give to the uniform
  11210. * @return the texture itself allowing "fluent" like uniform updates
  11211. */
  11212. setVector2(name: string, value: Vector2): ProceduralTexture;
  11213. /**
  11214. * Set a vec3 in the shader from a Vector3.
  11215. * @param name Define the name of the uniform as defined in the shader
  11216. * @param value Define the value to give to the uniform
  11217. * @return the texture itself allowing "fluent" like uniform updates
  11218. */
  11219. setVector3(name: string, value: Vector3): ProceduralTexture;
  11220. /**
  11221. * Set a mat4 in the shader from a MAtrix.
  11222. * @param name Define the name of the uniform as defined in the shader
  11223. * @param value Define the value to give to the uniform
  11224. * @return the texture itself allowing "fluent" like uniform updates
  11225. */
  11226. setMatrix(name: string, value: Matrix): ProceduralTexture;
  11227. /**
  11228. * Render the texture to its associated render target.
  11229. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  11230. */
  11231. render(useCameraPostProcess?: boolean): void;
  11232. /**
  11233. * Clone the texture.
  11234. * @returns the cloned texture
  11235. */
  11236. clone(): ProceduralTexture;
  11237. /**
  11238. * Dispose the texture and release its asoociated resources.
  11239. */
  11240. dispose(): void;
  11241. }
  11242. }
  11243. declare module "babylonjs/Particles/baseParticleSystem" {
  11244. import { Nullable } from "babylonjs/types";
  11245. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  11246. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11247. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  11248. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  11249. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  11250. import { Scene } from "babylonjs/scene";
  11251. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  11252. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  11253. import { Texture } from "babylonjs/Materials/Textures/texture";
  11254. import { Color4 } from "babylonjs/Maths/math.color";
  11255. import { Animation } from "babylonjs/Animations/animation";
  11256. /**
  11257. * This represents the base class for particle system in Babylon.
  11258. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  11259. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  11260. * @example https://doc.babylonjs.com/babylon101/particles
  11261. */
  11262. export class BaseParticleSystem {
  11263. /**
  11264. * Source color is added to the destination color without alpha affecting the result
  11265. */
  11266. static BLENDMODE_ONEONE: number;
  11267. /**
  11268. * Blend current color and particle color using particle’s alpha
  11269. */
  11270. static BLENDMODE_STANDARD: number;
  11271. /**
  11272. * Add current color and particle color multiplied by particle’s alpha
  11273. */
  11274. static BLENDMODE_ADD: number;
  11275. /**
  11276. * Multiply current color with particle color
  11277. */
  11278. static BLENDMODE_MULTIPLY: number;
  11279. /**
  11280. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  11281. */
  11282. static BLENDMODE_MULTIPLYADD: number;
  11283. /**
  11284. * List of animations used by the particle system.
  11285. */
  11286. animations: Animation[];
  11287. /**
  11288. * Gets or sets the unique id of the particle system
  11289. */
  11290. uniqueId: number;
  11291. /**
  11292. * The id of the Particle system.
  11293. */
  11294. id: string;
  11295. /**
  11296. * The friendly name of the Particle system.
  11297. */
  11298. name: string;
  11299. /**
  11300. * Snippet ID if the particle system was created from the snippet server
  11301. */
  11302. snippetId: string;
  11303. /**
  11304. * The rendering group used by the Particle system to chose when to render.
  11305. */
  11306. renderingGroupId: number;
  11307. /**
  11308. * The emitter represents the Mesh or position we are attaching the particle system to.
  11309. */
  11310. emitter: Nullable<AbstractMesh | Vector3>;
  11311. /**
  11312. * The maximum number of particles to emit per frame
  11313. */
  11314. emitRate: number;
  11315. /**
  11316. * If you want to launch only a few particles at once, that can be done, as well.
  11317. */
  11318. manualEmitCount: number;
  11319. /**
  11320. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  11321. */
  11322. updateSpeed: number;
  11323. /**
  11324. * The amount of time the particle system is running (depends of the overall update speed).
  11325. */
  11326. targetStopDuration: number;
  11327. /**
  11328. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  11329. */
  11330. disposeOnStop: boolean;
  11331. /**
  11332. * Minimum power of emitting particles.
  11333. */
  11334. minEmitPower: number;
  11335. /**
  11336. * Maximum power of emitting particles.
  11337. */
  11338. maxEmitPower: number;
  11339. /**
  11340. * Minimum life time of emitting particles.
  11341. */
  11342. minLifeTime: number;
  11343. /**
  11344. * Maximum life time of emitting particles.
  11345. */
  11346. maxLifeTime: number;
  11347. /**
  11348. * Minimum Size of emitting particles.
  11349. */
  11350. minSize: number;
  11351. /**
  11352. * Maximum Size of emitting particles.
  11353. */
  11354. maxSize: number;
  11355. /**
  11356. * Minimum scale of emitting particles on X axis.
  11357. */
  11358. minScaleX: number;
  11359. /**
  11360. * Maximum scale of emitting particles on X axis.
  11361. */
  11362. maxScaleX: number;
  11363. /**
  11364. * Minimum scale of emitting particles on Y axis.
  11365. */
  11366. minScaleY: number;
  11367. /**
  11368. * Maximum scale of emitting particles on Y axis.
  11369. */
  11370. maxScaleY: number;
  11371. /**
  11372. * Gets or sets the minimal initial rotation in radians.
  11373. */
  11374. minInitialRotation: number;
  11375. /**
  11376. * Gets or sets the maximal initial rotation in radians.
  11377. */
  11378. maxInitialRotation: number;
  11379. /**
  11380. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  11381. */
  11382. minAngularSpeed: number;
  11383. /**
  11384. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  11385. */
  11386. maxAngularSpeed: number;
  11387. /**
  11388. * The texture used to render each particle. (this can be a spritesheet)
  11389. */
  11390. particleTexture: Nullable<Texture>;
  11391. /**
  11392. * The layer mask we are rendering the particles through.
  11393. */
  11394. layerMask: number;
  11395. /**
  11396. * This can help using your own shader to render the particle system.
  11397. * The according effect will be created
  11398. */
  11399. customShader: any;
  11400. /**
  11401. * By default particle system starts as soon as they are created. This prevents the
  11402. * automatic start to happen and let you decide when to start emitting particles.
  11403. */
  11404. preventAutoStart: boolean;
  11405. private _noiseTexture;
  11406. /**
  11407. * Gets or sets a texture used to add random noise to particle positions
  11408. */
  11409. get noiseTexture(): Nullable<ProceduralTexture>;
  11410. set noiseTexture(value: Nullable<ProceduralTexture>);
  11411. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  11412. noiseStrength: Vector3;
  11413. /**
  11414. * Callback triggered when the particle animation is ending.
  11415. */
  11416. onAnimationEnd: Nullable<() => void>;
  11417. /**
  11418. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  11419. */
  11420. blendMode: number;
  11421. /**
  11422. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  11423. * to override the particles.
  11424. */
  11425. forceDepthWrite: boolean;
  11426. /** Gets or sets a value indicating how many cycles (or frames) must be executed before first rendering (this value has to be set before starting the system). Default is 0 */
  11427. preWarmCycles: number;
  11428. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  11429. preWarmStepOffset: number;
  11430. /**
  11431. * If using a spritesheet (isAnimationSheetEnabled) defines the speed of the sprite loop (default is 1 meaning the animation will play once during the entire particle lifetime)
  11432. */
  11433. spriteCellChangeSpeed: number;
  11434. /**
  11435. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  11436. */
  11437. startSpriteCellID: number;
  11438. /**
  11439. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  11440. */
  11441. endSpriteCellID: number;
  11442. /**
  11443. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  11444. */
  11445. spriteCellWidth: number;
  11446. /**
  11447. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  11448. */
  11449. spriteCellHeight: number;
  11450. /**
  11451. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  11452. */
  11453. spriteRandomStartCell: boolean;
  11454. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  11455. translationPivot: Vector2;
  11456. /** @hidden */
  11457. protected _isAnimationSheetEnabled: boolean;
  11458. /**
  11459. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  11460. */
  11461. beginAnimationOnStart: boolean;
  11462. /**
  11463. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  11464. */
  11465. beginAnimationFrom: number;
  11466. /**
  11467. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  11468. */
  11469. beginAnimationTo: number;
  11470. /**
  11471. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  11472. */
  11473. beginAnimationLoop: boolean;
  11474. /**
  11475. * Gets or sets a world offset applied to all particles
  11476. */
  11477. worldOffset: Vector3;
  11478. /**
  11479. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  11480. */
  11481. get isAnimationSheetEnabled(): boolean;
  11482. set isAnimationSheetEnabled(value: boolean);
  11483. /**
  11484. * Get hosting scene
  11485. * @returns the scene
  11486. */
  11487. getScene(): Scene;
  11488. /**
  11489. * You can use gravity if you want to give an orientation to your particles.
  11490. */
  11491. gravity: Vector3;
  11492. protected _colorGradients: Nullable<Array<ColorGradient>>;
  11493. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  11494. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  11495. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  11496. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  11497. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  11498. protected _dragGradients: Nullable<Array<FactorGradient>>;
  11499. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  11500. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  11501. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  11502. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  11503. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  11504. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  11505. /**
  11506. * Defines the delay in milliseconds before starting the system (0 by default)
  11507. */
  11508. startDelay: number;
  11509. /**
  11510. * Gets the current list of drag gradients.
  11511. * You must use addDragGradient and removeDragGradient to udpate this list
  11512. * @returns the list of drag gradients
  11513. */
  11514. getDragGradients(): Nullable<Array<FactorGradient>>;
  11515. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  11516. limitVelocityDamping: number;
  11517. /**
  11518. * Gets the current list of limit velocity gradients.
  11519. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  11520. * @returns the list of limit velocity gradients
  11521. */
  11522. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  11523. /**
  11524. * Gets the current list of color gradients.
  11525. * You must use addColorGradient and removeColorGradient to udpate this list
  11526. * @returns the list of color gradients
  11527. */
  11528. getColorGradients(): Nullable<Array<ColorGradient>>;
  11529. /**
  11530. * Gets the current list of size gradients.
  11531. * You must use addSizeGradient and removeSizeGradient to udpate this list
  11532. * @returns the list of size gradients
  11533. */
  11534. getSizeGradients(): Nullable<Array<FactorGradient>>;
  11535. /**
  11536. * Gets the current list of color remap gradients.
  11537. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  11538. * @returns the list of color remap gradients
  11539. */
  11540. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  11541. /**
  11542. * Gets the current list of alpha remap gradients.
  11543. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  11544. * @returns the list of alpha remap gradients
  11545. */
  11546. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  11547. /**
  11548. * Gets the current list of life time gradients.
  11549. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  11550. * @returns the list of life time gradients
  11551. */
  11552. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  11553. /**
  11554. * Gets the current list of angular speed gradients.
  11555. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  11556. * @returns the list of angular speed gradients
  11557. */
  11558. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  11559. /**
  11560. * Gets the current list of velocity gradients.
  11561. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  11562. * @returns the list of velocity gradients
  11563. */
  11564. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  11565. /**
  11566. * Gets the current list of start size gradients.
  11567. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  11568. * @returns the list of start size gradients
  11569. */
  11570. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  11571. /**
  11572. * Gets the current list of emit rate gradients.
  11573. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  11574. * @returns the list of emit rate gradients
  11575. */
  11576. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  11577. /**
  11578. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  11579. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11580. */
  11581. get direction1(): Vector3;
  11582. set direction1(value: Vector3);
  11583. /**
  11584. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  11585. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11586. */
  11587. get direction2(): Vector3;
  11588. set direction2(value: Vector3);
  11589. /**
  11590. * Minimum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  11591. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11592. */
  11593. get minEmitBox(): Vector3;
  11594. set minEmitBox(value: Vector3);
  11595. /**
  11596. * Maximum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  11597. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11598. */
  11599. get maxEmitBox(): Vector3;
  11600. set maxEmitBox(value: Vector3);
  11601. /**
  11602. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  11603. */
  11604. color1: Color4;
  11605. /**
  11606. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  11607. */
  11608. color2: Color4;
  11609. /**
  11610. * Color the particle will have at the end of its lifetime
  11611. */
  11612. colorDead: Color4;
  11613. /**
  11614. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  11615. */
  11616. textureMask: Color4;
  11617. /**
  11618. * The particle emitter type defines the emitter used by the particle system.
  11619. * It can be for example box, sphere, or cone...
  11620. */
  11621. particleEmitterType: IParticleEmitterType;
  11622. /** @hidden */
  11623. _isSubEmitter: boolean;
  11624. /**
  11625. * Gets or sets the billboard mode to use when isBillboardBased = true.
  11626. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  11627. */
  11628. billboardMode: number;
  11629. protected _isBillboardBased: boolean;
  11630. /**
  11631. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  11632. */
  11633. get isBillboardBased(): boolean;
  11634. set isBillboardBased(value: boolean);
  11635. /**
  11636. * The scene the particle system belongs to.
  11637. */
  11638. protected _scene: Scene;
  11639. /**
  11640. * Local cache of defines for image processing.
  11641. */
  11642. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  11643. /**
  11644. * Default configuration related to image processing available in the standard Material.
  11645. */
  11646. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  11647. /**
  11648. * Gets the image processing configuration used either in this material.
  11649. */
  11650. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  11651. /**
  11652. * Sets the Default image processing configuration used either in the this material.
  11653. *
  11654. * If sets to null, the scene one is in use.
  11655. */
  11656. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  11657. /**
  11658. * Attaches a new image processing configuration to the Standard Material.
  11659. * @param configuration
  11660. */
  11661. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  11662. /** @hidden */
  11663. protected _reset(): void;
  11664. /** @hidden */
  11665. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  11666. /**
  11667. * Instantiates a particle system.
  11668. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  11669. * @param name The name of the particle system
  11670. */
  11671. constructor(name: string);
  11672. /**
  11673. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  11674. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  11675. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  11676. * @returns the emitter
  11677. */
  11678. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  11679. /**
  11680. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  11681. * @param radius The radius of the hemisphere to emit from
  11682. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  11683. * @returns the emitter
  11684. */
  11685. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  11686. /**
  11687. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  11688. * @param radius The radius of the sphere to emit from
  11689. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  11690. * @returns the emitter
  11691. */
  11692. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  11693. /**
  11694. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  11695. * @param radius The radius of the sphere to emit from
  11696. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  11697. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  11698. * @returns the emitter
  11699. */
  11700. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  11701. /**
  11702. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  11703. * @param radius The radius of the emission cylinder
  11704. * @param height The height of the emission cylinder
  11705. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  11706. * @param directionRandomizer How much to randomize the particle direction [0-1]
  11707. * @returns the emitter
  11708. */
  11709. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  11710. /**
  11711. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  11712. * @param radius The radius of the cylinder to emit from
  11713. * @param height The height of the emission cylinder
  11714. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  11715. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  11716. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  11717. * @returns the emitter
  11718. */
  11719. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  11720. /**
  11721. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  11722. * @param radius The radius of the cone to emit from
  11723. * @param angle The base angle of the cone
  11724. * @returns the emitter
  11725. */
  11726. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  11727. /**
  11728. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  11729. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  11730. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  11731. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  11732. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  11733. * @returns the emitter
  11734. */
  11735. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  11736. }
  11737. }
  11738. declare module "babylonjs/Particles/subEmitter" {
  11739. import { Scene } from "babylonjs/scene";
  11740. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  11741. /**
  11742. * Type of sub emitter
  11743. */
  11744. export enum SubEmitterType {
  11745. /**
  11746. * Attached to the particle over it's lifetime
  11747. */
  11748. ATTACHED = 0,
  11749. /**
  11750. * Created when the particle dies
  11751. */
  11752. END = 1
  11753. }
  11754. /**
  11755. * Sub emitter class used to emit particles from an existing particle
  11756. */
  11757. export class SubEmitter {
  11758. /**
  11759. * the particle system to be used by the sub emitter
  11760. */
  11761. particleSystem: ParticleSystem;
  11762. /**
  11763. * Type of the submitter (Default: END)
  11764. */
  11765. type: SubEmitterType;
  11766. /**
  11767. * If the particle should inherit the direction from the particle it's attached to. (+Y will face the direction the particle is moving) (Default: false)
  11768. * Note: This only is supported when using an emitter of type Mesh
  11769. */
  11770. inheritDirection: boolean;
  11771. /**
  11772. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  11773. */
  11774. inheritedVelocityAmount: number;
  11775. /**
  11776. * Creates a sub emitter
  11777. * @param particleSystem the particle system to be used by the sub emitter
  11778. */
  11779. constructor(
  11780. /**
  11781. * the particle system to be used by the sub emitter
  11782. */
  11783. particleSystem: ParticleSystem);
  11784. /**
  11785. * Clones the sub emitter
  11786. * @returns the cloned sub emitter
  11787. */
  11788. clone(): SubEmitter;
  11789. /**
  11790. * Serialize current object to a JSON object
  11791. * @returns the serialized object
  11792. */
  11793. serialize(): any;
  11794. /** @hidden */
  11795. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  11796. /**
  11797. * Creates a new SubEmitter from a serialized JSON version
  11798. * @param serializationObject defines the JSON object to read from
  11799. * @param scene defines the hosting scene
  11800. * @param rootUrl defines the rootUrl for data loading
  11801. * @returns a new SubEmitter
  11802. */
  11803. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  11804. /** Release associated resources */
  11805. dispose(): void;
  11806. }
  11807. }
  11808. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  11809. /** @hidden */
  11810. export var imageProcessingDeclaration: {
  11811. name: string;
  11812. shader: string;
  11813. };
  11814. }
  11815. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  11816. /** @hidden */
  11817. export var imageProcessingFunctions: {
  11818. name: string;
  11819. shader: string;
  11820. };
  11821. }
  11822. declare module "babylonjs/Shaders/particles.fragment" {
  11823. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  11824. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  11825. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  11826. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  11827. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  11828. /** @hidden */
  11829. export var particlesPixelShader: {
  11830. name: string;
  11831. shader: string;
  11832. };
  11833. }
  11834. declare module "babylonjs/Shaders/particles.vertex" {
  11835. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  11836. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  11837. /** @hidden */
  11838. export var particlesVertexShader: {
  11839. name: string;
  11840. shader: string;
  11841. };
  11842. }
  11843. declare module "babylonjs/Particles/particleSystem" {
  11844. import { Nullable } from "babylonjs/types";
  11845. import { FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  11846. import { Observable } from "babylonjs/Misc/observable";
  11847. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  11848. import { Effect } from "babylonjs/Materials/effect";
  11849. import { Scene, IDisposable } from "babylonjs/scene";
  11850. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  11851. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  11852. import { Particle } from "babylonjs/Particles/particle";
  11853. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  11854. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  11855. import "babylonjs/Shaders/particles.fragment";
  11856. import "babylonjs/Shaders/particles.vertex";
  11857. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  11858. /**
  11859. * This represents a particle system in Babylon.
  11860. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  11861. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  11862. * @example https://doc.babylonjs.com/babylon101/particles
  11863. */
  11864. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  11865. /**
  11866. * Billboard mode will only apply to Y axis
  11867. */
  11868. static readonly BILLBOARDMODE_Y: number;
  11869. /**
  11870. * Billboard mode will apply to all axes
  11871. */
  11872. static readonly BILLBOARDMODE_ALL: number;
  11873. /**
  11874. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  11875. */
  11876. static readonly BILLBOARDMODE_STRETCHED: number;
  11877. /**
  11878. * This function can be defined to provide custom update for active particles.
  11879. * This function will be called instead of regular update (age, position, color, etc.).
  11880. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  11881. */
  11882. updateFunction: (particles: Particle[]) => void;
  11883. private _emitterWorldMatrix;
  11884. /**
  11885. * This function can be defined to specify initial direction for every new particle.
  11886. * It by default use the emitterType defined function
  11887. */
  11888. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  11889. /**
  11890. * This function can be defined to specify initial position for every new particle.
  11891. * It by default use the emitterType defined function
  11892. */
  11893. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  11894. /**
  11895. * @hidden
  11896. */
  11897. _inheritedVelocityOffset: Vector3;
  11898. /**
  11899. * An event triggered when the system is disposed
  11900. */
  11901. onDisposeObservable: Observable<ParticleSystem>;
  11902. private _onDisposeObserver;
  11903. /**
  11904. * Sets a callback that will be triggered when the system is disposed
  11905. */
  11906. set onDispose(callback: () => void);
  11907. private _particles;
  11908. private _epsilon;
  11909. private _capacity;
  11910. private _stockParticles;
  11911. private _newPartsExcess;
  11912. private _vertexData;
  11913. private _vertexBuffer;
  11914. private _vertexBuffers;
  11915. private _spriteBuffer;
  11916. private _indexBuffer;
  11917. private _effect;
  11918. private _customEffect;
  11919. private _cachedDefines;
  11920. private _scaledColorStep;
  11921. private _colorDiff;
  11922. private _scaledDirection;
  11923. private _scaledGravity;
  11924. private _currentRenderId;
  11925. private _alive;
  11926. private _useInstancing;
  11927. private _started;
  11928. private _stopped;
  11929. private _actualFrame;
  11930. private _scaledUpdateSpeed;
  11931. private _vertexBufferSize;
  11932. /** @hidden */
  11933. _currentEmitRateGradient: Nullable<FactorGradient>;
  11934. /** @hidden */
  11935. _currentEmitRate1: number;
  11936. /** @hidden */
  11937. _currentEmitRate2: number;
  11938. /** @hidden */
  11939. _currentStartSizeGradient: Nullable<FactorGradient>;
  11940. /** @hidden */
  11941. _currentStartSize1: number;
  11942. /** @hidden */
  11943. _currentStartSize2: number;
  11944. private readonly _rawTextureWidth;
  11945. private _rampGradientsTexture;
  11946. private _useRampGradients;
  11947. /** Gets or sets a boolean indicating that ramp gradients must be used
  11948. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  11949. */
  11950. get useRampGradients(): boolean;
  11951. set useRampGradients(value: boolean);
  11952. /**
  11953. * The Sub-emitters templates that will be used to generate the sub particle system to be associated with the system, this property is used by the root particle system only.
  11954. * When a particle is spawned, an array will be chosen at random and all the emitters in that array will be attached to the particle. (Default: [])
  11955. */
  11956. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  11957. private _subEmitters;
  11958. /**
  11959. * @hidden
  11960. * If the particle systems emitter should be disposed when the particle system is disposed
  11961. */
  11962. _disposeEmitterOnDispose: boolean;
  11963. /**
  11964. * The current active Sub-systems, this property is used by the root particle system only.
  11965. */
  11966. activeSubSystems: Array<ParticleSystem>;
  11967. /**
  11968. * Specifies if the particles are updated in emitter local space or world space
  11969. */
  11970. isLocal: boolean;
  11971. private _rootParticleSystem;
  11972. /**
  11973. * Gets the current list of active particles
  11974. */
  11975. get particles(): Particle[];
  11976. /**
  11977. * Gets the number of particles active at the same time.
  11978. * @returns The number of active particles.
  11979. */
  11980. getActiveCount(): number;
  11981. /**
  11982. * Returns the string "ParticleSystem"
  11983. * @returns a string containing the class name
  11984. */
  11985. getClassName(): string;
  11986. /**
  11987. * Gets a boolean indicating that the system is stopping
  11988. * @returns true if the system is currently stopping
  11989. */
  11990. isStopping(): boolean;
  11991. /**
  11992. * Instantiates a particle system.
  11993. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  11994. * @param name The name of the particle system
  11995. * @param capacity The max number of particles alive at the same time
  11996. * @param scene The scene the particle system belongs to
  11997. * @param customEffect a custom effect used to change the way particles are rendered by default
  11998. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  11999. * @param epsilon Offset used to render the particles
  12000. */
  12001. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  12002. private _addFactorGradient;
  12003. private _removeFactorGradient;
  12004. /**
  12005. * Adds a new life time gradient
  12006. * @param gradient defines the gradient to use (between 0 and 1)
  12007. * @param factor defines the life time factor to affect to the specified gradient
  12008. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12009. * @returns the current particle system
  12010. */
  12011. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12012. /**
  12013. * Remove a specific life time gradient
  12014. * @param gradient defines the gradient to remove
  12015. * @returns the current particle system
  12016. */
  12017. removeLifeTimeGradient(gradient: number): IParticleSystem;
  12018. /**
  12019. * Adds a new size gradient
  12020. * @param gradient defines the gradient to use (between 0 and 1)
  12021. * @param factor defines the size factor to affect to the specified gradient
  12022. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12023. * @returns the current particle system
  12024. */
  12025. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12026. /**
  12027. * Remove a specific size gradient
  12028. * @param gradient defines the gradient to remove
  12029. * @returns the current particle system
  12030. */
  12031. removeSizeGradient(gradient: number): IParticleSystem;
  12032. /**
  12033. * Adds a new color remap gradient
  12034. * @param gradient defines the gradient to use (between 0 and 1)
  12035. * @param min defines the color remap minimal range
  12036. * @param max defines the color remap maximal range
  12037. * @returns the current particle system
  12038. */
  12039. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  12040. /**
  12041. * Remove a specific color remap gradient
  12042. * @param gradient defines the gradient to remove
  12043. * @returns the current particle system
  12044. */
  12045. removeColorRemapGradient(gradient: number): IParticleSystem;
  12046. /**
  12047. * Adds a new alpha remap gradient
  12048. * @param gradient defines the gradient to use (between 0 and 1)
  12049. * @param min defines the alpha remap minimal range
  12050. * @param max defines the alpha remap maximal range
  12051. * @returns the current particle system
  12052. */
  12053. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  12054. /**
  12055. * Remove a specific alpha remap gradient
  12056. * @param gradient defines the gradient to remove
  12057. * @returns the current particle system
  12058. */
  12059. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  12060. /**
  12061. * Adds a new angular speed gradient
  12062. * @param gradient defines the gradient to use (between 0 and 1)
  12063. * @param factor defines the angular speed to affect to the specified gradient
  12064. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12065. * @returns the current particle system
  12066. */
  12067. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12068. /**
  12069. * Remove a specific angular speed gradient
  12070. * @param gradient defines the gradient to remove
  12071. * @returns the current particle system
  12072. */
  12073. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  12074. /**
  12075. * Adds a new velocity gradient
  12076. * @param gradient defines the gradient to use (between 0 and 1)
  12077. * @param factor defines the velocity to affect to the specified gradient
  12078. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12079. * @returns the current particle system
  12080. */
  12081. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12082. /**
  12083. * Remove a specific velocity gradient
  12084. * @param gradient defines the gradient to remove
  12085. * @returns the current particle system
  12086. */
  12087. removeVelocityGradient(gradient: number): IParticleSystem;
  12088. /**
  12089. * Adds a new limit velocity gradient
  12090. * @param gradient defines the gradient to use (between 0 and 1)
  12091. * @param factor defines the limit velocity value to affect to the specified gradient
  12092. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12093. * @returns the current particle system
  12094. */
  12095. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12096. /**
  12097. * Remove a specific limit velocity gradient
  12098. * @param gradient defines the gradient to remove
  12099. * @returns the current particle system
  12100. */
  12101. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  12102. /**
  12103. * Adds a new drag gradient
  12104. * @param gradient defines the gradient to use (between 0 and 1)
  12105. * @param factor defines the drag value to affect to the specified gradient
  12106. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12107. * @returns the current particle system
  12108. */
  12109. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12110. /**
  12111. * Remove a specific drag gradient
  12112. * @param gradient defines the gradient to remove
  12113. * @returns the current particle system
  12114. */
  12115. removeDragGradient(gradient: number): IParticleSystem;
  12116. /**
  12117. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  12118. * @param gradient defines the gradient to use (between 0 and 1)
  12119. * @param factor defines the emit rate value to affect to the specified gradient
  12120. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12121. * @returns the current particle system
  12122. */
  12123. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12124. /**
  12125. * Remove a specific emit rate gradient
  12126. * @param gradient defines the gradient to remove
  12127. * @returns the current particle system
  12128. */
  12129. removeEmitRateGradient(gradient: number): IParticleSystem;
  12130. /**
  12131. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  12132. * @param gradient defines the gradient to use (between 0 and 1)
  12133. * @param factor defines the start size value to affect to the specified gradient
  12134. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12135. * @returns the current particle system
  12136. */
  12137. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12138. /**
  12139. * Remove a specific start size gradient
  12140. * @param gradient defines the gradient to remove
  12141. * @returns the current particle system
  12142. */
  12143. removeStartSizeGradient(gradient: number): IParticleSystem;
  12144. private _createRampGradientTexture;
  12145. /**
  12146. * Gets the current list of ramp gradients.
  12147. * You must use addRampGradient and removeRampGradient to udpate this list
  12148. * @returns the list of ramp gradients
  12149. */
  12150. getRampGradients(): Nullable<Array<Color3Gradient>>;
  12151. /** Force the system to rebuild all gradients that need to be resync */
  12152. forceRefreshGradients(): void;
  12153. private _syncRampGradientTexture;
  12154. /**
  12155. * Adds a new ramp gradient used to remap particle colors
  12156. * @param gradient defines the gradient to use (between 0 and 1)
  12157. * @param color defines the color to affect to the specified gradient
  12158. * @returns the current particle system
  12159. */
  12160. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  12161. /**
  12162. * Remove a specific ramp gradient
  12163. * @param gradient defines the gradient to remove
  12164. * @returns the current particle system
  12165. */
  12166. removeRampGradient(gradient: number): ParticleSystem;
  12167. /**
  12168. * Adds a new color gradient
  12169. * @param gradient defines the gradient to use (between 0 and 1)
  12170. * @param color1 defines the color to affect to the specified gradient
  12171. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  12172. * @returns this particle system
  12173. */
  12174. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  12175. /**
  12176. * Remove a specific color gradient
  12177. * @param gradient defines the gradient to remove
  12178. * @returns this particle system
  12179. */
  12180. removeColorGradient(gradient: number): IParticleSystem;
  12181. private _fetchR;
  12182. protected _reset(): void;
  12183. private _resetEffect;
  12184. private _createVertexBuffers;
  12185. private _createIndexBuffer;
  12186. /**
  12187. * Gets the maximum number of particles active at the same time.
  12188. * @returns The max number of active particles.
  12189. */
  12190. getCapacity(): number;
  12191. /**
  12192. * Gets whether there are still active particles in the system.
  12193. * @returns True if it is alive, otherwise false.
  12194. */
  12195. isAlive(): boolean;
  12196. /**
  12197. * Gets if the system has been started. (Note: this will still be true after stop is called)
  12198. * @returns True if it has been started, otherwise false.
  12199. */
  12200. isStarted(): boolean;
  12201. private _prepareSubEmitterInternalArray;
  12202. /**
  12203. * Starts the particle system and begins to emit
  12204. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  12205. */
  12206. start(delay?: number): void;
  12207. /**
  12208. * Stops the particle system.
  12209. * @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.
  12210. */
  12211. stop(stopSubEmitters?: boolean): void;
  12212. /**
  12213. * Remove all active particles
  12214. */
  12215. reset(): void;
  12216. /**
  12217. * @hidden (for internal use only)
  12218. */
  12219. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  12220. /**
  12221. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  12222. * Its lifetime will start back at 0.
  12223. */
  12224. recycleParticle: (particle: Particle) => void;
  12225. private _stopSubEmitters;
  12226. private _createParticle;
  12227. private _removeFromRoot;
  12228. private _emitFromParticle;
  12229. private _update;
  12230. /** @hidden */
  12231. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  12232. /** @hidden */
  12233. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  12234. /** @hidden */
  12235. private _getEffect;
  12236. /**
  12237. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  12238. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  12239. */
  12240. animate(preWarmOnly?: boolean): void;
  12241. private _appendParticleVertices;
  12242. /**
  12243. * Rebuilds the particle system.
  12244. */
  12245. rebuild(): void;
  12246. /**
  12247. * Is this system ready to be used/rendered
  12248. * @return true if the system is ready
  12249. */
  12250. isReady(): boolean;
  12251. private _render;
  12252. /**
  12253. * Renders the particle system in its current state.
  12254. * @returns the current number of particles
  12255. */
  12256. render(): number;
  12257. /**
  12258. * Disposes the particle system and free the associated resources
  12259. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  12260. */
  12261. dispose(disposeTexture?: boolean): void;
  12262. /**
  12263. * Clones the particle system.
  12264. * @param name The name of the cloned object
  12265. * @param newEmitter The new emitter to use
  12266. * @returns the cloned particle system
  12267. */
  12268. clone(name: string, newEmitter: any): ParticleSystem;
  12269. /**
  12270. * Serializes the particle system to a JSON object
  12271. * @param serializeTexture defines if the texture must be serialized as well
  12272. * @returns the JSON object
  12273. */
  12274. serialize(serializeTexture?: boolean): any;
  12275. /** @hidden */
  12276. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  12277. /** @hidden */
  12278. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  12279. /**
  12280. * Parses a JSON object to create a particle system.
  12281. * @param parsedParticleSystem The JSON object to parse
  12282. * @param scene The scene to create the particle system in
  12283. * @param rootUrl The root url to use to load external dependencies like texture
  12284. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  12285. * @returns the Parsed particle system
  12286. */
  12287. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  12288. }
  12289. }
  12290. declare module "babylonjs/Particles/particle" {
  12291. import { Nullable } from "babylonjs/types";
  12292. import { Vector2, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  12293. import { Color4 } from "babylonjs/Maths/math.color";
  12294. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  12295. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  12296. import { ColorGradient, FactorGradient } from "babylonjs/Misc/gradients";
  12297. /**
  12298. * A particle represents one of the element emitted by a particle system.
  12299. * This is mainly define by its coordinates, direction, velocity and age.
  12300. */
  12301. export class Particle {
  12302. /**
  12303. * The particle system the particle belongs to.
  12304. */
  12305. particleSystem: ParticleSystem;
  12306. private static _Count;
  12307. /**
  12308. * Unique ID of the particle
  12309. */
  12310. id: number;
  12311. /**
  12312. * The world position of the particle in the scene.
  12313. */
  12314. position: Vector3;
  12315. /**
  12316. * The world direction of the particle in the scene.
  12317. */
  12318. direction: Vector3;
  12319. /**
  12320. * The color of the particle.
  12321. */
  12322. color: Color4;
  12323. /**
  12324. * The color change of the particle per step.
  12325. */
  12326. colorStep: Color4;
  12327. /**
  12328. * Defines how long will the life of the particle be.
  12329. */
  12330. lifeTime: number;
  12331. /**
  12332. * The current age of the particle.
  12333. */
  12334. age: number;
  12335. /**
  12336. * The current size of the particle.
  12337. */
  12338. size: number;
  12339. /**
  12340. * The current scale of the particle.
  12341. */
  12342. scale: Vector2;
  12343. /**
  12344. * The current angle of the particle.
  12345. */
  12346. angle: number;
  12347. /**
  12348. * Defines how fast is the angle changing.
  12349. */
  12350. angularSpeed: number;
  12351. /**
  12352. * Defines the cell index used by the particle to be rendered from a sprite.
  12353. */
  12354. cellIndex: number;
  12355. /**
  12356. * The information required to support color remapping
  12357. */
  12358. remapData: Vector4;
  12359. /** @hidden */
  12360. _randomCellOffset?: number;
  12361. /** @hidden */
  12362. _initialDirection: Nullable<Vector3>;
  12363. /** @hidden */
  12364. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  12365. /** @hidden */
  12366. _initialStartSpriteCellID: number;
  12367. /** @hidden */
  12368. _initialEndSpriteCellID: number;
  12369. /** @hidden */
  12370. _currentColorGradient: Nullable<ColorGradient>;
  12371. /** @hidden */
  12372. _currentColor1: Color4;
  12373. /** @hidden */
  12374. _currentColor2: Color4;
  12375. /** @hidden */
  12376. _currentSizeGradient: Nullable<FactorGradient>;
  12377. /** @hidden */
  12378. _currentSize1: number;
  12379. /** @hidden */
  12380. _currentSize2: number;
  12381. /** @hidden */
  12382. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  12383. /** @hidden */
  12384. _currentAngularSpeed1: number;
  12385. /** @hidden */
  12386. _currentAngularSpeed2: number;
  12387. /** @hidden */
  12388. _currentVelocityGradient: Nullable<FactorGradient>;
  12389. /** @hidden */
  12390. _currentVelocity1: number;
  12391. /** @hidden */
  12392. _currentVelocity2: number;
  12393. /** @hidden */
  12394. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  12395. /** @hidden */
  12396. _currentLimitVelocity1: number;
  12397. /** @hidden */
  12398. _currentLimitVelocity2: number;
  12399. /** @hidden */
  12400. _currentDragGradient: Nullable<FactorGradient>;
  12401. /** @hidden */
  12402. _currentDrag1: number;
  12403. /** @hidden */
  12404. _currentDrag2: number;
  12405. /** @hidden */
  12406. _randomNoiseCoordinates1: Vector3;
  12407. /** @hidden */
  12408. _randomNoiseCoordinates2: Vector3;
  12409. /** @hidden */
  12410. _localPosition?: Vector3;
  12411. /**
  12412. * Creates a new instance Particle
  12413. * @param particleSystem the particle system the particle belongs to
  12414. */
  12415. constructor(
  12416. /**
  12417. * The particle system the particle belongs to.
  12418. */
  12419. particleSystem: ParticleSystem);
  12420. private updateCellInfoFromSystem;
  12421. /**
  12422. * Defines how the sprite cell index is updated for the particle
  12423. */
  12424. updateCellIndex(): void;
  12425. /** @hidden */
  12426. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  12427. /** @hidden */
  12428. _inheritParticleInfoToSubEmitters(): void;
  12429. /** @hidden */
  12430. _reset(): void;
  12431. /**
  12432. * Copy the properties of particle to another one.
  12433. * @param other the particle to copy the information to.
  12434. */
  12435. copyTo(other: Particle): void;
  12436. }
  12437. }
  12438. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  12439. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12440. import { Effect } from "babylonjs/Materials/effect";
  12441. import { Particle } from "babylonjs/Particles/particle";
  12442. import { Scene } from "babylonjs/scene";
  12443. /**
  12444. * Particle emitter represents a volume emitting particles.
  12445. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  12446. */
  12447. export interface IParticleEmitterType {
  12448. /**
  12449. * Called by the particle System when the direction is computed for the created particle.
  12450. * @param worldMatrix is the world matrix of the particle system
  12451. * @param directionToUpdate is the direction vector to update with the result
  12452. * @param particle is the particle we are computed the direction for
  12453. * @param isLocal defines if the direction should be set in local space
  12454. */
  12455. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12456. /**
  12457. * Called by the particle System when the position is computed for the created particle.
  12458. * @param worldMatrix is the world matrix of the particle system
  12459. * @param positionToUpdate is the position vector to update with the result
  12460. * @param particle is the particle we are computed the position for
  12461. * @param isLocal defines if the position should be set in local space
  12462. */
  12463. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12464. /**
  12465. * Clones the current emitter and returns a copy of it
  12466. * @returns the new emitter
  12467. */
  12468. clone(): IParticleEmitterType;
  12469. /**
  12470. * Called by the GPUParticleSystem to setup the update shader
  12471. * @param effect defines the update shader
  12472. */
  12473. applyToShader(effect: Effect): void;
  12474. /**
  12475. * Returns a string to use to update the GPU particles update shader
  12476. * @returns the effect defines string
  12477. */
  12478. getEffectDefines(): string;
  12479. /**
  12480. * Returns a string representing the class name
  12481. * @returns a string containing the class name
  12482. */
  12483. getClassName(): string;
  12484. /**
  12485. * Serializes the particle system to a JSON object.
  12486. * @returns the JSON object
  12487. */
  12488. serialize(): any;
  12489. /**
  12490. * Parse properties from a JSON object
  12491. * @param serializationObject defines the JSON object
  12492. * @param scene defines the hosting scene
  12493. */
  12494. parse(serializationObject: any, scene: Scene): void;
  12495. }
  12496. }
  12497. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  12498. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12499. import { Effect } from "babylonjs/Materials/effect";
  12500. import { Particle } from "babylonjs/Particles/particle";
  12501. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  12502. /**
  12503. * Particle emitter emitting particles from the inside of a box.
  12504. * It emits the particles randomly between 2 given directions.
  12505. */
  12506. export class BoxParticleEmitter implements IParticleEmitterType {
  12507. /**
  12508. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12509. */
  12510. direction1: Vector3;
  12511. /**
  12512. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12513. */
  12514. direction2: Vector3;
  12515. /**
  12516. * 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.
  12517. */
  12518. minEmitBox: Vector3;
  12519. /**
  12520. * 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.
  12521. */
  12522. maxEmitBox: Vector3;
  12523. /**
  12524. * Creates a new instance BoxParticleEmitter
  12525. */
  12526. constructor();
  12527. /**
  12528. * Called by the particle System when the direction is computed for the created particle.
  12529. * @param worldMatrix is the world matrix of the particle system
  12530. * @param directionToUpdate is the direction vector to update with the result
  12531. * @param particle is the particle we are computed the direction for
  12532. * @param isLocal defines if the direction should be set in local space
  12533. */
  12534. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12535. /**
  12536. * Called by the particle System when the position is computed for the created particle.
  12537. * @param worldMatrix is the world matrix of the particle system
  12538. * @param positionToUpdate is the position vector to update with the result
  12539. * @param particle is the particle we are computed the position for
  12540. * @param isLocal defines if the position should be set in local space
  12541. */
  12542. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12543. /**
  12544. * Clones the current emitter and returns a copy of it
  12545. * @returns the new emitter
  12546. */
  12547. clone(): BoxParticleEmitter;
  12548. /**
  12549. * Called by the GPUParticleSystem to setup the update shader
  12550. * @param effect defines the update shader
  12551. */
  12552. applyToShader(effect: Effect): void;
  12553. /**
  12554. * Returns a string to use to update the GPU particles update shader
  12555. * @returns a string containng the defines string
  12556. */
  12557. getEffectDefines(): string;
  12558. /**
  12559. * Returns the string "BoxParticleEmitter"
  12560. * @returns a string containing the class name
  12561. */
  12562. getClassName(): string;
  12563. /**
  12564. * Serializes the particle system to a JSON object.
  12565. * @returns the JSON object
  12566. */
  12567. serialize(): any;
  12568. /**
  12569. * Parse properties from a JSON object
  12570. * @param serializationObject defines the JSON object
  12571. */
  12572. parse(serializationObject: any): void;
  12573. }
  12574. }
  12575. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  12576. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12577. import { Effect } from "babylonjs/Materials/effect";
  12578. import { Particle } from "babylonjs/Particles/particle";
  12579. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  12580. /**
  12581. * Particle emitter emitting particles from the inside of a cone.
  12582. * It emits the particles alongside the cone volume from the base to the particle.
  12583. * The emission direction might be randomized.
  12584. */
  12585. export class ConeParticleEmitter implements IParticleEmitterType {
  12586. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  12587. directionRandomizer: number;
  12588. private _radius;
  12589. private _angle;
  12590. private _height;
  12591. /**
  12592. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  12593. */
  12594. radiusRange: number;
  12595. /**
  12596. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  12597. */
  12598. heightRange: number;
  12599. /**
  12600. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  12601. */
  12602. emitFromSpawnPointOnly: boolean;
  12603. /**
  12604. * Gets or sets the radius of the emission cone
  12605. */
  12606. get radius(): number;
  12607. set radius(value: number);
  12608. /**
  12609. * Gets or sets the angle of the emission cone
  12610. */
  12611. get angle(): number;
  12612. set angle(value: number);
  12613. private _buildHeight;
  12614. /**
  12615. * Creates a new instance ConeParticleEmitter
  12616. * @param radius the radius of the emission cone (1 by default)
  12617. * @param angle the cone base angle (PI by default)
  12618. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  12619. */
  12620. constructor(radius?: number, angle?: number,
  12621. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  12622. directionRandomizer?: number);
  12623. /**
  12624. * Called by the particle System when the direction is computed for the created particle.
  12625. * @param worldMatrix is the world matrix of the particle system
  12626. * @param directionToUpdate is the direction vector to update with the result
  12627. * @param particle is the particle we are computed the direction for
  12628. * @param isLocal defines if the direction should be set in local space
  12629. */
  12630. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12631. /**
  12632. * Called by the particle System when the position is computed for the created particle.
  12633. * @param worldMatrix is the world matrix of the particle system
  12634. * @param positionToUpdate is the position vector to update with the result
  12635. * @param particle is the particle we are computed the position for
  12636. * @param isLocal defines if the position should be set in local space
  12637. */
  12638. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12639. /**
  12640. * Clones the current emitter and returns a copy of it
  12641. * @returns the new emitter
  12642. */
  12643. clone(): ConeParticleEmitter;
  12644. /**
  12645. * Called by the GPUParticleSystem to setup the update shader
  12646. * @param effect defines the update shader
  12647. */
  12648. applyToShader(effect: Effect): void;
  12649. /**
  12650. * Returns a string to use to update the GPU particles update shader
  12651. * @returns a string containng the defines string
  12652. */
  12653. getEffectDefines(): string;
  12654. /**
  12655. * Returns the string "ConeParticleEmitter"
  12656. * @returns a string containing the class name
  12657. */
  12658. getClassName(): string;
  12659. /**
  12660. * Serializes the particle system to a JSON object.
  12661. * @returns the JSON object
  12662. */
  12663. serialize(): any;
  12664. /**
  12665. * Parse properties from a JSON object
  12666. * @param serializationObject defines the JSON object
  12667. */
  12668. parse(serializationObject: any): void;
  12669. }
  12670. }
  12671. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  12672. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12673. import { Effect } from "babylonjs/Materials/effect";
  12674. import { Particle } from "babylonjs/Particles/particle";
  12675. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  12676. /**
  12677. * Particle emitter emitting particles from the inside of a cylinder.
  12678. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  12679. */
  12680. export class CylinderParticleEmitter implements IParticleEmitterType {
  12681. /**
  12682. * The radius of the emission cylinder.
  12683. */
  12684. radius: number;
  12685. /**
  12686. * The height of the emission cylinder.
  12687. */
  12688. height: number;
  12689. /**
  12690. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12691. */
  12692. radiusRange: number;
  12693. /**
  12694. * How much to randomize the particle direction [0-1].
  12695. */
  12696. directionRandomizer: number;
  12697. /**
  12698. * Creates a new instance CylinderParticleEmitter
  12699. * @param radius the radius of the emission cylinder (1 by default)
  12700. * @param height the height of the emission cylinder (1 by default)
  12701. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12702. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  12703. */
  12704. constructor(
  12705. /**
  12706. * The radius of the emission cylinder.
  12707. */
  12708. radius?: number,
  12709. /**
  12710. * The height of the emission cylinder.
  12711. */
  12712. height?: number,
  12713. /**
  12714. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12715. */
  12716. radiusRange?: number,
  12717. /**
  12718. * How much to randomize the particle direction [0-1].
  12719. */
  12720. directionRandomizer?: number);
  12721. /**
  12722. * Called by the particle System when the direction is computed for the created particle.
  12723. * @param worldMatrix is the world matrix of the particle system
  12724. * @param directionToUpdate is the direction vector to update with the result
  12725. * @param particle is the particle we are computed the direction for
  12726. * @param isLocal defines if the direction should be set in local space
  12727. */
  12728. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12729. /**
  12730. * Called by the particle System when the position is computed for the created particle.
  12731. * @param worldMatrix is the world matrix of the particle system
  12732. * @param positionToUpdate is the position vector to update with the result
  12733. * @param particle is the particle we are computed the position for
  12734. * @param isLocal defines if the position should be set in local space
  12735. */
  12736. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12737. /**
  12738. * Clones the current emitter and returns a copy of it
  12739. * @returns the new emitter
  12740. */
  12741. clone(): CylinderParticleEmitter;
  12742. /**
  12743. * Called by the GPUParticleSystem to setup the update shader
  12744. * @param effect defines the update shader
  12745. */
  12746. applyToShader(effect: Effect): void;
  12747. /**
  12748. * Returns a string to use to update the GPU particles update shader
  12749. * @returns a string containng the defines string
  12750. */
  12751. getEffectDefines(): string;
  12752. /**
  12753. * Returns the string "CylinderParticleEmitter"
  12754. * @returns a string containing the class name
  12755. */
  12756. getClassName(): string;
  12757. /**
  12758. * Serializes the particle system to a JSON object.
  12759. * @returns the JSON object
  12760. */
  12761. serialize(): any;
  12762. /**
  12763. * Parse properties from a JSON object
  12764. * @param serializationObject defines the JSON object
  12765. */
  12766. parse(serializationObject: any): void;
  12767. }
  12768. /**
  12769. * Particle emitter emitting particles from the inside of a cylinder.
  12770. * It emits the particles randomly between two vectors.
  12771. */
  12772. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  12773. /**
  12774. * The min limit of the emission direction.
  12775. */
  12776. direction1: Vector3;
  12777. /**
  12778. * The max limit of the emission direction.
  12779. */
  12780. direction2: Vector3;
  12781. /**
  12782. * Creates a new instance CylinderDirectedParticleEmitter
  12783. * @param radius the radius of the emission cylinder (1 by default)
  12784. * @param height the height of the emission cylinder (1 by default)
  12785. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12786. * @param direction1 the min limit of the emission direction (up vector by default)
  12787. * @param direction2 the max limit of the emission direction (up vector by default)
  12788. */
  12789. constructor(radius?: number, height?: number, radiusRange?: number,
  12790. /**
  12791. * The min limit of the emission direction.
  12792. */
  12793. direction1?: Vector3,
  12794. /**
  12795. * The max limit of the emission direction.
  12796. */
  12797. direction2?: Vector3);
  12798. /**
  12799. * Called by the particle System when the direction is computed for the created particle.
  12800. * @param worldMatrix is the world matrix of the particle system
  12801. * @param directionToUpdate is the direction vector to update with the result
  12802. * @param particle is the particle we are computed the direction for
  12803. */
  12804. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12805. /**
  12806. * Clones the current emitter and returns a copy of it
  12807. * @returns the new emitter
  12808. */
  12809. clone(): CylinderDirectedParticleEmitter;
  12810. /**
  12811. * Called by the GPUParticleSystem to setup the update shader
  12812. * @param effect defines the update shader
  12813. */
  12814. applyToShader(effect: Effect): void;
  12815. /**
  12816. * Returns a string to use to update the GPU particles update shader
  12817. * @returns a string containng the defines string
  12818. */
  12819. getEffectDefines(): string;
  12820. /**
  12821. * Returns the string "CylinderDirectedParticleEmitter"
  12822. * @returns a string containing the class name
  12823. */
  12824. getClassName(): string;
  12825. /**
  12826. * Serializes the particle system to a JSON object.
  12827. * @returns the JSON object
  12828. */
  12829. serialize(): any;
  12830. /**
  12831. * Parse properties from a JSON object
  12832. * @param serializationObject defines the JSON object
  12833. */
  12834. parse(serializationObject: any): void;
  12835. }
  12836. }
  12837. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  12838. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12839. import { Effect } from "babylonjs/Materials/effect";
  12840. import { Particle } from "babylonjs/Particles/particle";
  12841. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  12842. /**
  12843. * Particle emitter emitting particles from the inside of a hemisphere.
  12844. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  12845. */
  12846. export class HemisphericParticleEmitter implements IParticleEmitterType {
  12847. /**
  12848. * The radius of the emission hemisphere.
  12849. */
  12850. radius: number;
  12851. /**
  12852. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12853. */
  12854. radiusRange: number;
  12855. /**
  12856. * How much to randomize the particle direction [0-1].
  12857. */
  12858. directionRandomizer: number;
  12859. /**
  12860. * Creates a new instance HemisphericParticleEmitter
  12861. * @param radius the radius of the emission hemisphere (1 by default)
  12862. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12863. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  12864. */
  12865. constructor(
  12866. /**
  12867. * The radius of the emission hemisphere.
  12868. */
  12869. radius?: number,
  12870. /**
  12871. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12872. */
  12873. radiusRange?: number,
  12874. /**
  12875. * How much to randomize the particle direction [0-1].
  12876. */
  12877. directionRandomizer?: number);
  12878. /**
  12879. * Called by the particle System when the direction is computed for the created particle.
  12880. * @param worldMatrix is the world matrix of the particle system
  12881. * @param directionToUpdate is the direction vector to update with the result
  12882. * @param particle is the particle we are computed the direction for
  12883. * @param isLocal defines if the direction should be set in local space
  12884. */
  12885. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12886. /**
  12887. * Called by the particle System when the position is computed for the created particle.
  12888. * @param worldMatrix is the world matrix of the particle system
  12889. * @param positionToUpdate is the position vector to update with the result
  12890. * @param particle is the particle we are computed the position for
  12891. * @param isLocal defines if the position should be set in local space
  12892. */
  12893. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12894. /**
  12895. * Clones the current emitter and returns a copy of it
  12896. * @returns the new emitter
  12897. */
  12898. clone(): HemisphericParticleEmitter;
  12899. /**
  12900. * Called by the GPUParticleSystem to setup the update shader
  12901. * @param effect defines the update shader
  12902. */
  12903. applyToShader(effect: Effect): void;
  12904. /**
  12905. * Returns a string to use to update the GPU particles update shader
  12906. * @returns a string containng the defines string
  12907. */
  12908. getEffectDefines(): string;
  12909. /**
  12910. * Returns the string "HemisphericParticleEmitter"
  12911. * @returns a string containing the class name
  12912. */
  12913. getClassName(): string;
  12914. /**
  12915. * Serializes the particle system to a JSON object.
  12916. * @returns the JSON object
  12917. */
  12918. serialize(): any;
  12919. /**
  12920. * Parse properties from a JSON object
  12921. * @param serializationObject defines the JSON object
  12922. */
  12923. parse(serializationObject: any): void;
  12924. }
  12925. }
  12926. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  12927. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12928. import { Effect } from "babylonjs/Materials/effect";
  12929. import { Particle } from "babylonjs/Particles/particle";
  12930. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  12931. /**
  12932. * Particle emitter emitting particles from a point.
  12933. * It emits the particles randomly between 2 given directions.
  12934. */
  12935. export class PointParticleEmitter implements IParticleEmitterType {
  12936. /**
  12937. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12938. */
  12939. direction1: Vector3;
  12940. /**
  12941. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12942. */
  12943. direction2: Vector3;
  12944. /**
  12945. * Creates a new instance PointParticleEmitter
  12946. */
  12947. constructor();
  12948. /**
  12949. * Called by the particle System when the direction is computed for the created particle.
  12950. * @param worldMatrix is the world matrix of the particle system
  12951. * @param directionToUpdate is the direction vector to update with the result
  12952. * @param particle is the particle we are computed the direction for
  12953. * @param isLocal defines if the direction should be set in local space
  12954. */
  12955. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12956. /**
  12957. * Called by the particle System when the position is computed for the created particle.
  12958. * @param worldMatrix is the world matrix of the particle system
  12959. * @param positionToUpdate is the position vector to update with the result
  12960. * @param particle is the particle we are computed the position for
  12961. * @param isLocal defines if the position should be set in local space
  12962. */
  12963. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12964. /**
  12965. * Clones the current emitter and returns a copy of it
  12966. * @returns the new emitter
  12967. */
  12968. clone(): PointParticleEmitter;
  12969. /**
  12970. * Called by the GPUParticleSystem to setup the update shader
  12971. * @param effect defines the update shader
  12972. */
  12973. applyToShader(effect: Effect): void;
  12974. /**
  12975. * Returns a string to use to update the GPU particles update shader
  12976. * @returns a string containng the defines string
  12977. */
  12978. getEffectDefines(): string;
  12979. /**
  12980. * Returns the string "PointParticleEmitter"
  12981. * @returns a string containing the class name
  12982. */
  12983. getClassName(): string;
  12984. /**
  12985. * Serializes the particle system to a JSON object.
  12986. * @returns the JSON object
  12987. */
  12988. serialize(): any;
  12989. /**
  12990. * Parse properties from a JSON object
  12991. * @param serializationObject defines the JSON object
  12992. */
  12993. parse(serializationObject: any): void;
  12994. }
  12995. }
  12996. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  12997. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12998. import { Effect } from "babylonjs/Materials/effect";
  12999. import { Particle } from "babylonjs/Particles/particle";
  13000. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13001. /**
  13002. * Particle emitter emitting particles from the inside of a sphere.
  13003. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  13004. */
  13005. export class SphereParticleEmitter implements IParticleEmitterType {
  13006. /**
  13007. * The radius of the emission sphere.
  13008. */
  13009. radius: number;
  13010. /**
  13011. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13012. */
  13013. radiusRange: number;
  13014. /**
  13015. * How much to randomize the particle direction [0-1].
  13016. */
  13017. directionRandomizer: number;
  13018. /**
  13019. * Creates a new instance SphereParticleEmitter
  13020. * @param radius the radius of the emission sphere (1 by default)
  13021. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13022. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13023. */
  13024. constructor(
  13025. /**
  13026. * The radius of the emission sphere.
  13027. */
  13028. radius?: number,
  13029. /**
  13030. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13031. */
  13032. radiusRange?: number,
  13033. /**
  13034. * How much to randomize the particle direction [0-1].
  13035. */
  13036. directionRandomizer?: number);
  13037. /**
  13038. * Called by the particle System when the direction is computed for the created particle.
  13039. * @param worldMatrix is the world matrix of the particle system
  13040. * @param directionToUpdate is the direction vector to update with the result
  13041. * @param particle is the particle we are computed the direction for
  13042. * @param isLocal defines if the direction should be set in local space
  13043. */
  13044. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13045. /**
  13046. * Called by the particle System when the position is computed for the created particle.
  13047. * @param worldMatrix is the world matrix of the particle system
  13048. * @param positionToUpdate is the position vector to update with the result
  13049. * @param particle is the particle we are computed the position for
  13050. * @param isLocal defines if the position should be set in local space
  13051. */
  13052. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13053. /**
  13054. * Clones the current emitter and returns a copy of it
  13055. * @returns the new emitter
  13056. */
  13057. clone(): SphereParticleEmitter;
  13058. /**
  13059. * Called by the GPUParticleSystem to setup the update shader
  13060. * @param effect defines the update shader
  13061. */
  13062. applyToShader(effect: Effect): void;
  13063. /**
  13064. * Returns a string to use to update the GPU particles update shader
  13065. * @returns a string containng the defines string
  13066. */
  13067. getEffectDefines(): string;
  13068. /**
  13069. * Returns the string "SphereParticleEmitter"
  13070. * @returns a string containing the class name
  13071. */
  13072. getClassName(): string;
  13073. /**
  13074. * Serializes the particle system to a JSON object.
  13075. * @returns the JSON object
  13076. */
  13077. serialize(): any;
  13078. /**
  13079. * Parse properties from a JSON object
  13080. * @param serializationObject defines the JSON object
  13081. */
  13082. parse(serializationObject: any): void;
  13083. }
  13084. /**
  13085. * Particle emitter emitting particles from the inside of a sphere.
  13086. * It emits the particles randomly between two vectors.
  13087. */
  13088. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  13089. /**
  13090. * The min limit of the emission direction.
  13091. */
  13092. direction1: Vector3;
  13093. /**
  13094. * The max limit of the emission direction.
  13095. */
  13096. direction2: Vector3;
  13097. /**
  13098. * Creates a new instance SphereDirectedParticleEmitter
  13099. * @param radius the radius of the emission sphere (1 by default)
  13100. * @param direction1 the min limit of the emission direction (up vector by default)
  13101. * @param direction2 the max limit of the emission direction (up vector by default)
  13102. */
  13103. constructor(radius?: number,
  13104. /**
  13105. * The min limit of the emission direction.
  13106. */
  13107. direction1?: Vector3,
  13108. /**
  13109. * The max limit of the emission direction.
  13110. */
  13111. direction2?: Vector3);
  13112. /**
  13113. * Called by the particle System when the direction is computed for the created particle.
  13114. * @param worldMatrix is the world matrix of the particle system
  13115. * @param directionToUpdate is the direction vector to update with the result
  13116. * @param particle is the particle we are computed the direction for
  13117. */
  13118. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13119. /**
  13120. * Clones the current emitter and returns a copy of it
  13121. * @returns the new emitter
  13122. */
  13123. clone(): SphereDirectedParticleEmitter;
  13124. /**
  13125. * Called by the GPUParticleSystem to setup the update shader
  13126. * @param effect defines the update shader
  13127. */
  13128. applyToShader(effect: Effect): void;
  13129. /**
  13130. * Returns a string to use to update the GPU particles update shader
  13131. * @returns a string containng the defines string
  13132. */
  13133. getEffectDefines(): string;
  13134. /**
  13135. * Returns the string "SphereDirectedParticleEmitter"
  13136. * @returns a string containing the class name
  13137. */
  13138. getClassName(): string;
  13139. /**
  13140. * Serializes the particle system to a JSON object.
  13141. * @returns the JSON object
  13142. */
  13143. serialize(): any;
  13144. /**
  13145. * Parse properties from a JSON object
  13146. * @param serializationObject defines the JSON object
  13147. */
  13148. parse(serializationObject: any): void;
  13149. }
  13150. }
  13151. declare module "babylonjs/Particles/EmitterTypes/customParticleEmitter" {
  13152. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13153. import { Effect } from "babylonjs/Materials/effect";
  13154. import { Particle } from "babylonjs/Particles/particle";
  13155. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13156. import { Nullable } from "babylonjs/types";
  13157. /**
  13158. * Particle emitter emitting particles from a custom list of positions.
  13159. */
  13160. export class CustomParticleEmitter implements IParticleEmitterType {
  13161. /**
  13162. * Gets or sets the position generator that will create the inital position of each particle.
  13163. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  13164. */
  13165. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  13166. /**
  13167. * Gets or sets the destination generator that will create the final destination of each particle.
  13168. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  13169. */
  13170. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  13171. /**
  13172. * Creates a new instance CustomParticleEmitter
  13173. */
  13174. constructor();
  13175. /**
  13176. * Called by the particle System when the direction is computed for the created particle.
  13177. * @param worldMatrix is the world matrix of the particle system
  13178. * @param directionToUpdate is the direction vector to update with the result
  13179. * @param particle is the particle we are computed the direction for
  13180. * @param isLocal defines if the direction should be set in local space
  13181. */
  13182. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13183. /**
  13184. * Called by the particle System when the position is computed for the created particle.
  13185. * @param worldMatrix is the world matrix of the particle system
  13186. * @param positionToUpdate is the position vector to update with the result
  13187. * @param particle is the particle we are computed the position for
  13188. * @param isLocal defines if the position should be set in local space
  13189. */
  13190. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13191. /**
  13192. * Clones the current emitter and returns a copy of it
  13193. * @returns the new emitter
  13194. */
  13195. clone(): CustomParticleEmitter;
  13196. /**
  13197. * Called by the GPUParticleSystem to setup the update shader
  13198. * @param effect defines the update shader
  13199. */
  13200. applyToShader(effect: Effect): void;
  13201. /**
  13202. * Returns a string to use to update the GPU particles update shader
  13203. * @returns a string containng the defines string
  13204. */
  13205. getEffectDefines(): string;
  13206. /**
  13207. * Returns the string "PointParticleEmitter"
  13208. * @returns a string containing the class name
  13209. */
  13210. getClassName(): string;
  13211. /**
  13212. * Serializes the particle system to a JSON object.
  13213. * @returns the JSON object
  13214. */
  13215. serialize(): any;
  13216. /**
  13217. * Parse properties from a JSON object
  13218. * @param serializationObject defines the JSON object
  13219. */
  13220. parse(serializationObject: any): void;
  13221. }
  13222. }
  13223. declare module "babylonjs/Particles/EmitterTypes/meshParticleEmitter" {
  13224. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13225. import { Effect } from "babylonjs/Materials/effect";
  13226. import { Particle } from "babylonjs/Particles/particle";
  13227. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13228. import { Nullable } from "babylonjs/types";
  13229. import { Scene } from "babylonjs/scene";
  13230. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13231. /**
  13232. * Particle emitter emitting particles from the inside of a box.
  13233. * It emits the particles randomly between 2 given directions.
  13234. */
  13235. export class MeshParticleEmitter implements IParticleEmitterType {
  13236. private _indices;
  13237. private _positions;
  13238. private _normals;
  13239. private _storedNormal;
  13240. private _mesh;
  13241. /**
  13242. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13243. */
  13244. direction1: Vector3;
  13245. /**
  13246. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13247. */
  13248. direction2: Vector3;
  13249. /**
  13250. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  13251. */
  13252. useMeshNormalsForDirection: boolean;
  13253. /** Defines the mesh to use as source */
  13254. get mesh(): Nullable<AbstractMesh>;
  13255. set mesh(value: Nullable<AbstractMesh>);
  13256. /**
  13257. * Creates a new instance MeshParticleEmitter
  13258. * @param mesh defines the mesh to use as source
  13259. */
  13260. constructor(mesh?: Nullable<AbstractMesh>);
  13261. /**
  13262. * Called by the particle System when the direction is computed for the created particle.
  13263. * @param worldMatrix is the world matrix of the particle system
  13264. * @param directionToUpdate is the direction vector to update with the result
  13265. * @param particle is the particle we are computed the direction for
  13266. * @param isLocal defines if the direction should be set in local space
  13267. */
  13268. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13269. /**
  13270. * Called by the particle System when the position is computed for the created particle.
  13271. * @param worldMatrix is the world matrix of the particle system
  13272. * @param positionToUpdate is the position vector to update with the result
  13273. * @param particle is the particle we are computed the position for
  13274. * @param isLocal defines if the position should be set in local space
  13275. */
  13276. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13277. /**
  13278. * Clones the current emitter and returns a copy of it
  13279. * @returns the new emitter
  13280. */
  13281. clone(): MeshParticleEmitter;
  13282. /**
  13283. * Called by the GPUParticleSystem to setup the update shader
  13284. * @param effect defines the update shader
  13285. */
  13286. applyToShader(effect: Effect): void;
  13287. /**
  13288. * Returns a string to use to update the GPU particles update shader
  13289. * @returns a string containng the defines string
  13290. */
  13291. getEffectDefines(): string;
  13292. /**
  13293. * Returns the string "BoxParticleEmitter"
  13294. * @returns a string containing the class name
  13295. */
  13296. getClassName(): string;
  13297. /**
  13298. * Serializes the particle system to a JSON object.
  13299. * @returns the JSON object
  13300. */
  13301. serialize(): any;
  13302. /**
  13303. * Parse properties from a JSON object
  13304. * @param serializationObject defines the JSON object
  13305. * @param scene defines the hosting scene
  13306. */
  13307. parse(serializationObject: any, scene: Scene): void;
  13308. }
  13309. }
  13310. declare module "babylonjs/Particles/EmitterTypes/index" {
  13311. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  13312. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  13313. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  13314. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  13315. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13316. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  13317. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  13318. export * from "babylonjs/Particles/EmitterTypes/customParticleEmitter";
  13319. export * from "babylonjs/Particles/EmitterTypes/meshParticleEmitter";
  13320. }
  13321. declare module "babylonjs/Particles/IParticleSystem" {
  13322. import { Nullable } from "babylonjs/types";
  13323. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  13324. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  13325. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13326. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  13327. import { Texture } from "babylonjs/Materials/Textures/texture";
  13328. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  13329. import { Scene } from "babylonjs/scene";
  13330. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  13331. import { Animation } from "babylonjs/Animations/animation";
  13332. /**
  13333. * Interface representing a particle system in Babylon.js.
  13334. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  13335. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  13336. */
  13337. export interface IParticleSystem {
  13338. /**
  13339. * List of animations used by the particle system.
  13340. */
  13341. animations: Animation[];
  13342. /**
  13343. * The id of the Particle system.
  13344. */
  13345. id: string;
  13346. /**
  13347. * The name of the Particle system.
  13348. */
  13349. name: string;
  13350. /**
  13351. * The emitter represents the Mesh or position we are attaching the particle system to.
  13352. */
  13353. emitter: Nullable<AbstractMesh | Vector3>;
  13354. /**
  13355. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  13356. */
  13357. isBillboardBased: boolean;
  13358. /**
  13359. * The rendering group used by the Particle system to chose when to render.
  13360. */
  13361. renderingGroupId: number;
  13362. /**
  13363. * The layer mask we are rendering the particles through.
  13364. */
  13365. layerMask: number;
  13366. /**
  13367. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  13368. */
  13369. updateSpeed: number;
  13370. /**
  13371. * The amount of time the particle system is running (depends of the overall update speed).
  13372. */
  13373. targetStopDuration: number;
  13374. /**
  13375. * The texture used to render each particle. (this can be a spritesheet)
  13376. */
  13377. particleTexture: Nullable<Texture>;
  13378. /**
  13379. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  13380. */
  13381. blendMode: number;
  13382. /**
  13383. * Minimum life time of emitting particles.
  13384. */
  13385. minLifeTime: number;
  13386. /**
  13387. * Maximum life time of emitting particles.
  13388. */
  13389. maxLifeTime: number;
  13390. /**
  13391. * Minimum Size of emitting particles.
  13392. */
  13393. minSize: number;
  13394. /**
  13395. * Maximum Size of emitting particles.
  13396. */
  13397. maxSize: number;
  13398. /**
  13399. * Minimum scale of emitting particles on X axis.
  13400. */
  13401. minScaleX: number;
  13402. /**
  13403. * Maximum scale of emitting particles on X axis.
  13404. */
  13405. maxScaleX: number;
  13406. /**
  13407. * Minimum scale of emitting particles on Y axis.
  13408. */
  13409. minScaleY: number;
  13410. /**
  13411. * Maximum scale of emitting particles on Y axis.
  13412. */
  13413. maxScaleY: number;
  13414. /**
  13415. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  13416. */
  13417. color1: Color4;
  13418. /**
  13419. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  13420. */
  13421. color2: Color4;
  13422. /**
  13423. * Color the particle will have at the end of its lifetime.
  13424. */
  13425. colorDead: Color4;
  13426. /**
  13427. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  13428. */
  13429. emitRate: number;
  13430. /**
  13431. * You can use gravity if you want to give an orientation to your particles.
  13432. */
  13433. gravity: Vector3;
  13434. /**
  13435. * Minimum power of emitting particles.
  13436. */
  13437. minEmitPower: number;
  13438. /**
  13439. * Maximum power of emitting particles.
  13440. */
  13441. maxEmitPower: number;
  13442. /**
  13443. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  13444. */
  13445. minAngularSpeed: number;
  13446. /**
  13447. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  13448. */
  13449. maxAngularSpeed: number;
  13450. /**
  13451. * Gets or sets the minimal initial rotation in radians.
  13452. */
  13453. minInitialRotation: number;
  13454. /**
  13455. * Gets or sets the maximal initial rotation in radians.
  13456. */
  13457. maxInitialRotation: number;
  13458. /**
  13459. * The particle emitter type defines the emitter used by the particle system.
  13460. * It can be for example box, sphere, or cone...
  13461. */
  13462. particleEmitterType: Nullable<IParticleEmitterType>;
  13463. /**
  13464. * Defines the delay in milliseconds before starting the system (0 by default)
  13465. */
  13466. startDelay: number;
  13467. /**
  13468. * 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
  13469. */
  13470. preWarmCycles: number;
  13471. /**
  13472. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  13473. */
  13474. preWarmStepOffset: number;
  13475. /**
  13476. * 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)
  13477. */
  13478. spriteCellChangeSpeed: number;
  13479. /**
  13480. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  13481. */
  13482. startSpriteCellID: number;
  13483. /**
  13484. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  13485. */
  13486. endSpriteCellID: number;
  13487. /**
  13488. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  13489. */
  13490. spriteCellWidth: number;
  13491. /**
  13492. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  13493. */
  13494. spriteCellHeight: number;
  13495. /**
  13496. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  13497. */
  13498. spriteRandomStartCell: boolean;
  13499. /**
  13500. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  13501. */
  13502. isAnimationSheetEnabled: boolean;
  13503. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  13504. translationPivot: Vector2;
  13505. /**
  13506. * Gets or sets a texture used to add random noise to particle positions
  13507. */
  13508. noiseTexture: Nullable<BaseTexture>;
  13509. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  13510. noiseStrength: Vector3;
  13511. /**
  13512. * Gets or sets the billboard mode to use when isBillboardBased = true.
  13513. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  13514. */
  13515. billboardMode: number;
  13516. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  13517. limitVelocityDamping: number;
  13518. /**
  13519. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  13520. */
  13521. beginAnimationOnStart: boolean;
  13522. /**
  13523. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  13524. */
  13525. beginAnimationFrom: number;
  13526. /**
  13527. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  13528. */
  13529. beginAnimationTo: number;
  13530. /**
  13531. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  13532. */
  13533. beginAnimationLoop: boolean;
  13534. /**
  13535. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  13536. */
  13537. disposeOnStop: boolean;
  13538. /**
  13539. * Specifies if the particles are updated in emitter local space or world space
  13540. */
  13541. isLocal: boolean;
  13542. /** Snippet ID if the particle system was created from the snippet server */
  13543. snippetId: string;
  13544. /**
  13545. * Gets the maximum number of particles active at the same time.
  13546. * @returns The max number of active particles.
  13547. */
  13548. getCapacity(): number;
  13549. /**
  13550. * Gets the number of particles active at the same time.
  13551. * @returns The number of active particles.
  13552. */
  13553. getActiveCount(): number;
  13554. /**
  13555. * Gets if the system has been started. (Note: this will still be true after stop is called)
  13556. * @returns True if it has been started, otherwise false.
  13557. */
  13558. isStarted(): boolean;
  13559. /**
  13560. * Animates the particle system for this frame.
  13561. */
  13562. animate(): void;
  13563. /**
  13564. * Renders the particle system in its current state.
  13565. * @returns the current number of particles
  13566. */
  13567. render(): number;
  13568. /**
  13569. * Dispose the particle system and frees its associated resources.
  13570. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  13571. */
  13572. dispose(disposeTexture?: boolean): void;
  13573. /**
  13574. * Clones the particle system.
  13575. * @param name The name of the cloned object
  13576. * @param newEmitter The new emitter to use
  13577. * @returns the cloned particle system
  13578. */
  13579. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  13580. /**
  13581. * Serializes the particle system to a JSON object
  13582. * @param serializeTexture defines if the texture must be serialized as well
  13583. * @returns the JSON object
  13584. */
  13585. serialize(serializeTexture: boolean): any;
  13586. /**
  13587. * Rebuild the particle system
  13588. */
  13589. rebuild(): void;
  13590. /** Force the system to rebuild all gradients that need to be resync */
  13591. forceRefreshGradients(): void;
  13592. /**
  13593. * Starts the particle system and begins to emit
  13594. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  13595. */
  13596. start(delay?: number): void;
  13597. /**
  13598. * Stops the particle system.
  13599. */
  13600. stop(): void;
  13601. /**
  13602. * Remove all active particles
  13603. */
  13604. reset(): void;
  13605. /**
  13606. * Gets a boolean indicating that the system is stopping
  13607. * @returns true if the system is currently stopping
  13608. */
  13609. isStopping(): boolean;
  13610. /**
  13611. * Is this system ready to be used/rendered
  13612. * @return true if the system is ready
  13613. */
  13614. isReady(): boolean;
  13615. /**
  13616. * Returns the string "ParticleSystem"
  13617. * @returns a string containing the class name
  13618. */
  13619. getClassName(): string;
  13620. /**
  13621. * Adds a new color gradient
  13622. * @param gradient defines the gradient to use (between 0 and 1)
  13623. * @param color1 defines the color to affect to the specified gradient
  13624. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  13625. * @returns the current particle system
  13626. */
  13627. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  13628. /**
  13629. * Remove a specific color gradient
  13630. * @param gradient defines the gradient to remove
  13631. * @returns the current particle system
  13632. */
  13633. removeColorGradient(gradient: number): IParticleSystem;
  13634. /**
  13635. * Adds a new size gradient
  13636. * @param gradient defines the gradient to use (between 0 and 1)
  13637. * @param factor defines the size factor to affect to the specified gradient
  13638. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13639. * @returns the current particle system
  13640. */
  13641. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13642. /**
  13643. * Remove a specific size gradient
  13644. * @param gradient defines the gradient to remove
  13645. * @returns the current particle system
  13646. */
  13647. removeSizeGradient(gradient: number): IParticleSystem;
  13648. /**
  13649. * Gets the current list of color gradients.
  13650. * You must use addColorGradient and removeColorGradient to udpate this list
  13651. * @returns the list of color gradients
  13652. */
  13653. getColorGradients(): Nullable<Array<ColorGradient>>;
  13654. /**
  13655. * Gets the current list of size gradients.
  13656. * You must use addSizeGradient and removeSizeGradient to udpate this list
  13657. * @returns the list of size gradients
  13658. */
  13659. getSizeGradients(): Nullable<Array<FactorGradient>>;
  13660. /**
  13661. * Gets the current list of angular speed gradients.
  13662. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  13663. * @returns the list of angular speed gradients
  13664. */
  13665. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  13666. /**
  13667. * Adds a new angular speed gradient
  13668. * @param gradient defines the gradient to use (between 0 and 1)
  13669. * @param factor defines the angular speed to affect to the specified gradient
  13670. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13671. * @returns the current particle system
  13672. */
  13673. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13674. /**
  13675. * Remove a specific angular speed gradient
  13676. * @param gradient defines the gradient to remove
  13677. * @returns the current particle system
  13678. */
  13679. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  13680. /**
  13681. * Gets the current list of velocity gradients.
  13682. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  13683. * @returns the list of velocity gradients
  13684. */
  13685. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  13686. /**
  13687. * Adds a new velocity gradient
  13688. * @param gradient defines the gradient to use (between 0 and 1)
  13689. * @param factor defines the velocity to affect to the specified gradient
  13690. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13691. * @returns the current particle system
  13692. */
  13693. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13694. /**
  13695. * Remove a specific velocity gradient
  13696. * @param gradient defines the gradient to remove
  13697. * @returns the current particle system
  13698. */
  13699. removeVelocityGradient(gradient: number): IParticleSystem;
  13700. /**
  13701. * Gets the current list of limit velocity gradients.
  13702. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  13703. * @returns the list of limit velocity gradients
  13704. */
  13705. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  13706. /**
  13707. * Adds a new limit velocity gradient
  13708. * @param gradient defines the gradient to use (between 0 and 1)
  13709. * @param factor defines the limit velocity to affect to the specified gradient
  13710. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13711. * @returns the current particle system
  13712. */
  13713. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13714. /**
  13715. * Remove a specific limit velocity gradient
  13716. * @param gradient defines the gradient to remove
  13717. * @returns the current particle system
  13718. */
  13719. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  13720. /**
  13721. * Adds a new drag gradient
  13722. * @param gradient defines the gradient to use (between 0 and 1)
  13723. * @param factor defines the drag to affect to the specified gradient
  13724. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13725. * @returns the current particle system
  13726. */
  13727. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13728. /**
  13729. * Remove a specific drag gradient
  13730. * @param gradient defines the gradient to remove
  13731. * @returns the current particle system
  13732. */
  13733. removeDragGradient(gradient: number): IParticleSystem;
  13734. /**
  13735. * Gets the current list of drag gradients.
  13736. * You must use addDragGradient and removeDragGradient to udpate this list
  13737. * @returns the list of drag gradients
  13738. */
  13739. getDragGradients(): Nullable<Array<FactorGradient>>;
  13740. /**
  13741. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  13742. * @param gradient defines the gradient to use (between 0 and 1)
  13743. * @param factor defines the emit rate to affect to the specified gradient
  13744. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13745. * @returns the current particle system
  13746. */
  13747. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13748. /**
  13749. * Remove a specific emit rate gradient
  13750. * @param gradient defines the gradient to remove
  13751. * @returns the current particle system
  13752. */
  13753. removeEmitRateGradient(gradient: number): IParticleSystem;
  13754. /**
  13755. * Gets the current list of emit rate gradients.
  13756. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  13757. * @returns the list of emit rate gradients
  13758. */
  13759. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  13760. /**
  13761. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  13762. * @param gradient defines the gradient to use (between 0 and 1)
  13763. * @param factor defines the start size to affect to the specified gradient
  13764. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13765. * @returns the current particle system
  13766. */
  13767. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13768. /**
  13769. * Remove a specific start size gradient
  13770. * @param gradient defines the gradient to remove
  13771. * @returns the current particle system
  13772. */
  13773. removeStartSizeGradient(gradient: number): IParticleSystem;
  13774. /**
  13775. * Gets the current list of start size gradients.
  13776. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  13777. * @returns the list of start size gradients
  13778. */
  13779. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  13780. /**
  13781. * Adds a new life time gradient
  13782. * @param gradient defines the gradient to use (between 0 and 1)
  13783. * @param factor defines the life time factor to affect to the specified gradient
  13784. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13785. * @returns the current particle system
  13786. */
  13787. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13788. /**
  13789. * Remove a specific life time gradient
  13790. * @param gradient defines the gradient to remove
  13791. * @returns the current particle system
  13792. */
  13793. removeLifeTimeGradient(gradient: number): IParticleSystem;
  13794. /**
  13795. * Gets the current list of life time gradients.
  13796. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  13797. * @returns the list of life time gradients
  13798. */
  13799. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  13800. /**
  13801. * Gets the current list of color gradients.
  13802. * You must use addColorGradient and removeColorGradient to udpate this list
  13803. * @returns the list of color gradients
  13804. */
  13805. getColorGradients(): Nullable<Array<ColorGradient>>;
  13806. /**
  13807. * Adds a new ramp gradient used to remap particle colors
  13808. * @param gradient defines the gradient to use (between 0 and 1)
  13809. * @param color defines the color to affect to the specified gradient
  13810. * @returns the current particle system
  13811. */
  13812. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  13813. /**
  13814. * Gets the current list of ramp gradients.
  13815. * You must use addRampGradient and removeRampGradient to udpate this list
  13816. * @returns the list of ramp gradients
  13817. */
  13818. getRampGradients(): Nullable<Array<Color3Gradient>>;
  13819. /** Gets or sets a boolean indicating that ramp gradients must be used
  13820. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  13821. */
  13822. useRampGradients: boolean;
  13823. /**
  13824. * Adds a new color remap gradient
  13825. * @param gradient defines the gradient to use (between 0 and 1)
  13826. * @param min defines the color remap minimal range
  13827. * @param max defines the color remap maximal range
  13828. * @returns the current particle system
  13829. */
  13830. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13831. /**
  13832. * Gets the current list of color remap gradients.
  13833. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  13834. * @returns the list of color remap gradients
  13835. */
  13836. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  13837. /**
  13838. * Adds a new alpha remap gradient
  13839. * @param gradient defines the gradient to use (between 0 and 1)
  13840. * @param min defines the alpha remap minimal range
  13841. * @param max defines the alpha remap maximal range
  13842. * @returns the current particle system
  13843. */
  13844. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13845. /**
  13846. * Gets the current list of alpha remap gradients.
  13847. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  13848. * @returns the list of alpha remap gradients
  13849. */
  13850. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  13851. /**
  13852. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  13853. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  13854. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  13855. * @returns the emitter
  13856. */
  13857. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  13858. /**
  13859. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  13860. * @param radius The radius of the hemisphere to emit from
  13861. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  13862. * @returns the emitter
  13863. */
  13864. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  13865. /**
  13866. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  13867. * @param radius The radius of the sphere to emit from
  13868. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  13869. * @returns the emitter
  13870. */
  13871. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  13872. /**
  13873. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  13874. * @param radius The radius of the sphere to emit from
  13875. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  13876. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  13877. * @returns the emitter
  13878. */
  13879. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  13880. /**
  13881. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  13882. * @param radius The radius of the emission cylinder
  13883. * @param height The height of the emission cylinder
  13884. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  13885. * @param directionRandomizer How much to randomize the particle direction [0-1]
  13886. * @returns the emitter
  13887. */
  13888. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  13889. /**
  13890. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  13891. * @param radius The radius of the cylinder to emit from
  13892. * @param height The height of the emission cylinder
  13893. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13894. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  13895. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  13896. * @returns the emitter
  13897. */
  13898. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  13899. /**
  13900. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  13901. * @param radius The radius of the cone to emit from
  13902. * @param angle The base angle of the cone
  13903. * @returns the emitter
  13904. */
  13905. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  13906. /**
  13907. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  13908. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  13909. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  13910. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  13911. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  13912. * @returns the emitter
  13913. */
  13914. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  13915. /**
  13916. * Get hosting scene
  13917. * @returns the scene
  13918. */
  13919. getScene(): Scene;
  13920. }
  13921. }
  13922. declare module "babylonjs/Meshes/transformNode" {
  13923. import { DeepImmutable } from "babylonjs/types";
  13924. import { Observable } from "babylonjs/Misc/observable";
  13925. import { Nullable } from "babylonjs/types";
  13926. import { Camera } from "babylonjs/Cameras/camera";
  13927. import { Scene } from "babylonjs/scene";
  13928. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  13929. import { Node } from "babylonjs/node";
  13930. import { Bone } from "babylonjs/Bones/bone";
  13931. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13932. import { Space } from "babylonjs/Maths/math.axis";
  13933. /**
  13934. * 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.
  13935. * @see https://doc.babylonjs.com/how_to/transformnode
  13936. */
  13937. export class TransformNode extends Node {
  13938. /**
  13939. * Object will not rotate to face the camera
  13940. */
  13941. static BILLBOARDMODE_NONE: number;
  13942. /**
  13943. * Object will rotate to face the camera but only on the x axis
  13944. */
  13945. static BILLBOARDMODE_X: number;
  13946. /**
  13947. * Object will rotate to face the camera but only on the y axis
  13948. */
  13949. static BILLBOARDMODE_Y: number;
  13950. /**
  13951. * Object will rotate to face the camera but only on the z axis
  13952. */
  13953. static BILLBOARDMODE_Z: number;
  13954. /**
  13955. * Object will rotate to face the camera
  13956. */
  13957. static BILLBOARDMODE_ALL: number;
  13958. /**
  13959. * Object will rotate to face the camera's position instead of orientation
  13960. */
  13961. static BILLBOARDMODE_USE_POSITION: number;
  13962. private _forward;
  13963. private _forwardInverted;
  13964. private _up;
  13965. private _right;
  13966. private _rightInverted;
  13967. private _position;
  13968. private _rotation;
  13969. private _rotationQuaternion;
  13970. protected _scaling: Vector3;
  13971. protected _isDirty: boolean;
  13972. private _transformToBoneReferal;
  13973. private _isAbsoluteSynced;
  13974. private _billboardMode;
  13975. /**
  13976. * Gets or sets the billboard mode. Default is 0.
  13977. *
  13978. * | Value | Type | Description |
  13979. * | --- | --- | --- |
  13980. * | 0 | BILLBOARDMODE_NONE | |
  13981. * | 1 | BILLBOARDMODE_X | |
  13982. * | 2 | BILLBOARDMODE_Y | |
  13983. * | 4 | BILLBOARDMODE_Z | |
  13984. * | 7 | BILLBOARDMODE_ALL | |
  13985. *
  13986. */
  13987. get billboardMode(): number;
  13988. set billboardMode(value: number);
  13989. private _preserveParentRotationForBillboard;
  13990. /**
  13991. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  13992. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  13993. */
  13994. get preserveParentRotationForBillboard(): boolean;
  13995. set preserveParentRotationForBillboard(value: boolean);
  13996. /**
  13997. * 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
  13998. */
  13999. scalingDeterminant: number;
  14000. private _infiniteDistance;
  14001. /**
  14002. * Gets or sets the distance of the object to max, often used by skybox
  14003. */
  14004. get infiniteDistance(): boolean;
  14005. set infiniteDistance(value: boolean);
  14006. /**
  14007. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  14008. * By default the system will update normals to compensate
  14009. */
  14010. ignoreNonUniformScaling: boolean;
  14011. /**
  14012. * 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
  14013. */
  14014. reIntegrateRotationIntoRotationQuaternion: boolean;
  14015. /** @hidden */
  14016. _poseMatrix: Nullable<Matrix>;
  14017. /** @hidden */
  14018. _localMatrix: Matrix;
  14019. private _usePivotMatrix;
  14020. private _absolutePosition;
  14021. private _absoluteScaling;
  14022. private _absoluteRotationQuaternion;
  14023. private _pivotMatrix;
  14024. private _pivotMatrixInverse;
  14025. protected _postMultiplyPivotMatrix: boolean;
  14026. protected _isWorldMatrixFrozen: boolean;
  14027. /** @hidden */
  14028. _indexInSceneTransformNodesArray: number;
  14029. /**
  14030. * An event triggered after the world matrix is updated
  14031. */
  14032. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14033. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14034. /**
  14035. * Gets a string identifying the name of the class
  14036. * @returns "TransformNode" string
  14037. */
  14038. getClassName(): string;
  14039. /**
  14040. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14041. */
  14042. get position(): Vector3;
  14043. set position(newPosition: Vector3);
  14044. /**
  14045. * 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)).
  14046. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  14047. */
  14048. get rotation(): Vector3;
  14049. set rotation(newRotation: Vector3);
  14050. /**
  14051. * 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)).
  14052. */
  14053. get scaling(): Vector3;
  14054. set scaling(newScaling: Vector3);
  14055. /**
  14056. * 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).
  14057. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  14058. */
  14059. get rotationQuaternion(): Nullable<Quaternion>;
  14060. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  14061. /**
  14062. * The forward direction of that transform in world space.
  14063. */
  14064. get forward(): Vector3;
  14065. /**
  14066. * The up direction of that transform in world space.
  14067. */
  14068. get up(): Vector3;
  14069. /**
  14070. * The right direction of that transform in world space.
  14071. */
  14072. get right(): Vector3;
  14073. /**
  14074. * Copies the parameter passed Matrix into the mesh Pose matrix.
  14075. * @param matrix the matrix to copy the pose from
  14076. * @returns this TransformNode.
  14077. */
  14078. updatePoseMatrix(matrix: Matrix): TransformNode;
  14079. /**
  14080. * Returns the mesh Pose matrix.
  14081. * @returns the pose matrix
  14082. */
  14083. getPoseMatrix(): Matrix;
  14084. /** @hidden */
  14085. _isSynchronized(): boolean;
  14086. /** @hidden */
  14087. _initCache(): void;
  14088. /**
  14089. * Flag the transform node as dirty (Forcing it to update everything)
  14090. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  14091. * @returns this transform node
  14092. */
  14093. markAsDirty(property: string): TransformNode;
  14094. /**
  14095. * Returns the current mesh absolute position.
  14096. * Returns a Vector3.
  14097. */
  14098. get absolutePosition(): Vector3;
  14099. /**
  14100. * Returns the current mesh absolute scaling.
  14101. * Returns a Vector3.
  14102. */
  14103. get absoluteScaling(): Vector3;
  14104. /**
  14105. * Returns the current mesh absolute rotation.
  14106. * Returns a Quaternion.
  14107. */
  14108. get absoluteRotationQuaternion(): Quaternion;
  14109. /**
  14110. * Sets a new matrix to apply before all other transformation
  14111. * @param matrix defines the transform matrix
  14112. * @returns the current TransformNode
  14113. */
  14114. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14115. /**
  14116. * Sets a new pivot matrix to the current node
  14117. * @param matrix defines the new pivot matrix to use
  14118. * @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
  14119. * @returns the current TransformNode
  14120. */
  14121. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14122. /**
  14123. * Returns the mesh pivot matrix.
  14124. * Default : Identity.
  14125. * @returns the matrix
  14126. */
  14127. getPivotMatrix(): Matrix;
  14128. /**
  14129. * Instantiate (when possible) or clone that node with its hierarchy
  14130. * @param newParent defines the new parent to use for the instance (or clone)
  14131. * @param options defines options to configure how copy is done
  14132. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  14133. * @returns an instance (or a clone) of the current node with its hiearchy
  14134. */
  14135. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  14136. doNotInstantiate: boolean;
  14137. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  14138. /**
  14139. * Prevents the World matrix to be computed any longer
  14140. * @param newWorldMatrix defines an optional matrix to use as world matrix
  14141. * @returns the TransformNode.
  14142. */
  14143. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  14144. /**
  14145. * Allows back the World matrix computation.
  14146. * @returns the TransformNode.
  14147. */
  14148. unfreezeWorldMatrix(): this;
  14149. /**
  14150. * True if the World matrix has been frozen.
  14151. */
  14152. get isWorldMatrixFrozen(): boolean;
  14153. /**
  14154. * Retuns the mesh absolute position in the World.
  14155. * @returns a Vector3.
  14156. */
  14157. getAbsolutePosition(): Vector3;
  14158. /**
  14159. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14160. * @param absolutePosition the absolute position to set
  14161. * @returns the TransformNode.
  14162. */
  14163. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14164. /**
  14165. * Sets the mesh position in its local space.
  14166. * @param vector3 the position to set in localspace
  14167. * @returns the TransformNode.
  14168. */
  14169. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14170. /**
  14171. * Returns the mesh position in the local space from the current World matrix values.
  14172. * @returns a new Vector3.
  14173. */
  14174. getPositionExpressedInLocalSpace(): Vector3;
  14175. /**
  14176. * Translates the mesh along the passed Vector3 in its local space.
  14177. * @param vector3 the distance to translate in localspace
  14178. * @returns the TransformNode.
  14179. */
  14180. locallyTranslate(vector3: Vector3): TransformNode;
  14181. private static _lookAtVectorCache;
  14182. /**
  14183. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14184. * @param targetPoint the position (must be in same space as current mesh) to look at
  14185. * @param yawCor optional yaw (y-axis) correction in radians
  14186. * @param pitchCor optional pitch (x-axis) correction in radians
  14187. * @param rollCor optional roll (z-axis) correction in radians
  14188. * @param space the choosen space of the target
  14189. * @returns the TransformNode.
  14190. */
  14191. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14192. /**
  14193. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14194. * This Vector3 is expressed in the World space.
  14195. * @param localAxis axis to rotate
  14196. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14197. */
  14198. getDirection(localAxis: Vector3): Vector3;
  14199. /**
  14200. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14201. * localAxis is expressed in the mesh local space.
  14202. * result is computed in the Wordl space from the mesh World matrix.
  14203. * @param localAxis axis to rotate
  14204. * @param result the resulting transformnode
  14205. * @returns this TransformNode.
  14206. */
  14207. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14208. /**
  14209. * Sets this transform node rotation to the given local axis.
  14210. * @param localAxis the axis in local space
  14211. * @param yawCor optional yaw (y-axis) correction in radians
  14212. * @param pitchCor optional pitch (x-axis) correction in radians
  14213. * @param rollCor optional roll (z-axis) correction in radians
  14214. * @returns this TransformNode
  14215. */
  14216. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14217. /**
  14218. * Sets a new pivot point to the current node
  14219. * @param point defines the new pivot point to use
  14220. * @param space defines if the point is in world or local space (local by default)
  14221. * @returns the current TransformNode
  14222. */
  14223. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14224. /**
  14225. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14226. * @returns the pivot point
  14227. */
  14228. getPivotPoint(): Vector3;
  14229. /**
  14230. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14231. * @param result the vector3 to store the result
  14232. * @returns this TransformNode.
  14233. */
  14234. getPivotPointToRef(result: Vector3): TransformNode;
  14235. /**
  14236. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14237. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14238. */
  14239. getAbsolutePivotPoint(): Vector3;
  14240. /**
  14241. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14242. * @param result vector3 to store the result
  14243. * @returns this TransformNode.
  14244. */
  14245. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14246. /**
  14247. * Defines the passed node as the parent of the current node.
  14248. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14249. * @see https://doc.babylonjs.com/how_to/parenting
  14250. * @param node the node ot set as the parent
  14251. * @returns this TransformNode.
  14252. */
  14253. setParent(node: Nullable<Node>): TransformNode;
  14254. private _nonUniformScaling;
  14255. /**
  14256. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14257. */
  14258. get nonUniformScaling(): boolean;
  14259. /** @hidden */
  14260. _updateNonUniformScalingState(value: boolean): boolean;
  14261. /**
  14262. * Attach the current TransformNode to another TransformNode associated with a bone
  14263. * @param bone Bone affecting the TransformNode
  14264. * @param affectedTransformNode TransformNode associated with the bone
  14265. * @returns this object
  14266. */
  14267. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14268. /**
  14269. * Detach the transform node if its associated with a bone
  14270. * @returns this object
  14271. */
  14272. detachFromBone(): TransformNode;
  14273. private static _rotationAxisCache;
  14274. /**
  14275. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14276. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14277. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14278. * The passed axis is also normalized.
  14279. * @param axis the axis to rotate around
  14280. * @param amount the amount to rotate in radians
  14281. * @param space Space to rotate in (Default: local)
  14282. * @returns the TransformNode.
  14283. */
  14284. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14285. /**
  14286. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14287. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14288. * The passed axis is also normalized. .
  14289. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14290. * @param point the point to rotate around
  14291. * @param axis the axis to rotate around
  14292. * @param amount the amount to rotate in radians
  14293. * @returns the TransformNode
  14294. */
  14295. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14296. /**
  14297. * Translates the mesh along the axis vector for the passed distance in the given space.
  14298. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14299. * @param axis the axis to translate in
  14300. * @param distance the distance to translate
  14301. * @param space Space to rotate in (Default: local)
  14302. * @returns the TransformNode.
  14303. */
  14304. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14305. /**
  14306. * Adds a rotation step to the mesh current rotation.
  14307. * x, y, z are Euler angles expressed in radians.
  14308. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14309. * This means this rotation is made in the mesh local space only.
  14310. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14311. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14312. * ```javascript
  14313. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14314. * ```
  14315. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14316. * 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.
  14317. * @param x Rotation to add
  14318. * @param y Rotation to add
  14319. * @param z Rotation to add
  14320. * @returns the TransformNode.
  14321. */
  14322. addRotation(x: number, y: number, z: number): TransformNode;
  14323. /**
  14324. * @hidden
  14325. */
  14326. protected _getEffectiveParent(): Nullable<Node>;
  14327. /**
  14328. * Computes the world matrix of the node
  14329. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14330. * @returns the world matrix
  14331. */
  14332. computeWorldMatrix(force?: boolean): Matrix;
  14333. /**
  14334. * Resets this nodeTransform's local matrix to Matrix.Identity().
  14335. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  14336. */
  14337. resetLocalMatrix(independentOfChildren?: boolean): void;
  14338. protected _afterComputeWorldMatrix(): void;
  14339. /**
  14340. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14341. * @param func callback function to add
  14342. *
  14343. * @returns the TransformNode.
  14344. */
  14345. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14346. /**
  14347. * Removes a registered callback function.
  14348. * @param func callback function to remove
  14349. * @returns the TransformNode.
  14350. */
  14351. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14352. /**
  14353. * Gets the position of the current mesh in camera space
  14354. * @param camera defines the camera to use
  14355. * @returns a position
  14356. */
  14357. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14358. /**
  14359. * Returns the distance from the mesh to the active camera
  14360. * @param camera defines the camera to use
  14361. * @returns the distance
  14362. */
  14363. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14364. /**
  14365. * Clone the current transform node
  14366. * @param name Name of the new clone
  14367. * @param newParent New parent for the clone
  14368. * @param doNotCloneChildren Do not clone children hierarchy
  14369. * @returns the new transform node
  14370. */
  14371. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14372. /**
  14373. * Serializes the objects information.
  14374. * @param currentSerializationObject defines the object to serialize in
  14375. * @returns the serialized object
  14376. */
  14377. serialize(currentSerializationObject?: any): any;
  14378. /**
  14379. * Returns a new TransformNode object parsed from the source provided.
  14380. * @param parsedTransformNode is the source.
  14381. * @param scene the scne the object belongs to
  14382. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14383. * @returns a new TransformNode object parsed from the source provided.
  14384. */
  14385. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14386. /**
  14387. * Get all child-transformNodes of this node
  14388. * @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
  14389. * @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
  14390. * @returns an array of TransformNode
  14391. */
  14392. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14393. /**
  14394. * Releases resources associated with this transform node.
  14395. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14396. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14397. */
  14398. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14399. /**
  14400. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14401. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14402. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14403. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14404. * @returns the current mesh
  14405. */
  14406. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14407. private _syncAbsoluteScalingAndRotation;
  14408. }
  14409. }
  14410. declare module "babylonjs/Animations/animationPropertiesOverride" {
  14411. /**
  14412. * Class used to override all child animations of a given target
  14413. */
  14414. export class AnimationPropertiesOverride {
  14415. /**
  14416. * Gets or sets a value indicating if animation blending must be used
  14417. */
  14418. enableBlending: boolean;
  14419. /**
  14420. * Gets or sets the blending speed to use when enableBlending is true
  14421. */
  14422. blendingSpeed: number;
  14423. /**
  14424. * Gets or sets the default loop mode to use
  14425. */
  14426. loopMode: number;
  14427. }
  14428. }
  14429. declare module "babylonjs/Bones/bone" {
  14430. import { Skeleton } from "babylonjs/Bones/skeleton";
  14431. import { Vector3, Quaternion, Matrix } from "babylonjs/Maths/math.vector";
  14432. import { Nullable } from "babylonjs/types";
  14433. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14434. import { TransformNode } from "babylonjs/Meshes/transformNode";
  14435. import { Node } from "babylonjs/node";
  14436. import { Space } from "babylonjs/Maths/math.axis";
  14437. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  14438. /**
  14439. * Class used to store bone information
  14440. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  14441. */
  14442. export class Bone extends Node {
  14443. /**
  14444. * defines the bone name
  14445. */
  14446. name: string;
  14447. private static _tmpVecs;
  14448. private static _tmpQuat;
  14449. private static _tmpMats;
  14450. /**
  14451. * Gets the list of child bones
  14452. */
  14453. children: Bone[];
  14454. /** Gets the animations associated with this bone */
  14455. animations: import("babylonjs/Animations/animation").Animation[];
  14456. /**
  14457. * Gets or sets bone length
  14458. */
  14459. length: number;
  14460. /**
  14461. * @hidden Internal only
  14462. * Set this value to map this bone to a different index in the transform matrices
  14463. * Set this value to -1 to exclude the bone from the transform matrices
  14464. */
  14465. _index: Nullable<number>;
  14466. private _skeleton;
  14467. private _localMatrix;
  14468. private _restPose;
  14469. private _baseMatrix;
  14470. private _absoluteTransform;
  14471. private _invertedAbsoluteTransform;
  14472. private _parent;
  14473. private _scalingDeterminant;
  14474. private _worldTransform;
  14475. private _localScaling;
  14476. private _localRotation;
  14477. private _localPosition;
  14478. private _needToDecompose;
  14479. private _needToCompose;
  14480. /** @hidden */
  14481. _linkedTransformNode: Nullable<TransformNode>;
  14482. /** @hidden */
  14483. _waitingTransformNodeId: Nullable<string>;
  14484. /** @hidden */
  14485. get _matrix(): Matrix;
  14486. /** @hidden */
  14487. set _matrix(value: Matrix);
  14488. /**
  14489. * Create a new bone
  14490. * @param name defines the bone name
  14491. * @param skeleton defines the parent skeleton
  14492. * @param parentBone defines the parent (can be null if the bone is the root)
  14493. * @param localMatrix defines the local matrix
  14494. * @param restPose defines the rest pose matrix
  14495. * @param baseMatrix defines the base matrix
  14496. * @param index defines index of the bone in the hiearchy
  14497. */
  14498. constructor(
  14499. /**
  14500. * defines the bone name
  14501. */
  14502. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  14503. /**
  14504. * Gets the current object class name.
  14505. * @return the class name
  14506. */
  14507. getClassName(): string;
  14508. /**
  14509. * Gets the parent skeleton
  14510. * @returns a skeleton
  14511. */
  14512. getSkeleton(): Skeleton;
  14513. /**
  14514. * Gets parent bone
  14515. * @returns a bone or null if the bone is the root of the bone hierarchy
  14516. */
  14517. getParent(): Nullable<Bone>;
  14518. /**
  14519. * Returns an array containing the root bones
  14520. * @returns an array containing the root bones
  14521. */
  14522. getChildren(): Array<Bone>;
  14523. /**
  14524. * Gets the node index in matrix array generated for rendering
  14525. * @returns the node index
  14526. */
  14527. getIndex(): number;
  14528. /**
  14529. * Sets the parent bone
  14530. * @param parent defines the parent (can be null if the bone is the root)
  14531. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  14532. */
  14533. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  14534. /**
  14535. * Gets the local matrix
  14536. * @returns a matrix
  14537. */
  14538. getLocalMatrix(): Matrix;
  14539. /**
  14540. * Gets the base matrix (initial matrix which remains unchanged)
  14541. * @returns a matrix
  14542. */
  14543. getBaseMatrix(): Matrix;
  14544. /**
  14545. * Gets the rest pose matrix
  14546. * @returns a matrix
  14547. */
  14548. getRestPose(): Matrix;
  14549. /**
  14550. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  14551. */
  14552. getWorldMatrix(): Matrix;
  14553. /**
  14554. * Sets the local matrix to rest pose matrix
  14555. */
  14556. returnToRest(): void;
  14557. /**
  14558. * Gets the inverse of the absolute transform matrix.
  14559. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  14560. * @returns a matrix
  14561. */
  14562. getInvertedAbsoluteTransform(): Matrix;
  14563. /**
  14564. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  14565. * @returns a matrix
  14566. */
  14567. getAbsoluteTransform(): Matrix;
  14568. /**
  14569. * Links with the given transform node.
  14570. * The local matrix of this bone is copied from the transform node every frame.
  14571. * @param transformNode defines the transform node to link to
  14572. */
  14573. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  14574. /**
  14575. * Gets the node used to drive the bone's transformation
  14576. * @returns a transform node or null
  14577. */
  14578. getTransformNode(): Nullable<TransformNode>;
  14579. /** Gets or sets current position (in local space) */
  14580. get position(): Vector3;
  14581. set position(newPosition: Vector3);
  14582. /** Gets or sets current rotation (in local space) */
  14583. get rotation(): Vector3;
  14584. set rotation(newRotation: Vector3);
  14585. /** Gets or sets current rotation quaternion (in local space) */
  14586. get rotationQuaternion(): Quaternion;
  14587. set rotationQuaternion(newRotation: Quaternion);
  14588. /** Gets or sets current scaling (in local space) */
  14589. get scaling(): Vector3;
  14590. set scaling(newScaling: Vector3);
  14591. /**
  14592. * Gets the animation properties override
  14593. */
  14594. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  14595. private _decompose;
  14596. private _compose;
  14597. /**
  14598. * Update the base and local matrices
  14599. * @param matrix defines the new base or local matrix
  14600. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  14601. * @param updateLocalMatrix defines if the local matrix should be updated
  14602. */
  14603. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  14604. /** @hidden */
  14605. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  14606. /**
  14607. * Flag the bone as dirty (Forcing it to update everything)
  14608. */
  14609. markAsDirty(): void;
  14610. /** @hidden */
  14611. _markAsDirtyAndCompose(): void;
  14612. private _markAsDirtyAndDecompose;
  14613. /**
  14614. * Translate the bone in local or world space
  14615. * @param vec The amount to translate the bone
  14616. * @param space The space that the translation is in
  14617. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14618. */
  14619. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14620. /**
  14621. * Set the postion of the bone in local or world space
  14622. * @param position The position to set the bone
  14623. * @param space The space that the position is in
  14624. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14625. */
  14626. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14627. /**
  14628. * Set the absolute position of the bone (world space)
  14629. * @param position The position to set the bone
  14630. * @param mesh The mesh that this bone is attached to
  14631. */
  14632. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  14633. /**
  14634. * Scale the bone on the x, y and z axes (in local space)
  14635. * @param x The amount to scale the bone on the x axis
  14636. * @param y The amount to scale the bone on the y axis
  14637. * @param z The amount to scale the bone on the z axis
  14638. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  14639. */
  14640. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  14641. /**
  14642. * Set the bone scaling in local space
  14643. * @param scale defines the scaling vector
  14644. */
  14645. setScale(scale: Vector3): void;
  14646. /**
  14647. * Gets the current scaling in local space
  14648. * @returns the current scaling vector
  14649. */
  14650. getScale(): Vector3;
  14651. /**
  14652. * Gets the current scaling in local space and stores it in a target vector
  14653. * @param result defines the target vector
  14654. */
  14655. getScaleToRef(result: Vector3): void;
  14656. /**
  14657. * Set the yaw, pitch, and roll of the bone in local or world space
  14658. * @param yaw The rotation of the bone on the y axis
  14659. * @param pitch The rotation of the bone on the x axis
  14660. * @param roll The rotation of the bone on the z axis
  14661. * @param space The space that the axes of rotation are in
  14662. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14663. */
  14664. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  14665. /**
  14666. * Add a rotation to the bone on an axis in local or world space
  14667. * @param axis The axis to rotate the bone on
  14668. * @param amount The amount to rotate the bone
  14669. * @param space The space that the axis is in
  14670. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14671. */
  14672. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  14673. /**
  14674. * Set the rotation of the bone to a particular axis angle in local or world space
  14675. * @param axis The axis to rotate the bone on
  14676. * @param angle The angle that the bone should be rotated to
  14677. * @param space The space that the axis is in
  14678. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14679. */
  14680. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  14681. /**
  14682. * Set the euler rotation of the bone in local of world space
  14683. * @param rotation The euler rotation that the bone should be set to
  14684. * @param space The space that the rotation is in
  14685. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14686. */
  14687. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14688. /**
  14689. * Set the quaternion rotation of the bone in local of world space
  14690. * @param quat The quaternion rotation that the bone should be set to
  14691. * @param space The space that the rotation is in
  14692. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14693. */
  14694. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  14695. /**
  14696. * Set the rotation matrix of the bone in local of world space
  14697. * @param rotMat The rotation matrix that the bone should be set to
  14698. * @param space The space that the rotation is in
  14699. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14700. */
  14701. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  14702. private _rotateWithMatrix;
  14703. private _getNegativeRotationToRef;
  14704. /**
  14705. * Get the position of the bone in local or world space
  14706. * @param space The space that the returned position is in
  14707. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14708. * @returns The position of the bone
  14709. */
  14710. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14711. /**
  14712. * Copy the position of the bone to a vector3 in local or world space
  14713. * @param space The space that the returned position is in
  14714. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14715. * @param result The vector3 to copy the position to
  14716. */
  14717. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  14718. /**
  14719. * Get the absolute position of the bone (world space)
  14720. * @param mesh The mesh that this bone is attached to
  14721. * @returns The absolute position of the bone
  14722. */
  14723. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  14724. /**
  14725. * Copy the absolute position of the bone (world space) to the result param
  14726. * @param mesh The mesh that this bone is attached to
  14727. * @param result The vector3 to copy the absolute position to
  14728. */
  14729. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  14730. /**
  14731. * Compute the absolute transforms of this bone and its children
  14732. */
  14733. computeAbsoluteTransforms(): void;
  14734. /**
  14735. * Get the world direction from an axis that is in the local space of the bone
  14736. * @param localAxis The local direction that is used to compute the world direction
  14737. * @param mesh The mesh that this bone is attached to
  14738. * @returns The world direction
  14739. */
  14740. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14741. /**
  14742. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  14743. * @param localAxis The local direction that is used to compute the world direction
  14744. * @param mesh The mesh that this bone is attached to
  14745. * @param result The vector3 that the world direction will be copied to
  14746. */
  14747. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14748. /**
  14749. * Get the euler rotation of the bone in local or world space
  14750. * @param space The space that the rotation should be in
  14751. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14752. * @returns The euler rotation
  14753. */
  14754. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14755. /**
  14756. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  14757. * @param space The space that the rotation should be in
  14758. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14759. * @param result The vector3 that the rotation should be copied to
  14760. */
  14761. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14762. /**
  14763. * Get the quaternion rotation of the bone in either local or world space
  14764. * @param space The space that the rotation should be in
  14765. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14766. * @returns The quaternion rotation
  14767. */
  14768. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  14769. /**
  14770. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  14771. * @param space The space that the rotation should be in
  14772. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14773. * @param result The quaternion that the rotation should be copied to
  14774. */
  14775. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  14776. /**
  14777. * Get the rotation matrix of the bone in local or world space
  14778. * @param space The space that the rotation should be in
  14779. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14780. * @returns The rotation matrix
  14781. */
  14782. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  14783. /**
  14784. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  14785. * @param space The space that the rotation should be in
  14786. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14787. * @param result The quaternion that the rotation should be copied to
  14788. */
  14789. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  14790. /**
  14791. * Get the world position of a point that is in the local space of the bone
  14792. * @param position The local position
  14793. * @param mesh The mesh that this bone is attached to
  14794. * @returns The world position
  14795. */
  14796. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14797. /**
  14798. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  14799. * @param position The local position
  14800. * @param mesh The mesh that this bone is attached to
  14801. * @param result The vector3 that the world position should be copied to
  14802. */
  14803. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14804. /**
  14805. * Get the local position of a point that is in world space
  14806. * @param position The world position
  14807. * @param mesh The mesh that this bone is attached to
  14808. * @returns The local position
  14809. */
  14810. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14811. /**
  14812. * Get the local position of a point that is in world space and copy it to the result param
  14813. * @param position The world position
  14814. * @param mesh The mesh that this bone is attached to
  14815. * @param result The vector3 that the local position should be copied to
  14816. */
  14817. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14818. }
  14819. }
  14820. declare module "babylonjs/Animations/runtimeAnimation" {
  14821. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  14822. import { Animatable } from "babylonjs/Animations/animatable";
  14823. import { Scene } from "babylonjs/scene";
  14824. /**
  14825. * Defines a runtime animation
  14826. */
  14827. export class RuntimeAnimation {
  14828. private _events;
  14829. /**
  14830. * The current frame of the runtime animation
  14831. */
  14832. private _currentFrame;
  14833. /**
  14834. * The animation used by the runtime animation
  14835. */
  14836. private _animation;
  14837. /**
  14838. * The target of the runtime animation
  14839. */
  14840. private _target;
  14841. /**
  14842. * The initiating animatable
  14843. */
  14844. private _host;
  14845. /**
  14846. * The original value of the runtime animation
  14847. */
  14848. private _originalValue;
  14849. /**
  14850. * The original blend value of the runtime animation
  14851. */
  14852. private _originalBlendValue;
  14853. /**
  14854. * The offsets cache of the runtime animation
  14855. */
  14856. private _offsetsCache;
  14857. /**
  14858. * The high limits cache of the runtime animation
  14859. */
  14860. private _highLimitsCache;
  14861. /**
  14862. * Specifies if the runtime animation has been stopped
  14863. */
  14864. private _stopped;
  14865. /**
  14866. * The blending factor of the runtime animation
  14867. */
  14868. private _blendingFactor;
  14869. /**
  14870. * The BabylonJS scene
  14871. */
  14872. private _scene;
  14873. /**
  14874. * The current value of the runtime animation
  14875. */
  14876. private _currentValue;
  14877. /** @hidden */
  14878. _animationState: _IAnimationState;
  14879. /**
  14880. * The active target of the runtime animation
  14881. */
  14882. private _activeTargets;
  14883. private _currentActiveTarget;
  14884. private _directTarget;
  14885. /**
  14886. * The target path of the runtime animation
  14887. */
  14888. private _targetPath;
  14889. /**
  14890. * The weight of the runtime animation
  14891. */
  14892. private _weight;
  14893. /**
  14894. * The ratio offset of the runtime animation
  14895. */
  14896. private _ratioOffset;
  14897. /**
  14898. * The previous delay of the runtime animation
  14899. */
  14900. private _previousDelay;
  14901. /**
  14902. * The previous ratio of the runtime animation
  14903. */
  14904. private _previousRatio;
  14905. private _enableBlending;
  14906. private _keys;
  14907. private _minFrame;
  14908. private _maxFrame;
  14909. private _minValue;
  14910. private _maxValue;
  14911. private _targetIsArray;
  14912. /**
  14913. * Gets the current frame of the runtime animation
  14914. */
  14915. get currentFrame(): number;
  14916. /**
  14917. * Gets the weight of the runtime animation
  14918. */
  14919. get weight(): number;
  14920. /**
  14921. * Gets the current value of the runtime animation
  14922. */
  14923. get currentValue(): any;
  14924. /**
  14925. * Gets the target path of the runtime animation
  14926. */
  14927. get targetPath(): string;
  14928. /**
  14929. * Gets the actual target of the runtime animation
  14930. */
  14931. get target(): any;
  14932. /**
  14933. * Gets the additive state of the runtime animation
  14934. */
  14935. get isAdditive(): boolean;
  14936. /** @hidden */
  14937. _onLoop: () => void;
  14938. /**
  14939. * Create a new RuntimeAnimation object
  14940. * @param target defines the target of the animation
  14941. * @param animation defines the source animation object
  14942. * @param scene defines the hosting scene
  14943. * @param host defines the initiating Animatable
  14944. */
  14945. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  14946. private _preparePath;
  14947. /**
  14948. * Gets the animation from the runtime animation
  14949. */
  14950. get animation(): Animation;
  14951. /**
  14952. * Resets the runtime animation to the beginning
  14953. * @param restoreOriginal defines whether to restore the target property to the original value
  14954. */
  14955. reset(restoreOriginal?: boolean): void;
  14956. /**
  14957. * Specifies if the runtime animation is stopped
  14958. * @returns Boolean specifying if the runtime animation is stopped
  14959. */
  14960. isStopped(): boolean;
  14961. /**
  14962. * Disposes of the runtime animation
  14963. */
  14964. dispose(): void;
  14965. /**
  14966. * Apply the interpolated value to the target
  14967. * @param currentValue defines the value computed by the animation
  14968. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  14969. */
  14970. setValue(currentValue: any, weight: number): void;
  14971. private _getOriginalValues;
  14972. private _setValue;
  14973. /**
  14974. * Gets the loop pmode of the runtime animation
  14975. * @returns Loop Mode
  14976. */
  14977. private _getCorrectLoopMode;
  14978. /**
  14979. * Move the current animation to a given frame
  14980. * @param frame defines the frame to move to
  14981. */
  14982. goToFrame(frame: number): void;
  14983. /**
  14984. * @hidden Internal use only
  14985. */
  14986. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  14987. /**
  14988. * Execute the current animation
  14989. * @param delay defines the delay to add to the current frame
  14990. * @param from defines the lower bound of the animation range
  14991. * @param to defines the upper bound of the animation range
  14992. * @param loop defines if the current animation must loop
  14993. * @param speedRatio defines the current speed ratio
  14994. * @param weight defines the weight of the animation (default is -1 so no weight)
  14995. * @param onLoop optional callback called when animation loops
  14996. * @returns a boolean indicating if the animation is running
  14997. */
  14998. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  14999. }
  15000. }
  15001. declare module "babylonjs/Animations/animatable" {
  15002. import { Animation } from "babylonjs/Animations/animation";
  15003. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  15004. import { Nullable } from "babylonjs/types";
  15005. import { Observable } from "babylonjs/Misc/observable";
  15006. import { Scene } from "babylonjs/scene";
  15007. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  15008. import { Node } from "babylonjs/node";
  15009. /**
  15010. * Class used to store an actual running animation
  15011. */
  15012. export class Animatable {
  15013. /** defines the target object */
  15014. target: any;
  15015. /** defines the starting frame number (default is 0) */
  15016. fromFrame: number;
  15017. /** defines the ending frame number (default is 100) */
  15018. toFrame: number;
  15019. /** defines if the animation must loop (default is false) */
  15020. loopAnimation: boolean;
  15021. /** defines a callback to call when animation ends if it is not looping */
  15022. onAnimationEnd?: (() => void) | null | undefined;
  15023. /** defines a callback to call when animation loops */
  15024. onAnimationLoop?: (() => void) | null | undefined;
  15025. /** defines whether the animation should be evaluated additively */
  15026. isAdditive: boolean;
  15027. private _localDelayOffset;
  15028. private _pausedDelay;
  15029. private _runtimeAnimations;
  15030. private _paused;
  15031. private _scene;
  15032. private _speedRatio;
  15033. private _weight;
  15034. private _syncRoot;
  15035. /**
  15036. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  15037. * This will only apply for non looping animation (default is true)
  15038. */
  15039. disposeOnEnd: boolean;
  15040. /**
  15041. * Gets a boolean indicating if the animation has started
  15042. */
  15043. animationStarted: boolean;
  15044. /**
  15045. * Observer raised when the animation ends
  15046. */
  15047. onAnimationEndObservable: Observable<Animatable>;
  15048. /**
  15049. * Observer raised when the animation loops
  15050. */
  15051. onAnimationLoopObservable: Observable<Animatable>;
  15052. /**
  15053. * Gets the root Animatable used to synchronize and normalize animations
  15054. */
  15055. get syncRoot(): Nullable<Animatable>;
  15056. /**
  15057. * Gets the current frame of the first RuntimeAnimation
  15058. * Used to synchronize Animatables
  15059. */
  15060. get masterFrame(): number;
  15061. /**
  15062. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  15063. */
  15064. get weight(): number;
  15065. set weight(value: number);
  15066. /**
  15067. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  15068. */
  15069. get speedRatio(): number;
  15070. set speedRatio(value: number);
  15071. /**
  15072. * Creates a new Animatable
  15073. * @param scene defines the hosting scene
  15074. * @param target defines the target object
  15075. * @param fromFrame defines the starting frame number (default is 0)
  15076. * @param toFrame defines the ending frame number (default is 100)
  15077. * @param loopAnimation defines if the animation must loop (default is false)
  15078. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  15079. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  15080. * @param animations defines a group of animation to add to the new Animatable
  15081. * @param onAnimationLoop defines a callback to call when animation loops
  15082. * @param isAdditive defines whether the animation should be evaluated additively
  15083. */
  15084. constructor(scene: Scene,
  15085. /** defines the target object */
  15086. target: any,
  15087. /** defines the starting frame number (default is 0) */
  15088. fromFrame?: number,
  15089. /** defines the ending frame number (default is 100) */
  15090. toFrame?: number,
  15091. /** defines if the animation must loop (default is false) */
  15092. loopAnimation?: boolean, speedRatio?: number,
  15093. /** defines a callback to call when animation ends if it is not looping */
  15094. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  15095. /** defines a callback to call when animation loops */
  15096. onAnimationLoop?: (() => void) | null | undefined,
  15097. /** defines whether the animation should be evaluated additively */
  15098. isAdditive?: boolean);
  15099. /**
  15100. * Synchronize and normalize current Animatable with a source Animatable
  15101. * This is useful when using animation weights and when animations are not of the same length
  15102. * @param root defines the root Animatable to synchronize with
  15103. * @returns the current Animatable
  15104. */
  15105. syncWith(root: Animatable): Animatable;
  15106. /**
  15107. * Gets the list of runtime animations
  15108. * @returns an array of RuntimeAnimation
  15109. */
  15110. getAnimations(): RuntimeAnimation[];
  15111. /**
  15112. * Adds more animations to the current animatable
  15113. * @param target defines the target of the animations
  15114. * @param animations defines the new animations to add
  15115. */
  15116. appendAnimations(target: any, animations: Animation[]): void;
  15117. /**
  15118. * Gets the source animation for a specific property
  15119. * @param property defines the propertyu to look for
  15120. * @returns null or the source animation for the given property
  15121. */
  15122. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  15123. /**
  15124. * Gets the runtime animation for a specific property
  15125. * @param property defines the propertyu to look for
  15126. * @returns null or the runtime animation for the given property
  15127. */
  15128. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  15129. /**
  15130. * Resets the animatable to its original state
  15131. */
  15132. reset(): void;
  15133. /**
  15134. * Allows the animatable to blend with current running animations
  15135. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  15136. * @param blendingSpeed defines the blending speed to use
  15137. */
  15138. enableBlending(blendingSpeed: number): void;
  15139. /**
  15140. * Disable animation blending
  15141. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  15142. */
  15143. disableBlending(): void;
  15144. /**
  15145. * Jump directly to a given frame
  15146. * @param frame defines the frame to jump to
  15147. */
  15148. goToFrame(frame: number): void;
  15149. /**
  15150. * Pause the animation
  15151. */
  15152. pause(): void;
  15153. /**
  15154. * Restart the animation
  15155. */
  15156. restart(): void;
  15157. private _raiseOnAnimationEnd;
  15158. /**
  15159. * Stop and delete the current animation
  15160. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  15161. * @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)
  15162. */
  15163. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  15164. /**
  15165. * Wait asynchronously for the animation to end
  15166. * @returns a promise which will be fullfilled when the animation ends
  15167. */
  15168. waitAsync(): Promise<Animatable>;
  15169. /** @hidden */
  15170. _animate(delay: number): boolean;
  15171. }
  15172. module "babylonjs/scene" {
  15173. interface Scene {
  15174. /** @hidden */
  15175. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  15176. /** @hidden */
  15177. _processLateAnimationBindingsForMatrices(holder: {
  15178. totalWeight: number;
  15179. totalAdditiveWeight: number;
  15180. animations: RuntimeAnimation[];
  15181. additiveAnimations: RuntimeAnimation[];
  15182. originalValue: Matrix;
  15183. }): any;
  15184. /** @hidden */
  15185. _processLateAnimationBindingsForQuaternions(holder: {
  15186. totalWeight: number;
  15187. totalAdditiveWeight: number;
  15188. animations: RuntimeAnimation[];
  15189. additiveAnimations: RuntimeAnimation[];
  15190. originalValue: Quaternion;
  15191. }, refQuaternion: Quaternion): Quaternion;
  15192. /** @hidden */
  15193. _processLateAnimationBindings(): void;
  15194. /**
  15195. * Will start the animation sequence of a given target
  15196. * @param target defines the target
  15197. * @param from defines from which frame should animation start
  15198. * @param to defines until which frame should animation run.
  15199. * @param weight defines the weight to apply to the animation (1.0 by default)
  15200. * @param loop defines if the animation loops
  15201. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15202. * @param onAnimationEnd defines the function to be executed when the animation ends
  15203. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15204. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  15205. * @param onAnimationLoop defines the callback to call when an animation loops
  15206. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15207. * @returns the animatable object created for this animation
  15208. */
  15209. 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;
  15210. /**
  15211. * Will start the animation sequence of a given target
  15212. * @param target defines the target
  15213. * @param from defines from which frame should animation start
  15214. * @param to defines until which frame should animation run.
  15215. * @param loop defines if the animation loops
  15216. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15217. * @param onAnimationEnd defines the function to be executed when the animation ends
  15218. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15219. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  15220. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  15221. * @param onAnimationLoop defines the callback to call when an animation loops
  15222. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15223. * @returns the animatable object created for this animation
  15224. */
  15225. 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;
  15226. /**
  15227. * Will start the animation sequence of a given target and its hierarchy
  15228. * @param target defines the target
  15229. * @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.
  15230. * @param from defines from which frame should animation start
  15231. * @param to defines until which frame should animation run.
  15232. * @param loop defines if the animation loops
  15233. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15234. * @param onAnimationEnd defines the function to be executed when the animation ends
  15235. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15236. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  15237. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  15238. * @param onAnimationLoop defines the callback to call when an animation loops
  15239. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15240. * @returns the list of created animatables
  15241. */
  15242. 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[];
  15243. /**
  15244. * Begin a new animation on a given node
  15245. * @param target defines the target where the animation will take place
  15246. * @param animations defines the list of animations to start
  15247. * @param from defines the initial value
  15248. * @param to defines the final value
  15249. * @param loop defines if you want animation to loop (off by default)
  15250. * @param speedRatio defines the speed ratio to apply to all animations
  15251. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  15252. * @param onAnimationLoop defines the callback to call when an animation loops
  15253. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15254. * @returns the list of created animatables
  15255. */
  15256. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  15257. /**
  15258. * Begin a new animation on a given node and its hierarchy
  15259. * @param target defines the root node where the animation will take place
  15260. * @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.
  15261. * @param animations defines the list of animations to start
  15262. * @param from defines the initial value
  15263. * @param to defines the final value
  15264. * @param loop defines if you want animation to loop (off by default)
  15265. * @param speedRatio defines the speed ratio to apply to all animations
  15266. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  15267. * @param onAnimationLoop defines the callback to call when an animation loops
  15268. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15269. * @returns the list of animatables created for all nodes
  15270. */
  15271. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  15272. /**
  15273. * Gets the animatable associated with a specific target
  15274. * @param target defines the target of the animatable
  15275. * @returns the required animatable if found
  15276. */
  15277. getAnimatableByTarget(target: any): Nullable<Animatable>;
  15278. /**
  15279. * Gets all animatables associated with a given target
  15280. * @param target defines the target to look animatables for
  15281. * @returns an array of Animatables
  15282. */
  15283. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  15284. /**
  15285. * Stops and removes all animations that have been applied to the scene
  15286. */
  15287. stopAllAnimations(): void;
  15288. /**
  15289. * Gets the current delta time used by animation engine
  15290. */
  15291. deltaTime: number;
  15292. }
  15293. }
  15294. module "babylonjs/Bones/bone" {
  15295. interface Bone {
  15296. /**
  15297. * Copy an animation range from another bone
  15298. * @param source defines the source bone
  15299. * @param rangeName defines the range name to copy
  15300. * @param frameOffset defines the frame offset
  15301. * @param rescaleAsRequired defines if rescaling must be applied if required
  15302. * @param skelDimensionsRatio defines the scaling ratio
  15303. * @returns true if operation was successful
  15304. */
  15305. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  15306. }
  15307. }
  15308. }
  15309. declare module "babylonjs/Bones/skeleton" {
  15310. import { Bone } from "babylonjs/Bones/bone";
  15311. import { Observable } from "babylonjs/Misc/observable";
  15312. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  15313. import { Scene } from "babylonjs/scene";
  15314. import { Nullable } from "babylonjs/types";
  15315. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15316. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  15317. import { Animatable } from "babylonjs/Animations/animatable";
  15318. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  15319. import { Animation } from "babylonjs/Animations/animation";
  15320. import { AnimationRange } from "babylonjs/Animations/animationRange";
  15321. import { IInspectable } from "babylonjs/Misc/iInspectable";
  15322. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  15323. /**
  15324. * Class used to handle skinning animations
  15325. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  15326. */
  15327. export class Skeleton implements IAnimatable {
  15328. /** defines the skeleton name */
  15329. name: string;
  15330. /** defines the skeleton Id */
  15331. id: string;
  15332. /**
  15333. * Defines the list of child bones
  15334. */
  15335. bones: Bone[];
  15336. /**
  15337. * Defines an estimate of the dimension of the skeleton at rest
  15338. */
  15339. dimensionsAtRest: Vector3;
  15340. /**
  15341. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  15342. */
  15343. needInitialSkinMatrix: boolean;
  15344. /**
  15345. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  15346. */
  15347. overrideMesh: Nullable<AbstractMesh>;
  15348. /**
  15349. * Gets the list of animations attached to this skeleton
  15350. */
  15351. animations: Array<Animation>;
  15352. private _scene;
  15353. private _isDirty;
  15354. private _transformMatrices;
  15355. private _transformMatrixTexture;
  15356. private _meshesWithPoseMatrix;
  15357. private _animatables;
  15358. private _identity;
  15359. private _synchronizedWithMesh;
  15360. private _ranges;
  15361. private _lastAbsoluteTransformsUpdateId;
  15362. private _canUseTextureForBones;
  15363. private _uniqueId;
  15364. /** @hidden */
  15365. _numBonesWithLinkedTransformNode: number;
  15366. /** @hidden */
  15367. _hasWaitingData: Nullable<boolean>;
  15368. /**
  15369. * Specifies if the skeleton should be serialized
  15370. */
  15371. doNotSerialize: boolean;
  15372. private _useTextureToStoreBoneMatrices;
  15373. /**
  15374. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  15375. * Please note that this option is not available if the hardware does not support it
  15376. */
  15377. get useTextureToStoreBoneMatrices(): boolean;
  15378. set useTextureToStoreBoneMatrices(value: boolean);
  15379. private _animationPropertiesOverride;
  15380. /**
  15381. * Gets or sets the animation properties override
  15382. */
  15383. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  15384. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  15385. /**
  15386. * List of inspectable custom properties (used by the Inspector)
  15387. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15388. */
  15389. inspectableCustomProperties: IInspectable[];
  15390. /**
  15391. * An observable triggered before computing the skeleton's matrices
  15392. */
  15393. onBeforeComputeObservable: Observable<Skeleton>;
  15394. /**
  15395. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  15396. */
  15397. get isUsingTextureForMatrices(): boolean;
  15398. /**
  15399. * Gets the unique ID of this skeleton
  15400. */
  15401. get uniqueId(): number;
  15402. /**
  15403. * Creates a new skeleton
  15404. * @param name defines the skeleton name
  15405. * @param id defines the skeleton Id
  15406. * @param scene defines the hosting scene
  15407. */
  15408. constructor(
  15409. /** defines the skeleton name */
  15410. name: string,
  15411. /** defines the skeleton Id */
  15412. id: string, scene: Scene);
  15413. /**
  15414. * Gets the current object class name.
  15415. * @return the class name
  15416. */
  15417. getClassName(): string;
  15418. /**
  15419. * Returns an array containing the root bones
  15420. * @returns an array containing the root bones
  15421. */
  15422. getChildren(): Array<Bone>;
  15423. /**
  15424. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  15425. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  15426. * @returns a Float32Array containing matrices data
  15427. */
  15428. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  15429. /**
  15430. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  15431. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  15432. * @returns a raw texture containing the data
  15433. */
  15434. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  15435. /**
  15436. * Gets the current hosting scene
  15437. * @returns a scene object
  15438. */
  15439. getScene(): Scene;
  15440. /**
  15441. * Gets a string representing the current skeleton data
  15442. * @param fullDetails defines a boolean indicating if we want a verbose version
  15443. * @returns a string representing the current skeleton data
  15444. */
  15445. toString(fullDetails?: boolean): string;
  15446. /**
  15447. * Get bone's index searching by name
  15448. * @param name defines bone's name to search for
  15449. * @return the indice of the bone. Returns -1 if not found
  15450. */
  15451. getBoneIndexByName(name: string): number;
  15452. /**
  15453. * Creater a new animation range
  15454. * @param name defines the name of the range
  15455. * @param from defines the start key
  15456. * @param to defines the end key
  15457. */
  15458. createAnimationRange(name: string, from: number, to: number): void;
  15459. /**
  15460. * Delete a specific animation range
  15461. * @param name defines the name of the range
  15462. * @param deleteFrames defines if frames must be removed as well
  15463. */
  15464. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  15465. /**
  15466. * Gets a specific animation range
  15467. * @param name defines the name of the range to look for
  15468. * @returns the requested animation range or null if not found
  15469. */
  15470. getAnimationRange(name: string): Nullable<AnimationRange>;
  15471. /**
  15472. * Gets the list of all animation ranges defined on this skeleton
  15473. * @returns an array
  15474. */
  15475. getAnimationRanges(): Nullable<AnimationRange>[];
  15476. /**
  15477. * Copy animation range from a source skeleton.
  15478. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  15479. * @param source defines the source skeleton
  15480. * @param name defines the name of the range to copy
  15481. * @param rescaleAsRequired defines if rescaling must be applied if required
  15482. * @returns true if operation was successful
  15483. */
  15484. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  15485. /**
  15486. * Forces the skeleton to go to rest pose
  15487. */
  15488. returnToRest(): void;
  15489. private _getHighestAnimationFrame;
  15490. /**
  15491. * Begin a specific animation range
  15492. * @param name defines the name of the range to start
  15493. * @param loop defines if looping must be turned on (false by default)
  15494. * @param speedRatio defines the speed ratio to apply (1 by default)
  15495. * @param onAnimationEnd defines a callback which will be called when animation will end
  15496. * @returns a new animatable
  15497. */
  15498. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  15499. /**
  15500. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  15501. * @param skeleton defines the Skeleton containing the animation range to convert
  15502. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  15503. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  15504. * @returns the original skeleton
  15505. */
  15506. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  15507. /** @hidden */
  15508. _markAsDirty(): void;
  15509. /** @hidden */
  15510. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  15511. /** @hidden */
  15512. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  15513. private _computeTransformMatrices;
  15514. /**
  15515. * Build all resources required to render a skeleton
  15516. */
  15517. prepare(): void;
  15518. /**
  15519. * Gets the list of animatables currently running for this skeleton
  15520. * @returns an array of animatables
  15521. */
  15522. getAnimatables(): IAnimatable[];
  15523. /**
  15524. * Clone the current skeleton
  15525. * @param name defines the name of the new skeleton
  15526. * @param id defines the id of the new skeleton
  15527. * @returns the new skeleton
  15528. */
  15529. clone(name: string, id?: string): Skeleton;
  15530. /**
  15531. * Enable animation blending for this skeleton
  15532. * @param blendingSpeed defines the blending speed to apply
  15533. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  15534. */
  15535. enableBlending(blendingSpeed?: number): void;
  15536. /**
  15537. * Releases all resources associated with the current skeleton
  15538. */
  15539. dispose(): void;
  15540. /**
  15541. * Serialize the skeleton in a JSON object
  15542. * @returns a JSON object
  15543. */
  15544. serialize(): any;
  15545. /**
  15546. * Creates a new skeleton from serialized data
  15547. * @param parsedSkeleton defines the serialized data
  15548. * @param scene defines the hosting scene
  15549. * @returns a new skeleton
  15550. */
  15551. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  15552. /**
  15553. * Compute all node absolute transforms
  15554. * @param forceUpdate defines if computation must be done even if cache is up to date
  15555. */
  15556. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  15557. /**
  15558. * Gets the root pose matrix
  15559. * @returns a matrix
  15560. */
  15561. getPoseMatrix(): Nullable<Matrix>;
  15562. /**
  15563. * Sorts bones per internal index
  15564. */
  15565. sortBones(): void;
  15566. private _sortBones;
  15567. }
  15568. }
  15569. declare module "babylonjs/Meshes/instancedMesh" {
  15570. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  15571. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  15572. import { Camera } from "babylonjs/Cameras/camera";
  15573. import { Node } from "babylonjs/node";
  15574. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15575. import { Mesh } from "babylonjs/Meshes/mesh";
  15576. import { Material } from "babylonjs/Materials/material";
  15577. import { Skeleton } from "babylonjs/Bones/skeleton";
  15578. import { Light } from "babylonjs/Lights/light";
  15579. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  15580. /**
  15581. * Creates an instance based on a source mesh.
  15582. */
  15583. export class InstancedMesh extends AbstractMesh {
  15584. private _sourceMesh;
  15585. private _currentLOD;
  15586. /** @hidden */
  15587. _indexInSourceMeshInstanceArray: number;
  15588. constructor(name: string, source: Mesh);
  15589. /**
  15590. * Returns the string "InstancedMesh".
  15591. */
  15592. getClassName(): string;
  15593. /** Gets the list of lights affecting that mesh */
  15594. get lightSources(): Light[];
  15595. _resyncLightSources(): void;
  15596. _resyncLightSource(light: Light): void;
  15597. _removeLightSource(light: Light, dispose: boolean): void;
  15598. /**
  15599. * If the source mesh receives shadows
  15600. */
  15601. get receiveShadows(): boolean;
  15602. /**
  15603. * The material of the source mesh
  15604. */
  15605. get material(): Nullable<Material>;
  15606. /**
  15607. * Visibility of the source mesh
  15608. */
  15609. get visibility(): number;
  15610. /**
  15611. * Skeleton of the source mesh
  15612. */
  15613. get skeleton(): Nullable<Skeleton>;
  15614. /**
  15615. * Rendering ground id of the source mesh
  15616. */
  15617. get renderingGroupId(): number;
  15618. set renderingGroupId(value: number);
  15619. /**
  15620. * Returns the total number of vertices (integer).
  15621. */
  15622. getTotalVertices(): number;
  15623. /**
  15624. * Returns a positive integer : the total number of indices in this mesh geometry.
  15625. * @returns the numner of indices or zero if the mesh has no geometry.
  15626. */
  15627. getTotalIndices(): number;
  15628. /**
  15629. * The source mesh of the instance
  15630. */
  15631. get sourceMesh(): Mesh;
  15632. /**
  15633. * Is this node ready to be used/rendered
  15634. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  15635. * @return {boolean} is it ready
  15636. */
  15637. isReady(completeCheck?: boolean): boolean;
  15638. /**
  15639. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  15640. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  15641. * @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.
  15642. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  15643. */
  15644. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  15645. /**
  15646. * Sets the vertex data of the mesh geometry for the requested `kind`.
  15647. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  15648. * The `data` are either a numeric array either a Float32Array.
  15649. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  15650. * 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).
  15651. * Note that a new underlying VertexBuffer object is created each call.
  15652. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  15653. *
  15654. * Possible `kind` values :
  15655. * - VertexBuffer.PositionKind
  15656. * - VertexBuffer.UVKind
  15657. * - VertexBuffer.UV2Kind
  15658. * - VertexBuffer.UV3Kind
  15659. * - VertexBuffer.UV4Kind
  15660. * - VertexBuffer.UV5Kind
  15661. * - VertexBuffer.UV6Kind
  15662. * - VertexBuffer.ColorKind
  15663. * - VertexBuffer.MatricesIndicesKind
  15664. * - VertexBuffer.MatricesIndicesExtraKind
  15665. * - VertexBuffer.MatricesWeightsKind
  15666. * - VertexBuffer.MatricesWeightsExtraKind
  15667. *
  15668. * Returns the Mesh.
  15669. */
  15670. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  15671. /**
  15672. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  15673. * If the mesh has no geometry, it is simply returned as it is.
  15674. * The `data` are either a numeric array either a Float32Array.
  15675. * No new underlying VertexBuffer object is created.
  15676. * 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.
  15677. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  15678. *
  15679. * Possible `kind` values :
  15680. * - VertexBuffer.PositionKind
  15681. * - VertexBuffer.UVKind
  15682. * - VertexBuffer.UV2Kind
  15683. * - VertexBuffer.UV3Kind
  15684. * - VertexBuffer.UV4Kind
  15685. * - VertexBuffer.UV5Kind
  15686. * - VertexBuffer.UV6Kind
  15687. * - VertexBuffer.ColorKind
  15688. * - VertexBuffer.MatricesIndicesKind
  15689. * - VertexBuffer.MatricesIndicesExtraKind
  15690. * - VertexBuffer.MatricesWeightsKind
  15691. * - VertexBuffer.MatricesWeightsExtraKind
  15692. *
  15693. * Returns the Mesh.
  15694. */
  15695. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  15696. /**
  15697. * Sets the mesh indices.
  15698. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  15699. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  15700. * This method creates a new index buffer each call.
  15701. * Returns the Mesh.
  15702. */
  15703. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  15704. /**
  15705. * Boolean : True if the mesh owns the requested kind of data.
  15706. */
  15707. isVerticesDataPresent(kind: string): boolean;
  15708. /**
  15709. * Returns an array of indices (IndicesArray).
  15710. */
  15711. getIndices(): Nullable<IndicesArray>;
  15712. get _positions(): Nullable<Vector3[]>;
  15713. /**
  15714. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  15715. * This means the mesh underlying bounding box and sphere are recomputed.
  15716. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  15717. * @returns the current mesh
  15718. */
  15719. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  15720. /** @hidden */
  15721. _preActivate(): InstancedMesh;
  15722. /** @hidden */
  15723. _activate(renderId: number, intermediateRendering: boolean): boolean;
  15724. /** @hidden */
  15725. _postActivate(): void;
  15726. getWorldMatrix(): Matrix;
  15727. get isAnInstance(): boolean;
  15728. /**
  15729. * Returns the current associated LOD AbstractMesh.
  15730. */
  15731. getLOD(camera: Camera): AbstractMesh;
  15732. /** @hidden */
  15733. _preActivateForIntermediateRendering(renderId: number): Mesh;
  15734. /** @hidden */
  15735. _syncSubMeshes(): InstancedMesh;
  15736. /** @hidden */
  15737. _generatePointsArray(): boolean;
  15738. /**
  15739. * Creates a new InstancedMesh from the current mesh.
  15740. * - name (string) : the cloned mesh name
  15741. * - newParent (optional Node) : the optional Node to parent the clone to.
  15742. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  15743. *
  15744. * Returns the clone.
  15745. */
  15746. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  15747. /**
  15748. * Disposes the InstancedMesh.
  15749. * Returns nothing.
  15750. */
  15751. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  15752. }
  15753. module "babylonjs/Meshes/mesh" {
  15754. interface Mesh {
  15755. /**
  15756. * Register a custom buffer that will be instanced
  15757. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  15758. * @param kind defines the buffer kind
  15759. * @param stride defines the stride in floats
  15760. */
  15761. registerInstancedBuffer(kind: string, stride: number): void;
  15762. /** @hidden */
  15763. _userInstancedBuffersStorage: {
  15764. data: {
  15765. [key: string]: Float32Array;
  15766. };
  15767. sizes: {
  15768. [key: string]: number;
  15769. };
  15770. vertexBuffers: {
  15771. [key: string]: Nullable<VertexBuffer>;
  15772. };
  15773. strides: {
  15774. [key: string]: number;
  15775. };
  15776. };
  15777. }
  15778. }
  15779. module "babylonjs/Meshes/abstractMesh" {
  15780. interface AbstractMesh {
  15781. /**
  15782. * Object used to store instanced buffers defined by user
  15783. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  15784. */
  15785. instancedBuffers: {
  15786. [key: string]: any;
  15787. };
  15788. }
  15789. }
  15790. }
  15791. declare module "babylonjs/Materials/shaderMaterial" {
  15792. import { Scene } from "babylonjs/scene";
  15793. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  15794. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15795. import { Mesh } from "babylonjs/Meshes/mesh";
  15796. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  15797. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  15798. import { Material } from "babylonjs/Materials/material";
  15799. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  15800. /**
  15801. * Defines the options associated with the creation of a shader material.
  15802. */
  15803. export interface IShaderMaterialOptions {
  15804. /**
  15805. * Does the material work in alpha blend mode
  15806. */
  15807. needAlphaBlending: boolean;
  15808. /**
  15809. * Does the material work in alpha test mode
  15810. */
  15811. needAlphaTesting: boolean;
  15812. /**
  15813. * The list of attribute names used in the shader
  15814. */
  15815. attributes: string[];
  15816. /**
  15817. * The list of unifrom names used in the shader
  15818. */
  15819. uniforms: string[];
  15820. /**
  15821. * The list of UBO names used in the shader
  15822. */
  15823. uniformBuffers: string[];
  15824. /**
  15825. * The list of sampler names used in the shader
  15826. */
  15827. samplers: string[];
  15828. /**
  15829. * The list of defines used in the shader
  15830. */
  15831. defines: string[];
  15832. }
  15833. /**
  15834. * 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.
  15835. *
  15836. * This returned material effects how the mesh will look based on the code in the shaders.
  15837. *
  15838. * @see http://doc.babylonjs.com/how_to/shader_material
  15839. */
  15840. export class ShaderMaterial extends Material {
  15841. private _shaderPath;
  15842. private _options;
  15843. private _textures;
  15844. private _textureArrays;
  15845. private _floats;
  15846. private _ints;
  15847. private _floatsArrays;
  15848. private _colors3;
  15849. private _colors3Arrays;
  15850. private _colors4;
  15851. private _colors4Arrays;
  15852. private _vectors2;
  15853. private _vectors3;
  15854. private _vectors4;
  15855. private _matrices;
  15856. private _matrixArrays;
  15857. private _matrices3x3;
  15858. private _matrices2x2;
  15859. private _vectors2Arrays;
  15860. private _vectors3Arrays;
  15861. private _vectors4Arrays;
  15862. private _cachedWorldViewMatrix;
  15863. private _cachedWorldViewProjectionMatrix;
  15864. private _renderId;
  15865. private _multiview;
  15866. /**
  15867. * Instantiate a new shader material.
  15868. * 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.
  15869. * This returned material effects how the mesh will look based on the code in the shaders.
  15870. * @see http://doc.babylonjs.com/how_to/shader_material
  15871. * @param name Define the name of the material in the scene
  15872. * @param scene Define the scene the material belongs to
  15873. * @param shaderPath Defines the route to the shader code in one of three ways:
  15874. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  15875. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  15876. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  15877. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  15878. * @param options Define the options used to create the shader
  15879. */
  15880. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  15881. /**
  15882. * Gets the shader path used to define the shader code
  15883. * It can be modified to trigger a new compilation
  15884. */
  15885. get shaderPath(): any;
  15886. /**
  15887. * Sets the shader path used to define the shader code
  15888. * It can be modified to trigger a new compilation
  15889. */
  15890. set shaderPath(shaderPath: any);
  15891. /**
  15892. * Gets the options used to compile the shader.
  15893. * They can be modified to trigger a new compilation
  15894. */
  15895. get options(): IShaderMaterialOptions;
  15896. /**
  15897. * Gets the current class name of the material e.g. "ShaderMaterial"
  15898. * Mainly use in serialization.
  15899. * @returns the class name
  15900. */
  15901. getClassName(): string;
  15902. /**
  15903. * Specifies if the material will require alpha blending
  15904. * @returns a boolean specifying if alpha blending is needed
  15905. */
  15906. needAlphaBlending(): boolean;
  15907. /**
  15908. * Specifies if this material should be rendered in alpha test mode
  15909. * @returns a boolean specifying if an alpha test is needed.
  15910. */
  15911. needAlphaTesting(): boolean;
  15912. private _checkUniform;
  15913. /**
  15914. * Set a texture in the shader.
  15915. * @param name Define the name of the uniform samplers as defined in the shader
  15916. * @param texture Define the texture to bind to this sampler
  15917. * @return the material itself allowing "fluent" like uniform updates
  15918. */
  15919. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  15920. /**
  15921. * Set a texture array in the shader.
  15922. * @param name Define the name of the uniform sampler array as defined in the shader
  15923. * @param textures Define the list of textures to bind to this sampler
  15924. * @return the material itself allowing "fluent" like uniform updates
  15925. */
  15926. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  15927. /**
  15928. * Set a float in the shader.
  15929. * @param name Define the name of the uniform as defined in the shader
  15930. * @param value Define the value to give to the uniform
  15931. * @return the material itself allowing "fluent" like uniform updates
  15932. */
  15933. setFloat(name: string, value: number): ShaderMaterial;
  15934. /**
  15935. * Set a int in the shader.
  15936. * @param name Define the name of the uniform as defined in the shader
  15937. * @param value Define the value to give to the uniform
  15938. * @return the material itself allowing "fluent" like uniform updates
  15939. */
  15940. setInt(name: string, value: number): ShaderMaterial;
  15941. /**
  15942. * Set an array of floats in the shader.
  15943. * @param name Define the name of the uniform as defined in the shader
  15944. * @param value Define the value to give to the uniform
  15945. * @return the material itself allowing "fluent" like uniform updates
  15946. */
  15947. setFloats(name: string, value: number[]): ShaderMaterial;
  15948. /**
  15949. * Set a vec3 in the shader from a Color3.
  15950. * @param name Define the name of the uniform as defined in the shader
  15951. * @param value Define the value to give to the uniform
  15952. * @return the material itself allowing "fluent" like uniform updates
  15953. */
  15954. setColor3(name: string, value: Color3): ShaderMaterial;
  15955. /**
  15956. * Set a vec3 array in the shader from a Color3 array.
  15957. * @param name Define the name of the uniform as defined in the shader
  15958. * @param value Define the value to give to the uniform
  15959. * @return the material itself allowing "fluent" like uniform updates
  15960. */
  15961. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  15962. /**
  15963. * Set a vec4 in the shader from a Color4.
  15964. * @param name Define the name of the uniform as defined in the shader
  15965. * @param value Define the value to give to the uniform
  15966. * @return the material itself allowing "fluent" like uniform updates
  15967. */
  15968. setColor4(name: string, value: Color4): ShaderMaterial;
  15969. /**
  15970. * Set a vec4 array in the shader from a Color4 array.
  15971. * @param name Define the name of the uniform as defined in the shader
  15972. * @param value Define the value to give to the uniform
  15973. * @return the material itself allowing "fluent" like uniform updates
  15974. */
  15975. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  15976. /**
  15977. * Set a vec2 in the shader from a Vector2.
  15978. * @param name Define the name of the uniform as defined in the shader
  15979. * @param value Define the value to give to the uniform
  15980. * @return the material itself allowing "fluent" like uniform updates
  15981. */
  15982. setVector2(name: string, value: Vector2): ShaderMaterial;
  15983. /**
  15984. * Set a vec3 in the shader from a Vector3.
  15985. * @param name Define the name of the uniform as defined in the shader
  15986. * @param value Define the value to give to the uniform
  15987. * @return the material itself allowing "fluent" like uniform updates
  15988. */
  15989. setVector3(name: string, value: Vector3): ShaderMaterial;
  15990. /**
  15991. * Set a vec4 in the shader from a Vector4.
  15992. * @param name Define the name of the uniform as defined in the shader
  15993. * @param value Define the value to give to the uniform
  15994. * @return the material itself allowing "fluent" like uniform updates
  15995. */
  15996. setVector4(name: string, value: Vector4): ShaderMaterial;
  15997. /**
  15998. * Set a mat4 in the shader from a Matrix.
  15999. * @param name Define the name of the uniform as defined in the shader
  16000. * @param value Define the value to give to the uniform
  16001. * @return the material itself allowing "fluent" like uniform updates
  16002. */
  16003. setMatrix(name: string, value: Matrix): ShaderMaterial;
  16004. /**
  16005. * Set a float32Array in the shader from a matrix array.
  16006. * @param name Define the name of the uniform as defined in the shader
  16007. * @param value Define the value to give to the uniform
  16008. * @return the material itself allowing "fluent" like uniform updates
  16009. */
  16010. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  16011. /**
  16012. * Set a mat3 in the shader from a Float32Array.
  16013. * @param name Define the name of the uniform as defined in the shader
  16014. * @param value Define the value to give to the uniform
  16015. * @return the material itself allowing "fluent" like uniform updates
  16016. */
  16017. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  16018. /**
  16019. * Set a mat2 in the shader from a Float32Array.
  16020. * @param name Define the name of the uniform as defined in the shader
  16021. * @param value Define the value to give to the uniform
  16022. * @return the material itself allowing "fluent" like uniform updates
  16023. */
  16024. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  16025. /**
  16026. * Set a vec2 array in the shader from a number array.
  16027. * @param name Define the name of the uniform as defined in the shader
  16028. * @param value Define the value to give to the uniform
  16029. * @return the material itself allowing "fluent" like uniform updates
  16030. */
  16031. setArray2(name: string, value: number[]): ShaderMaterial;
  16032. /**
  16033. * Set a vec3 array in the shader from a number array.
  16034. * @param name Define the name of the uniform as defined in the shader
  16035. * @param value Define the value to give to the uniform
  16036. * @return the material itself allowing "fluent" like uniform updates
  16037. */
  16038. setArray3(name: string, value: number[]): ShaderMaterial;
  16039. /**
  16040. * Set a vec4 array in the shader from a number array.
  16041. * @param name Define the name of the uniform as defined in the shader
  16042. * @param value Define the value to give to the uniform
  16043. * @return the material itself allowing "fluent" like uniform updates
  16044. */
  16045. setArray4(name: string, value: number[]): ShaderMaterial;
  16046. private _checkCache;
  16047. /**
  16048. * Specifies that the submesh is ready to be used
  16049. * @param mesh defines the mesh to check
  16050. * @param subMesh defines which submesh to check
  16051. * @param useInstances specifies that instances should be used
  16052. * @returns a boolean indicating that the submesh is ready or not
  16053. */
  16054. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  16055. /**
  16056. * Checks if the material is ready to render the requested mesh
  16057. * @param mesh Define the mesh to render
  16058. * @param useInstances Define whether or not the material is used with instances
  16059. * @returns true if ready, otherwise false
  16060. */
  16061. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  16062. /**
  16063. * Binds the world matrix to the material
  16064. * @param world defines the world transformation matrix
  16065. */
  16066. bindOnlyWorldMatrix(world: Matrix): void;
  16067. /**
  16068. * Binds the material to the mesh
  16069. * @param world defines the world transformation matrix
  16070. * @param mesh defines the mesh to bind the material to
  16071. */
  16072. bind(world: Matrix, mesh?: Mesh): void;
  16073. /**
  16074. * Gets the active textures from the material
  16075. * @returns an array of textures
  16076. */
  16077. getActiveTextures(): BaseTexture[];
  16078. /**
  16079. * Specifies if the material uses a texture
  16080. * @param texture defines the texture to check against the material
  16081. * @returns a boolean specifying if the material uses the texture
  16082. */
  16083. hasTexture(texture: BaseTexture): boolean;
  16084. /**
  16085. * Makes a duplicate of the material, and gives it a new name
  16086. * @param name defines the new name for the duplicated material
  16087. * @returns the cloned material
  16088. */
  16089. clone(name: string): ShaderMaterial;
  16090. /**
  16091. * Disposes the material
  16092. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  16093. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  16094. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  16095. */
  16096. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  16097. /**
  16098. * Serializes this material in a JSON representation
  16099. * @returns the serialized material object
  16100. */
  16101. serialize(): any;
  16102. /**
  16103. * Creates a shader material from parsed shader material data
  16104. * @param source defines the JSON represnetation of the material
  16105. * @param scene defines the hosting scene
  16106. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16107. * @returns a new material
  16108. */
  16109. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  16110. }
  16111. }
  16112. declare module "babylonjs/Shaders/color.fragment" {
  16113. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  16114. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  16115. /** @hidden */
  16116. export var colorPixelShader: {
  16117. name: string;
  16118. shader: string;
  16119. };
  16120. }
  16121. declare module "babylonjs/Shaders/color.vertex" {
  16122. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  16123. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  16124. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  16125. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  16126. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  16127. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  16128. /** @hidden */
  16129. export var colorVertexShader: {
  16130. name: string;
  16131. shader: string;
  16132. };
  16133. }
  16134. declare module "babylonjs/Meshes/linesMesh" {
  16135. import { Nullable } from "babylonjs/types";
  16136. import { Scene } from "babylonjs/scene";
  16137. import { Color3 } from "babylonjs/Maths/math.color";
  16138. import { Node } from "babylonjs/node";
  16139. import { SubMesh } from "babylonjs/Meshes/subMesh";
  16140. import { Mesh } from "babylonjs/Meshes/mesh";
  16141. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  16142. import { Effect } from "babylonjs/Materials/effect";
  16143. import { Material } from "babylonjs/Materials/material";
  16144. import "babylonjs/Shaders/color.fragment";
  16145. import "babylonjs/Shaders/color.vertex";
  16146. /**
  16147. * Line mesh
  16148. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  16149. */
  16150. export class LinesMesh extends Mesh {
  16151. /**
  16152. * If vertex color should be applied to the mesh
  16153. */
  16154. readonly useVertexColor?: boolean | undefined;
  16155. /**
  16156. * If vertex alpha should be applied to the mesh
  16157. */
  16158. readonly useVertexAlpha?: boolean | undefined;
  16159. /**
  16160. * Color of the line (Default: White)
  16161. */
  16162. color: Color3;
  16163. /**
  16164. * Alpha of the line (Default: 1)
  16165. */
  16166. alpha: number;
  16167. /**
  16168. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16169. * This margin is expressed in world space coordinates, so its value may vary.
  16170. * Default value is 0.1
  16171. */
  16172. intersectionThreshold: number;
  16173. private _colorShader;
  16174. private color4;
  16175. /**
  16176. * Creates a new LinesMesh
  16177. * @param name defines the name
  16178. * @param scene defines the hosting scene
  16179. * @param parent defines the parent mesh if any
  16180. * @param source defines the optional source LinesMesh used to clone data from
  16181. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  16182. * When false, achieved by calling a clone(), also passing False.
  16183. * This will make creation of children, recursive.
  16184. * @param useVertexColor defines if this LinesMesh supports vertex color
  16185. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  16186. */
  16187. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  16188. /**
  16189. * If vertex color should be applied to the mesh
  16190. */
  16191. useVertexColor?: boolean | undefined,
  16192. /**
  16193. * If vertex alpha should be applied to the mesh
  16194. */
  16195. useVertexAlpha?: boolean | undefined);
  16196. private _addClipPlaneDefine;
  16197. private _removeClipPlaneDefine;
  16198. isReady(): boolean;
  16199. /**
  16200. * Returns the string "LineMesh"
  16201. */
  16202. getClassName(): string;
  16203. /**
  16204. * @hidden
  16205. */
  16206. get material(): Material;
  16207. /**
  16208. * @hidden
  16209. */
  16210. set material(value: Material);
  16211. /**
  16212. * @hidden
  16213. */
  16214. get checkCollisions(): boolean;
  16215. /** @hidden */
  16216. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  16217. /** @hidden */
  16218. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  16219. /**
  16220. * Disposes of the line mesh
  16221. * @param doNotRecurse If children should be disposed
  16222. */
  16223. dispose(doNotRecurse?: boolean): void;
  16224. /**
  16225. * Returns a new LineMesh object cloned from the current one.
  16226. */
  16227. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  16228. /**
  16229. * Creates a new InstancedLinesMesh object from the mesh model.
  16230. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  16231. * @param name defines the name of the new instance
  16232. * @returns a new InstancedLinesMesh
  16233. */
  16234. createInstance(name: string): InstancedLinesMesh;
  16235. }
  16236. /**
  16237. * Creates an instance based on a source LinesMesh
  16238. */
  16239. export class InstancedLinesMesh extends InstancedMesh {
  16240. /**
  16241. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16242. * This margin is expressed in world space coordinates, so its value may vary.
  16243. * Initilized with the intersectionThreshold value of the source LinesMesh
  16244. */
  16245. intersectionThreshold: number;
  16246. constructor(name: string, source: LinesMesh);
  16247. /**
  16248. * Returns the string "InstancedLinesMesh".
  16249. */
  16250. getClassName(): string;
  16251. }
  16252. }
  16253. declare module "babylonjs/Shaders/line.fragment" {
  16254. /** @hidden */
  16255. export var linePixelShader: {
  16256. name: string;
  16257. shader: string;
  16258. };
  16259. }
  16260. declare module "babylonjs/Shaders/line.vertex" {
  16261. /** @hidden */
  16262. export var lineVertexShader: {
  16263. name: string;
  16264. shader: string;
  16265. };
  16266. }
  16267. declare module "babylonjs/Rendering/edgesRenderer" {
  16268. import { Nullable } from "babylonjs/types";
  16269. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  16270. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16271. import { Vector3 } from "babylonjs/Maths/math.vector";
  16272. import { IDisposable } from "babylonjs/scene";
  16273. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  16274. import "babylonjs/Shaders/line.fragment";
  16275. import "babylonjs/Shaders/line.vertex";
  16276. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  16277. module "babylonjs/Meshes/abstractMesh" {
  16278. interface AbstractMesh {
  16279. /**
  16280. * Gets the edgesRenderer associated with the mesh
  16281. */
  16282. edgesRenderer: Nullable<EdgesRenderer>;
  16283. }
  16284. }
  16285. module "babylonjs/Meshes/linesMesh" {
  16286. interface LinesMesh {
  16287. /**
  16288. * Enables the edge rendering mode on the mesh.
  16289. * This mode makes the mesh edges visible
  16290. * @param epsilon defines the maximal distance between two angles to detect a face
  16291. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16292. * @returns the currentAbstractMesh
  16293. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16294. */
  16295. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  16296. }
  16297. }
  16298. module "babylonjs/Meshes/linesMesh" {
  16299. interface InstancedLinesMesh {
  16300. /**
  16301. * Enables the edge rendering mode on the mesh.
  16302. * This mode makes the mesh edges visible
  16303. * @param epsilon defines the maximal distance between two angles to detect a face
  16304. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16305. * @returns the current InstancedLinesMesh
  16306. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16307. */
  16308. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  16309. }
  16310. }
  16311. /**
  16312. * Defines the minimum contract an Edges renderer should follow.
  16313. */
  16314. export interface IEdgesRenderer extends IDisposable {
  16315. /**
  16316. * Gets or sets a boolean indicating if the edgesRenderer is active
  16317. */
  16318. isEnabled: boolean;
  16319. /**
  16320. * Renders the edges of the attached mesh,
  16321. */
  16322. render(): void;
  16323. /**
  16324. * Checks wether or not the edges renderer is ready to render.
  16325. * @return true if ready, otherwise false.
  16326. */
  16327. isReady(): boolean;
  16328. }
  16329. /**
  16330. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  16331. */
  16332. export class EdgesRenderer implements IEdgesRenderer {
  16333. /**
  16334. * Define the size of the edges with an orthographic camera
  16335. */
  16336. edgesWidthScalerForOrthographic: number;
  16337. /**
  16338. * Define the size of the edges with a perspective camera
  16339. */
  16340. edgesWidthScalerForPerspective: number;
  16341. protected _source: AbstractMesh;
  16342. protected _linesPositions: number[];
  16343. protected _linesNormals: number[];
  16344. protected _linesIndices: number[];
  16345. protected _epsilon: number;
  16346. protected _indicesCount: number;
  16347. protected _lineShader: ShaderMaterial;
  16348. protected _ib: DataBuffer;
  16349. protected _buffers: {
  16350. [key: string]: Nullable<VertexBuffer>;
  16351. };
  16352. protected _checkVerticesInsteadOfIndices: boolean;
  16353. private _meshRebuildObserver;
  16354. private _meshDisposeObserver;
  16355. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  16356. isEnabled: boolean;
  16357. /**
  16358. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  16359. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  16360. * @param source Mesh used to create edges
  16361. * @param epsilon sum of angles in adjacency to check for edge
  16362. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  16363. * @param generateEdgesLines - should generate Lines or only prepare resources.
  16364. */
  16365. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  16366. protected _prepareRessources(): void;
  16367. /** @hidden */
  16368. _rebuild(): void;
  16369. /**
  16370. * Releases the required resources for the edges renderer
  16371. */
  16372. dispose(): void;
  16373. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  16374. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  16375. /**
  16376. * Checks if the pair of p0 and p1 is en edge
  16377. * @param faceIndex
  16378. * @param edge
  16379. * @param faceNormals
  16380. * @param p0
  16381. * @param p1
  16382. * @private
  16383. */
  16384. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  16385. /**
  16386. * push line into the position, normal and index buffer
  16387. * @protected
  16388. */
  16389. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  16390. /**
  16391. * Generates lines edges from adjacencjes
  16392. * @private
  16393. */
  16394. _generateEdgesLines(): void;
  16395. /**
  16396. * Checks wether or not the edges renderer is ready to render.
  16397. * @return true if ready, otherwise false.
  16398. */
  16399. isReady(): boolean;
  16400. /**
  16401. * Renders the edges of the attached mesh,
  16402. */
  16403. render(): void;
  16404. }
  16405. /**
  16406. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  16407. */
  16408. export class LineEdgesRenderer extends EdgesRenderer {
  16409. /**
  16410. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  16411. * @param source LineMesh used to generate edges
  16412. * @param epsilon not important (specified angle for edge detection)
  16413. * @param checkVerticesInsteadOfIndices not important for LineMesh
  16414. */
  16415. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  16416. /**
  16417. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  16418. */
  16419. _generateEdgesLines(): void;
  16420. }
  16421. }
  16422. declare module "babylonjs/Rendering/renderingGroup" {
  16423. import { SmartArray } from "babylonjs/Misc/smartArray";
  16424. import { SubMesh } from "babylonjs/Meshes/subMesh";
  16425. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16426. import { Nullable } from "babylonjs/types";
  16427. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  16428. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  16429. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  16430. import { Material } from "babylonjs/Materials/material";
  16431. import { Scene } from "babylonjs/scene";
  16432. /**
  16433. * This represents the object necessary to create a rendering group.
  16434. * This is exclusively used and created by the rendering manager.
  16435. * To modify the behavior, you use the available helpers in your scene or meshes.
  16436. * @hidden
  16437. */
  16438. export class RenderingGroup {
  16439. index: number;
  16440. private static _zeroVector;
  16441. private _scene;
  16442. private _opaqueSubMeshes;
  16443. private _transparentSubMeshes;
  16444. private _alphaTestSubMeshes;
  16445. private _depthOnlySubMeshes;
  16446. private _particleSystems;
  16447. private _spriteManagers;
  16448. private _opaqueSortCompareFn;
  16449. private _alphaTestSortCompareFn;
  16450. private _transparentSortCompareFn;
  16451. private _renderOpaque;
  16452. private _renderAlphaTest;
  16453. private _renderTransparent;
  16454. /** @hidden */
  16455. _edgesRenderers: SmartArray<IEdgesRenderer>;
  16456. onBeforeTransparentRendering: () => void;
  16457. /**
  16458. * Set the opaque sort comparison function.
  16459. * If null the sub meshes will be render in the order they were created
  16460. */
  16461. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16462. /**
  16463. * Set the alpha test sort comparison function.
  16464. * If null the sub meshes will be render in the order they were created
  16465. */
  16466. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16467. /**
  16468. * Set the transparent sort comparison function.
  16469. * If null the sub meshes will be render in the order they were created
  16470. */
  16471. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16472. /**
  16473. * Creates a new rendering group.
  16474. * @param index The rendering group index
  16475. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  16476. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  16477. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  16478. */
  16479. 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>);
  16480. /**
  16481. * Render all the sub meshes contained in the group.
  16482. * @param customRenderFunction Used to override the default render behaviour of the group.
  16483. * @returns true if rendered some submeshes.
  16484. */
  16485. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  16486. /**
  16487. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  16488. * @param subMeshes The submeshes to render
  16489. */
  16490. private renderOpaqueSorted;
  16491. /**
  16492. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  16493. * @param subMeshes The submeshes to render
  16494. */
  16495. private renderAlphaTestSorted;
  16496. /**
  16497. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  16498. * @param subMeshes The submeshes to render
  16499. */
  16500. private renderTransparentSorted;
  16501. /**
  16502. * Renders the submeshes in a specified order.
  16503. * @param subMeshes The submeshes to sort before render
  16504. * @param sortCompareFn The comparison function use to sort
  16505. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  16506. * @param transparent Specifies to activate blending if true
  16507. */
  16508. private static renderSorted;
  16509. /**
  16510. * Renders the submeshes in the order they were dispatched (no sort applied).
  16511. * @param subMeshes The submeshes to render
  16512. */
  16513. private static renderUnsorted;
  16514. /**
  16515. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16516. * are rendered back to front if in the same alpha index.
  16517. *
  16518. * @param a The first submesh
  16519. * @param b The second submesh
  16520. * @returns The result of the comparison
  16521. */
  16522. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  16523. /**
  16524. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16525. * are rendered back to front.
  16526. *
  16527. * @param a The first submesh
  16528. * @param b The second submesh
  16529. * @returns The result of the comparison
  16530. */
  16531. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  16532. /**
  16533. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16534. * are rendered front to back (prevent overdraw).
  16535. *
  16536. * @param a The first submesh
  16537. * @param b The second submesh
  16538. * @returns The result of the comparison
  16539. */
  16540. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  16541. /**
  16542. * Resets the different lists of submeshes to prepare a new frame.
  16543. */
  16544. prepare(): void;
  16545. dispose(): void;
  16546. /**
  16547. * Inserts the submesh in its correct queue depending on its material.
  16548. * @param subMesh The submesh to dispatch
  16549. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  16550. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  16551. */
  16552. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  16553. dispatchSprites(spriteManager: ISpriteManager): void;
  16554. dispatchParticles(particleSystem: IParticleSystem): void;
  16555. private _renderParticles;
  16556. private _renderSprites;
  16557. }
  16558. }
  16559. declare module "babylonjs/Rendering/renderingManager" {
  16560. import { Nullable } from "babylonjs/types";
  16561. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16562. import { SubMesh } from "babylonjs/Meshes/subMesh";
  16563. import { SmartArray } from "babylonjs/Misc/smartArray";
  16564. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  16565. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  16566. import { Material } from "babylonjs/Materials/material";
  16567. import { Scene } from "babylonjs/scene";
  16568. import { Camera } from "babylonjs/Cameras/camera";
  16569. /**
  16570. * Interface describing the different options available in the rendering manager
  16571. * regarding Auto Clear between groups.
  16572. */
  16573. export interface IRenderingManagerAutoClearSetup {
  16574. /**
  16575. * Defines whether or not autoclear is enable.
  16576. */
  16577. autoClear: boolean;
  16578. /**
  16579. * Defines whether or not to autoclear the depth buffer.
  16580. */
  16581. depth: boolean;
  16582. /**
  16583. * Defines whether or not to autoclear the stencil buffer.
  16584. */
  16585. stencil: boolean;
  16586. }
  16587. /**
  16588. * This class is used by the onRenderingGroupObservable
  16589. */
  16590. export class RenderingGroupInfo {
  16591. /**
  16592. * The Scene that being rendered
  16593. */
  16594. scene: Scene;
  16595. /**
  16596. * The camera currently used for the rendering pass
  16597. */
  16598. camera: Nullable<Camera>;
  16599. /**
  16600. * The ID of the renderingGroup being processed
  16601. */
  16602. renderingGroupId: number;
  16603. }
  16604. /**
  16605. * This is the manager responsible of all the rendering for meshes sprites and particles.
  16606. * It is enable to manage the different groups as well as the different necessary sort functions.
  16607. * This should not be used directly aside of the few static configurations
  16608. */
  16609. export class RenderingManager {
  16610. /**
  16611. * The max id used for rendering groups (not included)
  16612. */
  16613. static MAX_RENDERINGGROUPS: number;
  16614. /**
  16615. * The min id used for rendering groups (included)
  16616. */
  16617. static MIN_RENDERINGGROUPS: number;
  16618. /**
  16619. * Used to globally prevent autoclearing scenes.
  16620. */
  16621. static AUTOCLEAR: boolean;
  16622. /**
  16623. * @hidden
  16624. */
  16625. _useSceneAutoClearSetup: boolean;
  16626. private _scene;
  16627. private _renderingGroups;
  16628. private _depthStencilBufferAlreadyCleaned;
  16629. private _autoClearDepthStencil;
  16630. private _customOpaqueSortCompareFn;
  16631. private _customAlphaTestSortCompareFn;
  16632. private _customTransparentSortCompareFn;
  16633. private _renderingGroupInfo;
  16634. /**
  16635. * Instantiates a new rendering group for a particular scene
  16636. * @param scene Defines the scene the groups belongs to
  16637. */
  16638. constructor(scene: Scene);
  16639. private _clearDepthStencilBuffer;
  16640. /**
  16641. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  16642. * @hidden
  16643. */
  16644. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  16645. /**
  16646. * Resets the different information of the group to prepare a new frame
  16647. * @hidden
  16648. */
  16649. reset(): void;
  16650. /**
  16651. * Dispose and release the group and its associated resources.
  16652. * @hidden
  16653. */
  16654. dispose(): void;
  16655. /**
  16656. * Clear the info related to rendering groups preventing retention points during dispose.
  16657. */
  16658. freeRenderingGroups(): void;
  16659. private _prepareRenderingGroup;
  16660. /**
  16661. * Add a sprite manager to the rendering manager in order to render it this frame.
  16662. * @param spriteManager Define the sprite manager to render
  16663. */
  16664. dispatchSprites(spriteManager: ISpriteManager): void;
  16665. /**
  16666. * Add a particle system to the rendering manager in order to render it this frame.
  16667. * @param particleSystem Define the particle system to render
  16668. */
  16669. dispatchParticles(particleSystem: IParticleSystem): void;
  16670. /**
  16671. * Add a submesh to the manager in order to render it this frame
  16672. * @param subMesh The submesh to dispatch
  16673. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  16674. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  16675. */
  16676. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  16677. /**
  16678. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  16679. * This allowed control for front to back rendering or reversly depending of the special needs.
  16680. *
  16681. * @param renderingGroupId The rendering group id corresponding to its index
  16682. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  16683. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  16684. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  16685. */
  16686. 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;
  16687. /**
  16688. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  16689. *
  16690. * @param renderingGroupId The rendering group id corresponding to its index
  16691. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  16692. * @param depth Automatically clears depth between groups if true and autoClear is true.
  16693. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  16694. */
  16695. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  16696. /**
  16697. * Gets the current auto clear configuration for one rendering group of the rendering
  16698. * manager.
  16699. * @param index the rendering group index to get the information for
  16700. * @returns The auto clear setup for the requested rendering group
  16701. */
  16702. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  16703. }
  16704. }
  16705. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  16706. import { SmartArray } from "babylonjs/Misc/smartArray";
  16707. import { Nullable } from "babylonjs/types";
  16708. import { Scene } from "babylonjs/scene";
  16709. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  16710. import { SubMesh } from "babylonjs/Meshes/subMesh";
  16711. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16712. import { Mesh } from "babylonjs/Meshes/mesh";
  16713. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  16714. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  16715. import { Effect } from "babylonjs/Materials/effect";
  16716. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  16717. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  16718. import "babylonjs/Shaders/shadowMap.fragment";
  16719. import "babylonjs/Shaders/shadowMap.vertex";
  16720. import "babylonjs/Shaders/depthBoxBlur.fragment";
  16721. import { Observable } from "babylonjs/Misc/observable";
  16722. /**
  16723. * Defines the options associated with the creation of a custom shader for a shadow generator.
  16724. */
  16725. export interface ICustomShaderOptions {
  16726. /**
  16727. * Gets or sets the custom shader name to use
  16728. */
  16729. shaderName: string;
  16730. /**
  16731. * The list of attribute names used in the shader
  16732. */
  16733. attributes?: string[];
  16734. /**
  16735. * The list of unifrom names used in the shader
  16736. */
  16737. uniforms?: string[];
  16738. /**
  16739. * The list of sampler names used in the shader
  16740. */
  16741. samplers?: string[];
  16742. /**
  16743. * The list of defines used in the shader
  16744. */
  16745. defines?: string[];
  16746. }
  16747. /**
  16748. * Interface to implement to create a shadow generator compatible with BJS.
  16749. */
  16750. export interface IShadowGenerator {
  16751. /**
  16752. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  16753. * @returns The render target texture if present otherwise, null
  16754. */
  16755. getShadowMap(): Nullable<RenderTargetTexture>;
  16756. /**
  16757. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  16758. * @param subMesh The submesh we want to render in the shadow map
  16759. * @param useInstances Defines wether will draw in the map using instances
  16760. * @returns true if ready otherwise, false
  16761. */
  16762. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  16763. /**
  16764. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  16765. * @param defines Defines of the material we want to update
  16766. * @param lightIndex Index of the light in the enabled light list of the material
  16767. */
  16768. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  16769. /**
  16770. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  16771. * defined in the generator but impacting the effect).
  16772. * It implies the unifroms available on the materials are the standard BJS ones.
  16773. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  16774. * @param effect The effect we are binfing the information for
  16775. */
  16776. bindShadowLight(lightIndex: string, effect: Effect): void;
  16777. /**
  16778. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  16779. * (eq to shadow prjection matrix * light transform matrix)
  16780. * @returns The transform matrix used to create the shadow map
  16781. */
  16782. getTransformMatrix(): Matrix;
  16783. /**
  16784. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  16785. * Cube and 2D textures for instance.
  16786. */
  16787. recreateShadowMap(): void;
  16788. /**
  16789. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16790. * @param onCompiled Callback triggered at the and of the effects compilation
  16791. * @param options Sets of optional options forcing the compilation with different modes
  16792. */
  16793. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  16794. useInstances: boolean;
  16795. }>): void;
  16796. /**
  16797. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16798. * @param options Sets of optional options forcing the compilation with different modes
  16799. * @returns A promise that resolves when the compilation completes
  16800. */
  16801. forceCompilationAsync(options?: Partial<{
  16802. useInstances: boolean;
  16803. }>): Promise<void>;
  16804. /**
  16805. * Serializes the shadow generator setup to a json object.
  16806. * @returns The serialized JSON object
  16807. */
  16808. serialize(): any;
  16809. /**
  16810. * Disposes the Shadow map and related Textures and effects.
  16811. */
  16812. dispose(): void;
  16813. }
  16814. /**
  16815. * Default implementation IShadowGenerator.
  16816. * This is the main object responsible of generating shadows in the framework.
  16817. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  16818. */
  16819. export class ShadowGenerator implements IShadowGenerator {
  16820. /**
  16821. * Name of the shadow generator class
  16822. */
  16823. static CLASSNAME: string;
  16824. /**
  16825. * Shadow generator mode None: no filtering applied.
  16826. */
  16827. static readonly FILTER_NONE: number;
  16828. /**
  16829. * Shadow generator mode ESM: Exponential Shadow Mapping.
  16830. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16831. */
  16832. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  16833. /**
  16834. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  16835. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  16836. */
  16837. static readonly FILTER_POISSONSAMPLING: number;
  16838. /**
  16839. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  16840. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16841. */
  16842. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  16843. /**
  16844. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  16845. * edge artifacts on steep falloff.
  16846. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16847. */
  16848. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  16849. /**
  16850. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  16851. * edge artifacts on steep falloff.
  16852. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16853. */
  16854. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  16855. /**
  16856. * Shadow generator mode PCF: Percentage Closer Filtering
  16857. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  16858. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  16859. */
  16860. static readonly FILTER_PCF: number;
  16861. /**
  16862. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  16863. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  16864. * Contact Hardening
  16865. */
  16866. static readonly FILTER_PCSS: number;
  16867. /**
  16868. * Reserved for PCF and PCSS
  16869. * Highest Quality.
  16870. *
  16871. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  16872. *
  16873. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  16874. */
  16875. static readonly QUALITY_HIGH: number;
  16876. /**
  16877. * Reserved for PCF and PCSS
  16878. * Good tradeoff for quality/perf cross devices
  16879. *
  16880. * Execute PCF on a 3*3 kernel.
  16881. *
  16882. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  16883. */
  16884. static readonly QUALITY_MEDIUM: number;
  16885. /**
  16886. * Reserved for PCF and PCSS
  16887. * The lowest quality but the fastest.
  16888. *
  16889. * Execute PCF on a 1*1 kernel.
  16890. *
  16891. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  16892. */
  16893. static readonly QUALITY_LOW: number;
  16894. /** Gets or sets the custom shader name to use */
  16895. customShaderOptions: ICustomShaderOptions;
  16896. /**
  16897. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  16898. */
  16899. onBeforeShadowMapRenderObservable: Observable<Effect>;
  16900. /**
  16901. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  16902. */
  16903. onAfterShadowMapRenderObservable: Observable<Effect>;
  16904. /**
  16905. * Observable triggered before a mesh is rendered in the shadow map.
  16906. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  16907. */
  16908. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  16909. /**
  16910. * Observable triggered after a mesh is rendered in the shadow map.
  16911. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  16912. */
  16913. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  16914. protected _bias: number;
  16915. /**
  16916. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  16917. */
  16918. get bias(): number;
  16919. /**
  16920. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  16921. */
  16922. set bias(bias: number);
  16923. protected _normalBias: number;
  16924. /**
  16925. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  16926. */
  16927. get normalBias(): number;
  16928. /**
  16929. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  16930. */
  16931. set normalBias(normalBias: number);
  16932. protected _blurBoxOffset: number;
  16933. /**
  16934. * Gets the blur box offset: offset applied during the blur pass.
  16935. * Only useful if useKernelBlur = false
  16936. */
  16937. get blurBoxOffset(): number;
  16938. /**
  16939. * Sets the blur box offset: offset applied during the blur pass.
  16940. * Only useful if useKernelBlur = false
  16941. */
  16942. set blurBoxOffset(value: number);
  16943. protected _blurScale: number;
  16944. /**
  16945. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  16946. * 2 means half of the size.
  16947. */
  16948. get blurScale(): number;
  16949. /**
  16950. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  16951. * 2 means half of the size.
  16952. */
  16953. set blurScale(value: number);
  16954. protected _blurKernel: number;
  16955. /**
  16956. * Gets the blur kernel: kernel size of the blur pass.
  16957. * Only useful if useKernelBlur = true
  16958. */
  16959. get blurKernel(): number;
  16960. /**
  16961. * Sets the blur kernel: kernel size of the blur pass.
  16962. * Only useful if useKernelBlur = true
  16963. */
  16964. set blurKernel(value: number);
  16965. protected _useKernelBlur: boolean;
  16966. /**
  16967. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  16968. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  16969. */
  16970. get useKernelBlur(): boolean;
  16971. /**
  16972. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  16973. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  16974. */
  16975. set useKernelBlur(value: boolean);
  16976. protected _depthScale: number;
  16977. /**
  16978. * Gets the depth scale used in ESM mode.
  16979. */
  16980. get depthScale(): number;
  16981. /**
  16982. * Sets the depth scale used in ESM mode.
  16983. * This can override the scale stored on the light.
  16984. */
  16985. set depthScale(value: number);
  16986. protected _validateFilter(filter: number): number;
  16987. protected _filter: number;
  16988. /**
  16989. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  16990. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  16991. */
  16992. get filter(): number;
  16993. /**
  16994. * Sets 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. set filter(value: number);
  16998. /**
  16999. * Gets if the current filter is set to Poisson Sampling.
  17000. */
  17001. get usePoissonSampling(): boolean;
  17002. /**
  17003. * Sets the current filter to Poisson Sampling.
  17004. */
  17005. set usePoissonSampling(value: boolean);
  17006. /**
  17007. * Gets if the current filter is set to ESM.
  17008. */
  17009. get useExponentialShadowMap(): boolean;
  17010. /**
  17011. * Sets the current filter is to ESM.
  17012. */
  17013. set useExponentialShadowMap(value: boolean);
  17014. /**
  17015. * Gets if the current filter is set to filtered ESM.
  17016. */
  17017. get useBlurExponentialShadowMap(): boolean;
  17018. /**
  17019. * Gets if the current filter is set to filtered ESM.
  17020. */
  17021. set useBlurExponentialShadowMap(value: boolean);
  17022. /**
  17023. * Gets if the current filter is set to "close ESM" (using the inverse of the
  17024. * exponential to prevent steep falloff artifacts).
  17025. */
  17026. get useCloseExponentialShadowMap(): boolean;
  17027. /**
  17028. * Sets the current filter to "close ESM" (using the inverse of the
  17029. * exponential to prevent steep falloff artifacts).
  17030. */
  17031. set useCloseExponentialShadowMap(value: boolean);
  17032. /**
  17033. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  17034. * exponential to prevent steep falloff artifacts).
  17035. */
  17036. get useBlurCloseExponentialShadowMap(): boolean;
  17037. /**
  17038. * Sets the current filter to filtered "close ESM" (using the inverse of the
  17039. * exponential to prevent steep falloff artifacts).
  17040. */
  17041. set useBlurCloseExponentialShadowMap(value: boolean);
  17042. /**
  17043. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  17044. */
  17045. get usePercentageCloserFiltering(): boolean;
  17046. /**
  17047. * Sets the current filter to "PCF" (percentage closer filtering).
  17048. */
  17049. set usePercentageCloserFiltering(value: boolean);
  17050. protected _filteringQuality: number;
  17051. /**
  17052. * Gets the PCF or PCSS Quality.
  17053. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  17054. */
  17055. get filteringQuality(): number;
  17056. /**
  17057. * Sets the PCF or PCSS Quality.
  17058. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  17059. */
  17060. set filteringQuality(filteringQuality: number);
  17061. /**
  17062. * Gets if the current filter is set to "PCSS" (contact hardening).
  17063. */
  17064. get useContactHardeningShadow(): boolean;
  17065. /**
  17066. * Sets the current filter to "PCSS" (contact hardening).
  17067. */
  17068. set useContactHardeningShadow(value: boolean);
  17069. protected _contactHardeningLightSizeUVRatio: number;
  17070. /**
  17071. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  17072. * Using a ratio helps keeping shape stability independently of the map size.
  17073. *
  17074. * It does not account for the light projection as it was having too much
  17075. * instability during the light setup or during light position changes.
  17076. *
  17077. * Only valid if useContactHardeningShadow is true.
  17078. */
  17079. get contactHardeningLightSizeUVRatio(): number;
  17080. /**
  17081. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  17082. * Using a ratio helps keeping shape stability independently of the map size.
  17083. *
  17084. * It does not account for the light projection as it was having too much
  17085. * instability during the light setup or during light position changes.
  17086. *
  17087. * Only valid if useContactHardeningShadow is true.
  17088. */
  17089. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  17090. protected _darkness: number;
  17091. /** Gets or sets the actual darkness of a shadow */
  17092. get darkness(): number;
  17093. set darkness(value: number);
  17094. /**
  17095. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  17096. * 0 means strongest and 1 would means no shadow.
  17097. * @returns the darkness.
  17098. */
  17099. getDarkness(): number;
  17100. /**
  17101. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  17102. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  17103. * @returns the shadow generator allowing fluent coding.
  17104. */
  17105. setDarkness(darkness: number): ShadowGenerator;
  17106. protected _transparencyShadow: boolean;
  17107. /** Gets or sets the ability to have transparent shadow */
  17108. get transparencyShadow(): boolean;
  17109. set transparencyShadow(value: boolean);
  17110. /**
  17111. * Sets the ability to have transparent shadow (boolean).
  17112. * @param transparent True if transparent else False
  17113. * @returns the shadow generator allowing fluent coding
  17114. */
  17115. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  17116. protected _shadowMap: Nullable<RenderTargetTexture>;
  17117. protected _shadowMap2: Nullable<RenderTargetTexture>;
  17118. /**
  17119. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  17120. * @returns The render target texture if present otherwise, null
  17121. */
  17122. getShadowMap(): Nullable<RenderTargetTexture>;
  17123. /**
  17124. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  17125. * @returns The render target texture if the shadow map is present otherwise, null
  17126. */
  17127. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  17128. /**
  17129. * Gets the class name of that object
  17130. * @returns "ShadowGenerator"
  17131. */
  17132. getClassName(): string;
  17133. /**
  17134. * Helper function to add a mesh and its descendants to the list of shadow casters.
  17135. * @param mesh Mesh to add
  17136. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  17137. * @returns the Shadow Generator itself
  17138. */
  17139. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  17140. /**
  17141. * Helper function to remove a mesh and its descendants from the list of shadow casters
  17142. * @param mesh Mesh to remove
  17143. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  17144. * @returns the Shadow Generator itself
  17145. */
  17146. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  17147. /**
  17148. * Controls the extent to which the shadows fade out at the edge of the frustum
  17149. */
  17150. frustumEdgeFalloff: number;
  17151. protected _light: IShadowLight;
  17152. /**
  17153. * Returns the associated light object.
  17154. * @returns the light generating the shadow
  17155. */
  17156. getLight(): IShadowLight;
  17157. /**
  17158. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  17159. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  17160. * It might on the other hand introduce peter panning.
  17161. */
  17162. forceBackFacesOnly: boolean;
  17163. protected _scene: Scene;
  17164. protected _lightDirection: Vector3;
  17165. protected _effect: Effect;
  17166. protected _viewMatrix: Matrix;
  17167. protected _projectionMatrix: Matrix;
  17168. protected _transformMatrix: Matrix;
  17169. protected _cachedPosition: Vector3;
  17170. protected _cachedDirection: Vector3;
  17171. protected _cachedDefines: string;
  17172. protected _currentRenderID: number;
  17173. protected _boxBlurPostprocess: Nullable<PostProcess>;
  17174. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  17175. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  17176. protected _blurPostProcesses: PostProcess[];
  17177. protected _mapSize: number;
  17178. protected _currentFaceIndex: number;
  17179. protected _currentFaceIndexCache: number;
  17180. protected _textureType: number;
  17181. protected _defaultTextureMatrix: Matrix;
  17182. protected _storedUniqueId: Nullable<number>;
  17183. /** @hidden */
  17184. static _SceneComponentInitialization: (scene: Scene) => void;
  17185. /**
  17186. * Creates a ShadowGenerator object.
  17187. * A ShadowGenerator is the required tool to use the shadows.
  17188. * Each light casting shadows needs to use its own ShadowGenerator.
  17189. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  17190. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  17191. * @param light The light object generating the shadows.
  17192. * @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.
  17193. */
  17194. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  17195. protected _initializeGenerator(): void;
  17196. protected _createTargetRenderTexture(): void;
  17197. protected _initializeShadowMap(): void;
  17198. protected _initializeBlurRTTAndPostProcesses(): void;
  17199. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  17200. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect): void;
  17201. protected _renderSubMeshForShadowMap(subMesh: SubMesh): void;
  17202. protected _applyFilterValues(): void;
  17203. /**
  17204. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17205. * @param onCompiled Callback triggered at the and of the effects compilation
  17206. * @param options Sets of optional options forcing the compilation with different modes
  17207. */
  17208. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  17209. useInstances: boolean;
  17210. }>): void;
  17211. /**
  17212. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17213. * @param options Sets of optional options forcing the compilation with different modes
  17214. * @returns A promise that resolves when the compilation completes
  17215. */
  17216. forceCompilationAsync(options?: Partial<{
  17217. useInstances: boolean;
  17218. }>): Promise<void>;
  17219. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  17220. /**
  17221. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  17222. * @param subMesh The submesh we want to render in the shadow map
  17223. * @param useInstances Defines wether will draw in the map using instances
  17224. * @returns true if ready otherwise, false
  17225. */
  17226. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  17227. /**
  17228. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  17229. * @param defines Defines of the material we want to update
  17230. * @param lightIndex Index of the light in the enabled light list of the material
  17231. */
  17232. prepareDefines(defines: any, lightIndex: number): void;
  17233. /**
  17234. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  17235. * defined in the generator but impacting the effect).
  17236. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  17237. * @param effect The effect we are binfing the information for
  17238. */
  17239. bindShadowLight(lightIndex: string, effect: Effect): void;
  17240. /**
  17241. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  17242. * (eq to shadow prjection matrix * light transform matrix)
  17243. * @returns The transform matrix used to create the shadow map
  17244. */
  17245. getTransformMatrix(): Matrix;
  17246. /**
  17247. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  17248. * Cube and 2D textures for instance.
  17249. */
  17250. recreateShadowMap(): void;
  17251. protected _disposeBlurPostProcesses(): void;
  17252. protected _disposeRTTandPostProcesses(): void;
  17253. /**
  17254. * Disposes the ShadowGenerator.
  17255. * Returns nothing.
  17256. */
  17257. dispose(): void;
  17258. /**
  17259. * Serializes the shadow generator setup to a json object.
  17260. * @returns The serialized JSON object
  17261. */
  17262. serialize(): any;
  17263. /**
  17264. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  17265. * @param parsedShadowGenerator The JSON object to parse
  17266. * @param scene The scene to create the shadow map for
  17267. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  17268. * @returns The parsed shadow generator
  17269. */
  17270. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  17271. }
  17272. }
  17273. declare module "babylonjs/Lights/light" {
  17274. import { Nullable } from "babylonjs/types";
  17275. import { Scene } from "babylonjs/scene";
  17276. import { Vector3 } from "babylonjs/Maths/math.vector";
  17277. import { Color3 } from "babylonjs/Maths/math.color";
  17278. import { Node } from "babylonjs/node";
  17279. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17280. import { Effect } from "babylonjs/Materials/effect";
  17281. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  17282. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  17283. /**
  17284. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  17285. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  17286. * 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.
  17287. */
  17288. export abstract class Light extends Node {
  17289. /**
  17290. * Falloff Default: light is falling off following the material specification:
  17291. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  17292. */
  17293. static readonly FALLOFF_DEFAULT: number;
  17294. /**
  17295. * Falloff Physical: light is falling off following the inverse squared distance law.
  17296. */
  17297. static readonly FALLOFF_PHYSICAL: number;
  17298. /**
  17299. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  17300. * to enhance interoperability with other engines.
  17301. */
  17302. static readonly FALLOFF_GLTF: number;
  17303. /**
  17304. * Falloff Standard: light is falling off like in the standard material
  17305. * to enhance interoperability with other materials.
  17306. */
  17307. static readonly FALLOFF_STANDARD: number;
  17308. /**
  17309. * If every light affecting the material is in this lightmapMode,
  17310. * material.lightmapTexture adds or multiplies
  17311. * (depends on material.useLightmapAsShadowmap)
  17312. * after every other light calculations.
  17313. */
  17314. static readonly LIGHTMAP_DEFAULT: number;
  17315. /**
  17316. * material.lightmapTexture as only diffuse lighting from this light
  17317. * adds only specular lighting from this light
  17318. * adds dynamic shadows
  17319. */
  17320. static readonly LIGHTMAP_SPECULAR: number;
  17321. /**
  17322. * material.lightmapTexture as only lighting
  17323. * no light calculation from this light
  17324. * only adds dynamic shadows from this light
  17325. */
  17326. static readonly LIGHTMAP_SHADOWSONLY: number;
  17327. /**
  17328. * Each light type uses the default quantity according to its type:
  17329. * point/spot lights use luminous intensity
  17330. * directional lights use illuminance
  17331. */
  17332. static readonly INTENSITYMODE_AUTOMATIC: number;
  17333. /**
  17334. * lumen (lm)
  17335. */
  17336. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  17337. /**
  17338. * candela (lm/sr)
  17339. */
  17340. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  17341. /**
  17342. * lux (lm/m^2)
  17343. */
  17344. static readonly INTENSITYMODE_ILLUMINANCE: number;
  17345. /**
  17346. * nit (cd/m^2)
  17347. */
  17348. static readonly INTENSITYMODE_LUMINANCE: number;
  17349. /**
  17350. * Light type const id of the point light.
  17351. */
  17352. static readonly LIGHTTYPEID_POINTLIGHT: number;
  17353. /**
  17354. * Light type const id of the directional light.
  17355. */
  17356. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  17357. /**
  17358. * Light type const id of the spot light.
  17359. */
  17360. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  17361. /**
  17362. * Light type const id of the hemispheric light.
  17363. */
  17364. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  17365. /**
  17366. * Diffuse gives the basic color to an object.
  17367. */
  17368. diffuse: Color3;
  17369. /**
  17370. * Specular produces a highlight color on an object.
  17371. * Note: This is note affecting PBR materials.
  17372. */
  17373. specular: Color3;
  17374. /**
  17375. * Defines the falloff type for this light. This lets overrriding how punctual light are
  17376. * falling off base on range or angle.
  17377. * This can be set to any values in Light.FALLOFF_x.
  17378. *
  17379. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  17380. * other types of materials.
  17381. */
  17382. falloffType: number;
  17383. /**
  17384. * Strength of the light.
  17385. * Note: By default it is define in the framework own unit.
  17386. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  17387. */
  17388. intensity: number;
  17389. private _range;
  17390. protected _inverseSquaredRange: number;
  17391. /**
  17392. * Defines how far from the source the light is impacting in scene units.
  17393. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  17394. */
  17395. get range(): 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. set range(value: number);
  17401. /**
  17402. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  17403. * of light.
  17404. */
  17405. private _photometricScale;
  17406. private _intensityMode;
  17407. /**
  17408. * Gets the photometric scale used to interpret the intensity.
  17409. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  17410. */
  17411. get intensityMode(): number;
  17412. /**
  17413. * Sets 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. set intensityMode(value: number);
  17417. private _radius;
  17418. /**
  17419. * Gets the light radius used by PBR Materials to simulate soft area lights.
  17420. */
  17421. get radius(): number;
  17422. /**
  17423. * sets the light radius used by PBR Materials to simulate soft area lights.
  17424. */
  17425. set radius(value: number);
  17426. private _renderPriority;
  17427. /**
  17428. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  17429. * exceeding the number allowed of the materials.
  17430. */
  17431. renderPriority: number;
  17432. private _shadowEnabled;
  17433. /**
  17434. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  17435. * the current shadow generator.
  17436. */
  17437. get shadowEnabled(): boolean;
  17438. /**
  17439. * Sets 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. set shadowEnabled(value: boolean);
  17443. private _includedOnlyMeshes;
  17444. /**
  17445. * Gets the only meshes impacted by this light.
  17446. */
  17447. get includedOnlyMeshes(): AbstractMesh[];
  17448. /**
  17449. * Sets the only meshes impacted by this light.
  17450. */
  17451. set includedOnlyMeshes(value: AbstractMesh[]);
  17452. private _excludedMeshes;
  17453. /**
  17454. * Gets the meshes not impacted by this light.
  17455. */
  17456. get excludedMeshes(): AbstractMesh[];
  17457. /**
  17458. * Sets the meshes not impacted by this light.
  17459. */
  17460. set excludedMeshes(value: AbstractMesh[]);
  17461. private _excludeWithLayerMask;
  17462. /**
  17463. * Gets the layer id use to find what meshes are not impacted by the light.
  17464. * Inactive if 0
  17465. */
  17466. get excludeWithLayerMask(): number;
  17467. /**
  17468. * Sets the layer id use to find what meshes are not impacted by the light.
  17469. * Inactive if 0
  17470. */
  17471. set excludeWithLayerMask(value: number);
  17472. private _includeOnlyWithLayerMask;
  17473. /**
  17474. * Gets the layer id use to find what meshes are impacted by the light.
  17475. * Inactive if 0
  17476. */
  17477. get includeOnlyWithLayerMask(): number;
  17478. /**
  17479. * Sets the layer id use to find what meshes are impacted by the light.
  17480. * Inactive if 0
  17481. */
  17482. set includeOnlyWithLayerMask(value: number);
  17483. private _lightmapMode;
  17484. /**
  17485. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  17486. */
  17487. get lightmapMode(): number;
  17488. /**
  17489. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  17490. */
  17491. set lightmapMode(value: number);
  17492. /**
  17493. * Shadow generator associted to the light.
  17494. * @hidden Internal use only.
  17495. */
  17496. _shadowGenerator: Nullable<IShadowGenerator>;
  17497. /**
  17498. * @hidden Internal use only.
  17499. */
  17500. _excludedMeshesIds: string[];
  17501. /**
  17502. * @hidden Internal use only.
  17503. */
  17504. _includedOnlyMeshesIds: string[];
  17505. /**
  17506. * The current light unifom buffer.
  17507. * @hidden Internal use only.
  17508. */
  17509. _uniformBuffer: UniformBuffer;
  17510. /** @hidden */
  17511. _renderId: number;
  17512. /**
  17513. * Creates a Light object in the scene.
  17514. * Documentation : https://doc.babylonjs.com/babylon101/lights
  17515. * @param name The firendly name of the light
  17516. * @param scene The scene the light belongs too
  17517. */
  17518. constructor(name: string, scene: Scene);
  17519. protected abstract _buildUniformLayout(): void;
  17520. /**
  17521. * Sets the passed Effect "effect" with the Light information.
  17522. * @param effect The effect to update
  17523. * @param lightIndex The index of the light in the effect to update
  17524. * @returns The light
  17525. */
  17526. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  17527. /**
  17528. * Sets the passed Effect "effect" with the Light textures.
  17529. * @param effect The effect to update
  17530. * @param lightIndex The index of the light in the effect to update
  17531. * @returns The light
  17532. */
  17533. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  17534. /**
  17535. * Binds the lights information from the scene to the effect for the given mesh.
  17536. * @param lightIndex Light index
  17537. * @param scene The scene where the light belongs to
  17538. * @param effect The effect we are binding the data to
  17539. * @param useSpecular Defines if specular is supported
  17540. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  17541. */
  17542. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  17543. /**
  17544. * Sets the passed Effect "effect" with the Light information.
  17545. * @param effect The effect to update
  17546. * @param lightDataUniformName The uniform used to store light data (position or direction)
  17547. * @returns The light
  17548. */
  17549. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  17550. /**
  17551. * Returns the string "Light".
  17552. * @returns the class name
  17553. */
  17554. getClassName(): string;
  17555. /** @hidden */
  17556. readonly _isLight: boolean;
  17557. /**
  17558. * Converts the light information to a readable string for debug purpose.
  17559. * @param fullDetails Supports for multiple levels of logging within scene loading
  17560. * @returns the human readable light info
  17561. */
  17562. toString(fullDetails?: boolean): string;
  17563. /** @hidden */
  17564. protected _syncParentEnabledState(): void;
  17565. /**
  17566. * Set the enabled state of this node.
  17567. * @param value - the new enabled state
  17568. */
  17569. setEnabled(value: boolean): void;
  17570. /**
  17571. * Returns the Light associated shadow generator if any.
  17572. * @return the associated shadow generator.
  17573. */
  17574. getShadowGenerator(): Nullable<IShadowGenerator>;
  17575. /**
  17576. * Returns a Vector3, the absolute light position in the World.
  17577. * @returns the world space position of the light
  17578. */
  17579. getAbsolutePosition(): Vector3;
  17580. /**
  17581. * Specifies if the light will affect the passed mesh.
  17582. * @param mesh The mesh to test against the light
  17583. * @return true the mesh is affected otherwise, false.
  17584. */
  17585. canAffectMesh(mesh: AbstractMesh): boolean;
  17586. /**
  17587. * Sort function to order lights for rendering.
  17588. * @param a First Light object to compare to second.
  17589. * @param b Second Light object to compare first.
  17590. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  17591. */
  17592. static CompareLightsPriority(a: Light, b: Light): number;
  17593. /**
  17594. * Releases resources associated with this node.
  17595. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  17596. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  17597. */
  17598. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  17599. /**
  17600. * Returns the light type ID (integer).
  17601. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  17602. */
  17603. getTypeID(): number;
  17604. /**
  17605. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  17606. * @returns the scaled intensity in intensity mode unit
  17607. */
  17608. getScaledIntensity(): number;
  17609. /**
  17610. * Returns a new Light object, named "name", from the current one.
  17611. * @param name The name of the cloned light
  17612. * @returns the new created light
  17613. */
  17614. clone(name: string): Nullable<Light>;
  17615. /**
  17616. * Serializes the current light into a Serialization object.
  17617. * @returns the serialized object.
  17618. */
  17619. serialize(): any;
  17620. /**
  17621. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  17622. * This new light is named "name" and added to the passed scene.
  17623. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  17624. * @param name The friendly name of the light
  17625. * @param scene The scene the new light will belong to
  17626. * @returns the constructor function
  17627. */
  17628. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  17629. /**
  17630. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  17631. * @param parsedLight The JSON representation of the light
  17632. * @param scene The scene to create the parsed light in
  17633. * @returns the created light after parsing
  17634. */
  17635. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  17636. private _hookArrayForExcluded;
  17637. private _hookArrayForIncludedOnly;
  17638. private _resyncMeshes;
  17639. /**
  17640. * Forces the meshes to update their light related information in their rendering used effects
  17641. * @hidden Internal Use Only
  17642. */
  17643. _markMeshesAsLightDirty(): void;
  17644. /**
  17645. * Recomputes the cached photometric scale if needed.
  17646. */
  17647. private _computePhotometricScale;
  17648. /**
  17649. * Returns the Photometric Scale according to the light type and intensity mode.
  17650. */
  17651. private _getPhotometricScale;
  17652. /**
  17653. * Reorder the light in the scene according to their defined priority.
  17654. * @hidden Internal Use Only
  17655. */
  17656. _reorderLightsInScene(): void;
  17657. /**
  17658. * Prepares the list of defines specific to the light type.
  17659. * @param defines the list of defines
  17660. * @param lightIndex defines the index of the light for the effect
  17661. */
  17662. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  17663. }
  17664. }
  17665. declare module "babylonjs/Actions/action" {
  17666. import { Observable } from "babylonjs/Misc/observable";
  17667. import { Condition } from "babylonjs/Actions/condition";
  17668. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  17669. import { ActionManager } from "babylonjs/Actions/actionManager";
  17670. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  17671. /**
  17672. * Interface used to define Action
  17673. */
  17674. export interface IAction {
  17675. /**
  17676. * Trigger for the action
  17677. */
  17678. trigger: number;
  17679. /** Options of the trigger */
  17680. triggerOptions: any;
  17681. /**
  17682. * Gets the trigger parameters
  17683. * @returns the trigger parameters
  17684. */
  17685. getTriggerParameter(): any;
  17686. /**
  17687. * Internal only - executes current action event
  17688. * @hidden
  17689. */
  17690. _executeCurrent(evt?: ActionEvent): void;
  17691. /**
  17692. * Serialize placeholder for child classes
  17693. * @param parent of child
  17694. * @returns the serialized object
  17695. */
  17696. serialize(parent: any): any;
  17697. /**
  17698. * Internal only
  17699. * @hidden
  17700. */
  17701. _prepare(): void;
  17702. /**
  17703. * Internal only - manager for action
  17704. * @hidden
  17705. */
  17706. _actionManager: AbstractActionManager;
  17707. /**
  17708. * Adds action to chain of actions, may be a DoNothingAction
  17709. * @param action defines the next action to execute
  17710. * @returns The action passed in
  17711. * @see https://www.babylonjs-playground.com/#1T30HR#0
  17712. */
  17713. then(action: IAction): IAction;
  17714. }
  17715. /**
  17716. * The action to be carried out following a trigger
  17717. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  17718. */
  17719. export class Action implements IAction {
  17720. /** the trigger, with or without parameters, for the action */
  17721. triggerOptions: any;
  17722. /**
  17723. * Trigger for the action
  17724. */
  17725. trigger: number;
  17726. /**
  17727. * Internal only - manager for action
  17728. * @hidden
  17729. */
  17730. _actionManager: ActionManager;
  17731. private _nextActiveAction;
  17732. private _child;
  17733. private _condition?;
  17734. private _triggerParameter;
  17735. /**
  17736. * An event triggered prior to action being executed.
  17737. */
  17738. onBeforeExecuteObservable: Observable<Action>;
  17739. /**
  17740. * Creates a new Action
  17741. * @param triggerOptions the trigger, with or without parameters, for the action
  17742. * @param condition an optional determinant of action
  17743. */
  17744. constructor(
  17745. /** the trigger, with or without parameters, for the action */
  17746. triggerOptions: any, condition?: Condition);
  17747. /**
  17748. * Internal only
  17749. * @hidden
  17750. */
  17751. _prepare(): void;
  17752. /**
  17753. * Gets the trigger parameters
  17754. * @returns the trigger parameters
  17755. */
  17756. getTriggerParameter(): any;
  17757. /**
  17758. * Internal only - executes current action event
  17759. * @hidden
  17760. */
  17761. _executeCurrent(evt?: ActionEvent): void;
  17762. /**
  17763. * Execute placeholder for child classes
  17764. * @param evt optional action event
  17765. */
  17766. execute(evt?: ActionEvent): void;
  17767. /**
  17768. * Skips to next active action
  17769. */
  17770. skipToNextActiveAction(): void;
  17771. /**
  17772. * Adds action to chain of actions, may be a DoNothingAction
  17773. * @param action defines the next action to execute
  17774. * @returns The action passed in
  17775. * @see https://www.babylonjs-playground.com/#1T30HR#0
  17776. */
  17777. then(action: Action): Action;
  17778. /**
  17779. * Internal only
  17780. * @hidden
  17781. */
  17782. _getProperty(propertyPath: string): string;
  17783. /**
  17784. * Internal only
  17785. * @hidden
  17786. */
  17787. _getEffectiveTarget(target: any, propertyPath: string): any;
  17788. /**
  17789. * Serialize placeholder for child classes
  17790. * @param parent of child
  17791. * @returns the serialized object
  17792. */
  17793. serialize(parent: any): any;
  17794. /**
  17795. * Internal only called by serialize
  17796. * @hidden
  17797. */
  17798. protected _serialize(serializedAction: any, parent?: any): any;
  17799. /**
  17800. * Internal only
  17801. * @hidden
  17802. */
  17803. static _SerializeValueAsString: (value: any) => string;
  17804. /**
  17805. * Internal only
  17806. * @hidden
  17807. */
  17808. static _GetTargetProperty: (target: import("babylonjs/node").Node | import("babylonjs/scene").Scene) => {
  17809. name: string;
  17810. targetType: string;
  17811. value: string;
  17812. };
  17813. }
  17814. }
  17815. declare module "babylonjs/Actions/condition" {
  17816. import { ActionManager } from "babylonjs/Actions/actionManager";
  17817. /**
  17818. * A Condition applied to an Action
  17819. */
  17820. export class Condition {
  17821. /**
  17822. * Internal only - manager for action
  17823. * @hidden
  17824. */
  17825. _actionManager: ActionManager;
  17826. /**
  17827. * Internal only
  17828. * @hidden
  17829. */
  17830. _evaluationId: number;
  17831. /**
  17832. * Internal only
  17833. * @hidden
  17834. */
  17835. _currentResult: boolean;
  17836. /**
  17837. * Creates a new Condition
  17838. * @param actionManager the manager of the action the condition is applied to
  17839. */
  17840. constructor(actionManager: ActionManager);
  17841. /**
  17842. * Check if the current condition is valid
  17843. * @returns a boolean
  17844. */
  17845. isValid(): boolean;
  17846. /**
  17847. * Internal only
  17848. * @hidden
  17849. */
  17850. _getProperty(propertyPath: string): string;
  17851. /**
  17852. * Internal only
  17853. * @hidden
  17854. */
  17855. _getEffectiveTarget(target: any, propertyPath: string): any;
  17856. /**
  17857. * Serialize placeholder for child classes
  17858. * @returns the serialized object
  17859. */
  17860. serialize(): any;
  17861. /**
  17862. * Internal only
  17863. * @hidden
  17864. */
  17865. protected _serialize(serializedCondition: any): any;
  17866. }
  17867. /**
  17868. * Defines specific conditional operators as extensions of Condition
  17869. */
  17870. export class ValueCondition extends Condition {
  17871. /** path to specify the property of the target the conditional operator uses */
  17872. propertyPath: string;
  17873. /** the value compared by the conditional operator against the current value of the property */
  17874. value: any;
  17875. /** the conditional operator, default ValueCondition.IsEqual */
  17876. operator: number;
  17877. /**
  17878. * Internal only
  17879. * @hidden
  17880. */
  17881. private static _IsEqual;
  17882. /**
  17883. * Internal only
  17884. * @hidden
  17885. */
  17886. private static _IsDifferent;
  17887. /**
  17888. * Internal only
  17889. * @hidden
  17890. */
  17891. private static _IsGreater;
  17892. /**
  17893. * Internal only
  17894. * @hidden
  17895. */
  17896. private static _IsLesser;
  17897. /**
  17898. * returns the number for IsEqual
  17899. */
  17900. static get IsEqual(): number;
  17901. /**
  17902. * Returns the number for IsDifferent
  17903. */
  17904. static get IsDifferent(): number;
  17905. /**
  17906. * Returns the number for IsGreater
  17907. */
  17908. static get IsGreater(): number;
  17909. /**
  17910. * Returns the number for IsLesser
  17911. */
  17912. static get IsLesser(): number;
  17913. /**
  17914. * Internal only The action manager for the condition
  17915. * @hidden
  17916. */
  17917. _actionManager: ActionManager;
  17918. /**
  17919. * Internal only
  17920. * @hidden
  17921. */
  17922. private _target;
  17923. /**
  17924. * Internal only
  17925. * @hidden
  17926. */
  17927. private _effectiveTarget;
  17928. /**
  17929. * Internal only
  17930. * @hidden
  17931. */
  17932. private _property;
  17933. /**
  17934. * Creates a new ValueCondition
  17935. * @param actionManager manager for the action the condition applies to
  17936. * @param target for the action
  17937. * @param propertyPath path to specify the property of the target the conditional operator uses
  17938. * @param value the value compared by the conditional operator against the current value of the property
  17939. * @param operator the conditional operator, default ValueCondition.IsEqual
  17940. */
  17941. constructor(actionManager: ActionManager, target: any,
  17942. /** path to specify the property of the target the conditional operator uses */
  17943. propertyPath: string,
  17944. /** the value compared by the conditional operator against the current value of the property */
  17945. value: any,
  17946. /** the conditional operator, default ValueCondition.IsEqual */
  17947. operator?: number);
  17948. /**
  17949. * Compares the given value with the property value for the specified conditional operator
  17950. * @returns the result of the comparison
  17951. */
  17952. isValid(): boolean;
  17953. /**
  17954. * Serialize the ValueCondition into a JSON compatible object
  17955. * @returns serialization object
  17956. */
  17957. serialize(): any;
  17958. /**
  17959. * Gets the name of the conditional operator for the ValueCondition
  17960. * @param operator the conditional operator
  17961. * @returns the name
  17962. */
  17963. static GetOperatorName(operator: number): string;
  17964. }
  17965. /**
  17966. * Defines a predicate condition as an extension of Condition
  17967. */
  17968. export class PredicateCondition extends Condition {
  17969. /** defines the predicate function used to validate the condition */
  17970. predicate: () => boolean;
  17971. /**
  17972. * Internal only - manager for action
  17973. * @hidden
  17974. */
  17975. _actionManager: ActionManager;
  17976. /**
  17977. * Creates a new PredicateCondition
  17978. * @param actionManager manager for the action the condition applies to
  17979. * @param predicate defines the predicate function used to validate the condition
  17980. */
  17981. constructor(actionManager: ActionManager,
  17982. /** defines the predicate function used to validate the condition */
  17983. predicate: () => boolean);
  17984. /**
  17985. * @returns the validity of the predicate condition
  17986. */
  17987. isValid(): boolean;
  17988. }
  17989. /**
  17990. * Defines a state condition as an extension of Condition
  17991. */
  17992. export class StateCondition extends Condition {
  17993. /** Value to compare with target state */
  17994. value: string;
  17995. /**
  17996. * Internal only - manager for action
  17997. * @hidden
  17998. */
  17999. _actionManager: ActionManager;
  18000. /**
  18001. * Internal only
  18002. * @hidden
  18003. */
  18004. private _target;
  18005. /**
  18006. * Creates a new StateCondition
  18007. * @param actionManager manager for the action the condition applies to
  18008. * @param target of the condition
  18009. * @param value to compare with target state
  18010. */
  18011. constructor(actionManager: ActionManager, target: any,
  18012. /** Value to compare with target state */
  18013. value: string);
  18014. /**
  18015. * Gets a boolean indicating if the current condition is met
  18016. * @returns the validity of the state
  18017. */
  18018. isValid(): boolean;
  18019. /**
  18020. * Serialize the StateCondition into a JSON compatible object
  18021. * @returns serialization object
  18022. */
  18023. serialize(): any;
  18024. }
  18025. }
  18026. declare module "babylonjs/Actions/directActions" {
  18027. import { Action } from "babylonjs/Actions/action";
  18028. import { Condition } from "babylonjs/Actions/condition";
  18029. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  18030. /**
  18031. * This defines an action responsible to toggle a boolean once triggered.
  18032. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18033. */
  18034. export class SwitchBooleanAction extends Action {
  18035. /**
  18036. * The path to the boolean property in the target object
  18037. */
  18038. propertyPath: string;
  18039. private _target;
  18040. private _effectiveTarget;
  18041. private _property;
  18042. /**
  18043. * Instantiate the action
  18044. * @param triggerOptions defines the trigger options
  18045. * @param target defines the object containing the boolean
  18046. * @param propertyPath defines the path to the boolean property in the target object
  18047. * @param condition defines the trigger related conditions
  18048. */
  18049. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  18050. /** @hidden */
  18051. _prepare(): void;
  18052. /**
  18053. * Execute the action toggle the boolean value.
  18054. */
  18055. execute(): void;
  18056. /**
  18057. * Serializes the actions and its related information.
  18058. * @param parent defines the object to serialize in
  18059. * @returns the serialized object
  18060. */
  18061. serialize(parent: any): any;
  18062. }
  18063. /**
  18064. * This defines an action responsible to set a the state field of the target
  18065. * to a desired value once triggered.
  18066. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18067. */
  18068. export class SetStateAction extends Action {
  18069. /**
  18070. * The value to store in the state field.
  18071. */
  18072. value: string;
  18073. private _target;
  18074. /**
  18075. * Instantiate the action
  18076. * @param triggerOptions defines the trigger options
  18077. * @param target defines the object containing the state property
  18078. * @param value defines the value to store in the state field
  18079. * @param condition defines the trigger related conditions
  18080. */
  18081. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  18082. /**
  18083. * Execute the action and store the value on the target state property.
  18084. */
  18085. execute(): void;
  18086. /**
  18087. * Serializes the actions and its related information.
  18088. * @param parent defines the object to serialize in
  18089. * @returns the serialized object
  18090. */
  18091. serialize(parent: any): any;
  18092. }
  18093. /**
  18094. * This defines an action responsible to set a property of the target
  18095. * to a desired value once triggered.
  18096. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18097. */
  18098. export class SetValueAction extends Action {
  18099. /**
  18100. * The path of the property to set in the target.
  18101. */
  18102. propertyPath: string;
  18103. /**
  18104. * The value to set in the property
  18105. */
  18106. value: any;
  18107. private _target;
  18108. private _effectiveTarget;
  18109. private _property;
  18110. /**
  18111. * Instantiate the action
  18112. * @param triggerOptions defines the trigger options
  18113. * @param target defines the object containing the property
  18114. * @param propertyPath defines the path of the property to set in the target
  18115. * @param value defines the value to set in the property
  18116. * @param condition defines the trigger related conditions
  18117. */
  18118. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  18119. /** @hidden */
  18120. _prepare(): void;
  18121. /**
  18122. * Execute the action and set the targetted property to the desired value.
  18123. */
  18124. execute(): void;
  18125. /**
  18126. * Serializes the actions and its related information.
  18127. * @param parent defines the object to serialize in
  18128. * @returns the serialized object
  18129. */
  18130. serialize(parent: any): any;
  18131. }
  18132. /**
  18133. * This defines an action responsible to increment the target value
  18134. * to a desired value once triggered.
  18135. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18136. */
  18137. export class IncrementValueAction extends Action {
  18138. /**
  18139. * The path of the property to increment in the target.
  18140. */
  18141. propertyPath: string;
  18142. /**
  18143. * The value we should increment the property by.
  18144. */
  18145. value: any;
  18146. private _target;
  18147. private _effectiveTarget;
  18148. private _property;
  18149. /**
  18150. * Instantiate the action
  18151. * @param triggerOptions defines the trigger options
  18152. * @param target defines the object containing the property
  18153. * @param propertyPath defines the path of the property to increment in the target
  18154. * @param value defines the value value we should increment the property by
  18155. * @param condition defines the trigger related conditions
  18156. */
  18157. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  18158. /** @hidden */
  18159. _prepare(): void;
  18160. /**
  18161. * Execute the action and increment the target of the value amount.
  18162. */
  18163. execute(): void;
  18164. /**
  18165. * Serializes the actions and its related information.
  18166. * @param parent defines the object to serialize in
  18167. * @returns the serialized object
  18168. */
  18169. serialize(parent: any): any;
  18170. }
  18171. /**
  18172. * This defines an action responsible to start an animation once triggered.
  18173. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18174. */
  18175. export class PlayAnimationAction extends Action {
  18176. /**
  18177. * Where the animation should start (animation frame)
  18178. */
  18179. from: number;
  18180. /**
  18181. * Where the animation should stop (animation frame)
  18182. */
  18183. to: number;
  18184. /**
  18185. * Define if the animation should loop or stop after the first play.
  18186. */
  18187. loop?: boolean;
  18188. private _target;
  18189. /**
  18190. * Instantiate the action
  18191. * @param triggerOptions defines the trigger options
  18192. * @param target defines the target animation or animation name
  18193. * @param from defines from where the animation should start (animation frame)
  18194. * @param end defines where the animation should stop (animation frame)
  18195. * @param loop defines if the animation should loop or stop after the first play
  18196. * @param condition defines the trigger related conditions
  18197. */
  18198. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  18199. /** @hidden */
  18200. _prepare(): void;
  18201. /**
  18202. * Execute the action and play the animation.
  18203. */
  18204. execute(): void;
  18205. /**
  18206. * Serializes the actions and its related information.
  18207. * @param parent defines the object to serialize in
  18208. * @returns the serialized object
  18209. */
  18210. serialize(parent: any): any;
  18211. }
  18212. /**
  18213. * This defines an action responsible to stop an animation once triggered.
  18214. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18215. */
  18216. export class StopAnimationAction extends Action {
  18217. private _target;
  18218. /**
  18219. * Instantiate the action
  18220. * @param triggerOptions defines the trigger options
  18221. * @param target defines the target animation or animation name
  18222. * @param condition defines the trigger related conditions
  18223. */
  18224. constructor(triggerOptions: any, target: any, condition?: Condition);
  18225. /** @hidden */
  18226. _prepare(): void;
  18227. /**
  18228. * Execute the action and stop the animation.
  18229. */
  18230. execute(): void;
  18231. /**
  18232. * Serializes the actions and its related information.
  18233. * @param parent defines the object to serialize in
  18234. * @returns the serialized object
  18235. */
  18236. serialize(parent: any): any;
  18237. }
  18238. /**
  18239. * This defines an action responsible that does nothing once triggered.
  18240. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18241. */
  18242. export class DoNothingAction extends Action {
  18243. /**
  18244. * Instantiate the action
  18245. * @param triggerOptions defines the trigger options
  18246. * @param condition defines the trigger related conditions
  18247. */
  18248. constructor(triggerOptions?: any, condition?: Condition);
  18249. /**
  18250. * Execute the action and do nothing.
  18251. */
  18252. execute(): void;
  18253. /**
  18254. * Serializes the actions and its related information.
  18255. * @param parent defines the object to serialize in
  18256. * @returns the serialized object
  18257. */
  18258. serialize(parent: any): any;
  18259. }
  18260. /**
  18261. * This defines an action responsible to trigger several actions once triggered.
  18262. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18263. */
  18264. export class CombineAction extends Action {
  18265. /**
  18266. * The list of aggregated animations to run.
  18267. */
  18268. children: Action[];
  18269. /**
  18270. * Instantiate the action
  18271. * @param triggerOptions defines the trigger options
  18272. * @param children defines the list of aggregated animations to run
  18273. * @param condition defines the trigger related conditions
  18274. */
  18275. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  18276. /** @hidden */
  18277. _prepare(): void;
  18278. /**
  18279. * Execute the action and executes all the aggregated actions.
  18280. */
  18281. execute(evt: ActionEvent): void;
  18282. /**
  18283. * Serializes the actions and its related information.
  18284. * @param parent defines the object to serialize in
  18285. * @returns the serialized object
  18286. */
  18287. serialize(parent: any): any;
  18288. }
  18289. /**
  18290. * This defines an action responsible to run code (external event) once triggered.
  18291. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18292. */
  18293. export class ExecuteCodeAction extends Action {
  18294. /**
  18295. * The callback function to run.
  18296. */
  18297. func: (evt: ActionEvent) => void;
  18298. /**
  18299. * Instantiate the action
  18300. * @param triggerOptions defines the trigger options
  18301. * @param func defines the callback function to run
  18302. * @param condition defines the trigger related conditions
  18303. */
  18304. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  18305. /**
  18306. * Execute the action and run the attached code.
  18307. */
  18308. execute(evt: ActionEvent): void;
  18309. }
  18310. /**
  18311. * This defines an action responsible to set the parent property of the target once triggered.
  18312. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18313. */
  18314. export class SetParentAction extends Action {
  18315. private _parent;
  18316. private _target;
  18317. /**
  18318. * Instantiate the action
  18319. * @param triggerOptions defines the trigger options
  18320. * @param target defines the target containing the parent property
  18321. * @param parent defines from where the animation should start (animation frame)
  18322. * @param condition defines the trigger related conditions
  18323. */
  18324. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  18325. /** @hidden */
  18326. _prepare(): void;
  18327. /**
  18328. * Execute the action and set the parent property.
  18329. */
  18330. execute(): void;
  18331. /**
  18332. * Serializes the actions and its related information.
  18333. * @param parent defines the object to serialize in
  18334. * @returns the serialized object
  18335. */
  18336. serialize(parent: any): any;
  18337. }
  18338. }
  18339. declare module "babylonjs/Actions/actionManager" {
  18340. import { Nullable } from "babylonjs/types";
  18341. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18342. import { Scene } from "babylonjs/scene";
  18343. import { IAction } from "babylonjs/Actions/action";
  18344. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  18345. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  18346. /**
  18347. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  18348. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  18349. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18350. */
  18351. export class ActionManager extends AbstractActionManager {
  18352. /**
  18353. * Nothing
  18354. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18355. */
  18356. static readonly NothingTrigger: number;
  18357. /**
  18358. * On pick
  18359. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18360. */
  18361. static readonly OnPickTrigger: number;
  18362. /**
  18363. * On left pick
  18364. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18365. */
  18366. static readonly OnLeftPickTrigger: number;
  18367. /**
  18368. * On right pick
  18369. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18370. */
  18371. static readonly OnRightPickTrigger: number;
  18372. /**
  18373. * On center pick
  18374. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18375. */
  18376. static readonly OnCenterPickTrigger: number;
  18377. /**
  18378. * On pick down
  18379. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18380. */
  18381. static readonly OnPickDownTrigger: number;
  18382. /**
  18383. * On double pick
  18384. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18385. */
  18386. static readonly OnDoublePickTrigger: number;
  18387. /**
  18388. * On pick up
  18389. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18390. */
  18391. static readonly OnPickUpTrigger: number;
  18392. /**
  18393. * On pick out.
  18394. * This trigger will only be raised if you also declared a OnPickDown
  18395. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18396. */
  18397. static readonly OnPickOutTrigger: number;
  18398. /**
  18399. * On long press
  18400. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18401. */
  18402. static readonly OnLongPressTrigger: number;
  18403. /**
  18404. * On pointer over
  18405. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18406. */
  18407. static readonly OnPointerOverTrigger: number;
  18408. /**
  18409. * On pointer out
  18410. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18411. */
  18412. static readonly OnPointerOutTrigger: number;
  18413. /**
  18414. * On every frame
  18415. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18416. */
  18417. static readonly OnEveryFrameTrigger: number;
  18418. /**
  18419. * On intersection enter
  18420. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18421. */
  18422. static readonly OnIntersectionEnterTrigger: number;
  18423. /**
  18424. * On intersection exit
  18425. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18426. */
  18427. static readonly OnIntersectionExitTrigger: number;
  18428. /**
  18429. * On key down
  18430. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18431. */
  18432. static readonly OnKeyDownTrigger: number;
  18433. /**
  18434. * On key up
  18435. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18436. */
  18437. static readonly OnKeyUpTrigger: number;
  18438. private _scene;
  18439. /**
  18440. * Creates a new action manager
  18441. * @param scene defines the hosting scene
  18442. */
  18443. constructor(scene: Scene);
  18444. /**
  18445. * Releases all associated resources
  18446. */
  18447. dispose(): void;
  18448. /**
  18449. * Gets hosting scene
  18450. * @returns the hosting scene
  18451. */
  18452. getScene(): Scene;
  18453. /**
  18454. * Does this action manager handles actions of any of the given triggers
  18455. * @param triggers defines the triggers to be tested
  18456. * @return a boolean indicating whether one (or more) of the triggers is handled
  18457. */
  18458. hasSpecificTriggers(triggers: number[]): boolean;
  18459. /**
  18460. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  18461. * speed.
  18462. * @param triggerA defines the trigger to be tested
  18463. * @param triggerB defines the trigger to be tested
  18464. * @return a boolean indicating whether one (or more) of the triggers is handled
  18465. */
  18466. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  18467. /**
  18468. * Does this action manager handles actions of a given trigger
  18469. * @param trigger defines the trigger to be tested
  18470. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  18471. * @return whether the trigger is handled
  18472. */
  18473. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  18474. /**
  18475. * Does this action manager has pointer triggers
  18476. */
  18477. get hasPointerTriggers(): boolean;
  18478. /**
  18479. * Does this action manager has pick triggers
  18480. */
  18481. get hasPickTriggers(): boolean;
  18482. /**
  18483. * Registers an action to this action manager
  18484. * @param action defines the action to be registered
  18485. * @return the action amended (prepared) after registration
  18486. */
  18487. registerAction(action: IAction): Nullable<IAction>;
  18488. /**
  18489. * Unregisters an action to this action manager
  18490. * @param action defines the action to be unregistered
  18491. * @return a boolean indicating whether the action has been unregistered
  18492. */
  18493. unregisterAction(action: IAction): Boolean;
  18494. /**
  18495. * Process a specific trigger
  18496. * @param trigger defines the trigger to process
  18497. * @param evt defines the event details to be processed
  18498. */
  18499. processTrigger(trigger: number, evt?: IActionEvent): void;
  18500. /** @hidden */
  18501. _getEffectiveTarget(target: any, propertyPath: string): any;
  18502. /** @hidden */
  18503. _getProperty(propertyPath: string): string;
  18504. /**
  18505. * Serialize this manager to a JSON object
  18506. * @param name defines the property name to store this manager
  18507. * @returns a JSON representation of this manager
  18508. */
  18509. serialize(name: string): any;
  18510. /**
  18511. * Creates a new ActionManager from a JSON data
  18512. * @param parsedActions defines the JSON data to read from
  18513. * @param object defines the hosting mesh
  18514. * @param scene defines the hosting scene
  18515. */
  18516. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  18517. /**
  18518. * Get a trigger name by index
  18519. * @param trigger defines the trigger index
  18520. * @returns a trigger name
  18521. */
  18522. static GetTriggerName(trigger: number): string;
  18523. }
  18524. }
  18525. declare module "babylonjs/Sprites/sprite" {
  18526. import { Vector3 } from "babylonjs/Maths/math.vector";
  18527. import { Nullable } from "babylonjs/types";
  18528. import { ActionManager } from "babylonjs/Actions/actionManager";
  18529. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  18530. import { Color4 } from "babylonjs/Maths/math.color";
  18531. /**
  18532. * Class used to represent a sprite
  18533. * @see http://doc.babylonjs.com/babylon101/sprites
  18534. */
  18535. export class Sprite {
  18536. /** defines the name */
  18537. name: string;
  18538. /** Gets or sets the current world position */
  18539. position: Vector3;
  18540. /** Gets or sets the main color */
  18541. color: Color4;
  18542. /** Gets or sets the width */
  18543. width: number;
  18544. /** Gets or sets the height */
  18545. height: number;
  18546. /** Gets or sets rotation angle */
  18547. angle: number;
  18548. /** Gets or sets the cell index in the sprite sheet */
  18549. cellIndex: number;
  18550. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  18551. cellRef: string;
  18552. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  18553. invertU: number;
  18554. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  18555. invertV: number;
  18556. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  18557. disposeWhenFinishedAnimating: boolean;
  18558. /** Gets the list of attached animations */
  18559. animations: Animation[];
  18560. /** Gets or sets a boolean indicating if the sprite can be picked */
  18561. isPickable: boolean;
  18562. /**
  18563. * Gets or sets the associated action manager
  18564. */
  18565. actionManager: Nullable<ActionManager>;
  18566. private _animationStarted;
  18567. private _loopAnimation;
  18568. private _fromIndex;
  18569. private _toIndex;
  18570. private _delay;
  18571. private _direction;
  18572. private _manager;
  18573. private _time;
  18574. private _onAnimationEnd;
  18575. /**
  18576. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  18577. */
  18578. isVisible: boolean;
  18579. /**
  18580. * Gets or sets the sprite size
  18581. */
  18582. get size(): number;
  18583. set size(value: number);
  18584. /**
  18585. * Creates a new Sprite
  18586. * @param name defines the name
  18587. * @param manager defines the manager
  18588. */
  18589. constructor(
  18590. /** defines the name */
  18591. name: string, manager: ISpriteManager);
  18592. /**
  18593. * Starts an animation
  18594. * @param from defines the initial key
  18595. * @param to defines the end key
  18596. * @param loop defines if the animation must loop
  18597. * @param delay defines the start delay (in ms)
  18598. * @param onAnimationEnd defines a callback to call when animation ends
  18599. */
  18600. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  18601. /** Stops current animation (if any) */
  18602. stopAnimation(): void;
  18603. /** @hidden */
  18604. _animate(deltaTime: number): void;
  18605. /** Release associated resources */
  18606. dispose(): void;
  18607. }
  18608. }
  18609. declare module "babylonjs/Collisions/pickingInfo" {
  18610. import { Nullable } from "babylonjs/types";
  18611. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  18612. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18613. import { Sprite } from "babylonjs/Sprites/sprite";
  18614. import { Ray } from "babylonjs/Culling/ray";
  18615. /**
  18616. * Information about the result of picking within a scene
  18617. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  18618. */
  18619. export class PickingInfo {
  18620. /** @hidden */
  18621. _pickingUnavailable: boolean;
  18622. /**
  18623. * If the pick collided with an object
  18624. */
  18625. hit: boolean;
  18626. /**
  18627. * Distance away where the pick collided
  18628. */
  18629. distance: number;
  18630. /**
  18631. * The location of pick collision
  18632. */
  18633. pickedPoint: Nullable<Vector3>;
  18634. /**
  18635. * The mesh corresponding the the pick collision
  18636. */
  18637. pickedMesh: Nullable<AbstractMesh>;
  18638. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  18639. bu: number;
  18640. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  18641. bv: number;
  18642. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  18643. faceId: number;
  18644. /** Id of the the submesh that was picked */
  18645. subMeshId: number;
  18646. /** If a sprite was picked, this will be the sprite the pick collided with */
  18647. pickedSprite: Nullable<Sprite>;
  18648. /**
  18649. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  18650. */
  18651. originMesh: Nullable<AbstractMesh>;
  18652. /**
  18653. * The ray that was used to perform the picking.
  18654. */
  18655. ray: Nullable<Ray>;
  18656. /**
  18657. * Gets the normal correspodning to the face the pick collided with
  18658. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  18659. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  18660. * @returns The normal correspodning to the face the pick collided with
  18661. */
  18662. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  18663. /**
  18664. * Gets the texture coordinates of where the pick occured
  18665. * @returns the vector containing the coordnates of the texture
  18666. */
  18667. getTextureCoordinates(): Nullable<Vector2>;
  18668. }
  18669. }
  18670. declare module "babylonjs/Events/pointerEvents" {
  18671. import { Nullable } from "babylonjs/types";
  18672. import { Vector2 } from "babylonjs/Maths/math.vector";
  18673. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  18674. import { Ray } from "babylonjs/Culling/ray";
  18675. /**
  18676. * Gather the list of pointer event types as constants.
  18677. */
  18678. export class PointerEventTypes {
  18679. /**
  18680. * 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.
  18681. */
  18682. static readonly POINTERDOWN: number;
  18683. /**
  18684. * The pointerup event is fired when a pointer is no longer active.
  18685. */
  18686. static readonly POINTERUP: number;
  18687. /**
  18688. * The pointermove event is fired when a pointer changes coordinates.
  18689. */
  18690. static readonly POINTERMOVE: number;
  18691. /**
  18692. * The pointerwheel event is fired when a mouse wheel has been rotated.
  18693. */
  18694. static readonly POINTERWHEEL: number;
  18695. /**
  18696. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  18697. */
  18698. static readonly POINTERPICK: number;
  18699. /**
  18700. * The pointertap event is fired when a the object has been touched and released without drag.
  18701. */
  18702. static readonly POINTERTAP: number;
  18703. /**
  18704. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  18705. */
  18706. static readonly POINTERDOUBLETAP: number;
  18707. }
  18708. /**
  18709. * Base class of pointer info types.
  18710. */
  18711. export class PointerInfoBase {
  18712. /**
  18713. * Defines the type of event (PointerEventTypes)
  18714. */
  18715. type: number;
  18716. /**
  18717. * Defines the related dom event
  18718. */
  18719. event: PointerEvent | MouseWheelEvent;
  18720. /**
  18721. * Instantiates the base class of pointers info.
  18722. * @param type Defines the type of event (PointerEventTypes)
  18723. * @param event Defines the related dom event
  18724. */
  18725. constructor(
  18726. /**
  18727. * Defines the type of event (PointerEventTypes)
  18728. */
  18729. type: number,
  18730. /**
  18731. * Defines the related dom event
  18732. */
  18733. event: PointerEvent | MouseWheelEvent);
  18734. }
  18735. /**
  18736. * This class is used to store pointer related info for the onPrePointerObservable event.
  18737. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  18738. */
  18739. export class PointerInfoPre extends PointerInfoBase {
  18740. /**
  18741. * Ray from a pointer if availible (eg. 6dof controller)
  18742. */
  18743. ray: Nullable<Ray>;
  18744. /**
  18745. * Defines the local position of the pointer on the canvas.
  18746. */
  18747. localPosition: Vector2;
  18748. /**
  18749. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  18750. */
  18751. skipOnPointerObservable: boolean;
  18752. /**
  18753. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  18754. * @param type Defines the type of event (PointerEventTypes)
  18755. * @param event Defines the related dom event
  18756. * @param localX Defines the local x coordinates of the pointer when the event occured
  18757. * @param localY Defines the local y coordinates of the pointer when the event occured
  18758. */
  18759. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  18760. }
  18761. /**
  18762. * This type contains all the data related to a pointer event in Babylon.js.
  18763. * 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.
  18764. */
  18765. export class PointerInfo extends PointerInfoBase {
  18766. /**
  18767. * Defines the picking info associated to the info (if any)\
  18768. */
  18769. pickInfo: Nullable<PickingInfo>;
  18770. /**
  18771. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  18772. * @param type Defines the type of event (PointerEventTypes)
  18773. * @param event Defines the related dom event
  18774. * @param pickInfo Defines the picking info associated to the info (if any)\
  18775. */
  18776. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  18777. /**
  18778. * Defines the picking info associated to the info (if any)\
  18779. */
  18780. pickInfo: Nullable<PickingInfo>);
  18781. }
  18782. /**
  18783. * Data relating to a touch event on the screen.
  18784. */
  18785. export interface PointerTouch {
  18786. /**
  18787. * X coordinate of touch.
  18788. */
  18789. x: number;
  18790. /**
  18791. * Y coordinate of touch.
  18792. */
  18793. y: number;
  18794. /**
  18795. * Id of touch. Unique for each finger.
  18796. */
  18797. pointerId: number;
  18798. /**
  18799. * Event type passed from DOM.
  18800. */
  18801. type: any;
  18802. }
  18803. }
  18804. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  18805. import { Observable } from "babylonjs/Misc/observable";
  18806. import { Nullable } from "babylonjs/types";
  18807. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  18808. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  18809. /**
  18810. * Manage the mouse inputs to control the movement of a free camera.
  18811. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18812. */
  18813. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  18814. /**
  18815. * Define if touch is enabled in the mouse input
  18816. */
  18817. touchEnabled: boolean;
  18818. /**
  18819. * Defines the camera the input is attached to.
  18820. */
  18821. camera: FreeCamera;
  18822. /**
  18823. * Defines the buttons associated with the input to handle camera move.
  18824. */
  18825. buttons: number[];
  18826. /**
  18827. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  18828. */
  18829. angularSensibility: number;
  18830. private _pointerInput;
  18831. private _onMouseMove;
  18832. private _observer;
  18833. private previousPosition;
  18834. /**
  18835. * Observable for when a pointer move event occurs containing the move offset
  18836. */
  18837. onPointerMovedObservable: Observable<{
  18838. offsetX: number;
  18839. offsetY: number;
  18840. }>;
  18841. /**
  18842. * @hidden
  18843. * If the camera should be rotated automatically based on pointer movement
  18844. */
  18845. _allowCameraRotation: boolean;
  18846. /**
  18847. * Manage the mouse inputs to control the movement of a free camera.
  18848. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18849. * @param touchEnabled Defines if touch is enabled or not
  18850. */
  18851. constructor(
  18852. /**
  18853. * Define if touch is enabled in the mouse input
  18854. */
  18855. touchEnabled?: boolean);
  18856. /**
  18857. * Attach the input controls to a specific dom element to get the input from.
  18858. * @param element Defines the element the controls should be listened from
  18859. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18860. */
  18861. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18862. /**
  18863. * Called on JS contextmenu event.
  18864. * Override this method to provide functionality.
  18865. */
  18866. protected onContextMenu(evt: PointerEvent): void;
  18867. /**
  18868. * Detach the current controls from the specified dom element.
  18869. * @param element Defines the element to stop listening the inputs from
  18870. */
  18871. detachControl(element: Nullable<HTMLElement>): void;
  18872. /**
  18873. * Gets the class name of the current intput.
  18874. * @returns the class name
  18875. */
  18876. getClassName(): string;
  18877. /**
  18878. * Get the friendly name associated with the input class.
  18879. * @returns the input friendly name
  18880. */
  18881. getSimpleName(): string;
  18882. }
  18883. }
  18884. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  18885. import { Nullable } from "babylonjs/types";
  18886. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  18887. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  18888. /**
  18889. * Manage the touch inputs to control the movement of a free camera.
  18890. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18891. */
  18892. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  18893. /**
  18894. * Defines the camera the input is attached to.
  18895. */
  18896. camera: FreeCamera;
  18897. /**
  18898. * Defines the touch sensibility for rotation.
  18899. * The higher the faster.
  18900. */
  18901. touchAngularSensibility: number;
  18902. /**
  18903. * Defines the touch sensibility for move.
  18904. * The higher the faster.
  18905. */
  18906. touchMoveSensibility: number;
  18907. private _offsetX;
  18908. private _offsetY;
  18909. private _pointerPressed;
  18910. private _pointerInput;
  18911. private _observer;
  18912. private _onLostFocus;
  18913. /**
  18914. * Attach the input controls to a specific dom element to get the input from.
  18915. * @param element Defines the element the controls should be listened from
  18916. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18917. */
  18918. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18919. /**
  18920. * Detach the current controls from the specified dom element.
  18921. * @param element Defines the element to stop listening the inputs from
  18922. */
  18923. detachControl(element: Nullable<HTMLElement>): void;
  18924. /**
  18925. * Update the current camera state depending on the inputs that have been used this frame.
  18926. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  18927. */
  18928. checkInputs(): void;
  18929. /**
  18930. * Gets the class name of the current intput.
  18931. * @returns the class name
  18932. */
  18933. getClassName(): string;
  18934. /**
  18935. * Get the friendly name associated with the input class.
  18936. * @returns the input friendly name
  18937. */
  18938. getSimpleName(): string;
  18939. }
  18940. }
  18941. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  18942. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  18943. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  18944. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  18945. import { Nullable } from "babylonjs/types";
  18946. /**
  18947. * Default Inputs manager for the FreeCamera.
  18948. * It groups all the default supported inputs for ease of use.
  18949. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18950. */
  18951. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  18952. /**
  18953. * @hidden
  18954. */
  18955. _mouseInput: Nullable<FreeCameraMouseInput>;
  18956. /**
  18957. * Instantiates a new FreeCameraInputsManager.
  18958. * @param camera Defines the camera the inputs belong to
  18959. */
  18960. constructor(camera: FreeCamera);
  18961. /**
  18962. * Add keyboard input support to the input manager.
  18963. * @returns the current input manager
  18964. */
  18965. addKeyboard(): FreeCameraInputsManager;
  18966. /**
  18967. * Add mouse input support to the input manager.
  18968. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  18969. * @returns the current input manager
  18970. */
  18971. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  18972. /**
  18973. * Removes the mouse input support from the manager
  18974. * @returns the current input manager
  18975. */
  18976. removeMouse(): FreeCameraInputsManager;
  18977. /**
  18978. * Add touch input support to the input manager.
  18979. * @returns the current input manager
  18980. */
  18981. addTouch(): FreeCameraInputsManager;
  18982. /**
  18983. * Remove all attached input methods from a camera
  18984. */
  18985. clear(): void;
  18986. }
  18987. }
  18988. declare module "babylonjs/Cameras/freeCamera" {
  18989. import { Vector3 } from "babylonjs/Maths/math.vector";
  18990. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18991. import { Scene } from "babylonjs/scene";
  18992. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  18993. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  18994. /**
  18995. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  18996. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  18997. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  18998. */
  18999. export class FreeCamera extends TargetCamera {
  19000. /**
  19001. * Define the collision ellipsoid of the camera.
  19002. * This is helpful to simulate a camera body like the player body around the camera
  19003. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  19004. */
  19005. ellipsoid: Vector3;
  19006. /**
  19007. * Define an offset for the position of the ellipsoid around the camera.
  19008. * This can be helpful to determine the center of the body near the gravity center of the body
  19009. * instead of its head.
  19010. */
  19011. ellipsoidOffset: Vector3;
  19012. /**
  19013. * Enable or disable collisions of the camera with the rest of the scene objects.
  19014. */
  19015. checkCollisions: boolean;
  19016. /**
  19017. * Enable or disable gravity on the camera.
  19018. */
  19019. applyGravity: boolean;
  19020. /**
  19021. * Define the input manager associated to the camera.
  19022. */
  19023. inputs: FreeCameraInputsManager;
  19024. /**
  19025. * Gets the input sensibility for a mouse input. (default is 2000.0)
  19026. * Higher values reduce sensitivity.
  19027. */
  19028. get angularSensibility(): number;
  19029. /**
  19030. * Sets the input sensibility for a mouse input. (default is 2000.0)
  19031. * Higher values reduce sensitivity.
  19032. */
  19033. set angularSensibility(value: number);
  19034. /**
  19035. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  19036. */
  19037. get keysUp(): number[];
  19038. set keysUp(value: number[]);
  19039. /**
  19040. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  19041. */
  19042. get keysUpward(): number[];
  19043. set keysUpward(value: number[]);
  19044. /**
  19045. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  19046. */
  19047. get keysDown(): number[];
  19048. set keysDown(value: number[]);
  19049. /**
  19050. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  19051. */
  19052. get keysDownward(): number[];
  19053. set keysDownward(value: number[]);
  19054. /**
  19055. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  19056. */
  19057. get keysLeft(): number[];
  19058. set keysLeft(value: number[]);
  19059. /**
  19060. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  19061. */
  19062. get keysRight(): number[];
  19063. set keysRight(value: number[]);
  19064. /**
  19065. * Event raised when the camera collide with a mesh in the scene.
  19066. */
  19067. onCollide: (collidedMesh: AbstractMesh) => void;
  19068. private _collider;
  19069. private _needMoveForGravity;
  19070. private _oldPosition;
  19071. private _diffPosition;
  19072. private _newPosition;
  19073. /** @hidden */
  19074. _localDirection: Vector3;
  19075. /** @hidden */
  19076. _transformedDirection: Vector3;
  19077. /**
  19078. * Instantiates a Free Camera.
  19079. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  19080. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  19081. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  19082. * @param name Define the name of the camera in the scene
  19083. * @param position Define the start position of the camera in the scene
  19084. * @param scene Define the scene the camera belongs to
  19085. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  19086. */
  19087. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  19088. /**
  19089. * Attached controls to the current camera.
  19090. * @param element Defines the element the controls should be listened from
  19091. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19092. */
  19093. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19094. /**
  19095. * Detach the current controls from the camera.
  19096. * The camera will stop reacting to inputs.
  19097. * @param element Defines the element to stop listening the inputs from
  19098. */
  19099. detachControl(element: HTMLElement): void;
  19100. private _collisionMask;
  19101. /**
  19102. * Define a collision mask to limit the list of object the camera can collide with
  19103. */
  19104. get collisionMask(): number;
  19105. set collisionMask(mask: number);
  19106. /** @hidden */
  19107. _collideWithWorld(displacement: Vector3): void;
  19108. private _onCollisionPositionChange;
  19109. /** @hidden */
  19110. _checkInputs(): void;
  19111. /** @hidden */
  19112. _decideIfNeedsToMove(): boolean;
  19113. /** @hidden */
  19114. _updatePosition(): void;
  19115. /**
  19116. * Destroy the camera and release the current resources hold by it.
  19117. */
  19118. dispose(): void;
  19119. /**
  19120. * Gets the current object class name.
  19121. * @return the class name
  19122. */
  19123. getClassName(): string;
  19124. }
  19125. }
  19126. declare module "babylonjs/Gamepads/gamepad" {
  19127. import { Observable } from "babylonjs/Misc/observable";
  19128. /**
  19129. * Represents a gamepad control stick position
  19130. */
  19131. export class StickValues {
  19132. /**
  19133. * The x component of the control stick
  19134. */
  19135. x: number;
  19136. /**
  19137. * The y component of the control stick
  19138. */
  19139. y: number;
  19140. /**
  19141. * Initializes the gamepad x and y control stick values
  19142. * @param x The x component of the gamepad control stick value
  19143. * @param y The y component of the gamepad control stick value
  19144. */
  19145. constructor(
  19146. /**
  19147. * The x component of the control stick
  19148. */
  19149. x: number,
  19150. /**
  19151. * The y component of the control stick
  19152. */
  19153. y: number);
  19154. }
  19155. /**
  19156. * An interface which manages callbacks for gamepad button changes
  19157. */
  19158. export interface GamepadButtonChanges {
  19159. /**
  19160. * Called when a gamepad has been changed
  19161. */
  19162. changed: boolean;
  19163. /**
  19164. * Called when a gamepad press event has been triggered
  19165. */
  19166. pressChanged: boolean;
  19167. /**
  19168. * Called when a touch event has been triggered
  19169. */
  19170. touchChanged: boolean;
  19171. /**
  19172. * Called when a value has changed
  19173. */
  19174. valueChanged: boolean;
  19175. }
  19176. /**
  19177. * Represents a gamepad
  19178. */
  19179. export class Gamepad {
  19180. /**
  19181. * The id of the gamepad
  19182. */
  19183. id: string;
  19184. /**
  19185. * The index of the gamepad
  19186. */
  19187. index: number;
  19188. /**
  19189. * The browser gamepad
  19190. */
  19191. browserGamepad: any;
  19192. /**
  19193. * Specifies what type of gamepad this represents
  19194. */
  19195. type: number;
  19196. private _leftStick;
  19197. private _rightStick;
  19198. /** @hidden */
  19199. _isConnected: boolean;
  19200. private _leftStickAxisX;
  19201. private _leftStickAxisY;
  19202. private _rightStickAxisX;
  19203. private _rightStickAxisY;
  19204. /**
  19205. * Triggered when the left control stick has been changed
  19206. */
  19207. private _onleftstickchanged;
  19208. /**
  19209. * Triggered when the right control stick has been changed
  19210. */
  19211. private _onrightstickchanged;
  19212. /**
  19213. * Represents a gamepad controller
  19214. */
  19215. static GAMEPAD: number;
  19216. /**
  19217. * Represents a generic controller
  19218. */
  19219. static GENERIC: number;
  19220. /**
  19221. * Represents an XBox controller
  19222. */
  19223. static XBOX: number;
  19224. /**
  19225. * Represents a pose-enabled controller
  19226. */
  19227. static POSE_ENABLED: number;
  19228. /**
  19229. * Represents an Dual Shock controller
  19230. */
  19231. static DUALSHOCK: number;
  19232. /**
  19233. * Specifies whether the left control stick should be Y-inverted
  19234. */
  19235. protected _invertLeftStickY: boolean;
  19236. /**
  19237. * Specifies if the gamepad has been connected
  19238. */
  19239. get isConnected(): boolean;
  19240. /**
  19241. * Initializes the gamepad
  19242. * @param id The id of the gamepad
  19243. * @param index The index of the gamepad
  19244. * @param browserGamepad The browser gamepad
  19245. * @param leftStickX The x component of the left joystick
  19246. * @param leftStickY The y component of the left joystick
  19247. * @param rightStickX The x component of the right joystick
  19248. * @param rightStickY The y component of the right joystick
  19249. */
  19250. constructor(
  19251. /**
  19252. * The id of the gamepad
  19253. */
  19254. id: string,
  19255. /**
  19256. * The index of the gamepad
  19257. */
  19258. index: number,
  19259. /**
  19260. * The browser gamepad
  19261. */
  19262. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  19263. /**
  19264. * Callback triggered when the left joystick has changed
  19265. * @param callback
  19266. */
  19267. onleftstickchanged(callback: (values: StickValues) => void): void;
  19268. /**
  19269. * Callback triggered when the right joystick has changed
  19270. * @param callback
  19271. */
  19272. onrightstickchanged(callback: (values: StickValues) => void): void;
  19273. /**
  19274. * Gets the left joystick
  19275. */
  19276. get leftStick(): StickValues;
  19277. /**
  19278. * Sets the left joystick values
  19279. */
  19280. set leftStick(newValues: StickValues);
  19281. /**
  19282. * Gets the right joystick
  19283. */
  19284. get rightStick(): StickValues;
  19285. /**
  19286. * Sets the right joystick value
  19287. */
  19288. set rightStick(newValues: StickValues);
  19289. /**
  19290. * Updates the gamepad joystick positions
  19291. */
  19292. update(): void;
  19293. /**
  19294. * Disposes the gamepad
  19295. */
  19296. dispose(): void;
  19297. }
  19298. /**
  19299. * Represents a generic gamepad
  19300. */
  19301. export class GenericPad extends Gamepad {
  19302. private _buttons;
  19303. private _onbuttondown;
  19304. private _onbuttonup;
  19305. /**
  19306. * Observable triggered when a button has been pressed
  19307. */
  19308. onButtonDownObservable: Observable<number>;
  19309. /**
  19310. * Observable triggered when a button has been released
  19311. */
  19312. onButtonUpObservable: Observable<number>;
  19313. /**
  19314. * Callback triggered when a button has been pressed
  19315. * @param callback Called when a button has been pressed
  19316. */
  19317. onbuttondown(callback: (buttonPressed: number) => void): void;
  19318. /**
  19319. * Callback triggered when a button has been released
  19320. * @param callback Called when a button has been released
  19321. */
  19322. onbuttonup(callback: (buttonReleased: number) => void): void;
  19323. /**
  19324. * Initializes the generic gamepad
  19325. * @param id The id of the generic gamepad
  19326. * @param index The index of the generic gamepad
  19327. * @param browserGamepad The browser gamepad
  19328. */
  19329. constructor(id: string, index: number, browserGamepad: any);
  19330. private _setButtonValue;
  19331. /**
  19332. * Updates the generic gamepad
  19333. */
  19334. update(): void;
  19335. /**
  19336. * Disposes the generic gamepad
  19337. */
  19338. dispose(): void;
  19339. }
  19340. }
  19341. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  19342. import { Observable } from "babylonjs/Misc/observable";
  19343. import { Nullable } from "babylonjs/types";
  19344. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  19345. import { TransformNode } from "babylonjs/Meshes/transformNode";
  19346. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19347. import { Ray } from "babylonjs/Culling/ray";
  19348. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  19349. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  19350. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  19351. /**
  19352. * Defines the types of pose enabled controllers that are supported
  19353. */
  19354. export enum PoseEnabledControllerType {
  19355. /**
  19356. * HTC Vive
  19357. */
  19358. VIVE = 0,
  19359. /**
  19360. * Oculus Rift
  19361. */
  19362. OCULUS = 1,
  19363. /**
  19364. * Windows mixed reality
  19365. */
  19366. WINDOWS = 2,
  19367. /**
  19368. * Samsung gear VR
  19369. */
  19370. GEAR_VR = 3,
  19371. /**
  19372. * Google Daydream
  19373. */
  19374. DAYDREAM = 4,
  19375. /**
  19376. * Generic
  19377. */
  19378. GENERIC = 5
  19379. }
  19380. /**
  19381. * Defines the MutableGamepadButton interface for the state of a gamepad button
  19382. */
  19383. export interface MutableGamepadButton {
  19384. /**
  19385. * Value of the button/trigger
  19386. */
  19387. value: number;
  19388. /**
  19389. * If the button/trigger is currently touched
  19390. */
  19391. touched: boolean;
  19392. /**
  19393. * If the button/trigger is currently pressed
  19394. */
  19395. pressed: boolean;
  19396. }
  19397. /**
  19398. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  19399. * @hidden
  19400. */
  19401. export interface ExtendedGamepadButton extends GamepadButton {
  19402. /**
  19403. * If the button/trigger is currently pressed
  19404. */
  19405. readonly pressed: boolean;
  19406. /**
  19407. * If the button/trigger is currently touched
  19408. */
  19409. readonly touched: boolean;
  19410. /**
  19411. * Value of the button/trigger
  19412. */
  19413. readonly value: number;
  19414. }
  19415. /** @hidden */
  19416. export interface _GamePadFactory {
  19417. /**
  19418. * Returns whether or not the current gamepad can be created for this type of controller.
  19419. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19420. * @returns true if it can be created, otherwise false
  19421. */
  19422. canCreate(gamepadInfo: any): boolean;
  19423. /**
  19424. * Creates a new instance of the Gamepad.
  19425. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19426. * @returns the new gamepad instance
  19427. */
  19428. create(gamepadInfo: any): Gamepad;
  19429. }
  19430. /**
  19431. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19432. */
  19433. export class PoseEnabledControllerHelper {
  19434. /** @hidden */
  19435. static _ControllerFactories: _GamePadFactory[];
  19436. /** @hidden */
  19437. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  19438. /**
  19439. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19440. * @param vrGamepad the gamepad to initialized
  19441. * @returns a vr controller of the type the gamepad identified as
  19442. */
  19443. static InitiateController(vrGamepad: any): Gamepad;
  19444. }
  19445. /**
  19446. * Defines the PoseEnabledController object that contains state of a vr capable controller
  19447. */
  19448. export class PoseEnabledController extends Gamepad implements PoseControlled {
  19449. /**
  19450. * If the controller is used in a webXR session
  19451. */
  19452. isXR: boolean;
  19453. private _deviceRoomPosition;
  19454. private _deviceRoomRotationQuaternion;
  19455. /**
  19456. * The device position in babylon space
  19457. */
  19458. devicePosition: Vector3;
  19459. /**
  19460. * The device rotation in babylon space
  19461. */
  19462. deviceRotationQuaternion: Quaternion;
  19463. /**
  19464. * The scale factor of the device in babylon space
  19465. */
  19466. deviceScaleFactor: number;
  19467. /**
  19468. * (Likely devicePosition should be used instead) The device position in its room space
  19469. */
  19470. position: Vector3;
  19471. /**
  19472. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  19473. */
  19474. rotationQuaternion: Quaternion;
  19475. /**
  19476. * The type of controller (Eg. Windows mixed reality)
  19477. */
  19478. controllerType: PoseEnabledControllerType;
  19479. protected _calculatedPosition: Vector3;
  19480. private _calculatedRotation;
  19481. /**
  19482. * The raw pose from the device
  19483. */
  19484. rawPose: DevicePose;
  19485. private _trackPosition;
  19486. private _maxRotationDistFromHeadset;
  19487. private _draggedRoomRotation;
  19488. /**
  19489. * @hidden
  19490. */
  19491. _disableTrackPosition(fixedPosition: Vector3): void;
  19492. /**
  19493. * Internal, the mesh attached to the controller
  19494. * @hidden
  19495. */
  19496. _mesh: Nullable<AbstractMesh>;
  19497. private _poseControlledCamera;
  19498. private _leftHandSystemQuaternion;
  19499. /**
  19500. * Internal, matrix used to convert room space to babylon space
  19501. * @hidden
  19502. */
  19503. _deviceToWorld: Matrix;
  19504. /**
  19505. * Node to be used when casting a ray from the controller
  19506. * @hidden
  19507. */
  19508. _pointingPoseNode: Nullable<TransformNode>;
  19509. /**
  19510. * Name of the child mesh that can be used to cast a ray from the controller
  19511. */
  19512. static readonly POINTING_POSE: string;
  19513. /**
  19514. * Creates a new PoseEnabledController from a gamepad
  19515. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  19516. */
  19517. constructor(browserGamepad: any);
  19518. private _workingMatrix;
  19519. /**
  19520. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  19521. */
  19522. update(): void;
  19523. /**
  19524. * Updates only the pose device and mesh without doing any button event checking
  19525. */
  19526. protected _updatePoseAndMesh(): void;
  19527. /**
  19528. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  19529. * @param poseData raw pose fromthe device
  19530. */
  19531. updateFromDevice(poseData: DevicePose): void;
  19532. /**
  19533. * @hidden
  19534. */
  19535. _meshAttachedObservable: Observable<AbstractMesh>;
  19536. /**
  19537. * Attaches a mesh to the controller
  19538. * @param mesh the mesh to be attached
  19539. */
  19540. attachToMesh(mesh: AbstractMesh): void;
  19541. /**
  19542. * Attaches the controllers mesh to a camera
  19543. * @param camera the camera the mesh should be attached to
  19544. */
  19545. attachToPoseControlledCamera(camera: TargetCamera): void;
  19546. /**
  19547. * Disposes of the controller
  19548. */
  19549. dispose(): void;
  19550. /**
  19551. * The mesh that is attached to the controller
  19552. */
  19553. get mesh(): Nullable<AbstractMesh>;
  19554. /**
  19555. * Gets the ray of the controller in the direction the controller is pointing
  19556. * @param length the length the resulting ray should be
  19557. * @returns a ray in the direction the controller is pointing
  19558. */
  19559. getForwardRay(length?: number): Ray;
  19560. }
  19561. }
  19562. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  19563. import { Observable } from "babylonjs/Misc/observable";
  19564. import { Scene } from "babylonjs/scene";
  19565. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19566. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  19567. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  19568. import { Nullable } from "babylonjs/types";
  19569. /**
  19570. * Defines the WebVRController object that represents controllers tracked in 3D space
  19571. */
  19572. export abstract class WebVRController extends PoseEnabledController {
  19573. /**
  19574. * Internal, the default controller model for the controller
  19575. */
  19576. protected _defaultModel: Nullable<AbstractMesh>;
  19577. /**
  19578. * Fired when the trigger state has changed
  19579. */
  19580. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  19581. /**
  19582. * Fired when the main button state has changed
  19583. */
  19584. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19585. /**
  19586. * Fired when the secondary button state has changed
  19587. */
  19588. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19589. /**
  19590. * Fired when the pad state has changed
  19591. */
  19592. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  19593. /**
  19594. * Fired when controllers stick values have changed
  19595. */
  19596. onPadValuesChangedObservable: Observable<StickValues>;
  19597. /**
  19598. * Array of button availible on the controller
  19599. */
  19600. protected _buttons: Array<MutableGamepadButton>;
  19601. private _onButtonStateChange;
  19602. /**
  19603. * Fired when a controller button's state has changed
  19604. * @param callback the callback containing the button that was modified
  19605. */
  19606. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  19607. /**
  19608. * X and Y axis corresponding to the controllers joystick
  19609. */
  19610. pad: StickValues;
  19611. /**
  19612. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  19613. */
  19614. hand: string;
  19615. /**
  19616. * The default controller model for the controller
  19617. */
  19618. get defaultModel(): Nullable<AbstractMesh>;
  19619. /**
  19620. * Creates a new WebVRController from a gamepad
  19621. * @param vrGamepad the gamepad that the WebVRController should be created from
  19622. */
  19623. constructor(vrGamepad: any);
  19624. /**
  19625. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  19626. */
  19627. update(): void;
  19628. /**
  19629. * Function to be called when a button is modified
  19630. */
  19631. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  19632. /**
  19633. * Loads a mesh and attaches it to the controller
  19634. * @param scene the scene the mesh should be added to
  19635. * @param meshLoaded callback for when the mesh has been loaded
  19636. */
  19637. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  19638. private _setButtonValue;
  19639. private _changes;
  19640. private _checkChanges;
  19641. /**
  19642. * Disposes of th webVRCOntroller
  19643. */
  19644. dispose(): void;
  19645. }
  19646. }
  19647. declare module "babylonjs/Lights/hemisphericLight" {
  19648. import { Nullable } from "babylonjs/types";
  19649. import { Scene } from "babylonjs/scene";
  19650. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  19651. import { Color3 } from "babylonjs/Maths/math.color";
  19652. import { Effect } from "babylonjs/Materials/effect";
  19653. import { Light } from "babylonjs/Lights/light";
  19654. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  19655. /**
  19656. * The HemisphericLight simulates the ambient environment light,
  19657. * so the passed direction is the light reflection direction, not the incoming direction.
  19658. */
  19659. export class HemisphericLight extends Light {
  19660. /**
  19661. * The groundColor is the light in the opposite direction to the one specified during creation.
  19662. * 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.
  19663. */
  19664. groundColor: Color3;
  19665. /**
  19666. * The light reflection direction, not the incoming direction.
  19667. */
  19668. direction: Vector3;
  19669. /**
  19670. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  19671. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  19672. * The HemisphericLight can't cast shadows.
  19673. * Documentation : https://doc.babylonjs.com/babylon101/lights
  19674. * @param name The friendly name of the light
  19675. * @param direction The direction of the light reflection
  19676. * @param scene The scene the light belongs to
  19677. */
  19678. constructor(name: string, direction: Vector3, scene: Scene);
  19679. protected _buildUniformLayout(): void;
  19680. /**
  19681. * Returns the string "HemisphericLight".
  19682. * @return The class name
  19683. */
  19684. getClassName(): string;
  19685. /**
  19686. * Sets the HemisphericLight direction towards the passed target (Vector3).
  19687. * Returns the updated direction.
  19688. * @param target The target the direction should point to
  19689. * @return The computed direction
  19690. */
  19691. setDirectionToTarget(target: Vector3): Vector3;
  19692. /**
  19693. * Returns the shadow generator associated to the light.
  19694. * @returns Always null for hemispheric lights because it does not support shadows.
  19695. */
  19696. getShadowGenerator(): Nullable<IShadowGenerator>;
  19697. /**
  19698. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  19699. * @param effect The effect to update
  19700. * @param lightIndex The index of the light in the effect to update
  19701. * @returns The hemispheric light
  19702. */
  19703. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  19704. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  19705. /**
  19706. * Computes the world matrix of the node
  19707. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  19708. * @param useWasUpdatedFlag defines a reserved property
  19709. * @returns the world matrix
  19710. */
  19711. computeWorldMatrix(): Matrix;
  19712. /**
  19713. * Returns the integer 3.
  19714. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  19715. */
  19716. getTypeID(): number;
  19717. /**
  19718. * Prepares the list of defines specific to the light type.
  19719. * @param defines the list of defines
  19720. * @param lightIndex defines the index of the light for the effect
  19721. */
  19722. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  19723. }
  19724. }
  19725. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  19726. /** @hidden */
  19727. export var vrMultiviewToSingleviewPixelShader: {
  19728. name: string;
  19729. shader: string;
  19730. };
  19731. }
  19732. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  19733. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  19734. import { Scene } from "babylonjs/scene";
  19735. /**
  19736. * Renders to multiple views with a single draw call
  19737. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  19738. */
  19739. export class MultiviewRenderTarget extends RenderTargetTexture {
  19740. /**
  19741. * Creates a multiview render target
  19742. * @param scene scene used with the render target
  19743. * @param size the size of the render target (used for each view)
  19744. */
  19745. constructor(scene: Scene, size?: number | {
  19746. width: number;
  19747. height: number;
  19748. } | {
  19749. ratio: number;
  19750. });
  19751. /**
  19752. * @hidden
  19753. * @param faceIndex the face index, if its a cube texture
  19754. */
  19755. _bindFrameBuffer(faceIndex?: number): void;
  19756. /**
  19757. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  19758. * @returns the view count
  19759. */
  19760. getViewCount(): number;
  19761. }
  19762. }
  19763. declare module "babylonjs/Maths/math.frustum" {
  19764. import { Matrix } from "babylonjs/Maths/math.vector";
  19765. import { DeepImmutable } from "babylonjs/types";
  19766. import { Plane } from "babylonjs/Maths/math.plane";
  19767. /**
  19768. * Represents a camera frustum
  19769. */
  19770. export class Frustum {
  19771. /**
  19772. * Gets the planes representing the frustum
  19773. * @param transform matrix to be applied to the returned planes
  19774. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  19775. */
  19776. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  19777. /**
  19778. * Gets the near frustum plane transformed by the transform matrix
  19779. * @param transform transformation matrix to be applied to the resulting frustum plane
  19780. * @param frustumPlane the resuling frustum plane
  19781. */
  19782. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19783. /**
  19784. * Gets the far frustum plane transformed by the transform matrix
  19785. * @param transform transformation matrix to be applied to the resulting frustum plane
  19786. * @param frustumPlane the resuling frustum plane
  19787. */
  19788. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19789. /**
  19790. * Gets the left frustum plane transformed by the transform matrix
  19791. * @param transform transformation matrix to be applied to the resulting frustum plane
  19792. * @param frustumPlane the resuling frustum plane
  19793. */
  19794. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19795. /**
  19796. * Gets the right frustum plane transformed by the transform matrix
  19797. * @param transform transformation matrix to be applied to the resulting frustum plane
  19798. * @param frustumPlane the resuling frustum plane
  19799. */
  19800. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19801. /**
  19802. * Gets the top frustum plane transformed by the transform matrix
  19803. * @param transform transformation matrix to be applied to the resulting frustum plane
  19804. * @param frustumPlane the resuling frustum plane
  19805. */
  19806. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19807. /**
  19808. * Gets the bottom frustum plane transformed by the transform matrix
  19809. * @param transform transformation matrix to be applied to the resulting frustum plane
  19810. * @param frustumPlane the resuling frustum plane
  19811. */
  19812. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19813. /**
  19814. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  19815. * @param transform transformation matrix to be applied to the resulting frustum planes
  19816. * @param frustumPlanes the resuling frustum planes
  19817. */
  19818. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  19819. }
  19820. }
  19821. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  19822. import { Camera } from "babylonjs/Cameras/camera";
  19823. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  19824. import { Nullable } from "babylonjs/types";
  19825. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  19826. import { Matrix } from "babylonjs/Maths/math.vector";
  19827. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  19828. module "babylonjs/Engines/engine" {
  19829. interface Engine {
  19830. /**
  19831. * Creates a new multiview render target
  19832. * @param width defines the width of the texture
  19833. * @param height defines the height of the texture
  19834. * @returns the created multiview texture
  19835. */
  19836. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  19837. /**
  19838. * Binds a multiview framebuffer to be drawn to
  19839. * @param multiviewTexture texture to bind
  19840. */
  19841. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  19842. }
  19843. }
  19844. module "babylonjs/Cameras/camera" {
  19845. interface Camera {
  19846. /**
  19847. * @hidden
  19848. * 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)
  19849. */
  19850. _useMultiviewToSingleView: boolean;
  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. _multiviewTexture: Nullable<RenderTargetTexture>;
  19856. /**
  19857. * @hidden
  19858. * ensures the multiview texture of the camera exists and has the specified width/height
  19859. * @param width height to set on the multiview texture
  19860. * @param height width to set on the multiview texture
  19861. */
  19862. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  19863. }
  19864. }
  19865. module "babylonjs/scene" {
  19866. interface Scene {
  19867. /** @hidden */
  19868. _transformMatrixR: Matrix;
  19869. /** @hidden */
  19870. _multiviewSceneUbo: Nullable<UniformBuffer>;
  19871. /** @hidden */
  19872. _createMultiviewUbo(): void;
  19873. /** @hidden */
  19874. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  19875. /** @hidden */
  19876. _renderMultiviewToSingleView(camera: Camera): void;
  19877. }
  19878. }
  19879. }
  19880. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  19881. import { Camera } from "babylonjs/Cameras/camera";
  19882. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  19883. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  19884. import "babylonjs/Engines/Extensions/engine.multiview";
  19885. /**
  19886. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  19887. * This will not be used for webXR as it supports displaying texture arrays directly
  19888. */
  19889. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  19890. /**
  19891. * Initializes a VRMultiviewToSingleview
  19892. * @param name name of the post process
  19893. * @param camera camera to be applied to
  19894. * @param scaleFactor scaling factor to the size of the output texture
  19895. */
  19896. constructor(name: string, camera: Camera, scaleFactor: number);
  19897. }
  19898. }
  19899. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  19900. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  19901. import { Nullable } from "babylonjs/types";
  19902. import { Size } from "babylonjs/Maths/math.size";
  19903. import { Observable } from "babylonjs/Misc/observable";
  19904. import { WebVROptions } from "babylonjs/Cameras/VR/webVRCamera";
  19905. /**
  19906. * Interface used to define additional presentation attributes
  19907. */
  19908. export interface IVRPresentationAttributes {
  19909. /**
  19910. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  19911. */
  19912. highRefreshRate: boolean;
  19913. /**
  19914. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  19915. */
  19916. foveationLevel: number;
  19917. }
  19918. module "babylonjs/Engines/engine" {
  19919. interface Engine {
  19920. /** @hidden */
  19921. _vrDisplay: any;
  19922. /** @hidden */
  19923. _vrSupported: boolean;
  19924. /** @hidden */
  19925. _oldSize: Size;
  19926. /** @hidden */
  19927. _oldHardwareScaleFactor: number;
  19928. /** @hidden */
  19929. _vrExclusivePointerMode: boolean;
  19930. /** @hidden */
  19931. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  19932. /** @hidden */
  19933. _onVRDisplayPointerRestricted: () => void;
  19934. /** @hidden */
  19935. _onVRDisplayPointerUnrestricted: () => void;
  19936. /** @hidden */
  19937. _onVrDisplayConnect: Nullable<(display: any) => void>;
  19938. /** @hidden */
  19939. _onVrDisplayDisconnect: Nullable<() => void>;
  19940. /** @hidden */
  19941. _onVrDisplayPresentChange: Nullable<() => void>;
  19942. /**
  19943. * Observable signaled when VR display mode changes
  19944. */
  19945. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  19946. /**
  19947. * Observable signaled when VR request present is complete
  19948. */
  19949. onVRRequestPresentComplete: Observable<boolean>;
  19950. /**
  19951. * Observable signaled when VR request present starts
  19952. */
  19953. onVRRequestPresentStart: Observable<Engine>;
  19954. /**
  19955. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  19956. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  19957. */
  19958. isInVRExclusivePointerMode: boolean;
  19959. /**
  19960. * Gets a boolean indicating if a webVR device was detected
  19961. * @returns true if a webVR device was detected
  19962. */
  19963. isVRDevicePresent(): boolean;
  19964. /**
  19965. * Gets the current webVR device
  19966. * @returns the current webVR device (or null)
  19967. */
  19968. getVRDevice(): any;
  19969. /**
  19970. * Initializes a webVR display and starts listening to display change events
  19971. * The onVRDisplayChangedObservable will be notified upon these changes
  19972. * @returns A promise containing a VRDisplay and if vr is supported
  19973. */
  19974. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  19975. /** @hidden */
  19976. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  19977. /**
  19978. * Gets or sets the presentation attributes used to configure VR rendering
  19979. */
  19980. vrPresentationAttributes?: IVRPresentationAttributes;
  19981. /**
  19982. * Call this function to switch to webVR mode
  19983. * Will do nothing if webVR is not supported or if there is no webVR device
  19984. * @param options the webvr options provided to the camera. mainly used for multiview
  19985. * @see http://doc.babylonjs.com/how_to/webvr_camera
  19986. */
  19987. enableVR(options: WebVROptions): void;
  19988. /** @hidden */
  19989. _onVRFullScreenTriggered(): void;
  19990. }
  19991. }
  19992. }
  19993. declare module "babylonjs/Cameras/VR/webVRCamera" {
  19994. import { Nullable } from "babylonjs/types";
  19995. import { Observable } from "babylonjs/Misc/observable";
  19996. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19997. import { Scene } from "babylonjs/scene";
  19998. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  19999. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  20000. import { Node } from "babylonjs/node";
  20001. import { Ray } from "babylonjs/Culling/ray";
  20002. import "babylonjs/Cameras/RigModes/webVRRigMode";
  20003. import "babylonjs/Engines/Extensions/engine.webVR";
  20004. /**
  20005. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  20006. * IMPORTANT!! The data is right-hand data.
  20007. * @export
  20008. * @interface DevicePose
  20009. */
  20010. export interface DevicePose {
  20011. /**
  20012. * The position of the device, values in array are [x,y,z].
  20013. */
  20014. readonly position: Nullable<Float32Array>;
  20015. /**
  20016. * The linearVelocity of the device, values in array are [x,y,z].
  20017. */
  20018. readonly linearVelocity: Nullable<Float32Array>;
  20019. /**
  20020. * The linearAcceleration of the device, values in array are [x,y,z].
  20021. */
  20022. readonly linearAcceleration: Nullable<Float32Array>;
  20023. /**
  20024. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  20025. */
  20026. readonly orientation: Nullable<Float32Array>;
  20027. /**
  20028. * The angularVelocity of the device, values in array are [x,y,z].
  20029. */
  20030. readonly angularVelocity: Nullable<Float32Array>;
  20031. /**
  20032. * The angularAcceleration of the device, values in array are [x,y,z].
  20033. */
  20034. readonly angularAcceleration: Nullable<Float32Array>;
  20035. }
  20036. /**
  20037. * Interface representing a pose controlled object in Babylon.
  20038. * A pose controlled object has both regular pose values as well as pose values
  20039. * from an external device such as a VR head mounted display
  20040. */
  20041. export interface PoseControlled {
  20042. /**
  20043. * The position of the object in babylon space.
  20044. */
  20045. position: Vector3;
  20046. /**
  20047. * The rotation quaternion of the object in babylon space.
  20048. */
  20049. rotationQuaternion: Quaternion;
  20050. /**
  20051. * The position of the device in babylon space.
  20052. */
  20053. devicePosition?: Vector3;
  20054. /**
  20055. * The rotation quaternion of the device in babylon space.
  20056. */
  20057. deviceRotationQuaternion: Quaternion;
  20058. /**
  20059. * The raw pose coming from the device.
  20060. */
  20061. rawPose: Nullable<DevicePose>;
  20062. /**
  20063. * The scale of the device to be used when translating from device space to babylon space.
  20064. */
  20065. deviceScaleFactor: number;
  20066. /**
  20067. * Updates the poseControlled values based on the input device pose.
  20068. * @param poseData the pose data to update the object with
  20069. */
  20070. updateFromDevice(poseData: DevicePose): void;
  20071. }
  20072. /**
  20073. * Set of options to customize the webVRCamera
  20074. */
  20075. export interface WebVROptions {
  20076. /**
  20077. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  20078. */
  20079. trackPosition?: boolean;
  20080. /**
  20081. * Sets the scale of the vrDevice in babylon space. (default: 1)
  20082. */
  20083. positionScale?: number;
  20084. /**
  20085. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  20086. */
  20087. displayName?: string;
  20088. /**
  20089. * Should the native controller meshes be initialized. (default: true)
  20090. */
  20091. controllerMeshes?: boolean;
  20092. /**
  20093. * Creating a default HemiLight only on controllers. (default: true)
  20094. */
  20095. defaultLightingOnControllers?: boolean;
  20096. /**
  20097. * If you don't want to use the default VR button of the helper. (default: false)
  20098. */
  20099. useCustomVRButton?: boolean;
  20100. /**
  20101. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  20102. */
  20103. customVRButton?: HTMLButtonElement;
  20104. /**
  20105. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  20106. */
  20107. rayLength?: number;
  20108. /**
  20109. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  20110. */
  20111. defaultHeight?: number;
  20112. /**
  20113. * If multiview should be used if availible (default: false)
  20114. */
  20115. useMultiview?: boolean;
  20116. }
  20117. /**
  20118. * This represents a WebVR camera.
  20119. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  20120. * @example http://doc.babylonjs.com/how_to/webvr_camera
  20121. */
  20122. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  20123. private webVROptions;
  20124. /**
  20125. * @hidden
  20126. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  20127. */
  20128. _vrDevice: any;
  20129. /**
  20130. * The rawPose of the vrDevice.
  20131. */
  20132. rawPose: Nullable<DevicePose>;
  20133. private _onVREnabled;
  20134. private _specsVersion;
  20135. private _attached;
  20136. private _frameData;
  20137. protected _descendants: Array<Node>;
  20138. private _deviceRoomPosition;
  20139. /** @hidden */
  20140. _deviceRoomRotationQuaternion: Quaternion;
  20141. private _standingMatrix;
  20142. /**
  20143. * Represents device position in babylon space.
  20144. */
  20145. devicePosition: Vector3;
  20146. /**
  20147. * Represents device rotation in babylon space.
  20148. */
  20149. deviceRotationQuaternion: Quaternion;
  20150. /**
  20151. * The scale of the device to be used when translating from device space to babylon space.
  20152. */
  20153. deviceScaleFactor: number;
  20154. private _deviceToWorld;
  20155. private _worldToDevice;
  20156. /**
  20157. * References to the webVR controllers for the vrDevice.
  20158. */
  20159. controllers: Array<WebVRController>;
  20160. /**
  20161. * Emits an event when a controller is attached.
  20162. */
  20163. onControllersAttachedObservable: Observable<WebVRController[]>;
  20164. /**
  20165. * Emits an event when a controller's mesh has been loaded;
  20166. */
  20167. onControllerMeshLoadedObservable: Observable<WebVRController>;
  20168. /**
  20169. * Emits an event when the HMD's pose has been updated.
  20170. */
  20171. onPoseUpdatedFromDeviceObservable: Observable<any>;
  20172. private _poseSet;
  20173. /**
  20174. * If the rig cameras be used as parent instead of this camera.
  20175. */
  20176. rigParenting: boolean;
  20177. private _lightOnControllers;
  20178. private _defaultHeight?;
  20179. /**
  20180. * Instantiates a WebVRFreeCamera.
  20181. * @param name The name of the WebVRFreeCamera
  20182. * @param position The starting anchor position for the camera
  20183. * @param scene The scene the camera belongs to
  20184. * @param webVROptions a set of customizable options for the webVRCamera
  20185. */
  20186. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  20187. /**
  20188. * Gets the device distance from the ground in meters.
  20189. * @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.
  20190. */
  20191. deviceDistanceToRoomGround(): number;
  20192. /**
  20193. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20194. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  20195. */
  20196. useStandingMatrix(callback?: (bool: boolean) => void): void;
  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. * @returns A promise with a boolean set to if the standing matrix is supported.
  20200. */
  20201. useStandingMatrixAsync(): Promise<boolean>;
  20202. /**
  20203. * Disposes the camera
  20204. */
  20205. dispose(): void;
  20206. /**
  20207. * Gets a vrController by name.
  20208. * @param name The name of the controller to retreive
  20209. * @returns the controller matching the name specified or null if not found
  20210. */
  20211. getControllerByName(name: string): Nullable<WebVRController>;
  20212. private _leftController;
  20213. /**
  20214. * The controller corresponding to the users left hand.
  20215. */
  20216. get leftController(): Nullable<WebVRController>;
  20217. private _rightController;
  20218. /**
  20219. * The controller corresponding to the users right hand.
  20220. */
  20221. get rightController(): Nullable<WebVRController>;
  20222. /**
  20223. * Casts a ray forward from the vrCamera's gaze.
  20224. * @param length Length of the ray (default: 100)
  20225. * @returns the ray corresponding to the gaze
  20226. */
  20227. getForwardRay(length?: number): Ray;
  20228. /**
  20229. * @hidden
  20230. * Updates the camera based on device's frame data
  20231. */
  20232. _checkInputs(): void;
  20233. /**
  20234. * Updates the poseControlled values based on the input device pose.
  20235. * @param poseData Pose coming from the device
  20236. */
  20237. updateFromDevice(poseData: DevicePose): void;
  20238. private _htmlElementAttached;
  20239. private _detachIfAttached;
  20240. /**
  20241. * WebVR's attach control will start broadcasting frames to the device.
  20242. * Note that in certain browsers (chrome for example) this function must be called
  20243. * within a user-interaction callback. Example:
  20244. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  20245. *
  20246. * @param element html element to attach the vrDevice to
  20247. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  20248. */
  20249. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  20250. /**
  20251. * Detaches the camera from the html element and disables VR
  20252. *
  20253. * @param element html element to detach from
  20254. */
  20255. detachControl(element: HTMLElement): void;
  20256. /**
  20257. * @returns the name of this class
  20258. */
  20259. getClassName(): string;
  20260. /**
  20261. * Calls resetPose on the vrDisplay
  20262. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  20263. */
  20264. resetToCurrentRotation(): void;
  20265. /**
  20266. * @hidden
  20267. * Updates the rig cameras (left and right eye)
  20268. */
  20269. _updateRigCameras(): void;
  20270. private _workingVector;
  20271. private _oneVector;
  20272. private _workingMatrix;
  20273. private updateCacheCalled;
  20274. private _correctPositionIfNotTrackPosition;
  20275. /**
  20276. * @hidden
  20277. * Updates the cached values of the camera
  20278. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  20279. */
  20280. _updateCache(ignoreParentClass?: boolean): void;
  20281. /**
  20282. * @hidden
  20283. * Get current device position in babylon world
  20284. */
  20285. _computeDevicePosition(): void;
  20286. /**
  20287. * Updates the current device position and rotation in the babylon world
  20288. */
  20289. update(): void;
  20290. /**
  20291. * @hidden
  20292. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  20293. * @returns an identity matrix
  20294. */
  20295. _getViewMatrix(): Matrix;
  20296. private _tmpMatrix;
  20297. /**
  20298. * This function is called by the two RIG cameras.
  20299. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  20300. * @hidden
  20301. */
  20302. _getWebVRViewMatrix(): Matrix;
  20303. /** @hidden */
  20304. _getWebVRProjectionMatrix(): Matrix;
  20305. private _onGamepadConnectedObserver;
  20306. private _onGamepadDisconnectedObserver;
  20307. private _updateCacheWhenTrackingDisabledObserver;
  20308. /**
  20309. * Initializes the controllers and their meshes
  20310. */
  20311. initControllers(): void;
  20312. }
  20313. }
  20314. declare module "babylonjs/PostProcesses/postProcess" {
  20315. import { Nullable } from "babylonjs/types";
  20316. import { SmartArray } from "babylonjs/Misc/smartArray";
  20317. import { Observable } from "babylonjs/Misc/observable";
  20318. import { Vector2 } from "babylonjs/Maths/math.vector";
  20319. import { Camera } from "babylonjs/Cameras/camera";
  20320. import { Effect } from "babylonjs/Materials/effect";
  20321. import "babylonjs/Shaders/postprocess.vertex";
  20322. import { IInspectable } from "babylonjs/Misc/iInspectable";
  20323. import { Engine } from "babylonjs/Engines/engine";
  20324. import { Color4 } from "babylonjs/Maths/math.color";
  20325. import "babylonjs/Engines/Extensions/engine.renderTarget";
  20326. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20327. /**
  20328. * Size options for a post process
  20329. */
  20330. export type PostProcessOptions = {
  20331. width: number;
  20332. height: number;
  20333. };
  20334. /**
  20335. * PostProcess can be used to apply a shader to a texture after it has been rendered
  20336. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  20337. */
  20338. export class PostProcess {
  20339. /** Name of the PostProcess. */
  20340. name: string;
  20341. /**
  20342. * Gets or sets the unique id of the post process
  20343. */
  20344. uniqueId: number;
  20345. /**
  20346. * Width of the texture to apply the post process on
  20347. */
  20348. width: number;
  20349. /**
  20350. * Height of the texture to apply the post process on
  20351. */
  20352. height: number;
  20353. /**
  20354. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  20355. * @hidden
  20356. */
  20357. _outputTexture: Nullable<InternalTexture>;
  20358. /**
  20359. * Sampling mode used by the shader
  20360. * See https://doc.babylonjs.com/classes/3.1/texture
  20361. */
  20362. renderTargetSamplingMode: number;
  20363. /**
  20364. * Clear color to use when screen clearing
  20365. */
  20366. clearColor: Color4;
  20367. /**
  20368. * If the buffer needs to be cleared before applying the post process. (default: true)
  20369. * Should be set to false if shader will overwrite all previous pixels.
  20370. */
  20371. autoClear: boolean;
  20372. /**
  20373. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  20374. */
  20375. alphaMode: number;
  20376. /**
  20377. * Sets the setAlphaBlendConstants of the babylon engine
  20378. */
  20379. alphaConstants: Color4;
  20380. /**
  20381. * Animations to be used for the post processing
  20382. */
  20383. animations: import("babylonjs/Animations/animation").Animation[];
  20384. /**
  20385. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  20386. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  20387. */
  20388. enablePixelPerfectMode: boolean;
  20389. /**
  20390. * Force the postprocess to be applied without taking in account viewport
  20391. */
  20392. forceFullscreenViewport: boolean;
  20393. /**
  20394. * List of inspectable custom properties (used by the Inspector)
  20395. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20396. */
  20397. inspectableCustomProperties: IInspectable[];
  20398. /**
  20399. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  20400. *
  20401. * | Value | Type | Description |
  20402. * | ----- | ----------------------------------- | ----------- |
  20403. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  20404. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  20405. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  20406. *
  20407. */
  20408. scaleMode: number;
  20409. /**
  20410. * Force textures to be a power of two (default: false)
  20411. */
  20412. alwaysForcePOT: boolean;
  20413. private _samples;
  20414. /**
  20415. * Number of sample textures (default: 1)
  20416. */
  20417. get samples(): number;
  20418. set samples(n: number);
  20419. /**
  20420. * Modify the scale of the post process to be the same as the viewport (default: false)
  20421. */
  20422. adaptScaleToCurrentViewport: boolean;
  20423. private _camera;
  20424. private _scene;
  20425. private _engine;
  20426. private _options;
  20427. private _reusable;
  20428. private _textureType;
  20429. private _textureFormat;
  20430. /**
  20431. * Smart array of input and output textures for the post process.
  20432. * @hidden
  20433. */
  20434. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  20435. /**
  20436. * The index in _textures that corresponds to the output texture.
  20437. * @hidden
  20438. */
  20439. _currentRenderTextureInd: number;
  20440. private _effect;
  20441. private _samplers;
  20442. private _fragmentUrl;
  20443. private _vertexUrl;
  20444. private _parameters;
  20445. private _scaleRatio;
  20446. protected _indexParameters: any;
  20447. private _shareOutputWithPostProcess;
  20448. private _texelSize;
  20449. private _forcedOutputTexture;
  20450. /**
  20451. * Returns the fragment url or shader name used in the post process.
  20452. * @returns the fragment url or name in the shader store.
  20453. */
  20454. getEffectName(): string;
  20455. /**
  20456. * An event triggered when the postprocess is activated.
  20457. */
  20458. onActivateObservable: Observable<Camera>;
  20459. private _onActivateObserver;
  20460. /**
  20461. * A function that is added to the onActivateObservable
  20462. */
  20463. set onActivate(callback: Nullable<(camera: Camera) => void>);
  20464. /**
  20465. * An event triggered when the postprocess changes its size.
  20466. */
  20467. onSizeChangedObservable: Observable<PostProcess>;
  20468. private _onSizeChangedObserver;
  20469. /**
  20470. * A function that is added to the onSizeChangedObservable
  20471. */
  20472. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  20473. /**
  20474. * An event triggered when the postprocess applies its effect.
  20475. */
  20476. onApplyObservable: Observable<Effect>;
  20477. private _onApplyObserver;
  20478. /**
  20479. * A function that is added to the onApplyObservable
  20480. */
  20481. set onApply(callback: (effect: Effect) => void);
  20482. /**
  20483. * An event triggered before rendering the postprocess
  20484. */
  20485. onBeforeRenderObservable: Observable<Effect>;
  20486. private _onBeforeRenderObserver;
  20487. /**
  20488. * A function that is added to the onBeforeRenderObservable
  20489. */
  20490. set onBeforeRender(callback: (effect: Effect) => void);
  20491. /**
  20492. * An event triggered after rendering the postprocess
  20493. */
  20494. onAfterRenderObservable: Observable<Effect>;
  20495. private _onAfterRenderObserver;
  20496. /**
  20497. * A function that is added to the onAfterRenderObservable
  20498. */
  20499. set onAfterRender(callback: (efect: Effect) => void);
  20500. /**
  20501. * 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
  20502. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  20503. */
  20504. get inputTexture(): InternalTexture;
  20505. set inputTexture(value: InternalTexture);
  20506. /**
  20507. * Gets the camera which post process is applied to.
  20508. * @returns The camera the post process is applied to.
  20509. */
  20510. getCamera(): Camera;
  20511. /**
  20512. * Gets the texel size of the postprocess.
  20513. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  20514. */
  20515. get texelSize(): Vector2;
  20516. /**
  20517. * Creates a new instance PostProcess
  20518. * @param name The name of the PostProcess.
  20519. * @param fragmentUrl The url of the fragment shader to be used.
  20520. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  20521. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  20522. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  20523. * @param camera The camera to apply the render pass to.
  20524. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  20525. * @param engine The engine which the post process will be applied. (default: current engine)
  20526. * @param reusable If the post process can be reused on the same frame. (default: false)
  20527. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  20528. * @param textureType Type of textures used when performing the post process. (default: 0)
  20529. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  20530. * @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
  20531. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  20532. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  20533. */
  20534. constructor(
  20535. /** Name of the PostProcess. */
  20536. 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);
  20537. /**
  20538. * Gets a string idenfifying the name of the class
  20539. * @returns "PostProcess" string
  20540. */
  20541. getClassName(): string;
  20542. /**
  20543. * Gets the engine which this post process belongs to.
  20544. * @returns The engine the post process was enabled with.
  20545. */
  20546. getEngine(): Engine;
  20547. /**
  20548. * The effect that is created when initializing the post process.
  20549. * @returns The created effect corresponding the the postprocess.
  20550. */
  20551. getEffect(): Effect;
  20552. /**
  20553. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  20554. * @param postProcess The post process to share the output with.
  20555. * @returns This post process.
  20556. */
  20557. shareOutputWith(postProcess: PostProcess): PostProcess;
  20558. /**
  20559. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  20560. * This should be called if the post process that shares output with this post process is disabled/disposed.
  20561. */
  20562. useOwnOutput(): void;
  20563. /**
  20564. * Updates the effect with the current post process compile time values and recompiles the shader.
  20565. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  20566. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  20567. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  20568. * @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
  20569. * @param onCompiled Called when the shader has been compiled.
  20570. * @param onError Called if there is an error when compiling a shader.
  20571. */
  20572. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  20573. /**
  20574. * The post process is reusable if it can be used multiple times within one frame.
  20575. * @returns If the post process is reusable
  20576. */
  20577. isReusable(): boolean;
  20578. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  20579. markTextureDirty(): void;
  20580. /**
  20581. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  20582. * 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.
  20583. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  20584. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  20585. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  20586. * @returns The target texture that was bound to be written to.
  20587. */
  20588. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  20589. /**
  20590. * If the post process is supported.
  20591. */
  20592. get isSupported(): boolean;
  20593. /**
  20594. * The aspect ratio of the output texture.
  20595. */
  20596. get aspectRatio(): number;
  20597. /**
  20598. * Get a value indicating if the post-process is ready to be used
  20599. * @returns true if the post-process is ready (shader is compiled)
  20600. */
  20601. isReady(): boolean;
  20602. /**
  20603. * Binds all textures and uniforms to the shader, this will be run on every pass.
  20604. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  20605. */
  20606. apply(): Nullable<Effect>;
  20607. private _disposeTextures;
  20608. /**
  20609. * Disposes the post process.
  20610. * @param camera The camera to dispose the post process on.
  20611. */
  20612. dispose(camera?: Camera): void;
  20613. }
  20614. }
  20615. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  20616. /** @hidden */
  20617. export var kernelBlurVaryingDeclaration: {
  20618. name: string;
  20619. shader: string;
  20620. };
  20621. }
  20622. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  20623. /** @hidden */
  20624. export var kernelBlurFragment: {
  20625. name: string;
  20626. shader: string;
  20627. };
  20628. }
  20629. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  20630. /** @hidden */
  20631. export var kernelBlurFragment2: {
  20632. name: string;
  20633. shader: string;
  20634. };
  20635. }
  20636. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  20637. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  20638. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  20639. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  20640. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  20641. /** @hidden */
  20642. export var kernelBlurPixelShader: {
  20643. name: string;
  20644. shader: string;
  20645. };
  20646. }
  20647. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  20648. /** @hidden */
  20649. export var kernelBlurVertex: {
  20650. name: string;
  20651. shader: string;
  20652. };
  20653. }
  20654. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  20655. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  20656. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  20657. /** @hidden */
  20658. export var kernelBlurVertexShader: {
  20659. name: string;
  20660. shader: string;
  20661. };
  20662. }
  20663. declare module "babylonjs/PostProcesses/blurPostProcess" {
  20664. import { Vector2 } from "babylonjs/Maths/math.vector";
  20665. import { Nullable } from "babylonjs/types";
  20666. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  20667. import { Camera } from "babylonjs/Cameras/camera";
  20668. import { Effect } from "babylonjs/Materials/effect";
  20669. import { Engine } from "babylonjs/Engines/engine";
  20670. import "babylonjs/Shaders/kernelBlur.fragment";
  20671. import "babylonjs/Shaders/kernelBlur.vertex";
  20672. /**
  20673. * The Blur Post Process which blurs an image based on a kernel and direction.
  20674. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  20675. */
  20676. export class BlurPostProcess extends PostProcess {
  20677. /** The direction in which to blur the image. */
  20678. direction: Vector2;
  20679. private blockCompilation;
  20680. protected _kernel: number;
  20681. protected _idealKernel: number;
  20682. protected _packedFloat: boolean;
  20683. private _staticDefines;
  20684. /**
  20685. * Sets the length in pixels of the blur sample region
  20686. */
  20687. set kernel(v: number);
  20688. /**
  20689. * Gets the length in pixels of the blur sample region
  20690. */
  20691. get kernel(): number;
  20692. /**
  20693. * Sets wether or not the blur needs to unpack/repack floats
  20694. */
  20695. set packedFloat(v: boolean);
  20696. /**
  20697. * Gets wether or not the blur is unpacking/repacking floats
  20698. */
  20699. get packedFloat(): boolean;
  20700. /**
  20701. * Creates a new instance BlurPostProcess
  20702. * @param name The name of the effect.
  20703. * @param direction The direction in which to blur the image.
  20704. * @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.
  20705. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  20706. * @param camera The camera to apply the render pass to.
  20707. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  20708. * @param engine The engine which the post process will be applied. (default: current engine)
  20709. * @param reusable If the post process can be reused on the same frame. (default: false)
  20710. * @param textureType Type of textures used when performing the post process. (default: 0)
  20711. * @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)
  20712. */
  20713. constructor(name: string,
  20714. /** The direction in which to blur the image. */
  20715. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  20716. /**
  20717. * Updates the effect with the current post process compile time values and recompiles the shader.
  20718. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  20719. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  20720. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  20721. * @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
  20722. * @param onCompiled Called when the shader has been compiled.
  20723. * @param onError Called if there is an error when compiling a shader.
  20724. */
  20725. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  20726. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  20727. /**
  20728. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  20729. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  20730. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  20731. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  20732. * The gaps between physical kernels are compensated for in the weighting of the samples
  20733. * @param idealKernel Ideal blur kernel.
  20734. * @return Nearest best kernel.
  20735. */
  20736. protected _nearestBestKernel(idealKernel: number): number;
  20737. /**
  20738. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  20739. * @param x The point on the Gaussian distribution to sample.
  20740. * @return the value of the Gaussian function at x.
  20741. */
  20742. protected _gaussianWeight(x: number): number;
  20743. /**
  20744. * Generates a string that can be used as a floating point number in GLSL.
  20745. * @param x Value to print.
  20746. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  20747. * @return GLSL float string.
  20748. */
  20749. protected _glslFloat(x: number, decimalFigures?: number): string;
  20750. }
  20751. }
  20752. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  20753. import { Scene } from "babylonjs/scene";
  20754. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20755. import { Plane } from "babylonjs/Maths/math.plane";
  20756. /**
  20757. * Mirror texture can be used to simulate the view from a mirror in a scene.
  20758. * It will dynamically be rendered every frame to adapt to the camera point of view.
  20759. * You can then easily use it as a reflectionTexture on a flat surface.
  20760. * In case the surface is not a plane, please consider relying on reflection probes.
  20761. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  20762. */
  20763. export class MirrorTexture extends RenderTargetTexture {
  20764. private scene;
  20765. /**
  20766. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  20767. * 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.
  20768. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  20769. */
  20770. mirrorPlane: Plane;
  20771. /**
  20772. * Define the blur ratio used to blur the reflection if needed.
  20773. */
  20774. set blurRatio(value: number);
  20775. get blurRatio(): number;
  20776. /**
  20777. * Define the adaptive blur kernel used to blur the reflection if needed.
  20778. * This will autocompute the closest best match for the `blurKernel`
  20779. */
  20780. set adaptiveBlurKernel(value: number);
  20781. /**
  20782. * Define the blur kernel used to blur the reflection if needed.
  20783. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  20784. */
  20785. set blurKernel(value: number);
  20786. /**
  20787. * Define the blur kernel on the X Axis 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 blurKernelX(value: number);
  20791. get blurKernelX(): number;
  20792. /**
  20793. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  20794. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  20795. */
  20796. set blurKernelY(value: number);
  20797. get blurKernelY(): number;
  20798. private _autoComputeBlurKernel;
  20799. protected _onRatioRescale(): void;
  20800. private _updateGammaSpace;
  20801. private _imageProcessingConfigChangeObserver;
  20802. private _transformMatrix;
  20803. private _mirrorMatrix;
  20804. private _savedViewMatrix;
  20805. private _blurX;
  20806. private _blurY;
  20807. private _adaptiveBlurKernel;
  20808. private _blurKernelX;
  20809. private _blurKernelY;
  20810. private _blurRatio;
  20811. /**
  20812. * Instantiates a Mirror Texture.
  20813. * Mirror texture can be used to simulate the view from a mirror in a scene.
  20814. * It will dynamically be rendered every frame to adapt to the camera point of view.
  20815. * You can then easily use it as a reflectionTexture on a flat surface.
  20816. * In case the surface is not a plane, please consider relying on reflection probes.
  20817. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  20818. * @param name
  20819. * @param size
  20820. * @param scene
  20821. * @param generateMipMaps
  20822. * @param type
  20823. * @param samplingMode
  20824. * @param generateDepthBuffer
  20825. */
  20826. constructor(name: string, size: number | {
  20827. width: number;
  20828. height: number;
  20829. } | {
  20830. ratio: number;
  20831. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  20832. private _preparePostProcesses;
  20833. /**
  20834. * Clone the mirror texture.
  20835. * @returns the cloned texture
  20836. */
  20837. clone(): MirrorTexture;
  20838. /**
  20839. * Serialize the texture to a JSON representation you could use in Parse later on
  20840. * @returns the serialized JSON representation
  20841. */
  20842. serialize(): any;
  20843. /**
  20844. * Dispose the texture and release its associated resources.
  20845. */
  20846. dispose(): void;
  20847. }
  20848. }
  20849. declare module "babylonjs/Materials/Textures/texture" {
  20850. import { Observable } from "babylonjs/Misc/observable";
  20851. import { Nullable } from "babylonjs/types";
  20852. import { Matrix } from "babylonjs/Maths/math.vector";
  20853. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20854. import { IInspectable } from "babylonjs/Misc/iInspectable";
  20855. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  20856. import { Scene } from "babylonjs/scene";
  20857. /**
  20858. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  20859. * @see http://doc.babylonjs.com/babylon101/materials#texture
  20860. */
  20861. export class Texture extends BaseTexture {
  20862. /**
  20863. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  20864. */
  20865. static SerializeBuffers: boolean;
  20866. /** @hidden */
  20867. static _CubeTextureParser: (jsonTexture: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  20868. /** @hidden */
  20869. static _CreateMirror: (name: string, renderTargetSize: number, scene: import("babylonjs/scene").Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  20870. /** @hidden */
  20871. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: import("babylonjs/scene").Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  20872. /** nearest is mag = nearest and min = nearest and mip = linear */
  20873. static readonly NEAREST_SAMPLINGMODE: number;
  20874. /** nearest is mag = nearest and min = nearest and mip = linear */
  20875. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  20876. /** Bilinear is mag = linear and min = linear and mip = nearest */
  20877. static readonly BILINEAR_SAMPLINGMODE: number;
  20878. /** Bilinear is mag = linear and min = linear and mip = nearest */
  20879. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  20880. /** Trilinear is mag = linear and min = linear and mip = linear */
  20881. static readonly TRILINEAR_SAMPLINGMODE: number;
  20882. /** Trilinear is mag = linear and min = linear and mip = linear */
  20883. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  20884. /** mag = nearest and min = nearest and mip = nearest */
  20885. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  20886. /** mag = nearest and min = linear and mip = nearest */
  20887. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  20888. /** mag = nearest and min = linear and mip = linear */
  20889. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  20890. /** mag = nearest and min = linear and mip = none */
  20891. static readonly NEAREST_LINEAR: number;
  20892. /** mag = nearest and min = nearest and mip = none */
  20893. static readonly NEAREST_NEAREST: number;
  20894. /** mag = linear and min = nearest and mip = nearest */
  20895. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  20896. /** mag = linear and min = nearest and mip = linear */
  20897. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  20898. /** mag = linear and min = linear and mip = none */
  20899. static readonly LINEAR_LINEAR: number;
  20900. /** mag = linear and min = nearest and mip = none */
  20901. static readonly LINEAR_NEAREST: number;
  20902. /** Explicit coordinates mode */
  20903. static readonly EXPLICIT_MODE: number;
  20904. /** Spherical coordinates mode */
  20905. static readonly SPHERICAL_MODE: number;
  20906. /** Planar coordinates mode */
  20907. static readonly PLANAR_MODE: number;
  20908. /** Cubic coordinates mode */
  20909. static readonly CUBIC_MODE: number;
  20910. /** Projection coordinates mode */
  20911. static readonly PROJECTION_MODE: number;
  20912. /** Inverse Cubic coordinates mode */
  20913. static readonly SKYBOX_MODE: number;
  20914. /** Inverse Cubic coordinates mode */
  20915. static readonly INVCUBIC_MODE: number;
  20916. /** Equirectangular coordinates mode */
  20917. static readonly EQUIRECTANGULAR_MODE: number;
  20918. /** Equirectangular Fixed coordinates mode */
  20919. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  20920. /** Equirectangular Fixed Mirrored coordinates mode */
  20921. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  20922. /** Texture is not repeating outside of 0..1 UVs */
  20923. static readonly CLAMP_ADDRESSMODE: number;
  20924. /** Texture is repeating outside of 0..1 UVs */
  20925. static readonly WRAP_ADDRESSMODE: number;
  20926. /** Texture is repeating and mirrored */
  20927. static readonly MIRROR_ADDRESSMODE: number;
  20928. /**
  20929. * 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
  20930. */
  20931. static UseSerializedUrlIfAny: boolean;
  20932. /**
  20933. * Define the url of the texture.
  20934. */
  20935. url: Nullable<string>;
  20936. /**
  20937. * Define an offset on the texture to offset the u coordinates of the UVs
  20938. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  20939. */
  20940. uOffset: number;
  20941. /**
  20942. * Define an offset on the texture to offset the v coordinates of the UVs
  20943. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  20944. */
  20945. vOffset: number;
  20946. /**
  20947. * Define an offset on the texture to scale the u coordinates of the UVs
  20948. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  20949. */
  20950. uScale: number;
  20951. /**
  20952. * Define an offset on the texture to scale the v coordinates of the UVs
  20953. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  20954. */
  20955. vScale: number;
  20956. /**
  20957. * Define an offset on the texture to rotate around the u coordinates of the UVs
  20958. * @see http://doc.babylonjs.com/how_to/more_materials
  20959. */
  20960. uAng: number;
  20961. /**
  20962. * Define an offset on the texture to rotate around the v coordinates of the UVs
  20963. * @see http://doc.babylonjs.com/how_to/more_materials
  20964. */
  20965. vAng: number;
  20966. /**
  20967. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  20968. * @see http://doc.babylonjs.com/how_to/more_materials
  20969. */
  20970. wAng: number;
  20971. /**
  20972. * Defines the center of rotation (U)
  20973. */
  20974. uRotationCenter: number;
  20975. /**
  20976. * Defines the center of rotation (V)
  20977. */
  20978. vRotationCenter: number;
  20979. /**
  20980. * Defines the center of rotation (W)
  20981. */
  20982. wRotationCenter: number;
  20983. /**
  20984. * Are mip maps generated for this texture or not.
  20985. */
  20986. get noMipmap(): boolean;
  20987. /**
  20988. * List of inspectable custom properties (used by the Inspector)
  20989. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20990. */
  20991. inspectableCustomProperties: Nullable<IInspectable[]>;
  20992. private _noMipmap;
  20993. /** @hidden */
  20994. _invertY: boolean;
  20995. private _rowGenerationMatrix;
  20996. private _cachedTextureMatrix;
  20997. private _projectionModeMatrix;
  20998. private _t0;
  20999. private _t1;
  21000. private _t2;
  21001. private _cachedUOffset;
  21002. private _cachedVOffset;
  21003. private _cachedUScale;
  21004. private _cachedVScale;
  21005. private _cachedUAng;
  21006. private _cachedVAng;
  21007. private _cachedWAng;
  21008. private _cachedProjectionMatrixId;
  21009. private _cachedCoordinatesMode;
  21010. /** @hidden */
  21011. protected _initialSamplingMode: number;
  21012. /** @hidden */
  21013. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  21014. private _deleteBuffer;
  21015. protected _format: Nullable<number>;
  21016. private _delayedOnLoad;
  21017. private _delayedOnError;
  21018. private _mimeType?;
  21019. /**
  21020. * Observable triggered once the texture has been loaded.
  21021. */
  21022. onLoadObservable: Observable<Texture>;
  21023. protected _isBlocking: boolean;
  21024. /**
  21025. * Is the texture preventing material to render while loading.
  21026. * If false, a default texture will be used instead of the loading one during the preparation step.
  21027. */
  21028. set isBlocking(value: boolean);
  21029. get isBlocking(): boolean;
  21030. /**
  21031. * Get the current sampling mode associated with the texture.
  21032. */
  21033. get samplingMode(): number;
  21034. /**
  21035. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  21036. */
  21037. get invertY(): boolean;
  21038. /**
  21039. * Instantiates a new texture.
  21040. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  21041. * @see http://doc.babylonjs.com/babylon101/materials#texture
  21042. * @param url defines the url of the picture to load as a texture
  21043. * @param scene defines the scene or engine the texture will belong to
  21044. * @param noMipmap defines if the texture will require mip maps or not
  21045. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  21046. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  21047. * @param onLoad defines a callback triggered when the texture has been loaded
  21048. * @param onError defines a callback triggered when an error occurred during the loading session
  21049. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  21050. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  21051. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  21052. * @param mimeType defines an optional mime type information
  21053. */
  21054. 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);
  21055. /**
  21056. * Update the url (and optional buffer) of this texture if url was null during construction.
  21057. * @param url the url of the texture
  21058. * @param buffer the buffer of the texture (defaults to null)
  21059. * @param onLoad callback called when the texture is loaded (defaults to null)
  21060. */
  21061. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  21062. /**
  21063. * Finish the loading sequence of a texture flagged as delayed load.
  21064. * @hidden
  21065. */
  21066. delayLoad(): void;
  21067. private _prepareRowForTextureGeneration;
  21068. /**
  21069. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  21070. * @returns the transform matrix of the texture.
  21071. */
  21072. getTextureMatrix(uBase?: number): Matrix;
  21073. /**
  21074. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  21075. * @returns The reflection texture transform
  21076. */
  21077. getReflectionTextureMatrix(): Matrix;
  21078. /**
  21079. * Clones the texture.
  21080. * @returns the cloned texture
  21081. */
  21082. clone(): Texture;
  21083. /**
  21084. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  21085. * @returns The JSON representation of the texture
  21086. */
  21087. serialize(): any;
  21088. /**
  21089. * Get the current class name of the texture useful for serialization or dynamic coding.
  21090. * @returns "Texture"
  21091. */
  21092. getClassName(): string;
  21093. /**
  21094. * Dispose the texture and release its associated resources.
  21095. */
  21096. dispose(): void;
  21097. /**
  21098. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  21099. * @param parsedTexture Define the JSON representation of the texture
  21100. * @param scene Define the scene the parsed texture should be instantiated in
  21101. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  21102. * @returns The parsed texture if successful
  21103. */
  21104. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  21105. /**
  21106. * Creates a texture from its base 64 representation.
  21107. * @param data Define the base64 payload without the data: prefix
  21108. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  21109. * @param scene Define the scene the texture should belong to
  21110. * @param noMipmap Forces the texture to not create mip map information if true
  21111. * @param invertY define if the texture needs to be inverted on the y axis during loading
  21112. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  21113. * @param onLoad define a callback triggered when the texture has been loaded
  21114. * @param onError define a callback triggered when an error occurred during the loading session
  21115. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  21116. * @returns the created texture
  21117. */
  21118. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  21119. /**
  21120. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  21121. * @param data Define the base64 payload without the data: prefix
  21122. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  21123. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  21124. * @param scene Define the scene the texture should belong to
  21125. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  21126. * @param noMipmap Forces the texture to not create mip map information if true
  21127. * @param invertY define if the texture needs to be inverted on the y axis during loading
  21128. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  21129. * @param onLoad define a callback triggered when the texture has been loaded
  21130. * @param onError define a callback triggered when an error occurred during the loading session
  21131. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  21132. * @returns the created texture
  21133. */
  21134. 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;
  21135. }
  21136. }
  21137. declare module "babylonjs/PostProcesses/postProcessManager" {
  21138. import { Nullable } from "babylonjs/types";
  21139. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  21140. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  21141. import { Scene } from "babylonjs/scene";
  21142. /**
  21143. * PostProcessManager is used to manage one or more post processes or post process pipelines
  21144. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  21145. */
  21146. export class PostProcessManager {
  21147. private _scene;
  21148. private _indexBuffer;
  21149. private _vertexBuffers;
  21150. /**
  21151. * Creates a new instance PostProcess
  21152. * @param scene The scene that the post process is associated with.
  21153. */
  21154. constructor(scene: Scene);
  21155. private _prepareBuffers;
  21156. private _buildIndexBuffer;
  21157. /**
  21158. * Rebuilds the vertex buffers of the manager.
  21159. * @hidden
  21160. */
  21161. _rebuild(): void;
  21162. /**
  21163. * Prepares a frame to be run through a post process.
  21164. * @param sourceTexture The input texture to the post procesess. (default: null)
  21165. * @param postProcesses An array of post processes to be run. (default: null)
  21166. * @returns True if the post processes were able to be run.
  21167. * @hidden
  21168. */
  21169. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  21170. /**
  21171. * Manually render a set of post processes to a texture.
  21172. * @param postProcesses An array of post processes to be run.
  21173. * @param targetTexture The target texture to render to.
  21174. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  21175. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  21176. * @param lodLevel defines which lod of the texture to render to
  21177. */
  21178. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  21179. /**
  21180. * Finalize the result of the output of the postprocesses.
  21181. * @param doNotPresent If true the result will not be displayed to the screen.
  21182. * @param targetTexture The target texture to render to.
  21183. * @param faceIndex The index of the face to bind the target texture to.
  21184. * @param postProcesses The array of post processes to render.
  21185. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  21186. * @hidden
  21187. */
  21188. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  21189. /**
  21190. * Disposes of the post process manager.
  21191. */
  21192. dispose(): void;
  21193. }
  21194. }
  21195. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  21196. import { Observable } from "babylonjs/Misc/observable";
  21197. import { SmartArray } from "babylonjs/Misc/smartArray";
  21198. import { Nullable, Immutable } from "babylonjs/types";
  21199. import { Camera } from "babylonjs/Cameras/camera";
  21200. import { Scene } from "babylonjs/scene";
  21201. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  21202. import { Color4 } from "babylonjs/Maths/math.color";
  21203. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  21204. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21205. import { SubMesh } from "babylonjs/Meshes/subMesh";
  21206. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  21207. import { Texture } from "babylonjs/Materials/Textures/texture";
  21208. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  21209. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  21210. import "babylonjs/Engines/Extensions/engine.renderTarget";
  21211. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  21212. import { Engine } from "babylonjs/Engines/engine";
  21213. /**
  21214. * This Helps creating a texture that will be created from a camera in your scene.
  21215. * It is basically a dynamic texture that could be used to create special effects for instance.
  21216. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  21217. */
  21218. export class RenderTargetTexture extends Texture {
  21219. isCube: boolean;
  21220. /**
  21221. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  21222. */
  21223. static readonly REFRESHRATE_RENDER_ONCE: number;
  21224. /**
  21225. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  21226. */
  21227. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  21228. /**
  21229. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  21230. * the central point of your effect and can save a lot of performances.
  21231. */
  21232. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  21233. /**
  21234. * Use this predicate to dynamically define the list of mesh you want to render.
  21235. * If set, the renderList property will be overwritten.
  21236. */
  21237. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  21238. private _renderList;
  21239. /**
  21240. * Use this list to define the list of mesh you want to render.
  21241. */
  21242. get renderList(): Nullable<Array<AbstractMesh>>;
  21243. set renderList(value: Nullable<Array<AbstractMesh>>);
  21244. /**
  21245. * Use this function to overload the renderList array at rendering time.
  21246. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  21247. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  21248. * the cube (if the RTT is a cube, else layerOrFace=0).
  21249. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  21250. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  21251. * hold dummy elements!
  21252. */
  21253. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  21254. private _hookArray;
  21255. /**
  21256. * Define if particles should be rendered in your texture.
  21257. */
  21258. renderParticles: boolean;
  21259. /**
  21260. * Define if sprites should be rendered in your texture.
  21261. */
  21262. renderSprites: boolean;
  21263. /**
  21264. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  21265. */
  21266. coordinatesMode: number;
  21267. /**
  21268. * Define the camera used to render the texture.
  21269. */
  21270. activeCamera: Nullable<Camera>;
  21271. /**
  21272. * Override the mesh isReady function with your own one.
  21273. */
  21274. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  21275. /**
  21276. * Override the render function of the texture with your own one.
  21277. */
  21278. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  21279. /**
  21280. * Define if camera post processes should be use while rendering the texture.
  21281. */
  21282. useCameraPostProcesses: boolean;
  21283. /**
  21284. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  21285. */
  21286. ignoreCameraViewport: boolean;
  21287. private _postProcessManager;
  21288. private _postProcesses;
  21289. private _resizeObserver;
  21290. /**
  21291. * An event triggered when the texture is unbind.
  21292. */
  21293. onBeforeBindObservable: Observable<RenderTargetTexture>;
  21294. /**
  21295. * An event triggered when the texture is unbind.
  21296. */
  21297. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  21298. private _onAfterUnbindObserver;
  21299. /**
  21300. * Set a after unbind callback in the texture.
  21301. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  21302. */
  21303. set onAfterUnbind(callback: () => void);
  21304. /**
  21305. * An event triggered before rendering the texture
  21306. */
  21307. onBeforeRenderObservable: Observable<number>;
  21308. private _onBeforeRenderObserver;
  21309. /**
  21310. * Set a before render callback in the texture.
  21311. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  21312. */
  21313. set onBeforeRender(callback: (faceIndex: number) => void);
  21314. /**
  21315. * An event triggered after rendering the texture
  21316. */
  21317. onAfterRenderObservable: Observable<number>;
  21318. private _onAfterRenderObserver;
  21319. /**
  21320. * Set a after render callback in the texture.
  21321. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  21322. */
  21323. set onAfterRender(callback: (faceIndex: number) => void);
  21324. /**
  21325. * An event triggered after the texture clear
  21326. */
  21327. onClearObservable: Observable<Engine>;
  21328. private _onClearObserver;
  21329. /**
  21330. * Set a clear callback in the texture.
  21331. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  21332. */
  21333. set onClear(callback: (Engine: Engine) => void);
  21334. /**
  21335. * An event triggered when the texture is resized.
  21336. */
  21337. onResizeObservable: Observable<RenderTargetTexture>;
  21338. /**
  21339. * Define the clear color of the Render Target if it should be different from the scene.
  21340. */
  21341. clearColor: Color4;
  21342. protected _size: number | {
  21343. width: number;
  21344. height: number;
  21345. layers?: number;
  21346. };
  21347. protected _initialSizeParameter: number | {
  21348. width: number;
  21349. height: number;
  21350. } | {
  21351. ratio: number;
  21352. };
  21353. protected _sizeRatio: Nullable<number>;
  21354. /** @hidden */
  21355. _generateMipMaps: boolean;
  21356. protected _renderingManager: RenderingManager;
  21357. /** @hidden */
  21358. _waitingRenderList: string[];
  21359. protected _doNotChangeAspectRatio: boolean;
  21360. protected _currentRefreshId: number;
  21361. protected _refreshRate: number;
  21362. protected _textureMatrix: Matrix;
  21363. protected _samples: number;
  21364. protected _renderTargetOptions: RenderTargetCreationOptions;
  21365. /**
  21366. * Gets render target creation options that were used.
  21367. */
  21368. get renderTargetOptions(): RenderTargetCreationOptions;
  21369. protected _engine: Engine;
  21370. protected _onRatioRescale(): void;
  21371. /**
  21372. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  21373. * It must define where the camera used to render the texture is set
  21374. */
  21375. boundingBoxPosition: Vector3;
  21376. private _boundingBoxSize;
  21377. /**
  21378. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  21379. * When defined, the cubemap will switch to local mode
  21380. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  21381. * @example https://www.babylonjs-playground.com/#RNASML
  21382. */
  21383. set boundingBoxSize(value: Vector3);
  21384. get boundingBoxSize(): Vector3;
  21385. /**
  21386. * In case the RTT has been created with a depth texture, get the associated
  21387. * depth texture.
  21388. * Otherwise, return null.
  21389. */
  21390. get depthStencilTexture(): Nullable<InternalTexture>;
  21391. /**
  21392. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  21393. * or used a shadow, depth texture...
  21394. * @param name The friendly name of the texture
  21395. * @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)
  21396. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  21397. * @param generateMipMaps True if mip maps need to be generated after render.
  21398. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  21399. * @param type The type of the buffer in the RTT (int, half float, float...)
  21400. * @param isCube True if a cube texture needs to be created
  21401. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  21402. * @param generateDepthBuffer True to generate a depth buffer
  21403. * @param generateStencilBuffer True to generate a stencil buffer
  21404. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  21405. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  21406. * @param delayAllocation if the texture allocation should be delayed (default: false)
  21407. */
  21408. constructor(name: string, size: number | {
  21409. width: number;
  21410. height: number;
  21411. layers?: number;
  21412. } | {
  21413. ratio: number;
  21414. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  21415. /**
  21416. * Creates a depth stencil texture.
  21417. * This is only available in WebGL 2 or with the depth texture extension available.
  21418. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  21419. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  21420. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  21421. */
  21422. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  21423. private _processSizeParameter;
  21424. /**
  21425. * Define the number of samples to use in case of MSAA.
  21426. * It defaults to one meaning no MSAA has been enabled.
  21427. */
  21428. get samples(): number;
  21429. set samples(value: number);
  21430. /**
  21431. * Resets the refresh counter of the texture and start bak from scratch.
  21432. * Could be useful to regenerate the texture if it is setup to render only once.
  21433. */
  21434. resetRefreshCounter(): void;
  21435. /**
  21436. * Define the refresh rate of the texture or the rendering frequency.
  21437. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  21438. */
  21439. get refreshRate(): number;
  21440. set refreshRate(value: number);
  21441. /**
  21442. * Adds a post process to the render target rendering passes.
  21443. * @param postProcess define the post process to add
  21444. */
  21445. addPostProcess(postProcess: PostProcess): void;
  21446. /**
  21447. * Clear all the post processes attached to the render target
  21448. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  21449. */
  21450. clearPostProcesses(dispose?: boolean): void;
  21451. /**
  21452. * Remove one of the post process from the list of attached post processes to the texture
  21453. * @param postProcess define the post process to remove from the list
  21454. */
  21455. removePostProcess(postProcess: PostProcess): void;
  21456. /** @hidden */
  21457. _shouldRender(): boolean;
  21458. /**
  21459. * Gets the actual render size of the texture.
  21460. * @returns the width of the render size
  21461. */
  21462. getRenderSize(): number;
  21463. /**
  21464. * Gets the actual render width of the texture.
  21465. * @returns the width of the render size
  21466. */
  21467. getRenderWidth(): number;
  21468. /**
  21469. * Gets the actual render height of the texture.
  21470. * @returns the height of the render size
  21471. */
  21472. getRenderHeight(): number;
  21473. /**
  21474. * Gets the actual number of layers of the texture.
  21475. * @returns the number of layers
  21476. */
  21477. getRenderLayers(): number;
  21478. /**
  21479. * Get if the texture can be rescaled or not.
  21480. */
  21481. get canRescale(): boolean;
  21482. /**
  21483. * Resize the texture using a ratio.
  21484. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  21485. */
  21486. scale(ratio: number): void;
  21487. /**
  21488. * Get the texture reflection matrix used to rotate/transform the reflection.
  21489. * @returns the reflection matrix
  21490. */
  21491. getReflectionTextureMatrix(): Matrix;
  21492. /**
  21493. * Resize the texture to a new desired size.
  21494. * Be carrefull as it will recreate all the data in the new texture.
  21495. * @param size Define the new size. It can be:
  21496. * - a number for squared texture,
  21497. * - an object containing { width: number, height: number }
  21498. * - or an object containing a ratio { ratio: number }
  21499. */
  21500. resize(size: number | {
  21501. width: number;
  21502. height: number;
  21503. } | {
  21504. ratio: number;
  21505. }): void;
  21506. private _defaultRenderListPrepared;
  21507. /**
  21508. * Renders all the objects from the render list into the texture.
  21509. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  21510. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  21511. */
  21512. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  21513. private _bestReflectionRenderTargetDimension;
  21514. private _prepareRenderingManager;
  21515. /**
  21516. * @hidden
  21517. * @param faceIndex face index to bind to if this is a cubetexture
  21518. * @param layer defines the index of the texture to bind in the array
  21519. */
  21520. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  21521. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  21522. private renderToTarget;
  21523. /**
  21524. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  21525. * This allowed control for front to back rendering or reversly depending of the special needs.
  21526. *
  21527. * @param renderingGroupId The rendering group id corresponding to its index
  21528. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  21529. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  21530. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  21531. */
  21532. 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;
  21533. /**
  21534. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  21535. *
  21536. * @param renderingGroupId The rendering group id corresponding to its index
  21537. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  21538. */
  21539. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  21540. /**
  21541. * Clones the texture.
  21542. * @returns the cloned texture
  21543. */
  21544. clone(): RenderTargetTexture;
  21545. /**
  21546. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  21547. * @returns The JSON representation of the texture
  21548. */
  21549. serialize(): any;
  21550. /**
  21551. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  21552. */
  21553. disposeFramebufferObjects(): void;
  21554. /**
  21555. * Dispose the texture and release its associated resources.
  21556. */
  21557. dispose(): void;
  21558. /** @hidden */
  21559. _rebuild(): void;
  21560. /**
  21561. * Clear the info related to rendering groups preventing retention point in material dispose.
  21562. */
  21563. freeRenderingGroups(): void;
  21564. /**
  21565. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  21566. * @returns the view count
  21567. */
  21568. getViewCount(): number;
  21569. }
  21570. }
  21571. declare module "babylonjs/Materials/material" {
  21572. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  21573. import { SmartArray } from "babylonjs/Misc/smartArray";
  21574. import { Observable } from "babylonjs/Misc/observable";
  21575. import { Nullable } from "babylonjs/types";
  21576. import { Scene } from "babylonjs/scene";
  21577. import { Matrix } from "babylonjs/Maths/math.vector";
  21578. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  21579. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21580. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  21581. import { Effect } from "babylonjs/Materials/effect";
  21582. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21583. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  21584. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  21585. import { IInspectable } from "babylonjs/Misc/iInspectable";
  21586. import { Mesh } from "babylonjs/Meshes/mesh";
  21587. import { Animation } from "babylonjs/Animations/animation";
  21588. /**
  21589. * Options for compiling materials.
  21590. */
  21591. export interface IMaterialCompilationOptions {
  21592. /**
  21593. * Defines whether clip planes are enabled.
  21594. */
  21595. clipPlane: boolean;
  21596. /**
  21597. * Defines whether instances are enabled.
  21598. */
  21599. useInstances: boolean;
  21600. }
  21601. /**
  21602. * Base class for the main features of a material in Babylon.js
  21603. */
  21604. export class Material implements IAnimatable {
  21605. /**
  21606. * Returns the triangle fill mode
  21607. */
  21608. static readonly TriangleFillMode: number;
  21609. /**
  21610. * Returns the wireframe mode
  21611. */
  21612. static readonly WireFrameFillMode: number;
  21613. /**
  21614. * Returns the point fill mode
  21615. */
  21616. static readonly PointFillMode: number;
  21617. /**
  21618. * Returns the point list draw mode
  21619. */
  21620. static readonly PointListDrawMode: number;
  21621. /**
  21622. * Returns the line list draw mode
  21623. */
  21624. static readonly LineListDrawMode: number;
  21625. /**
  21626. * Returns the line loop draw mode
  21627. */
  21628. static readonly LineLoopDrawMode: number;
  21629. /**
  21630. * Returns the line strip draw mode
  21631. */
  21632. static readonly LineStripDrawMode: number;
  21633. /**
  21634. * Returns the triangle strip draw mode
  21635. */
  21636. static readonly TriangleStripDrawMode: number;
  21637. /**
  21638. * Returns the triangle fan draw mode
  21639. */
  21640. static readonly TriangleFanDrawMode: number;
  21641. /**
  21642. * Stores the clock-wise side orientation
  21643. */
  21644. static readonly ClockWiseSideOrientation: number;
  21645. /**
  21646. * Stores the counter clock-wise side orientation
  21647. */
  21648. static readonly CounterClockWiseSideOrientation: number;
  21649. /**
  21650. * The dirty texture flag value
  21651. */
  21652. static readonly TextureDirtyFlag: number;
  21653. /**
  21654. * The dirty light flag value
  21655. */
  21656. static readonly LightDirtyFlag: number;
  21657. /**
  21658. * The dirty fresnel flag value
  21659. */
  21660. static readonly FresnelDirtyFlag: number;
  21661. /**
  21662. * The dirty attribute flag value
  21663. */
  21664. static readonly AttributesDirtyFlag: number;
  21665. /**
  21666. * The dirty misc flag value
  21667. */
  21668. static readonly MiscDirtyFlag: number;
  21669. /**
  21670. * The all dirty flag value
  21671. */
  21672. static readonly AllDirtyFlag: number;
  21673. /**
  21674. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  21675. */
  21676. static readonly MATERIAL_OPAQUE: number;
  21677. /**
  21678. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  21679. */
  21680. static readonly MATERIAL_ALPHATEST: number;
  21681. /**
  21682. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  21683. */
  21684. static readonly MATERIAL_ALPHABLEND: number;
  21685. /**
  21686. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  21687. * They are also discarded below the alpha cutoff threshold to improve performances.
  21688. */
  21689. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  21690. /**
  21691. * The ID of the material
  21692. */
  21693. id: string;
  21694. /**
  21695. * Gets or sets the unique id of the material
  21696. */
  21697. uniqueId: number;
  21698. /**
  21699. * The name of the material
  21700. */
  21701. name: string;
  21702. /**
  21703. * Gets or sets user defined metadata
  21704. */
  21705. metadata: any;
  21706. /**
  21707. * For internal use only. Please do not use.
  21708. */
  21709. reservedDataStore: any;
  21710. /**
  21711. * Specifies if the ready state should be checked on each call
  21712. */
  21713. checkReadyOnEveryCall: boolean;
  21714. /**
  21715. * Specifies if the ready state should be checked once
  21716. */
  21717. checkReadyOnlyOnce: boolean;
  21718. /**
  21719. * The state of the material
  21720. */
  21721. state: string;
  21722. /**
  21723. * The alpha value of the material
  21724. */
  21725. protected _alpha: number;
  21726. /**
  21727. * List of inspectable custom properties (used by the Inspector)
  21728. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  21729. */
  21730. inspectableCustomProperties: IInspectable[];
  21731. /**
  21732. * Sets the alpha value of the material
  21733. */
  21734. set alpha(value: number);
  21735. /**
  21736. * Gets the alpha value of the material
  21737. */
  21738. get alpha(): number;
  21739. /**
  21740. * Specifies if back face culling is enabled
  21741. */
  21742. protected _backFaceCulling: boolean;
  21743. /**
  21744. * Sets the back-face culling state
  21745. */
  21746. set backFaceCulling(value: boolean);
  21747. /**
  21748. * Gets the back-face culling state
  21749. */
  21750. get backFaceCulling(): boolean;
  21751. /**
  21752. * Stores the value for side orientation
  21753. */
  21754. sideOrientation: number;
  21755. /**
  21756. * Callback triggered when the material is compiled
  21757. */
  21758. onCompiled: Nullable<(effect: Effect) => void>;
  21759. /**
  21760. * Callback triggered when an error occurs
  21761. */
  21762. onError: Nullable<(effect: Effect, errors: string) => void>;
  21763. /**
  21764. * Callback triggered to get the render target textures
  21765. */
  21766. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  21767. /**
  21768. * Gets a boolean indicating that current material needs to register RTT
  21769. */
  21770. get hasRenderTargetTextures(): boolean;
  21771. /**
  21772. * Specifies if the material should be serialized
  21773. */
  21774. doNotSerialize: boolean;
  21775. /**
  21776. * @hidden
  21777. */
  21778. _storeEffectOnSubMeshes: boolean;
  21779. /**
  21780. * Stores the animations for the material
  21781. */
  21782. animations: Nullable<Array<Animation>>;
  21783. /**
  21784. * An event triggered when the material is disposed
  21785. */
  21786. onDisposeObservable: Observable<Material>;
  21787. /**
  21788. * An observer which watches for dispose events
  21789. */
  21790. private _onDisposeObserver;
  21791. private _onUnBindObservable;
  21792. /**
  21793. * Called during a dispose event
  21794. */
  21795. set onDispose(callback: () => void);
  21796. private _onBindObservable;
  21797. /**
  21798. * An event triggered when the material is bound
  21799. */
  21800. get onBindObservable(): Observable<AbstractMesh>;
  21801. /**
  21802. * An observer which watches for bind events
  21803. */
  21804. private _onBindObserver;
  21805. /**
  21806. * Called during a bind event
  21807. */
  21808. set onBind(callback: (Mesh: AbstractMesh) => void);
  21809. /**
  21810. * An event triggered when the material is unbound
  21811. */
  21812. get onUnBindObservable(): Observable<Material>;
  21813. /**
  21814. * Stores the value of the alpha mode
  21815. */
  21816. private _alphaMode;
  21817. /**
  21818. * Sets the value of the alpha mode.
  21819. *
  21820. * | Value | Type | Description |
  21821. * | --- | --- | --- |
  21822. * | 0 | ALPHA_DISABLE | |
  21823. * | 1 | ALPHA_ADD | |
  21824. * | 2 | ALPHA_COMBINE | |
  21825. * | 3 | ALPHA_SUBTRACT | |
  21826. * | 4 | ALPHA_MULTIPLY | |
  21827. * | 5 | ALPHA_MAXIMIZED | |
  21828. * | 6 | ALPHA_ONEONE | |
  21829. * | 7 | ALPHA_PREMULTIPLIED | |
  21830. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  21831. * | 9 | ALPHA_INTERPOLATE | |
  21832. * | 10 | ALPHA_SCREENMODE | |
  21833. *
  21834. */
  21835. set alphaMode(value: number);
  21836. /**
  21837. * Gets the value of the alpha mode
  21838. */
  21839. get alphaMode(): number;
  21840. /**
  21841. * Stores the state of the need depth pre-pass value
  21842. */
  21843. private _needDepthPrePass;
  21844. /**
  21845. * Sets the need depth pre-pass value
  21846. */
  21847. set needDepthPrePass(value: boolean);
  21848. /**
  21849. * Gets the depth pre-pass value
  21850. */
  21851. get needDepthPrePass(): boolean;
  21852. /**
  21853. * Specifies if depth writing should be disabled
  21854. */
  21855. disableDepthWrite: boolean;
  21856. /**
  21857. * Specifies if depth writing should be forced
  21858. */
  21859. forceDepthWrite: boolean;
  21860. /**
  21861. * Specifies the depth function that should be used. 0 means the default engine function
  21862. */
  21863. depthFunction: number;
  21864. /**
  21865. * Specifies if there should be a separate pass for culling
  21866. */
  21867. separateCullingPass: boolean;
  21868. /**
  21869. * Stores the state specifing if fog should be enabled
  21870. */
  21871. private _fogEnabled;
  21872. /**
  21873. * Sets the state for enabling fog
  21874. */
  21875. set fogEnabled(value: boolean);
  21876. /**
  21877. * Gets the value of the fog enabled state
  21878. */
  21879. get fogEnabled(): boolean;
  21880. /**
  21881. * Stores the size of points
  21882. */
  21883. pointSize: number;
  21884. /**
  21885. * Stores the z offset value
  21886. */
  21887. zOffset: number;
  21888. /**
  21889. * Gets a value specifying if wireframe mode is enabled
  21890. */
  21891. get wireframe(): boolean;
  21892. /**
  21893. * Sets the state of wireframe mode
  21894. */
  21895. set wireframe(value: boolean);
  21896. /**
  21897. * Gets the value specifying if point clouds are enabled
  21898. */
  21899. get pointsCloud(): boolean;
  21900. /**
  21901. * Sets the state of point cloud mode
  21902. */
  21903. set pointsCloud(value: boolean);
  21904. /**
  21905. * Gets the material fill mode
  21906. */
  21907. get fillMode(): number;
  21908. /**
  21909. * Sets the material fill mode
  21910. */
  21911. set fillMode(value: number);
  21912. /**
  21913. * @hidden
  21914. * Stores the effects for the material
  21915. */
  21916. _effect: Nullable<Effect>;
  21917. /**
  21918. * Specifies if uniform buffers should be used
  21919. */
  21920. private _useUBO;
  21921. /**
  21922. * Stores a reference to the scene
  21923. */
  21924. private _scene;
  21925. /**
  21926. * Stores the fill mode state
  21927. */
  21928. private _fillMode;
  21929. /**
  21930. * Specifies if the depth write state should be cached
  21931. */
  21932. private _cachedDepthWriteState;
  21933. /**
  21934. * Specifies if the depth function state should be cached
  21935. */
  21936. private _cachedDepthFunctionState;
  21937. /**
  21938. * Stores the uniform buffer
  21939. */
  21940. protected _uniformBuffer: UniformBuffer;
  21941. /** @hidden */
  21942. _indexInSceneMaterialArray: number;
  21943. /** @hidden */
  21944. meshMap: Nullable<{
  21945. [id: string]: AbstractMesh | undefined;
  21946. }>;
  21947. /**
  21948. * Creates a material instance
  21949. * @param name defines the name of the material
  21950. * @param scene defines the scene to reference
  21951. * @param doNotAdd specifies if the material should be added to the scene
  21952. */
  21953. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  21954. /**
  21955. * Returns a string representation of the current material
  21956. * @param fullDetails defines a boolean indicating which levels of logging is desired
  21957. * @returns a string with material information
  21958. */
  21959. toString(fullDetails?: boolean): string;
  21960. /**
  21961. * Gets the class name of the material
  21962. * @returns a string with the class name of the material
  21963. */
  21964. getClassName(): string;
  21965. /**
  21966. * Specifies if updates for the material been locked
  21967. */
  21968. get isFrozen(): boolean;
  21969. /**
  21970. * Locks updates for the material
  21971. */
  21972. freeze(): void;
  21973. /**
  21974. * Unlocks updates for the material
  21975. */
  21976. unfreeze(): void;
  21977. /**
  21978. * Specifies if the material is ready to be used
  21979. * @param mesh defines the mesh to check
  21980. * @param useInstances specifies if instances should be used
  21981. * @returns a boolean indicating if the material is ready to be used
  21982. */
  21983. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21984. /**
  21985. * Specifies that the submesh is ready to be used
  21986. * @param mesh defines the mesh to check
  21987. * @param subMesh defines which submesh to check
  21988. * @param useInstances specifies that instances should be used
  21989. * @returns a boolean indicating that the submesh is ready or not
  21990. */
  21991. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21992. /**
  21993. * Returns the material effect
  21994. * @returns the effect associated with the material
  21995. */
  21996. getEffect(): Nullable<Effect>;
  21997. /**
  21998. * Returns the current scene
  21999. * @returns a Scene
  22000. */
  22001. getScene(): Scene;
  22002. /**
  22003. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  22004. */
  22005. protected _forceAlphaTest: boolean;
  22006. /**
  22007. * The transparency mode of the material.
  22008. */
  22009. protected _transparencyMode: Nullable<number>;
  22010. /**
  22011. * Gets the current transparency mode.
  22012. */
  22013. get transparencyMode(): Nullable<number>;
  22014. /**
  22015. * Sets the transparency mode of the material.
  22016. *
  22017. * | Value | Type | Description |
  22018. * | ----- | ----------------------------------- | ----------- |
  22019. * | 0 | OPAQUE | |
  22020. * | 1 | ALPHATEST | |
  22021. * | 2 | ALPHABLEND | |
  22022. * | 3 | ALPHATESTANDBLEND | |
  22023. *
  22024. */
  22025. set transparencyMode(value: Nullable<number>);
  22026. /**
  22027. * Returns true if alpha blending should be disabled.
  22028. */
  22029. protected get _disableAlphaBlending(): boolean;
  22030. /**
  22031. * Specifies whether or not this material should be rendered in alpha blend mode.
  22032. * @returns a boolean specifying if alpha blending is needed
  22033. */
  22034. needAlphaBlending(): boolean;
  22035. /**
  22036. * Specifies if the mesh will require alpha blending
  22037. * @param mesh defines the mesh to check
  22038. * @returns a boolean specifying if alpha blending is needed for the mesh
  22039. */
  22040. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  22041. /**
  22042. * Specifies whether or not this material should be rendered in alpha test mode.
  22043. * @returns a boolean specifying if an alpha test is needed.
  22044. */
  22045. needAlphaTesting(): boolean;
  22046. /**
  22047. * Specifies if material alpha testing should be turned on for the mesh
  22048. * @param mesh defines the mesh to check
  22049. */
  22050. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  22051. /**
  22052. * Gets the texture used for the alpha test
  22053. * @returns the texture to use for alpha testing
  22054. */
  22055. getAlphaTestTexture(): Nullable<BaseTexture>;
  22056. /**
  22057. * Marks the material to indicate that it needs to be re-calculated
  22058. */
  22059. markDirty(): void;
  22060. /** @hidden */
  22061. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  22062. /**
  22063. * Binds the material to the mesh
  22064. * @param world defines the world transformation matrix
  22065. * @param mesh defines the mesh to bind the material to
  22066. */
  22067. bind(world: Matrix, mesh?: Mesh): void;
  22068. /**
  22069. * Binds the submesh to the material
  22070. * @param world defines the world transformation matrix
  22071. * @param mesh defines the mesh containing the submesh
  22072. * @param subMesh defines the submesh to bind the material to
  22073. */
  22074. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  22075. /**
  22076. * Binds the world matrix to the material
  22077. * @param world defines the world transformation matrix
  22078. */
  22079. bindOnlyWorldMatrix(world: Matrix): void;
  22080. /**
  22081. * Binds the scene's uniform buffer to the effect.
  22082. * @param effect defines the effect to bind to the scene uniform buffer
  22083. * @param sceneUbo defines the uniform buffer storing scene data
  22084. */
  22085. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  22086. /**
  22087. * Binds the view matrix to the effect
  22088. * @param effect defines the effect to bind the view matrix to
  22089. */
  22090. bindView(effect: Effect): void;
  22091. /**
  22092. * Binds the view projection matrix to the effect
  22093. * @param effect defines the effect to bind the view projection matrix to
  22094. */
  22095. bindViewProjection(effect: Effect): void;
  22096. /**
  22097. * Processes to execute after binding the material to a mesh
  22098. * @param mesh defines the rendered mesh
  22099. */
  22100. protected _afterBind(mesh?: Mesh): void;
  22101. /**
  22102. * Unbinds the material from the mesh
  22103. */
  22104. unbind(): void;
  22105. /**
  22106. * Gets the active textures from the material
  22107. * @returns an array of textures
  22108. */
  22109. getActiveTextures(): BaseTexture[];
  22110. /**
  22111. * Specifies if the material uses a texture
  22112. * @param texture defines the texture to check against the material
  22113. * @returns a boolean specifying if the material uses the texture
  22114. */
  22115. hasTexture(texture: BaseTexture): boolean;
  22116. /**
  22117. * Makes a duplicate of the material, and gives it a new name
  22118. * @param name defines the new name for the duplicated material
  22119. * @returns the cloned material
  22120. */
  22121. clone(name: string): Nullable<Material>;
  22122. /**
  22123. * Gets the meshes bound to the material
  22124. * @returns an array of meshes bound to the material
  22125. */
  22126. getBindedMeshes(): AbstractMesh[];
  22127. /**
  22128. * Force shader compilation
  22129. * @param mesh defines the mesh associated with this material
  22130. * @param onCompiled defines a function to execute once the material is compiled
  22131. * @param options defines the options to configure the compilation
  22132. * @param onError defines a function to execute if the material fails compiling
  22133. */
  22134. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  22135. /**
  22136. * Force shader compilation
  22137. * @param mesh defines the mesh that will use this material
  22138. * @param options defines additional options for compiling the shaders
  22139. * @returns a promise that resolves when the compilation completes
  22140. */
  22141. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  22142. private static readonly _AllDirtyCallBack;
  22143. private static readonly _ImageProcessingDirtyCallBack;
  22144. private static readonly _TextureDirtyCallBack;
  22145. private static readonly _FresnelDirtyCallBack;
  22146. private static readonly _MiscDirtyCallBack;
  22147. private static readonly _LightsDirtyCallBack;
  22148. private static readonly _AttributeDirtyCallBack;
  22149. private static _FresnelAndMiscDirtyCallBack;
  22150. private static _TextureAndMiscDirtyCallBack;
  22151. private static readonly _DirtyCallbackArray;
  22152. private static readonly _RunDirtyCallBacks;
  22153. /**
  22154. * Marks a define in the material to indicate that it needs to be re-computed
  22155. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  22156. */
  22157. markAsDirty(flag: number): void;
  22158. /**
  22159. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  22160. * @param func defines a function which checks material defines against the submeshes
  22161. */
  22162. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  22163. /**
  22164. * Indicates that we need to re-calculated for all submeshes
  22165. */
  22166. protected _markAllSubMeshesAsAllDirty(): void;
  22167. /**
  22168. * Indicates that image processing needs to be re-calculated for all submeshes
  22169. */
  22170. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  22171. /**
  22172. * Indicates that textures need to be re-calculated for all submeshes
  22173. */
  22174. protected _markAllSubMeshesAsTexturesDirty(): void;
  22175. /**
  22176. * Indicates that fresnel needs to be re-calculated for all submeshes
  22177. */
  22178. protected _markAllSubMeshesAsFresnelDirty(): void;
  22179. /**
  22180. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  22181. */
  22182. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  22183. /**
  22184. * Indicates that lights need to be re-calculated for all submeshes
  22185. */
  22186. protected _markAllSubMeshesAsLightsDirty(): void;
  22187. /**
  22188. * Indicates that attributes need to be re-calculated for all submeshes
  22189. */
  22190. protected _markAllSubMeshesAsAttributesDirty(): void;
  22191. /**
  22192. * Indicates that misc needs to be re-calculated for all submeshes
  22193. */
  22194. protected _markAllSubMeshesAsMiscDirty(): void;
  22195. /**
  22196. * Indicates that textures and misc need to be re-calculated for all submeshes
  22197. */
  22198. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  22199. /**
  22200. * Disposes the material
  22201. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  22202. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  22203. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  22204. */
  22205. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  22206. /** @hidden */
  22207. private releaseVertexArrayObject;
  22208. /**
  22209. * Serializes this material
  22210. * @returns the serialized material object
  22211. */
  22212. serialize(): any;
  22213. /**
  22214. * Creates a material from parsed material data
  22215. * @param parsedMaterial defines parsed material data
  22216. * @param scene defines the hosting scene
  22217. * @param rootUrl defines the root URL to use to load textures
  22218. * @returns a new material
  22219. */
  22220. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  22221. }
  22222. }
  22223. declare module "babylonjs/Materials/multiMaterial" {
  22224. import { Nullable } from "babylonjs/types";
  22225. import { Scene } from "babylonjs/scene";
  22226. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22227. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  22228. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  22229. import { Material } from "babylonjs/Materials/material";
  22230. /**
  22231. * A multi-material is used to apply different materials to different parts of the same object without the need of
  22232. * separate meshes. This can be use to improve performances.
  22233. * @see http://doc.babylonjs.com/how_to/multi_materials
  22234. */
  22235. export class MultiMaterial extends Material {
  22236. private _subMaterials;
  22237. /**
  22238. * Gets or Sets the list of Materials used within the multi material.
  22239. * They need to be ordered according to the submeshes order in the associated mesh
  22240. */
  22241. get subMaterials(): Nullable<Material>[];
  22242. set subMaterials(value: Nullable<Material>[]);
  22243. /**
  22244. * Function used to align with Node.getChildren()
  22245. * @returns the list of Materials used within the multi material
  22246. */
  22247. getChildren(): Nullable<Material>[];
  22248. /**
  22249. * Instantiates a new Multi Material
  22250. * A multi-material is used to apply different materials to different parts of the same object without the need of
  22251. * separate meshes. This can be use to improve performances.
  22252. * @see http://doc.babylonjs.com/how_to/multi_materials
  22253. * @param name Define the name in the scene
  22254. * @param scene Define the scene the material belongs to
  22255. */
  22256. constructor(name: string, scene: Scene);
  22257. private _hookArray;
  22258. /**
  22259. * Get one of the submaterial by its index in the submaterials array
  22260. * @param index The index to look the sub material at
  22261. * @returns The Material if the index has been defined
  22262. */
  22263. getSubMaterial(index: number): Nullable<Material>;
  22264. /**
  22265. * Get the list of active textures for the whole sub materials list.
  22266. * @returns All the textures that will be used during the rendering
  22267. */
  22268. getActiveTextures(): BaseTexture[];
  22269. /**
  22270. * Gets the current class name of the material e.g. "MultiMaterial"
  22271. * Mainly use in serialization.
  22272. * @returns the class name
  22273. */
  22274. getClassName(): string;
  22275. /**
  22276. * Checks if the material is ready to render the requested sub mesh
  22277. * @param mesh Define the mesh the submesh belongs to
  22278. * @param subMesh Define the sub mesh to look readyness for
  22279. * @param useInstances Define whether or not the material is used with instances
  22280. * @returns true if ready, otherwise false
  22281. */
  22282. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  22283. /**
  22284. * Clones the current material and its related sub materials
  22285. * @param name Define the name of the newly cloned material
  22286. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  22287. * @returns the cloned material
  22288. */
  22289. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  22290. /**
  22291. * Serializes the materials into a JSON representation.
  22292. * @returns the JSON representation
  22293. */
  22294. serialize(): any;
  22295. /**
  22296. * Dispose the material and release its associated resources
  22297. * @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)
  22298. * @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)
  22299. * @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)
  22300. */
  22301. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  22302. /**
  22303. * Creates a MultiMaterial from parsed MultiMaterial data.
  22304. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  22305. * @param scene defines the hosting scene
  22306. * @returns a new MultiMaterial
  22307. */
  22308. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  22309. }
  22310. }
  22311. declare module "babylonjs/Meshes/subMesh" {
  22312. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  22313. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  22314. import { Engine } from "babylonjs/Engines/engine";
  22315. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  22316. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  22317. import { Effect } from "babylonjs/Materials/effect";
  22318. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  22319. import { Plane } from "babylonjs/Maths/math.plane";
  22320. import { Collider } from "babylonjs/Collisions/collider";
  22321. import { Material } from "babylonjs/Materials/material";
  22322. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  22323. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22324. import { Mesh } from "babylonjs/Meshes/mesh";
  22325. import { Ray } from "babylonjs/Culling/ray";
  22326. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  22327. /**
  22328. * Base class for submeshes
  22329. */
  22330. export class BaseSubMesh {
  22331. /** @hidden */
  22332. _materialDefines: Nullable<MaterialDefines>;
  22333. /** @hidden */
  22334. _materialEffect: Nullable<Effect>;
  22335. /**
  22336. * Gets material defines used by the effect associated to the sub mesh
  22337. */
  22338. get materialDefines(): Nullable<MaterialDefines>;
  22339. /**
  22340. * Sets material defines used by the effect associated to the sub mesh
  22341. */
  22342. set materialDefines(defines: Nullable<MaterialDefines>);
  22343. /**
  22344. * Gets associated effect
  22345. */
  22346. get effect(): Nullable<Effect>;
  22347. /**
  22348. * Sets associated effect (effect used to render this submesh)
  22349. * @param effect defines the effect to associate with
  22350. * @param defines defines the set of defines used to compile this effect
  22351. */
  22352. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  22353. }
  22354. /**
  22355. * Defines a subdivision inside a mesh
  22356. */
  22357. export class SubMesh extends BaseSubMesh implements ICullable {
  22358. /** the material index to use */
  22359. materialIndex: number;
  22360. /** vertex index start */
  22361. verticesStart: number;
  22362. /** vertices count */
  22363. verticesCount: number;
  22364. /** index start */
  22365. indexStart: number;
  22366. /** indices count */
  22367. indexCount: number;
  22368. /** @hidden */
  22369. _linesIndexCount: number;
  22370. private _mesh;
  22371. private _renderingMesh;
  22372. private _boundingInfo;
  22373. private _linesIndexBuffer;
  22374. /** @hidden */
  22375. _lastColliderWorldVertices: Nullable<Vector3[]>;
  22376. /** @hidden */
  22377. _trianglePlanes: Plane[];
  22378. /** @hidden */
  22379. _lastColliderTransformMatrix: Nullable<Matrix>;
  22380. /** @hidden */
  22381. _renderId: number;
  22382. /** @hidden */
  22383. _alphaIndex: number;
  22384. /** @hidden */
  22385. _distanceToCamera: number;
  22386. /** @hidden */
  22387. _id: number;
  22388. private _currentMaterial;
  22389. /**
  22390. * Add a new submesh to a mesh
  22391. * @param materialIndex defines the material index to use
  22392. * @param verticesStart defines vertex index start
  22393. * @param verticesCount defines vertices count
  22394. * @param indexStart defines index start
  22395. * @param indexCount defines indices count
  22396. * @param mesh defines the parent mesh
  22397. * @param renderingMesh defines an optional rendering mesh
  22398. * @param createBoundingBox defines if bounding box should be created for this submesh
  22399. * @returns the new submesh
  22400. */
  22401. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  22402. /**
  22403. * Creates a new submesh
  22404. * @param materialIndex defines the material index to use
  22405. * @param verticesStart defines vertex index start
  22406. * @param verticesCount defines vertices count
  22407. * @param indexStart defines index start
  22408. * @param indexCount defines indices count
  22409. * @param mesh defines the parent mesh
  22410. * @param renderingMesh defines an optional rendering mesh
  22411. * @param createBoundingBox defines if bounding box should be created for this submesh
  22412. */
  22413. constructor(
  22414. /** the material index to use */
  22415. materialIndex: number,
  22416. /** vertex index start */
  22417. verticesStart: number,
  22418. /** vertices count */
  22419. verticesCount: number,
  22420. /** index start */
  22421. indexStart: number,
  22422. /** indices count */
  22423. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  22424. /**
  22425. * Returns true if this submesh covers the entire parent mesh
  22426. * @ignorenaming
  22427. */
  22428. get IsGlobal(): boolean;
  22429. /**
  22430. * Returns the submesh BoudingInfo object
  22431. * @returns current bounding info (or mesh's one if the submesh is global)
  22432. */
  22433. getBoundingInfo(): BoundingInfo;
  22434. /**
  22435. * Sets the submesh BoundingInfo
  22436. * @param boundingInfo defines the new bounding info to use
  22437. * @returns the SubMesh
  22438. */
  22439. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  22440. /**
  22441. * Returns the mesh of the current submesh
  22442. * @return the parent mesh
  22443. */
  22444. getMesh(): AbstractMesh;
  22445. /**
  22446. * Returns the rendering mesh of the submesh
  22447. * @returns the rendering mesh (could be different from parent mesh)
  22448. */
  22449. getRenderingMesh(): Mesh;
  22450. /**
  22451. * Returns the submesh material
  22452. * @returns null or the current material
  22453. */
  22454. getMaterial(): Nullable<Material>;
  22455. /**
  22456. * Sets a new updated BoundingInfo object to the submesh
  22457. * @param data defines an optional position array to use to determine the bounding info
  22458. * @returns the SubMesh
  22459. */
  22460. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  22461. /** @hidden */
  22462. _checkCollision(collider: Collider): boolean;
  22463. /**
  22464. * Updates the submesh BoundingInfo
  22465. * @param world defines the world matrix to use to update the bounding info
  22466. * @returns the submesh
  22467. */
  22468. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  22469. /**
  22470. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  22471. * @param frustumPlanes defines the frustum planes
  22472. * @returns true if the submesh is intersecting with the frustum
  22473. */
  22474. isInFrustum(frustumPlanes: Plane[]): boolean;
  22475. /**
  22476. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  22477. * @param frustumPlanes defines the frustum planes
  22478. * @returns true if the submesh is inside the frustum
  22479. */
  22480. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  22481. /**
  22482. * Renders the submesh
  22483. * @param enableAlphaMode defines if alpha needs to be used
  22484. * @returns the submesh
  22485. */
  22486. render(enableAlphaMode: boolean): SubMesh;
  22487. /**
  22488. * @hidden
  22489. */
  22490. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  22491. /**
  22492. * Checks if the submesh intersects with a ray
  22493. * @param ray defines the ray to test
  22494. * @returns true is the passed ray intersects the submesh bounding box
  22495. */
  22496. canIntersects(ray: Ray): boolean;
  22497. /**
  22498. * Intersects current submesh with a ray
  22499. * @param ray defines the ray to test
  22500. * @param positions defines mesh's positions array
  22501. * @param indices defines mesh's indices array
  22502. * @param fastCheck defines if only bounding info should be used
  22503. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  22504. * @returns intersection info or null if no intersection
  22505. */
  22506. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  22507. /** @hidden */
  22508. private _intersectLines;
  22509. /** @hidden */
  22510. private _intersectUnIndexedLines;
  22511. /** @hidden */
  22512. private _intersectTriangles;
  22513. /** @hidden */
  22514. private _intersectUnIndexedTriangles;
  22515. /** @hidden */
  22516. _rebuild(): void;
  22517. /**
  22518. * Creates a new submesh from the passed mesh
  22519. * @param newMesh defines the new hosting mesh
  22520. * @param newRenderingMesh defines an optional rendering mesh
  22521. * @returns the new submesh
  22522. */
  22523. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  22524. /**
  22525. * Release associated resources
  22526. */
  22527. dispose(): void;
  22528. /**
  22529. * Gets the class name
  22530. * @returns the string "SubMesh".
  22531. */
  22532. getClassName(): string;
  22533. /**
  22534. * Creates a new submesh from indices data
  22535. * @param materialIndex the index of the main mesh material
  22536. * @param startIndex the index where to start the copy in the mesh indices array
  22537. * @param indexCount the number of indices to copy then from the startIndex
  22538. * @param mesh the main mesh to create the submesh from
  22539. * @param renderingMesh the optional rendering mesh
  22540. * @returns a new submesh
  22541. */
  22542. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  22543. }
  22544. }
  22545. declare module "babylonjs/Loading/sceneLoaderFlags" {
  22546. /**
  22547. * Class used to represent data loading progression
  22548. */
  22549. export class SceneLoaderFlags {
  22550. private static _ForceFullSceneLoadingForIncremental;
  22551. private static _ShowLoadingScreen;
  22552. private static _CleanBoneMatrixWeights;
  22553. private static _loggingLevel;
  22554. /**
  22555. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  22556. */
  22557. static get ForceFullSceneLoadingForIncremental(): boolean;
  22558. static set ForceFullSceneLoadingForIncremental(value: boolean);
  22559. /**
  22560. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  22561. */
  22562. static get ShowLoadingScreen(): boolean;
  22563. static set ShowLoadingScreen(value: boolean);
  22564. /**
  22565. * Defines the current logging level (while loading the scene)
  22566. * @ignorenaming
  22567. */
  22568. static get loggingLevel(): number;
  22569. static set loggingLevel(value: number);
  22570. /**
  22571. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  22572. */
  22573. static get CleanBoneMatrixWeights(): boolean;
  22574. static set CleanBoneMatrixWeights(value: boolean);
  22575. }
  22576. }
  22577. declare module "babylonjs/Meshes/geometry" {
  22578. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  22579. import { Scene } from "babylonjs/scene";
  22580. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  22581. import { Engine } from "babylonjs/Engines/engine";
  22582. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  22583. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  22584. import { Effect } from "babylonjs/Materials/effect";
  22585. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  22586. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  22587. import { Mesh } from "babylonjs/Meshes/mesh";
  22588. /**
  22589. * Class used to store geometry data (vertex buffers + index buffer)
  22590. */
  22591. export class Geometry implements IGetSetVerticesData {
  22592. /**
  22593. * Gets or sets the ID of the geometry
  22594. */
  22595. id: string;
  22596. /**
  22597. * Gets or sets the unique ID of the geometry
  22598. */
  22599. uniqueId: number;
  22600. /**
  22601. * Gets the delay loading state of the geometry (none by default which means not delayed)
  22602. */
  22603. delayLoadState: number;
  22604. /**
  22605. * Gets the file containing the data to load when running in delay load state
  22606. */
  22607. delayLoadingFile: Nullable<string>;
  22608. /**
  22609. * Callback called when the geometry is updated
  22610. */
  22611. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  22612. private _scene;
  22613. private _engine;
  22614. private _meshes;
  22615. private _totalVertices;
  22616. /** @hidden */
  22617. _indices: IndicesArray;
  22618. /** @hidden */
  22619. _vertexBuffers: {
  22620. [key: string]: VertexBuffer;
  22621. };
  22622. private _isDisposed;
  22623. private _extend;
  22624. private _boundingBias;
  22625. /** @hidden */
  22626. _delayInfo: Array<string>;
  22627. private _indexBuffer;
  22628. private _indexBufferIsUpdatable;
  22629. /** @hidden */
  22630. _boundingInfo: Nullable<BoundingInfo>;
  22631. /** @hidden */
  22632. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  22633. /** @hidden */
  22634. _softwareSkinningFrameId: number;
  22635. private _vertexArrayObjects;
  22636. private _updatable;
  22637. /** @hidden */
  22638. _positions: Nullable<Vector3[]>;
  22639. /**
  22640. * 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
  22641. */
  22642. get boundingBias(): Vector2;
  22643. /**
  22644. * 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
  22645. */
  22646. set boundingBias(value: Vector2);
  22647. /**
  22648. * Static function used to attach a new empty geometry to a mesh
  22649. * @param mesh defines the mesh to attach the geometry to
  22650. * @returns the new Geometry
  22651. */
  22652. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  22653. /**
  22654. * Creates a new geometry
  22655. * @param id defines the unique ID
  22656. * @param scene defines the hosting scene
  22657. * @param vertexData defines the VertexData used to get geometry data
  22658. * @param updatable defines if geometry must be updatable (false by default)
  22659. * @param mesh defines the mesh that will be associated with the geometry
  22660. */
  22661. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  22662. /**
  22663. * Gets the current extend of the geometry
  22664. */
  22665. get extend(): {
  22666. minimum: Vector3;
  22667. maximum: Vector3;
  22668. };
  22669. /**
  22670. * Gets the hosting scene
  22671. * @returns the hosting Scene
  22672. */
  22673. getScene(): Scene;
  22674. /**
  22675. * Gets the hosting engine
  22676. * @returns the hosting Engine
  22677. */
  22678. getEngine(): Engine;
  22679. /**
  22680. * Defines if the geometry is ready to use
  22681. * @returns true if the geometry is ready to be used
  22682. */
  22683. isReady(): boolean;
  22684. /**
  22685. * Gets a value indicating that the geometry should not be serialized
  22686. */
  22687. get doNotSerialize(): boolean;
  22688. /** @hidden */
  22689. _rebuild(): void;
  22690. /**
  22691. * Affects all geometry data in one call
  22692. * @param vertexData defines the geometry data
  22693. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  22694. */
  22695. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  22696. /**
  22697. * Set specific vertex data
  22698. * @param kind defines the data kind (Position, normal, etc...)
  22699. * @param data defines the vertex data to use
  22700. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22701. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22702. */
  22703. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  22704. /**
  22705. * Removes a specific vertex data
  22706. * @param kind defines the data kind (Position, normal, etc...)
  22707. */
  22708. removeVerticesData(kind: string): void;
  22709. /**
  22710. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  22711. * @param buffer defines the vertex buffer to use
  22712. * @param totalVertices defines the total number of vertices for position kind (could be null)
  22713. */
  22714. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  22715. /**
  22716. * Update a specific vertex buffer
  22717. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  22718. * It will do nothing if the buffer is not updatable
  22719. * @param kind defines the data kind (Position, normal, etc...)
  22720. * @param data defines the data to use
  22721. * @param offset defines the offset in the target buffer where to store the data
  22722. * @param useBytes set to true if the offset is in bytes
  22723. */
  22724. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  22725. /**
  22726. * Update a specific vertex buffer
  22727. * This function will create a new buffer if the current one is not updatable
  22728. * @param kind defines the data kind (Position, normal, etc...)
  22729. * @param data defines the data to use
  22730. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  22731. */
  22732. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  22733. private _updateBoundingInfo;
  22734. /** @hidden */
  22735. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  22736. /**
  22737. * Gets total number of vertices
  22738. * @returns the total number of vertices
  22739. */
  22740. getTotalVertices(): number;
  22741. /**
  22742. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22743. * @param kind defines the data kind (Position, normal, etc...)
  22744. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22745. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22746. * @returns a float array containing vertex data
  22747. */
  22748. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22749. /**
  22750. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  22751. * @param kind defines the data kind (Position, normal, etc...)
  22752. * @returns true if the vertex buffer with the specified kind is updatable
  22753. */
  22754. isVertexBufferUpdatable(kind: string): boolean;
  22755. /**
  22756. * Gets a specific vertex buffer
  22757. * @param kind defines the data kind (Position, normal, etc...)
  22758. * @returns a VertexBuffer
  22759. */
  22760. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  22761. /**
  22762. * Returns all vertex buffers
  22763. * @return an object holding all vertex buffers indexed by kind
  22764. */
  22765. getVertexBuffers(): Nullable<{
  22766. [key: string]: VertexBuffer;
  22767. }>;
  22768. /**
  22769. * Gets a boolean indicating if specific vertex buffer is present
  22770. * @param kind defines the data kind (Position, normal, etc...)
  22771. * @returns true if data is present
  22772. */
  22773. isVerticesDataPresent(kind: string): boolean;
  22774. /**
  22775. * Gets a list of all attached data kinds (Position, normal, etc...)
  22776. * @returns a list of string containing all kinds
  22777. */
  22778. getVerticesDataKinds(): string[];
  22779. /**
  22780. * Update index buffer
  22781. * @param indices defines the indices to store in the index buffer
  22782. * @param offset defines the offset in the target buffer where to store the data
  22783. * @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)
  22784. */
  22785. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  22786. /**
  22787. * Creates a new index buffer
  22788. * @param indices defines the indices to store in the index buffer
  22789. * @param totalVertices defines the total number of vertices (could be null)
  22790. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22791. */
  22792. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  22793. /**
  22794. * Return the total number of indices
  22795. * @returns the total number of indices
  22796. */
  22797. getTotalIndices(): number;
  22798. /**
  22799. * Gets the index buffer array
  22800. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22801. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22802. * @returns the index buffer array
  22803. */
  22804. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22805. /**
  22806. * Gets the index buffer
  22807. * @return the index buffer
  22808. */
  22809. getIndexBuffer(): Nullable<DataBuffer>;
  22810. /** @hidden */
  22811. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  22812. /**
  22813. * Release the associated resources for a specific mesh
  22814. * @param mesh defines the source mesh
  22815. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  22816. */
  22817. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  22818. /**
  22819. * Apply current geometry to a given mesh
  22820. * @param mesh defines the mesh to apply geometry to
  22821. */
  22822. applyToMesh(mesh: Mesh): void;
  22823. private _updateExtend;
  22824. private _applyToMesh;
  22825. private notifyUpdate;
  22826. /**
  22827. * Load the geometry if it was flagged as delay loaded
  22828. * @param scene defines the hosting scene
  22829. * @param onLoaded defines a callback called when the geometry is loaded
  22830. */
  22831. load(scene: Scene, onLoaded?: () => void): void;
  22832. private _queueLoad;
  22833. /**
  22834. * Invert the geometry to move from a right handed system to a left handed one.
  22835. */
  22836. toLeftHanded(): void;
  22837. /** @hidden */
  22838. _resetPointsArrayCache(): void;
  22839. /** @hidden */
  22840. _generatePointsArray(): boolean;
  22841. /**
  22842. * Gets a value indicating if the geometry is disposed
  22843. * @returns true if the geometry was disposed
  22844. */
  22845. isDisposed(): boolean;
  22846. private _disposeVertexArrayObjects;
  22847. /**
  22848. * Free all associated resources
  22849. */
  22850. dispose(): void;
  22851. /**
  22852. * Clone the current geometry into a new geometry
  22853. * @param id defines the unique ID of the new geometry
  22854. * @returns a new geometry object
  22855. */
  22856. copy(id: string): Geometry;
  22857. /**
  22858. * Serialize the current geometry info (and not the vertices data) into a JSON object
  22859. * @return a JSON representation of the current geometry data (without the vertices data)
  22860. */
  22861. serialize(): any;
  22862. private toNumberArray;
  22863. /**
  22864. * Serialize all vertices data into a JSON oject
  22865. * @returns a JSON representation of the current geometry data
  22866. */
  22867. serializeVerticeData(): any;
  22868. /**
  22869. * Extracts a clone of a mesh geometry
  22870. * @param mesh defines the source mesh
  22871. * @param id defines the unique ID of the new geometry object
  22872. * @returns the new geometry object
  22873. */
  22874. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  22875. /**
  22876. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  22877. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  22878. * Be aware Math.random() could cause collisions, but:
  22879. * "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"
  22880. * @returns a string containing a new GUID
  22881. */
  22882. static RandomId(): string;
  22883. /** @hidden */
  22884. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  22885. private static _CleanMatricesWeights;
  22886. /**
  22887. * Create a new geometry from persisted data (Using .babylon file format)
  22888. * @param parsedVertexData defines the persisted data
  22889. * @param scene defines the hosting scene
  22890. * @param rootUrl defines the root url to use to load assets (like delayed data)
  22891. * @returns the new geometry object
  22892. */
  22893. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  22894. }
  22895. }
  22896. declare module "babylonjs/Meshes/mesh.vertexData" {
  22897. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  22898. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  22899. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  22900. import { Geometry } from "babylonjs/Meshes/geometry";
  22901. import { Mesh } from "babylonjs/Meshes/mesh";
  22902. /**
  22903. * Define an interface for all classes that will get and set the data on vertices
  22904. */
  22905. export interface IGetSetVerticesData {
  22906. /**
  22907. * Gets a boolean indicating if specific vertex data is present
  22908. * @param kind defines the vertex data kind to use
  22909. * @returns true is data kind is present
  22910. */
  22911. isVerticesDataPresent(kind: string): boolean;
  22912. /**
  22913. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22914. * @param kind defines the data kind (Position, normal, etc...)
  22915. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22916. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22917. * @returns a float array containing vertex data
  22918. */
  22919. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22920. /**
  22921. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  22922. * @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.
  22923. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22924. * @returns the indices array or an empty array if the mesh has no geometry
  22925. */
  22926. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22927. /**
  22928. * Set specific vertex data
  22929. * @param kind defines the data kind (Position, normal, etc...)
  22930. * @param data defines the vertex data to use
  22931. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22932. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22933. */
  22934. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  22935. /**
  22936. * Update a specific associated vertex buffer
  22937. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  22938. * - VertexBuffer.PositionKind
  22939. * - VertexBuffer.UVKind
  22940. * - VertexBuffer.UV2Kind
  22941. * - VertexBuffer.UV3Kind
  22942. * - VertexBuffer.UV4Kind
  22943. * - VertexBuffer.UV5Kind
  22944. * - VertexBuffer.UV6Kind
  22945. * - VertexBuffer.ColorKind
  22946. * - VertexBuffer.MatricesIndicesKind
  22947. * - VertexBuffer.MatricesIndicesExtraKind
  22948. * - VertexBuffer.MatricesWeightsKind
  22949. * - VertexBuffer.MatricesWeightsExtraKind
  22950. * @param data defines the data source
  22951. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  22952. * @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)
  22953. */
  22954. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  22955. /**
  22956. * Creates a new index buffer
  22957. * @param indices defines the indices to store in the index buffer
  22958. * @param totalVertices defines the total number of vertices (could be null)
  22959. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22960. */
  22961. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  22962. }
  22963. /**
  22964. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  22965. */
  22966. export class VertexData {
  22967. /**
  22968. * Mesh side orientation : usually the external or front surface
  22969. */
  22970. static readonly FRONTSIDE: number;
  22971. /**
  22972. * Mesh side orientation : usually the internal or back surface
  22973. */
  22974. static readonly BACKSIDE: number;
  22975. /**
  22976. * Mesh side orientation : both internal and external or front and back surfaces
  22977. */
  22978. static readonly DOUBLESIDE: number;
  22979. /**
  22980. * Mesh side orientation : by default, `FRONTSIDE`
  22981. */
  22982. static readonly DEFAULTSIDE: number;
  22983. /**
  22984. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  22985. */
  22986. positions: Nullable<FloatArray>;
  22987. /**
  22988. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  22989. */
  22990. normals: Nullable<FloatArray>;
  22991. /**
  22992. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  22993. */
  22994. tangents: Nullable<FloatArray>;
  22995. /**
  22996. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22997. */
  22998. uvs: Nullable<FloatArray>;
  22999. /**
  23000. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23001. */
  23002. uvs2: Nullable<FloatArray>;
  23003. /**
  23004. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23005. */
  23006. uvs3: Nullable<FloatArray>;
  23007. /**
  23008. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23009. */
  23010. uvs4: Nullable<FloatArray>;
  23011. /**
  23012. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23013. */
  23014. uvs5: Nullable<FloatArray>;
  23015. /**
  23016. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23017. */
  23018. uvs6: Nullable<FloatArray>;
  23019. /**
  23020. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  23021. */
  23022. colors: Nullable<FloatArray>;
  23023. /**
  23024. * 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).
  23025. */
  23026. matricesIndices: Nullable<FloatArray>;
  23027. /**
  23028. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  23029. */
  23030. matricesWeights: Nullable<FloatArray>;
  23031. /**
  23032. * An array extending the number of possible indices
  23033. */
  23034. matricesIndicesExtra: Nullable<FloatArray>;
  23035. /**
  23036. * An array extending the number of possible weights when the number of indices is extended
  23037. */
  23038. matricesWeightsExtra: Nullable<FloatArray>;
  23039. /**
  23040. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  23041. */
  23042. indices: Nullable<IndicesArray>;
  23043. /**
  23044. * Uses the passed data array to set the set the values for the specified kind of data
  23045. * @param data a linear array of floating numbers
  23046. * @param kind the type of data that is being set, eg positions, colors etc
  23047. */
  23048. set(data: FloatArray, kind: string): void;
  23049. /**
  23050. * Associates the vertexData to the passed Mesh.
  23051. * Sets it as updatable or not (default `false`)
  23052. * @param mesh the mesh the vertexData is applied to
  23053. * @param updatable when used and having the value true allows new data to update the vertexData
  23054. * @returns the VertexData
  23055. */
  23056. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  23057. /**
  23058. * Associates the vertexData to the passed Geometry.
  23059. * Sets it as updatable or not (default `false`)
  23060. * @param geometry the geometry the vertexData is applied to
  23061. * @param updatable when used and having the value true allows new data to update the vertexData
  23062. * @returns VertexData
  23063. */
  23064. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  23065. /**
  23066. * Updates the associated mesh
  23067. * @param mesh the mesh to be updated
  23068. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  23069. * @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
  23070. * @returns VertexData
  23071. */
  23072. updateMesh(mesh: Mesh): VertexData;
  23073. /**
  23074. * Updates the associated geometry
  23075. * @param geometry the geometry to be updated
  23076. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  23077. * @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
  23078. * @returns VertexData.
  23079. */
  23080. updateGeometry(geometry: Geometry): VertexData;
  23081. private _applyTo;
  23082. private _update;
  23083. /**
  23084. * Transforms each position and each normal of the vertexData according to the passed Matrix
  23085. * @param matrix the transforming matrix
  23086. * @returns the VertexData
  23087. */
  23088. transform(matrix: Matrix): VertexData;
  23089. /**
  23090. * Merges the passed VertexData into the current one
  23091. * @param other the VertexData to be merged into the current one
  23092. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  23093. * @returns the modified VertexData
  23094. */
  23095. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  23096. private _mergeElement;
  23097. private _validate;
  23098. /**
  23099. * Serializes the VertexData
  23100. * @returns a serialized object
  23101. */
  23102. serialize(): any;
  23103. /**
  23104. * Extracts the vertexData from a mesh
  23105. * @param mesh the mesh from which to extract the VertexData
  23106. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  23107. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  23108. * @returns the object VertexData associated to the passed mesh
  23109. */
  23110. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  23111. /**
  23112. * Extracts the vertexData from the geometry
  23113. * @param geometry the geometry from which to extract the VertexData
  23114. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  23115. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  23116. * @returns the object VertexData associated to the passed mesh
  23117. */
  23118. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  23119. private static _ExtractFrom;
  23120. /**
  23121. * Creates the VertexData for a Ribbon
  23122. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  23123. * * pathArray array of paths, each of which an array of successive Vector3
  23124. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  23125. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  23126. * * 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
  23127. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23128. * * 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)
  23129. * * 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)
  23130. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  23131. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  23132. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  23133. * @returns the VertexData of the ribbon
  23134. */
  23135. static CreateRibbon(options: {
  23136. pathArray: Vector3[][];
  23137. closeArray?: boolean;
  23138. closePath?: boolean;
  23139. offset?: number;
  23140. sideOrientation?: number;
  23141. frontUVs?: Vector4;
  23142. backUVs?: Vector4;
  23143. invertUV?: boolean;
  23144. uvs?: Vector2[];
  23145. colors?: Color4[];
  23146. }): VertexData;
  23147. /**
  23148. * Creates the VertexData for a box
  23149. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23150. * * size sets the width, height and depth of the box to the value of size, optional default 1
  23151. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  23152. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  23153. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  23154. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  23155. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  23156. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23157. * * 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)
  23158. * * 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)
  23159. * @returns the VertexData of the box
  23160. */
  23161. static CreateBox(options: {
  23162. size?: number;
  23163. width?: number;
  23164. height?: number;
  23165. depth?: number;
  23166. faceUV?: Vector4[];
  23167. faceColors?: Color4[];
  23168. sideOrientation?: number;
  23169. frontUVs?: Vector4;
  23170. backUVs?: Vector4;
  23171. }): VertexData;
  23172. /**
  23173. * Creates the VertexData for a tiled box
  23174. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23175. * * faceTiles sets the pattern, tile size and number of tiles for a face
  23176. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  23177. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  23178. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23179. * @returns the VertexData of the box
  23180. */
  23181. static CreateTiledBox(options: {
  23182. pattern?: number;
  23183. width?: number;
  23184. height?: number;
  23185. depth?: number;
  23186. tileSize?: number;
  23187. tileWidth?: number;
  23188. tileHeight?: number;
  23189. alignHorizontal?: number;
  23190. alignVertical?: number;
  23191. faceUV?: Vector4[];
  23192. faceColors?: Color4[];
  23193. sideOrientation?: number;
  23194. }): VertexData;
  23195. /**
  23196. * Creates the VertexData for a tiled plane
  23197. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23198. * * pattern a limited pattern arrangement depending on the number
  23199. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  23200. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  23201. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  23202. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23203. * * 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)
  23204. * * 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)
  23205. * @returns the VertexData of the tiled plane
  23206. */
  23207. static CreateTiledPlane(options: {
  23208. pattern?: number;
  23209. tileSize?: number;
  23210. tileWidth?: number;
  23211. tileHeight?: number;
  23212. size?: number;
  23213. width?: number;
  23214. height?: number;
  23215. alignHorizontal?: number;
  23216. alignVertical?: number;
  23217. sideOrientation?: number;
  23218. frontUVs?: Vector4;
  23219. backUVs?: Vector4;
  23220. }): VertexData;
  23221. /**
  23222. * Creates the VertexData for an ellipsoid, defaults to a sphere
  23223. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23224. * * segments sets the number of horizontal strips optional, default 32
  23225. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  23226. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  23227. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  23228. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  23229. * * 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
  23230. * * 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
  23231. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23232. * * 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)
  23233. * * 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)
  23234. * @returns the VertexData of the ellipsoid
  23235. */
  23236. static CreateSphere(options: {
  23237. segments?: number;
  23238. diameter?: number;
  23239. diameterX?: number;
  23240. diameterY?: number;
  23241. diameterZ?: number;
  23242. arc?: number;
  23243. slice?: number;
  23244. sideOrientation?: number;
  23245. frontUVs?: Vector4;
  23246. backUVs?: Vector4;
  23247. }): VertexData;
  23248. /**
  23249. * Creates the VertexData for a cylinder, cone or prism
  23250. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23251. * * height sets the height (y direction) of the cylinder, optional, default 2
  23252. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  23253. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  23254. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  23255. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  23256. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  23257. * * 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
  23258. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23259. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23260. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  23261. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  23262. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23263. * * 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)
  23264. * * 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)
  23265. * @returns the VertexData of the cylinder, cone or prism
  23266. */
  23267. static CreateCylinder(options: {
  23268. height?: number;
  23269. diameterTop?: number;
  23270. diameterBottom?: number;
  23271. diameter?: number;
  23272. tessellation?: number;
  23273. subdivisions?: number;
  23274. arc?: number;
  23275. faceColors?: Color4[];
  23276. faceUV?: Vector4[];
  23277. hasRings?: boolean;
  23278. enclose?: boolean;
  23279. sideOrientation?: number;
  23280. frontUVs?: Vector4;
  23281. backUVs?: Vector4;
  23282. }): VertexData;
  23283. /**
  23284. * Creates the VertexData for a torus
  23285. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23286. * * diameter the diameter of the torus, optional default 1
  23287. * * thickness the diameter of the tube forming the torus, optional default 0.5
  23288. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  23289. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23290. * * 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)
  23291. * * 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)
  23292. * @returns the VertexData of the torus
  23293. */
  23294. static CreateTorus(options: {
  23295. diameter?: number;
  23296. thickness?: number;
  23297. tessellation?: number;
  23298. sideOrientation?: number;
  23299. frontUVs?: Vector4;
  23300. backUVs?: Vector4;
  23301. }): VertexData;
  23302. /**
  23303. * Creates the VertexData of the LineSystem
  23304. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  23305. * - lines an array of lines, each line being an array of successive Vector3
  23306. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  23307. * @returns the VertexData of the LineSystem
  23308. */
  23309. static CreateLineSystem(options: {
  23310. lines: Vector3[][];
  23311. colors?: Nullable<Color4[][]>;
  23312. }): VertexData;
  23313. /**
  23314. * Create the VertexData for a DashedLines
  23315. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  23316. * - points an array successive Vector3
  23317. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  23318. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  23319. * - dashNb the intended total number of dashes, optional, default 200
  23320. * @returns the VertexData for the DashedLines
  23321. */
  23322. static CreateDashedLines(options: {
  23323. points: Vector3[];
  23324. dashSize?: number;
  23325. gapSize?: number;
  23326. dashNb?: number;
  23327. }): VertexData;
  23328. /**
  23329. * Creates the VertexData for a Ground
  23330. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23331. * - width the width (x direction) of the ground, optional, default 1
  23332. * - height the height (z direction) of the ground, optional, default 1
  23333. * - subdivisions the number of subdivisions per side, optional, default 1
  23334. * @returns the VertexData of the Ground
  23335. */
  23336. static CreateGround(options: {
  23337. width?: number;
  23338. height?: number;
  23339. subdivisions?: number;
  23340. subdivisionsX?: number;
  23341. subdivisionsY?: number;
  23342. }): VertexData;
  23343. /**
  23344. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  23345. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23346. * * xmin the ground minimum X coordinate, optional, default -1
  23347. * * zmin the ground minimum Z coordinate, optional, default -1
  23348. * * xmax the ground maximum X coordinate, optional, default 1
  23349. * * zmax the ground maximum Z coordinate, optional, default 1
  23350. * * 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}
  23351. * * 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}
  23352. * @returns the VertexData of the TiledGround
  23353. */
  23354. static CreateTiledGround(options: {
  23355. xmin: number;
  23356. zmin: number;
  23357. xmax: number;
  23358. zmax: number;
  23359. subdivisions?: {
  23360. w: number;
  23361. h: number;
  23362. };
  23363. precision?: {
  23364. w: number;
  23365. h: number;
  23366. };
  23367. }): VertexData;
  23368. /**
  23369. * Creates the VertexData of the Ground designed from a heightmap
  23370. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  23371. * * width the width (x direction) of the ground
  23372. * * height the height (z direction) of the ground
  23373. * * subdivisions the number of subdivisions per side
  23374. * * minHeight the minimum altitude on the ground, optional, default 0
  23375. * * maxHeight the maximum altitude on the ground, optional default 1
  23376. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  23377. * * buffer the array holding the image color data
  23378. * * bufferWidth the width of image
  23379. * * bufferHeight the height of image
  23380. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  23381. * @returns the VertexData of the Ground designed from a heightmap
  23382. */
  23383. static CreateGroundFromHeightMap(options: {
  23384. width: number;
  23385. height: number;
  23386. subdivisions: number;
  23387. minHeight: number;
  23388. maxHeight: number;
  23389. colorFilter: Color3;
  23390. buffer: Uint8Array;
  23391. bufferWidth: number;
  23392. bufferHeight: number;
  23393. alphaFilter: number;
  23394. }): VertexData;
  23395. /**
  23396. * Creates the VertexData for a Plane
  23397. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  23398. * * size sets the width and height of the plane to the value of size, optional default 1
  23399. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  23400. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  23401. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23402. * * 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)
  23403. * * 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)
  23404. * @returns the VertexData of the box
  23405. */
  23406. static CreatePlane(options: {
  23407. size?: number;
  23408. width?: number;
  23409. height?: number;
  23410. sideOrientation?: number;
  23411. frontUVs?: Vector4;
  23412. backUVs?: Vector4;
  23413. }): VertexData;
  23414. /**
  23415. * Creates the VertexData of the Disc or regular Polygon
  23416. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  23417. * * radius the radius of the disc, optional default 0.5
  23418. * * tessellation the number of polygon sides, optional, default 64
  23419. * * 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
  23420. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23421. * * 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)
  23422. * * 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)
  23423. * @returns the VertexData of the box
  23424. */
  23425. static CreateDisc(options: {
  23426. radius?: number;
  23427. tessellation?: number;
  23428. arc?: number;
  23429. sideOrientation?: number;
  23430. frontUVs?: Vector4;
  23431. backUVs?: Vector4;
  23432. }): VertexData;
  23433. /**
  23434. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  23435. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  23436. * @param polygon a mesh built from polygonTriangulation.build()
  23437. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23438. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23439. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23440. * @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)
  23441. * @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)
  23442. * @returns the VertexData of the Polygon
  23443. */
  23444. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  23445. /**
  23446. * Creates the VertexData of the IcoSphere
  23447. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  23448. * * radius the radius of the IcoSphere, optional default 1
  23449. * * radiusX allows stretching in the x direction, optional, default radius
  23450. * * radiusY allows stretching in the y direction, optional, default radius
  23451. * * radiusZ allows stretching in the z direction, optional, default radius
  23452. * * flat when true creates a flat shaded mesh, optional, default true
  23453. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23454. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23455. * * 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)
  23456. * * 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)
  23457. * @returns the VertexData of the IcoSphere
  23458. */
  23459. static CreateIcoSphere(options: {
  23460. radius?: number;
  23461. radiusX?: number;
  23462. radiusY?: number;
  23463. radiusZ?: number;
  23464. flat?: boolean;
  23465. subdivisions?: number;
  23466. sideOrientation?: number;
  23467. frontUVs?: Vector4;
  23468. backUVs?: Vector4;
  23469. }): VertexData;
  23470. /**
  23471. * Creates the VertexData for a Polyhedron
  23472. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  23473. * * type provided types are:
  23474. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  23475. * * 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)
  23476. * * size the size of the IcoSphere, optional default 1
  23477. * * sizeX allows stretching in the x direction, optional, default size
  23478. * * sizeY allows stretching in the y direction, optional, default size
  23479. * * sizeZ allows stretching in the z direction, optional, default size
  23480. * * 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
  23481. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23482. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23483. * * flat when true creates a flat shaded mesh, optional, default true
  23484. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23485. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23486. * * 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)
  23487. * * 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)
  23488. * @returns the VertexData of the Polyhedron
  23489. */
  23490. static CreatePolyhedron(options: {
  23491. type?: number;
  23492. size?: number;
  23493. sizeX?: number;
  23494. sizeY?: number;
  23495. sizeZ?: number;
  23496. custom?: any;
  23497. faceUV?: Vector4[];
  23498. faceColors?: Color4[];
  23499. flat?: boolean;
  23500. sideOrientation?: number;
  23501. frontUVs?: Vector4;
  23502. backUVs?: Vector4;
  23503. }): VertexData;
  23504. /**
  23505. * Creates the VertexData for a TorusKnot
  23506. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  23507. * * radius the radius of the torus knot, optional, default 2
  23508. * * tube the thickness of the tube, optional, default 0.5
  23509. * * radialSegments the number of sides on each tube segments, optional, default 32
  23510. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  23511. * * p the number of windings around the z axis, optional, default 2
  23512. * * q the number of windings around the x axis, optional, default 3
  23513. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23514. * * 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)
  23515. * * 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)
  23516. * @returns the VertexData of the Torus Knot
  23517. */
  23518. static CreateTorusKnot(options: {
  23519. radius?: number;
  23520. tube?: number;
  23521. radialSegments?: number;
  23522. tubularSegments?: number;
  23523. p?: number;
  23524. q?: number;
  23525. sideOrientation?: number;
  23526. frontUVs?: Vector4;
  23527. backUVs?: Vector4;
  23528. }): VertexData;
  23529. /**
  23530. * Compute normals for given positions and indices
  23531. * @param positions an array of vertex positions, [...., x, y, z, ......]
  23532. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  23533. * @param normals an array of vertex normals, [...., x, y, z, ......]
  23534. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  23535. * * facetNormals : optional array of facet normals (vector3)
  23536. * * facetPositions : optional array of facet positions (vector3)
  23537. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  23538. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  23539. * * bInfo : optional bounding info, required for facetPartitioning computation
  23540. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  23541. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  23542. * * useRightHandedSystem: optional boolean to for right handed system computation
  23543. * * depthSort : optional boolean to enable the facet depth sort computation
  23544. * * distanceTo : optional Vector3 to compute the facet depth from this location
  23545. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  23546. */
  23547. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  23548. facetNormals?: any;
  23549. facetPositions?: any;
  23550. facetPartitioning?: any;
  23551. ratio?: number;
  23552. bInfo?: any;
  23553. bbSize?: Vector3;
  23554. subDiv?: any;
  23555. useRightHandedSystem?: boolean;
  23556. depthSort?: boolean;
  23557. distanceTo?: Vector3;
  23558. depthSortedFacets?: any;
  23559. }): void;
  23560. /** @hidden */
  23561. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  23562. /**
  23563. * Applies VertexData created from the imported parameters to the geometry
  23564. * @param parsedVertexData the parsed data from an imported file
  23565. * @param geometry the geometry to apply the VertexData to
  23566. */
  23567. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  23568. }
  23569. }
  23570. declare module "babylonjs/Morph/morphTarget" {
  23571. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  23572. import { Observable } from "babylonjs/Misc/observable";
  23573. import { Nullable, FloatArray } from "babylonjs/types";
  23574. import { Scene } from "babylonjs/scene";
  23575. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23576. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  23577. /**
  23578. * Defines a target to use with MorphTargetManager
  23579. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23580. */
  23581. export class MorphTarget implements IAnimatable {
  23582. /** defines the name of the target */
  23583. name: string;
  23584. /**
  23585. * Gets or sets the list of animations
  23586. */
  23587. animations: import("babylonjs/Animations/animation").Animation[];
  23588. private _scene;
  23589. private _positions;
  23590. private _normals;
  23591. private _tangents;
  23592. private _uvs;
  23593. private _influence;
  23594. private _uniqueId;
  23595. /**
  23596. * Observable raised when the influence changes
  23597. */
  23598. onInfluenceChanged: Observable<boolean>;
  23599. /** @hidden */
  23600. _onDataLayoutChanged: Observable<void>;
  23601. /**
  23602. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  23603. */
  23604. get influence(): number;
  23605. set influence(influence: number);
  23606. /**
  23607. * Gets or sets the id of the morph Target
  23608. */
  23609. id: string;
  23610. private _animationPropertiesOverride;
  23611. /**
  23612. * Gets or sets the animation properties override
  23613. */
  23614. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  23615. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  23616. /**
  23617. * Creates a new MorphTarget
  23618. * @param name defines the name of the target
  23619. * @param influence defines the influence to use
  23620. * @param scene defines the scene the morphtarget belongs to
  23621. */
  23622. constructor(
  23623. /** defines the name of the target */
  23624. name: string, influence?: number, scene?: Nullable<Scene>);
  23625. /**
  23626. * Gets the unique ID of this manager
  23627. */
  23628. get uniqueId(): number;
  23629. /**
  23630. * Gets a boolean defining if the target contains position data
  23631. */
  23632. get hasPositions(): boolean;
  23633. /**
  23634. * Gets a boolean defining if the target contains normal data
  23635. */
  23636. get hasNormals(): boolean;
  23637. /**
  23638. * Gets a boolean defining if the target contains tangent data
  23639. */
  23640. get hasTangents(): boolean;
  23641. /**
  23642. * Gets a boolean defining if the target contains texture coordinates data
  23643. */
  23644. get hasUVs(): boolean;
  23645. /**
  23646. * Affects position data to this target
  23647. * @param data defines the position data to use
  23648. */
  23649. setPositions(data: Nullable<FloatArray>): void;
  23650. /**
  23651. * Gets the position data stored in this target
  23652. * @returns a FloatArray containing the position data (or null if not present)
  23653. */
  23654. getPositions(): Nullable<FloatArray>;
  23655. /**
  23656. * Affects normal data to this target
  23657. * @param data defines the normal data to use
  23658. */
  23659. setNormals(data: Nullable<FloatArray>): void;
  23660. /**
  23661. * Gets the normal data stored in this target
  23662. * @returns a FloatArray containing the normal data (or null if not present)
  23663. */
  23664. getNormals(): Nullable<FloatArray>;
  23665. /**
  23666. * Affects tangent data to this target
  23667. * @param data defines the tangent data to use
  23668. */
  23669. setTangents(data: Nullable<FloatArray>): void;
  23670. /**
  23671. * Gets the tangent data stored in this target
  23672. * @returns a FloatArray containing the tangent data (or null if not present)
  23673. */
  23674. getTangents(): Nullable<FloatArray>;
  23675. /**
  23676. * Affects texture coordinates data to this target
  23677. * @param data defines the texture coordinates data to use
  23678. */
  23679. setUVs(data: Nullable<FloatArray>): void;
  23680. /**
  23681. * Gets the texture coordinates data stored in this target
  23682. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  23683. */
  23684. getUVs(): Nullable<FloatArray>;
  23685. /**
  23686. * Clone the current target
  23687. * @returns a new MorphTarget
  23688. */
  23689. clone(): MorphTarget;
  23690. /**
  23691. * Serializes the current target into a Serialization object
  23692. * @returns the serialized object
  23693. */
  23694. serialize(): any;
  23695. /**
  23696. * Returns the string "MorphTarget"
  23697. * @returns "MorphTarget"
  23698. */
  23699. getClassName(): string;
  23700. /**
  23701. * Creates a new target from serialized data
  23702. * @param serializationObject defines the serialized data to use
  23703. * @returns a new MorphTarget
  23704. */
  23705. static Parse(serializationObject: any): MorphTarget;
  23706. /**
  23707. * Creates a MorphTarget from mesh data
  23708. * @param mesh defines the source mesh
  23709. * @param name defines the name to use for the new target
  23710. * @param influence defines the influence to attach to the target
  23711. * @returns a new MorphTarget
  23712. */
  23713. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  23714. }
  23715. }
  23716. declare module "babylonjs/Morph/morphTargetManager" {
  23717. import { Nullable } from "babylonjs/types";
  23718. import { Scene } from "babylonjs/scene";
  23719. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  23720. /**
  23721. * This class is used to deform meshes using morphing between different targets
  23722. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23723. */
  23724. export class MorphTargetManager {
  23725. private _targets;
  23726. private _targetInfluenceChangedObservers;
  23727. private _targetDataLayoutChangedObservers;
  23728. private _activeTargets;
  23729. private _scene;
  23730. private _influences;
  23731. private _supportsNormals;
  23732. private _supportsTangents;
  23733. private _supportsUVs;
  23734. private _vertexCount;
  23735. private _uniqueId;
  23736. private _tempInfluences;
  23737. /**
  23738. * Gets or sets a boolean indicating if normals must be morphed
  23739. */
  23740. enableNormalMorphing: boolean;
  23741. /**
  23742. * Gets or sets a boolean indicating if tangents must be morphed
  23743. */
  23744. enableTangentMorphing: boolean;
  23745. /**
  23746. * Gets or sets a boolean indicating if UV must be morphed
  23747. */
  23748. enableUVMorphing: boolean;
  23749. /**
  23750. * Creates a new MorphTargetManager
  23751. * @param scene defines the current scene
  23752. */
  23753. constructor(scene?: Nullable<Scene>);
  23754. /**
  23755. * Gets the unique ID of this manager
  23756. */
  23757. get uniqueId(): number;
  23758. /**
  23759. * Gets the number of vertices handled by this manager
  23760. */
  23761. get vertexCount(): number;
  23762. /**
  23763. * Gets a boolean indicating if this manager supports morphing of normals
  23764. */
  23765. get supportsNormals(): boolean;
  23766. /**
  23767. * Gets a boolean indicating if this manager supports morphing of tangents
  23768. */
  23769. get supportsTangents(): boolean;
  23770. /**
  23771. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  23772. */
  23773. get supportsUVs(): boolean;
  23774. /**
  23775. * Gets the number of targets stored in this manager
  23776. */
  23777. get numTargets(): number;
  23778. /**
  23779. * Gets the number of influencers (ie. the number of targets with influences > 0)
  23780. */
  23781. get numInfluencers(): number;
  23782. /**
  23783. * Gets the list of influences (one per target)
  23784. */
  23785. get influences(): Float32Array;
  23786. /**
  23787. * Gets the active target at specified index. An active target is a target with an influence > 0
  23788. * @param index defines the index to check
  23789. * @returns the requested target
  23790. */
  23791. getActiveTarget(index: number): MorphTarget;
  23792. /**
  23793. * Gets the target at specified index
  23794. * @param index defines the index to check
  23795. * @returns the requested target
  23796. */
  23797. getTarget(index: number): MorphTarget;
  23798. /**
  23799. * Add a new target to this manager
  23800. * @param target defines the target to add
  23801. */
  23802. addTarget(target: MorphTarget): void;
  23803. /**
  23804. * Removes a target from the manager
  23805. * @param target defines the target to remove
  23806. */
  23807. removeTarget(target: MorphTarget): void;
  23808. /**
  23809. * Clone the current manager
  23810. * @returns a new MorphTargetManager
  23811. */
  23812. clone(): MorphTargetManager;
  23813. /**
  23814. * Serializes the current manager into a Serialization object
  23815. * @returns the serialized object
  23816. */
  23817. serialize(): any;
  23818. private _syncActiveTargets;
  23819. /**
  23820. * Syncrhonize the targets with all the meshes using this morph target manager
  23821. */
  23822. synchronize(): void;
  23823. /**
  23824. * Creates a new MorphTargetManager from serialized data
  23825. * @param serializationObject defines the serialized data
  23826. * @param scene defines the hosting scene
  23827. * @returns the new MorphTargetManager
  23828. */
  23829. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  23830. }
  23831. }
  23832. declare module "babylonjs/Meshes/meshLODLevel" {
  23833. import { Mesh } from "babylonjs/Meshes/mesh";
  23834. import { Nullable } from "babylonjs/types";
  23835. /**
  23836. * Class used to represent a specific level of detail of a mesh
  23837. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  23838. */
  23839. export class MeshLODLevel {
  23840. /** Defines the distance where this level should start being displayed */
  23841. distance: number;
  23842. /** Defines the mesh to use to render this level */
  23843. mesh: Nullable<Mesh>;
  23844. /**
  23845. * Creates a new LOD level
  23846. * @param distance defines the distance where this level should star being displayed
  23847. * @param mesh defines the mesh to use to render this level
  23848. */
  23849. constructor(
  23850. /** Defines the distance where this level should start being displayed */
  23851. distance: number,
  23852. /** Defines the mesh to use to render this level */
  23853. mesh: Nullable<Mesh>);
  23854. }
  23855. }
  23856. declare module "babylonjs/Meshes/groundMesh" {
  23857. import { Scene } from "babylonjs/scene";
  23858. import { Vector3 } from "babylonjs/Maths/math.vector";
  23859. import { Mesh } from "babylonjs/Meshes/mesh";
  23860. /**
  23861. * Mesh representing the gorund
  23862. */
  23863. export class GroundMesh extends Mesh {
  23864. /** If octree should be generated */
  23865. generateOctree: boolean;
  23866. private _heightQuads;
  23867. /** @hidden */
  23868. _subdivisionsX: number;
  23869. /** @hidden */
  23870. _subdivisionsY: number;
  23871. /** @hidden */
  23872. _width: number;
  23873. /** @hidden */
  23874. _height: number;
  23875. /** @hidden */
  23876. _minX: number;
  23877. /** @hidden */
  23878. _maxX: number;
  23879. /** @hidden */
  23880. _minZ: number;
  23881. /** @hidden */
  23882. _maxZ: number;
  23883. constructor(name: string, scene: Scene);
  23884. /**
  23885. * "GroundMesh"
  23886. * @returns "GroundMesh"
  23887. */
  23888. getClassName(): string;
  23889. /**
  23890. * The minimum of x and y subdivisions
  23891. */
  23892. get subdivisions(): number;
  23893. /**
  23894. * X subdivisions
  23895. */
  23896. get subdivisionsX(): number;
  23897. /**
  23898. * Y subdivisions
  23899. */
  23900. get subdivisionsY(): number;
  23901. /**
  23902. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  23903. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  23904. * @param chunksCount the number of subdivisions for x and y
  23905. * @param octreeBlocksSize (Default: 32)
  23906. */
  23907. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  23908. /**
  23909. * Returns a height (y) value in the Worl system :
  23910. * the ground altitude at the coordinates (x, z) expressed in the World system.
  23911. * @param x x coordinate
  23912. * @param z z coordinate
  23913. * @returns the ground y position if (x, z) are outside the ground surface.
  23914. */
  23915. getHeightAtCoordinates(x: number, z: number): number;
  23916. /**
  23917. * Returns a normalized vector (Vector3) orthogonal to the ground
  23918. * at the ground coordinates (x, z) expressed in the World system.
  23919. * @param x x coordinate
  23920. * @param z z coordinate
  23921. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  23922. */
  23923. getNormalAtCoordinates(x: number, z: number): Vector3;
  23924. /**
  23925. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  23926. * at the ground coordinates (x, z) expressed in the World system.
  23927. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  23928. * @param x x coordinate
  23929. * @param z z coordinate
  23930. * @param ref vector to store the result
  23931. * @returns the GroundMesh.
  23932. */
  23933. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  23934. /**
  23935. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  23936. * if the ground has been updated.
  23937. * This can be used in the render loop.
  23938. * @returns the GroundMesh.
  23939. */
  23940. updateCoordinateHeights(): GroundMesh;
  23941. private _getFacetAt;
  23942. private _initHeightQuads;
  23943. private _computeHeightQuads;
  23944. /**
  23945. * Serializes this ground mesh
  23946. * @param serializationObject object to write serialization to
  23947. */
  23948. serialize(serializationObject: any): void;
  23949. /**
  23950. * Parses a serialized ground mesh
  23951. * @param parsedMesh the serialized mesh
  23952. * @param scene the scene to create the ground mesh in
  23953. * @returns the created ground mesh
  23954. */
  23955. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  23956. }
  23957. }
  23958. declare module "babylonjs/Physics/physicsJoint" {
  23959. import { Vector3 } from "babylonjs/Maths/math.vector";
  23960. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  23961. /**
  23962. * Interface for Physics-Joint data
  23963. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23964. */
  23965. export interface PhysicsJointData {
  23966. /**
  23967. * The main pivot of the joint
  23968. */
  23969. mainPivot?: Vector3;
  23970. /**
  23971. * The connected pivot of the joint
  23972. */
  23973. connectedPivot?: Vector3;
  23974. /**
  23975. * The main axis of the joint
  23976. */
  23977. mainAxis?: Vector3;
  23978. /**
  23979. * The connected axis of the joint
  23980. */
  23981. connectedAxis?: Vector3;
  23982. /**
  23983. * The collision of the joint
  23984. */
  23985. collision?: boolean;
  23986. /**
  23987. * Native Oimo/Cannon/Energy data
  23988. */
  23989. nativeParams?: any;
  23990. }
  23991. /**
  23992. * This is a holder class for the physics joint created by the physics plugin
  23993. * It holds a set of functions to control the underlying joint
  23994. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23995. */
  23996. export class PhysicsJoint {
  23997. /**
  23998. * The type of the physics joint
  23999. */
  24000. type: number;
  24001. /**
  24002. * The data for the physics joint
  24003. */
  24004. jointData: PhysicsJointData;
  24005. private _physicsJoint;
  24006. protected _physicsPlugin: IPhysicsEnginePlugin;
  24007. /**
  24008. * Initializes the physics joint
  24009. * @param type The type of the physics joint
  24010. * @param jointData The data for the physics joint
  24011. */
  24012. constructor(
  24013. /**
  24014. * The type of the physics joint
  24015. */
  24016. type: number,
  24017. /**
  24018. * The data for the physics joint
  24019. */
  24020. jointData: PhysicsJointData);
  24021. /**
  24022. * Gets the physics joint
  24023. */
  24024. get physicsJoint(): any;
  24025. /**
  24026. * Sets the physics joint
  24027. */
  24028. set physicsJoint(newJoint: any);
  24029. /**
  24030. * Sets the physics plugin
  24031. */
  24032. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  24033. /**
  24034. * Execute a function that is physics-plugin specific.
  24035. * @param {Function} func the function that will be executed.
  24036. * It accepts two parameters: the physics world and the physics joint
  24037. */
  24038. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  24039. /**
  24040. * Distance-Joint type
  24041. */
  24042. static DistanceJoint: number;
  24043. /**
  24044. * Hinge-Joint type
  24045. */
  24046. static HingeJoint: number;
  24047. /**
  24048. * Ball-and-Socket joint type
  24049. */
  24050. static BallAndSocketJoint: number;
  24051. /**
  24052. * Wheel-Joint type
  24053. */
  24054. static WheelJoint: number;
  24055. /**
  24056. * Slider-Joint type
  24057. */
  24058. static SliderJoint: number;
  24059. /**
  24060. * Prismatic-Joint type
  24061. */
  24062. static PrismaticJoint: number;
  24063. /**
  24064. * Universal-Joint type
  24065. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  24066. */
  24067. static UniversalJoint: number;
  24068. /**
  24069. * Hinge-Joint 2 type
  24070. */
  24071. static Hinge2Joint: number;
  24072. /**
  24073. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  24074. */
  24075. static PointToPointJoint: number;
  24076. /**
  24077. * Spring-Joint type
  24078. */
  24079. static SpringJoint: number;
  24080. /**
  24081. * Lock-Joint type
  24082. */
  24083. static LockJoint: number;
  24084. }
  24085. /**
  24086. * A class representing a physics distance joint
  24087. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24088. */
  24089. export class DistanceJoint extends PhysicsJoint {
  24090. /**
  24091. *
  24092. * @param jointData The data for the Distance-Joint
  24093. */
  24094. constructor(jointData: DistanceJointData);
  24095. /**
  24096. * Update the predefined distance.
  24097. * @param maxDistance The maximum preferred distance
  24098. * @param minDistance The minimum preferred distance
  24099. */
  24100. updateDistance(maxDistance: number, minDistance?: number): void;
  24101. }
  24102. /**
  24103. * Represents a Motor-Enabled Joint
  24104. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24105. */
  24106. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  24107. /**
  24108. * Initializes the Motor-Enabled Joint
  24109. * @param type The type of the joint
  24110. * @param jointData The physica joint data for the joint
  24111. */
  24112. constructor(type: number, jointData: PhysicsJointData);
  24113. /**
  24114. * Set the motor values.
  24115. * Attention, this function is plugin specific. Engines won't react 100% the same.
  24116. * @param force the force to apply
  24117. * @param maxForce max force for this motor.
  24118. */
  24119. setMotor(force?: number, maxForce?: number): void;
  24120. /**
  24121. * Set the motor's limits.
  24122. * Attention, this function is plugin specific. Engines won't react 100% the same.
  24123. * @param upperLimit The upper limit of the motor
  24124. * @param lowerLimit The lower limit of the motor
  24125. */
  24126. setLimit(upperLimit: number, lowerLimit?: number): void;
  24127. }
  24128. /**
  24129. * This class represents a single physics Hinge-Joint
  24130. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24131. */
  24132. export class HingeJoint extends MotorEnabledJoint {
  24133. /**
  24134. * Initializes the Hinge-Joint
  24135. * @param jointData The joint data for the Hinge-Joint
  24136. */
  24137. constructor(jointData: PhysicsJointData);
  24138. /**
  24139. * Set the motor values.
  24140. * Attention, this function is plugin specific. Engines won't react 100% the same.
  24141. * @param {number} force the force to apply
  24142. * @param {number} maxForce max force for this motor.
  24143. */
  24144. setMotor(force?: number, maxForce?: number): void;
  24145. /**
  24146. * Set the motor's limits.
  24147. * Attention, this function is plugin specific. Engines won't react 100% the same.
  24148. * @param upperLimit The upper limit of the motor
  24149. * @param lowerLimit The lower limit of the motor
  24150. */
  24151. setLimit(upperLimit: number, lowerLimit?: number): void;
  24152. }
  24153. /**
  24154. * This class represents a dual hinge physics joint (same as wheel joint)
  24155. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24156. */
  24157. export class Hinge2Joint extends MotorEnabledJoint {
  24158. /**
  24159. * Initializes the Hinge2-Joint
  24160. * @param jointData The joint data for the Hinge2-Joint
  24161. */
  24162. constructor(jointData: PhysicsJointData);
  24163. /**
  24164. * Set the motor values.
  24165. * Attention, this function is plugin specific. Engines won't react 100% the same.
  24166. * @param {number} targetSpeed the speed the motor is to reach
  24167. * @param {number} maxForce max force for this motor.
  24168. * @param {motorIndex} the motor's index, 0 or 1.
  24169. */
  24170. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  24171. /**
  24172. * Set the motor limits.
  24173. * Attention, this function is plugin specific. Engines won't react 100% the same.
  24174. * @param {number} upperLimit the upper limit
  24175. * @param {number} lowerLimit lower limit
  24176. * @param {motorIndex} the motor's index, 0 or 1.
  24177. */
  24178. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  24179. }
  24180. /**
  24181. * Interface for a motor enabled joint
  24182. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24183. */
  24184. export interface IMotorEnabledJoint {
  24185. /**
  24186. * Physics joint
  24187. */
  24188. physicsJoint: any;
  24189. /**
  24190. * Sets the motor of the motor-enabled joint
  24191. * @param force The force of the motor
  24192. * @param maxForce The maximum force of the motor
  24193. * @param motorIndex The index of the motor
  24194. */
  24195. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  24196. /**
  24197. * Sets the limit of the motor
  24198. * @param upperLimit The upper limit of the motor
  24199. * @param lowerLimit The lower limit of the motor
  24200. * @param motorIndex The index of the motor
  24201. */
  24202. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  24203. }
  24204. /**
  24205. * Joint data for a Distance-Joint
  24206. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24207. */
  24208. export interface DistanceJointData extends PhysicsJointData {
  24209. /**
  24210. * Max distance the 2 joint objects can be apart
  24211. */
  24212. maxDistance: number;
  24213. }
  24214. /**
  24215. * Joint data from a spring joint
  24216. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24217. */
  24218. export interface SpringJointData extends PhysicsJointData {
  24219. /**
  24220. * Length of the spring
  24221. */
  24222. length: number;
  24223. /**
  24224. * Stiffness of the spring
  24225. */
  24226. stiffness: number;
  24227. /**
  24228. * Damping of the spring
  24229. */
  24230. damping: number;
  24231. /** this callback will be called when applying the force to the impostors. */
  24232. forceApplicationCallback: () => void;
  24233. }
  24234. }
  24235. declare module "babylonjs/Physics/physicsRaycastResult" {
  24236. import { Vector3 } from "babylonjs/Maths/math.vector";
  24237. /**
  24238. * Holds the data for the raycast result
  24239. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24240. */
  24241. export class PhysicsRaycastResult {
  24242. private _hasHit;
  24243. private _hitDistance;
  24244. private _hitNormalWorld;
  24245. private _hitPointWorld;
  24246. private _rayFromWorld;
  24247. private _rayToWorld;
  24248. /**
  24249. * Gets if there was a hit
  24250. */
  24251. get hasHit(): boolean;
  24252. /**
  24253. * Gets the distance from the hit
  24254. */
  24255. get hitDistance(): number;
  24256. /**
  24257. * Gets the hit normal/direction in the world
  24258. */
  24259. get hitNormalWorld(): Vector3;
  24260. /**
  24261. * Gets the hit point in the world
  24262. */
  24263. get hitPointWorld(): Vector3;
  24264. /**
  24265. * Gets the ray "start point" of the ray in the world
  24266. */
  24267. get rayFromWorld(): Vector3;
  24268. /**
  24269. * Gets the ray "end point" of the ray in the world
  24270. */
  24271. get rayToWorld(): Vector3;
  24272. /**
  24273. * Sets the hit data (normal & point in world space)
  24274. * @param hitNormalWorld defines the normal in world space
  24275. * @param hitPointWorld defines the point in world space
  24276. */
  24277. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  24278. /**
  24279. * Sets the distance from the start point to the hit point
  24280. * @param distance
  24281. */
  24282. setHitDistance(distance: number): void;
  24283. /**
  24284. * Calculates the distance manually
  24285. */
  24286. calculateHitDistance(): void;
  24287. /**
  24288. * Resets all the values to default
  24289. * @param from The from point on world space
  24290. * @param to The to point on world space
  24291. */
  24292. reset(from?: Vector3, to?: Vector3): void;
  24293. }
  24294. /**
  24295. * Interface for the size containing width and height
  24296. */
  24297. interface IXYZ {
  24298. /**
  24299. * X
  24300. */
  24301. x: number;
  24302. /**
  24303. * Y
  24304. */
  24305. y: number;
  24306. /**
  24307. * Z
  24308. */
  24309. z: number;
  24310. }
  24311. }
  24312. declare module "babylonjs/Physics/IPhysicsEngine" {
  24313. import { Nullable } from "babylonjs/types";
  24314. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  24315. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24316. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  24317. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  24318. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  24319. /**
  24320. * Interface used to describe a physics joint
  24321. */
  24322. export interface PhysicsImpostorJoint {
  24323. /** Defines the main impostor to which the joint is linked */
  24324. mainImpostor: PhysicsImpostor;
  24325. /** Defines the impostor that is connected to the main impostor using this joint */
  24326. connectedImpostor: PhysicsImpostor;
  24327. /** Defines the joint itself */
  24328. joint: PhysicsJoint;
  24329. }
  24330. /** @hidden */
  24331. export interface IPhysicsEnginePlugin {
  24332. world: any;
  24333. name: string;
  24334. setGravity(gravity: Vector3): void;
  24335. setTimeStep(timeStep: number): void;
  24336. getTimeStep(): number;
  24337. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  24338. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  24339. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  24340. generatePhysicsBody(impostor: PhysicsImpostor): void;
  24341. removePhysicsBody(impostor: PhysicsImpostor): void;
  24342. generateJoint(joint: PhysicsImpostorJoint): void;
  24343. removeJoint(joint: PhysicsImpostorJoint): void;
  24344. isSupported(): boolean;
  24345. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  24346. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  24347. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  24348. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  24349. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  24350. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  24351. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  24352. getBodyMass(impostor: PhysicsImpostor): number;
  24353. getBodyFriction(impostor: PhysicsImpostor): number;
  24354. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  24355. getBodyRestitution(impostor: PhysicsImpostor): number;
  24356. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  24357. getBodyPressure?(impostor: PhysicsImpostor): number;
  24358. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  24359. getBodyStiffness?(impostor: PhysicsImpostor): number;
  24360. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  24361. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  24362. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  24363. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  24364. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  24365. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  24366. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  24367. sleepBody(impostor: PhysicsImpostor): void;
  24368. wakeUpBody(impostor: PhysicsImpostor): void;
  24369. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  24370. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  24371. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  24372. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  24373. getRadius(impostor: PhysicsImpostor): number;
  24374. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  24375. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  24376. dispose(): void;
  24377. }
  24378. /**
  24379. * Interface used to define a physics engine
  24380. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  24381. */
  24382. export interface IPhysicsEngine {
  24383. /**
  24384. * Gets the gravity vector used by the simulation
  24385. */
  24386. gravity: Vector3;
  24387. /**
  24388. * Sets the gravity vector used by the simulation
  24389. * @param gravity defines the gravity vector to use
  24390. */
  24391. setGravity(gravity: Vector3): void;
  24392. /**
  24393. * Set the time step of the physics engine.
  24394. * Default is 1/60.
  24395. * To slow it down, enter 1/600 for example.
  24396. * To speed it up, 1/30
  24397. * @param newTimeStep the new timestep to apply to this world.
  24398. */
  24399. setTimeStep(newTimeStep: number): void;
  24400. /**
  24401. * Get the time step of the physics engine.
  24402. * @returns the current time step
  24403. */
  24404. getTimeStep(): number;
  24405. /**
  24406. * Set the sub time step of the physics engine.
  24407. * Default is 0 meaning there is no sub steps
  24408. * To increase physics resolution precision, set a small value (like 1 ms)
  24409. * @param subTimeStep defines the new sub timestep used for physics resolution.
  24410. */
  24411. setSubTimeStep(subTimeStep: number): void;
  24412. /**
  24413. * Get the sub time step of the physics engine.
  24414. * @returns the current sub time step
  24415. */
  24416. getSubTimeStep(): number;
  24417. /**
  24418. * Release all resources
  24419. */
  24420. dispose(): void;
  24421. /**
  24422. * Gets the name of the current physics plugin
  24423. * @returns the name of the plugin
  24424. */
  24425. getPhysicsPluginName(): string;
  24426. /**
  24427. * Adding a new impostor for the impostor tracking.
  24428. * This will be done by the impostor itself.
  24429. * @param impostor the impostor to add
  24430. */
  24431. addImpostor(impostor: PhysicsImpostor): void;
  24432. /**
  24433. * Remove an impostor from the engine.
  24434. * This impostor and its mesh will not longer be updated by the physics engine.
  24435. * @param impostor the impostor to remove
  24436. */
  24437. removeImpostor(impostor: PhysicsImpostor): void;
  24438. /**
  24439. * Add a joint to the physics engine
  24440. * @param mainImpostor defines the main impostor to which the joint is added.
  24441. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  24442. * @param joint defines the joint that will connect both impostors.
  24443. */
  24444. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  24445. /**
  24446. * Removes a joint from the simulation
  24447. * @param mainImpostor defines the impostor used with the joint
  24448. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  24449. * @param joint defines the joint to remove
  24450. */
  24451. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  24452. /**
  24453. * Gets the current plugin used to run the simulation
  24454. * @returns current plugin
  24455. */
  24456. getPhysicsPlugin(): IPhysicsEnginePlugin;
  24457. /**
  24458. * Gets the list of physic impostors
  24459. * @returns an array of PhysicsImpostor
  24460. */
  24461. getImpostors(): Array<PhysicsImpostor>;
  24462. /**
  24463. * Gets the impostor for a physics enabled object
  24464. * @param object defines the object impersonated by the impostor
  24465. * @returns the PhysicsImpostor or null if not found
  24466. */
  24467. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  24468. /**
  24469. * Gets the impostor for a physics body object
  24470. * @param body defines physics body used by the impostor
  24471. * @returns the PhysicsImpostor or null if not found
  24472. */
  24473. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  24474. /**
  24475. * Does a raycast in the physics world
  24476. * @param from when should the ray start?
  24477. * @param to when should the ray end?
  24478. * @returns PhysicsRaycastResult
  24479. */
  24480. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  24481. /**
  24482. * Called by the scene. No need to call it.
  24483. * @param delta defines the timespam between frames
  24484. */
  24485. _step(delta: number): void;
  24486. }
  24487. }
  24488. declare module "babylonjs/Physics/physicsImpostor" {
  24489. import { Nullable, IndicesArray } from "babylonjs/types";
  24490. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  24491. import { TransformNode } from "babylonjs/Meshes/transformNode";
  24492. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24493. import { Scene } from "babylonjs/scene";
  24494. import { Bone } from "babylonjs/Bones/bone";
  24495. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  24496. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  24497. import { Space } from "babylonjs/Maths/math.axis";
  24498. /**
  24499. * The interface for the physics imposter parameters
  24500. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24501. */
  24502. export interface PhysicsImpostorParameters {
  24503. /**
  24504. * The mass of the physics imposter
  24505. */
  24506. mass: number;
  24507. /**
  24508. * The friction of the physics imposter
  24509. */
  24510. friction?: number;
  24511. /**
  24512. * The coefficient of restitution of the physics imposter
  24513. */
  24514. restitution?: number;
  24515. /**
  24516. * The native options of the physics imposter
  24517. */
  24518. nativeOptions?: any;
  24519. /**
  24520. * Specifies if the parent should be ignored
  24521. */
  24522. ignoreParent?: boolean;
  24523. /**
  24524. * Specifies if bi-directional transformations should be disabled
  24525. */
  24526. disableBidirectionalTransformation?: boolean;
  24527. /**
  24528. * The pressure inside the physics imposter, soft object only
  24529. */
  24530. pressure?: number;
  24531. /**
  24532. * The stiffness the physics imposter, soft object only
  24533. */
  24534. stiffness?: number;
  24535. /**
  24536. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  24537. */
  24538. velocityIterations?: number;
  24539. /**
  24540. * The number of iterations used in maintaining consistent vertex positions, soft object only
  24541. */
  24542. positionIterations?: number;
  24543. /**
  24544. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  24545. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  24546. * Add to fix multiple points
  24547. */
  24548. fixedPoints?: number;
  24549. /**
  24550. * The collision margin around a soft object
  24551. */
  24552. margin?: number;
  24553. /**
  24554. * The collision margin around a soft object
  24555. */
  24556. damping?: number;
  24557. /**
  24558. * The path for a rope based on an extrusion
  24559. */
  24560. path?: any;
  24561. /**
  24562. * The shape of an extrusion used for a rope based on an extrusion
  24563. */
  24564. shape?: any;
  24565. }
  24566. /**
  24567. * Interface for a physics-enabled object
  24568. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24569. */
  24570. export interface IPhysicsEnabledObject {
  24571. /**
  24572. * The position of the physics-enabled object
  24573. */
  24574. position: Vector3;
  24575. /**
  24576. * The rotation of the physics-enabled object
  24577. */
  24578. rotationQuaternion: Nullable<Quaternion>;
  24579. /**
  24580. * The scale of the physics-enabled object
  24581. */
  24582. scaling: Vector3;
  24583. /**
  24584. * The rotation of the physics-enabled object
  24585. */
  24586. rotation?: Vector3;
  24587. /**
  24588. * The parent of the physics-enabled object
  24589. */
  24590. parent?: any;
  24591. /**
  24592. * The bounding info of the physics-enabled object
  24593. * @returns The bounding info of the physics-enabled object
  24594. */
  24595. getBoundingInfo(): BoundingInfo;
  24596. /**
  24597. * Computes the world matrix
  24598. * @param force Specifies if the world matrix should be computed by force
  24599. * @returns A world matrix
  24600. */
  24601. computeWorldMatrix(force: boolean): Matrix;
  24602. /**
  24603. * Gets the world matrix
  24604. * @returns A world matrix
  24605. */
  24606. getWorldMatrix?(): Matrix;
  24607. /**
  24608. * Gets the child meshes
  24609. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  24610. * @returns An array of abstract meshes
  24611. */
  24612. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  24613. /**
  24614. * Gets the vertex data
  24615. * @param kind The type of vertex data
  24616. * @returns A nullable array of numbers, or a float32 array
  24617. */
  24618. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  24619. /**
  24620. * Gets the indices from the mesh
  24621. * @returns A nullable array of index arrays
  24622. */
  24623. getIndices?(): Nullable<IndicesArray>;
  24624. /**
  24625. * Gets the scene from the mesh
  24626. * @returns the indices array or null
  24627. */
  24628. getScene?(): Scene;
  24629. /**
  24630. * Gets the absolute position from the mesh
  24631. * @returns the absolute position
  24632. */
  24633. getAbsolutePosition(): Vector3;
  24634. /**
  24635. * Gets the absolute pivot point from the mesh
  24636. * @returns the absolute pivot point
  24637. */
  24638. getAbsolutePivotPoint(): Vector3;
  24639. /**
  24640. * Rotates the mesh
  24641. * @param axis The axis of rotation
  24642. * @param amount The amount of rotation
  24643. * @param space The space of the rotation
  24644. * @returns The rotation transform node
  24645. */
  24646. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  24647. /**
  24648. * Translates the mesh
  24649. * @param axis The axis of translation
  24650. * @param distance The distance of translation
  24651. * @param space The space of the translation
  24652. * @returns The transform node
  24653. */
  24654. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  24655. /**
  24656. * Sets the absolute position of the mesh
  24657. * @param absolutePosition The absolute position of the mesh
  24658. * @returns The transform node
  24659. */
  24660. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  24661. /**
  24662. * Gets the class name of the mesh
  24663. * @returns The class name
  24664. */
  24665. getClassName(): string;
  24666. }
  24667. /**
  24668. * Represents a physics imposter
  24669. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24670. */
  24671. export class PhysicsImpostor {
  24672. /**
  24673. * The physics-enabled object used as the physics imposter
  24674. */
  24675. object: IPhysicsEnabledObject;
  24676. /**
  24677. * The type of the physics imposter
  24678. */
  24679. type: number;
  24680. private _options;
  24681. private _scene?;
  24682. /**
  24683. * The default object size of the imposter
  24684. */
  24685. static DEFAULT_OBJECT_SIZE: Vector3;
  24686. /**
  24687. * The identity quaternion of the imposter
  24688. */
  24689. static IDENTITY_QUATERNION: Quaternion;
  24690. /** @hidden */
  24691. _pluginData: any;
  24692. private _physicsEngine;
  24693. private _physicsBody;
  24694. private _bodyUpdateRequired;
  24695. private _onBeforePhysicsStepCallbacks;
  24696. private _onAfterPhysicsStepCallbacks;
  24697. /** @hidden */
  24698. _onPhysicsCollideCallbacks: Array<{
  24699. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  24700. otherImpostors: Array<PhysicsImpostor>;
  24701. }>;
  24702. private _deltaPosition;
  24703. private _deltaRotation;
  24704. private _deltaRotationConjugated;
  24705. /** @hidden */
  24706. _isFromLine: boolean;
  24707. private _parent;
  24708. private _isDisposed;
  24709. private static _tmpVecs;
  24710. private static _tmpQuat;
  24711. /**
  24712. * Specifies if the physics imposter is disposed
  24713. */
  24714. get isDisposed(): boolean;
  24715. /**
  24716. * Gets the mass of the physics imposter
  24717. */
  24718. get mass(): number;
  24719. set mass(value: number);
  24720. /**
  24721. * Gets the coefficient of friction
  24722. */
  24723. get friction(): number;
  24724. /**
  24725. * Sets the coefficient of friction
  24726. */
  24727. set friction(value: number);
  24728. /**
  24729. * Gets the coefficient of restitution
  24730. */
  24731. get restitution(): number;
  24732. /**
  24733. * Sets the coefficient of restitution
  24734. */
  24735. set restitution(value: number);
  24736. /**
  24737. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  24738. */
  24739. get pressure(): number;
  24740. /**
  24741. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  24742. */
  24743. set pressure(value: number);
  24744. /**
  24745. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  24746. */
  24747. get stiffness(): number;
  24748. /**
  24749. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  24750. */
  24751. set stiffness(value: number);
  24752. /**
  24753. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  24754. */
  24755. get velocityIterations(): number;
  24756. /**
  24757. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  24758. */
  24759. set velocityIterations(value: number);
  24760. /**
  24761. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  24762. */
  24763. get positionIterations(): number;
  24764. /**
  24765. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  24766. */
  24767. set positionIterations(value: number);
  24768. /**
  24769. * The unique id of the physics imposter
  24770. * set by the physics engine when adding this impostor to the array
  24771. */
  24772. uniqueId: number;
  24773. /**
  24774. * @hidden
  24775. */
  24776. soft: boolean;
  24777. /**
  24778. * @hidden
  24779. */
  24780. segments: number;
  24781. private _joints;
  24782. /**
  24783. * Initializes the physics imposter
  24784. * @param object The physics-enabled object used as the physics imposter
  24785. * @param type The type of the physics imposter
  24786. * @param _options The options for the physics imposter
  24787. * @param _scene The Babylon scene
  24788. */
  24789. constructor(
  24790. /**
  24791. * The physics-enabled object used as the physics imposter
  24792. */
  24793. object: IPhysicsEnabledObject,
  24794. /**
  24795. * The type of the physics imposter
  24796. */
  24797. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  24798. /**
  24799. * This function will completly initialize this impostor.
  24800. * It will create a new body - but only if this mesh has no parent.
  24801. * If it has, this impostor will not be used other than to define the impostor
  24802. * of the child mesh.
  24803. * @hidden
  24804. */
  24805. _init(): void;
  24806. private _getPhysicsParent;
  24807. /**
  24808. * Should a new body be generated.
  24809. * @returns boolean specifying if body initialization is required
  24810. */
  24811. isBodyInitRequired(): boolean;
  24812. /**
  24813. * Sets the updated scaling
  24814. * @param updated Specifies if the scaling is updated
  24815. */
  24816. setScalingUpdated(): void;
  24817. /**
  24818. * Force a regeneration of this or the parent's impostor's body.
  24819. * Use under cautious - This will remove all joints already implemented.
  24820. */
  24821. forceUpdate(): void;
  24822. /**
  24823. * Gets the body that holds this impostor. Either its own, or its parent.
  24824. */
  24825. get physicsBody(): any;
  24826. /**
  24827. * Get the parent of the physics imposter
  24828. * @returns Physics imposter or null
  24829. */
  24830. get parent(): Nullable<PhysicsImpostor>;
  24831. /**
  24832. * Sets the parent of the physics imposter
  24833. */
  24834. set parent(value: Nullable<PhysicsImpostor>);
  24835. /**
  24836. * Set the physics body. Used mainly by the physics engine/plugin
  24837. */
  24838. set physicsBody(physicsBody: any);
  24839. /**
  24840. * Resets the update flags
  24841. */
  24842. resetUpdateFlags(): void;
  24843. /**
  24844. * Gets the object extend size
  24845. * @returns the object extend size
  24846. */
  24847. getObjectExtendSize(): Vector3;
  24848. /**
  24849. * Gets the object center
  24850. * @returns The object center
  24851. */
  24852. getObjectCenter(): Vector3;
  24853. /**
  24854. * Get a specific parameter from the options parameters
  24855. * @param paramName The object parameter name
  24856. * @returns The object parameter
  24857. */
  24858. getParam(paramName: string): any;
  24859. /**
  24860. * Sets a specific parameter in the options given to the physics plugin
  24861. * @param paramName The parameter name
  24862. * @param value The value of the parameter
  24863. */
  24864. setParam(paramName: string, value: number): void;
  24865. /**
  24866. * Specifically change the body's mass option. Won't recreate the physics body object
  24867. * @param mass The mass of the physics imposter
  24868. */
  24869. setMass(mass: number): void;
  24870. /**
  24871. * Gets the linear velocity
  24872. * @returns linear velocity or null
  24873. */
  24874. getLinearVelocity(): Nullable<Vector3>;
  24875. /**
  24876. * Sets the linear velocity
  24877. * @param velocity linear velocity or null
  24878. */
  24879. setLinearVelocity(velocity: Nullable<Vector3>): void;
  24880. /**
  24881. * Gets the angular velocity
  24882. * @returns angular velocity or null
  24883. */
  24884. getAngularVelocity(): Nullable<Vector3>;
  24885. /**
  24886. * Sets the angular velocity
  24887. * @param velocity The velocity or null
  24888. */
  24889. setAngularVelocity(velocity: Nullable<Vector3>): void;
  24890. /**
  24891. * Execute a function with the physics plugin native code
  24892. * Provide a function the will have two variables - the world object and the physics body object
  24893. * @param func The function to execute with the physics plugin native code
  24894. */
  24895. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  24896. /**
  24897. * Register a function that will be executed before the physics world is stepping forward
  24898. * @param func The function to execute before the physics world is stepped forward
  24899. */
  24900. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24901. /**
  24902. * Unregister a function that will be executed before the physics world is stepping forward
  24903. * @param func The function to execute before the physics world is stepped forward
  24904. */
  24905. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24906. /**
  24907. * Register a function that will be executed after the physics step
  24908. * @param func The function to execute after physics step
  24909. */
  24910. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24911. /**
  24912. * Unregisters a function that will be executed after the physics step
  24913. * @param func The function to execute after physics step
  24914. */
  24915. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24916. /**
  24917. * register a function that will be executed when this impostor collides against a different body
  24918. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  24919. * @param func Callback that is executed on collision
  24920. */
  24921. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  24922. /**
  24923. * Unregisters the physics imposter on contact
  24924. * @param collideAgainst The physics object to collide against
  24925. * @param func Callback to execute on collision
  24926. */
  24927. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  24928. private _tmpQuat;
  24929. private _tmpQuat2;
  24930. /**
  24931. * Get the parent rotation
  24932. * @returns The parent rotation
  24933. */
  24934. getParentsRotation(): Quaternion;
  24935. /**
  24936. * this function is executed by the physics engine.
  24937. */
  24938. beforeStep: () => void;
  24939. /**
  24940. * this function is executed by the physics engine
  24941. */
  24942. afterStep: () => void;
  24943. /**
  24944. * Legacy collision detection event support
  24945. */
  24946. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  24947. /**
  24948. * event and body object due to cannon's event-based architecture.
  24949. */
  24950. onCollide: (e: {
  24951. body: any;
  24952. }) => void;
  24953. /**
  24954. * Apply a force
  24955. * @param force The force to apply
  24956. * @param contactPoint The contact point for the force
  24957. * @returns The physics imposter
  24958. */
  24959. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24960. /**
  24961. * Apply an impulse
  24962. * @param force The impulse force
  24963. * @param contactPoint The contact point for the impulse force
  24964. * @returns The physics imposter
  24965. */
  24966. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24967. /**
  24968. * A help function to create a joint
  24969. * @param otherImpostor A physics imposter used to create a joint
  24970. * @param jointType The type of joint
  24971. * @param jointData The data for the joint
  24972. * @returns The physics imposter
  24973. */
  24974. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  24975. /**
  24976. * Add a joint to this impostor with a different impostor
  24977. * @param otherImpostor A physics imposter used to add a joint
  24978. * @param joint The joint to add
  24979. * @returns The physics imposter
  24980. */
  24981. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  24982. /**
  24983. * Add an anchor to a cloth impostor
  24984. * @param otherImpostor rigid impostor to anchor to
  24985. * @param width ratio across width from 0 to 1
  24986. * @param height ratio up height from 0 to 1
  24987. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  24988. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  24989. * @returns impostor the soft imposter
  24990. */
  24991. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24992. /**
  24993. * Add a hook to a rope impostor
  24994. * @param otherImpostor rigid impostor to anchor to
  24995. * @param length ratio across rope from 0 to 1
  24996. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  24997. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  24998. * @returns impostor the rope imposter
  24999. */
  25000. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  25001. /**
  25002. * Will keep this body still, in a sleep mode.
  25003. * @returns the physics imposter
  25004. */
  25005. sleep(): PhysicsImpostor;
  25006. /**
  25007. * Wake the body up.
  25008. * @returns The physics imposter
  25009. */
  25010. wakeUp(): PhysicsImpostor;
  25011. /**
  25012. * Clones the physics imposter
  25013. * @param newObject The physics imposter clones to this physics-enabled object
  25014. * @returns A nullable physics imposter
  25015. */
  25016. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  25017. /**
  25018. * Disposes the physics imposter
  25019. */
  25020. dispose(): void;
  25021. /**
  25022. * Sets the delta position
  25023. * @param position The delta position amount
  25024. */
  25025. setDeltaPosition(position: Vector3): void;
  25026. /**
  25027. * Sets the delta rotation
  25028. * @param rotation The delta rotation amount
  25029. */
  25030. setDeltaRotation(rotation: Quaternion): void;
  25031. /**
  25032. * Gets the box size of the physics imposter and stores the result in the input parameter
  25033. * @param result Stores the box size
  25034. * @returns The physics imposter
  25035. */
  25036. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  25037. /**
  25038. * Gets the radius of the physics imposter
  25039. * @returns Radius of the physics imposter
  25040. */
  25041. getRadius(): number;
  25042. /**
  25043. * Sync a bone with this impostor
  25044. * @param bone The bone to sync to the impostor.
  25045. * @param boneMesh The mesh that the bone is influencing.
  25046. * @param jointPivot The pivot of the joint / bone in local space.
  25047. * @param distToJoint Optional distance from the impostor to the joint.
  25048. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  25049. */
  25050. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  25051. /**
  25052. * Sync impostor to a bone
  25053. * @param bone The bone that the impostor will be synced to.
  25054. * @param boneMesh The mesh that the bone is influencing.
  25055. * @param jointPivot The pivot of the joint / bone in local space.
  25056. * @param distToJoint Optional distance from the impostor to the joint.
  25057. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  25058. * @param boneAxis Optional vector3 axis the bone is aligned with
  25059. */
  25060. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  25061. /**
  25062. * No-Imposter type
  25063. */
  25064. static NoImpostor: number;
  25065. /**
  25066. * Sphere-Imposter type
  25067. */
  25068. static SphereImpostor: number;
  25069. /**
  25070. * Box-Imposter type
  25071. */
  25072. static BoxImpostor: number;
  25073. /**
  25074. * Plane-Imposter type
  25075. */
  25076. static PlaneImpostor: number;
  25077. /**
  25078. * Mesh-imposter type
  25079. */
  25080. static MeshImpostor: number;
  25081. /**
  25082. * Capsule-Impostor type (Ammo.js plugin only)
  25083. */
  25084. static CapsuleImpostor: number;
  25085. /**
  25086. * Cylinder-Imposter type
  25087. */
  25088. static CylinderImpostor: number;
  25089. /**
  25090. * Particle-Imposter type
  25091. */
  25092. static ParticleImpostor: number;
  25093. /**
  25094. * Heightmap-Imposter type
  25095. */
  25096. static HeightmapImpostor: number;
  25097. /**
  25098. * ConvexHull-Impostor type (Ammo.js plugin only)
  25099. */
  25100. static ConvexHullImpostor: number;
  25101. /**
  25102. * Custom-Imposter type (Ammo.js plugin only)
  25103. */
  25104. static CustomImpostor: number;
  25105. /**
  25106. * Rope-Imposter type
  25107. */
  25108. static RopeImpostor: number;
  25109. /**
  25110. * Cloth-Imposter type
  25111. */
  25112. static ClothImpostor: number;
  25113. /**
  25114. * Softbody-Imposter type
  25115. */
  25116. static SoftbodyImpostor: number;
  25117. }
  25118. }
  25119. declare module "babylonjs/Meshes/mesh" {
  25120. import { Observable } from "babylonjs/Misc/observable";
  25121. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  25122. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  25123. import { Camera } from "babylonjs/Cameras/camera";
  25124. import { Scene } from "babylonjs/scene";
  25125. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  25126. import { Color4 } from "babylonjs/Maths/math.color";
  25127. import { Engine } from "babylonjs/Engines/engine";
  25128. import { Node } from "babylonjs/node";
  25129. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  25130. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  25131. import { Buffer } from "babylonjs/Meshes/buffer";
  25132. import { Geometry } from "babylonjs/Meshes/geometry";
  25133. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25134. import { SubMesh } from "babylonjs/Meshes/subMesh";
  25135. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  25136. import { Effect } from "babylonjs/Materials/effect";
  25137. import { Material } from "babylonjs/Materials/material";
  25138. import { Skeleton } from "babylonjs/Bones/skeleton";
  25139. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  25140. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  25141. import { Path3D } from "babylonjs/Maths/math.path";
  25142. import { Plane } from "babylonjs/Maths/math.plane";
  25143. import { TransformNode } from "babylonjs/Meshes/transformNode";
  25144. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  25145. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  25146. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  25147. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  25148. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  25149. /**
  25150. * @hidden
  25151. **/
  25152. export class _CreationDataStorage {
  25153. closePath?: boolean;
  25154. closeArray?: boolean;
  25155. idx: number[];
  25156. dashSize: number;
  25157. gapSize: number;
  25158. path3D: Path3D;
  25159. pathArray: Vector3[][];
  25160. arc: number;
  25161. radius: number;
  25162. cap: number;
  25163. tessellation: number;
  25164. }
  25165. /**
  25166. * @hidden
  25167. **/
  25168. class _InstanceDataStorage {
  25169. visibleInstances: any;
  25170. batchCache: _InstancesBatch;
  25171. instancesBufferSize: number;
  25172. instancesBuffer: Nullable<Buffer>;
  25173. instancesData: Float32Array;
  25174. overridenInstanceCount: number;
  25175. isFrozen: boolean;
  25176. previousBatch: Nullable<_InstancesBatch>;
  25177. hardwareInstancedRendering: boolean;
  25178. sideOrientation: number;
  25179. manualUpdate: boolean;
  25180. }
  25181. /**
  25182. * @hidden
  25183. **/
  25184. export class _InstancesBatch {
  25185. mustReturn: boolean;
  25186. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  25187. renderSelf: boolean[];
  25188. hardwareInstancedRendering: boolean[];
  25189. }
  25190. /**
  25191. * Class used to represent renderable models
  25192. */
  25193. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  25194. /**
  25195. * Mesh side orientation : usually the external or front surface
  25196. */
  25197. static readonly FRONTSIDE: number;
  25198. /**
  25199. * Mesh side orientation : usually the internal or back surface
  25200. */
  25201. static readonly BACKSIDE: number;
  25202. /**
  25203. * Mesh side orientation : both internal and external or front and back surfaces
  25204. */
  25205. static readonly DOUBLESIDE: number;
  25206. /**
  25207. * Mesh side orientation : by default, `FRONTSIDE`
  25208. */
  25209. static readonly DEFAULTSIDE: number;
  25210. /**
  25211. * Mesh cap setting : no cap
  25212. */
  25213. static readonly NO_CAP: number;
  25214. /**
  25215. * Mesh cap setting : one cap at the beginning of the mesh
  25216. */
  25217. static readonly CAP_START: number;
  25218. /**
  25219. * Mesh cap setting : one cap at the end of the mesh
  25220. */
  25221. static readonly CAP_END: number;
  25222. /**
  25223. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  25224. */
  25225. static readonly CAP_ALL: number;
  25226. /**
  25227. * Mesh pattern setting : no flip or rotate
  25228. */
  25229. static readonly NO_FLIP: number;
  25230. /**
  25231. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  25232. */
  25233. static readonly FLIP_TILE: number;
  25234. /**
  25235. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  25236. */
  25237. static readonly ROTATE_TILE: number;
  25238. /**
  25239. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  25240. */
  25241. static readonly FLIP_ROW: number;
  25242. /**
  25243. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  25244. */
  25245. static readonly ROTATE_ROW: number;
  25246. /**
  25247. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  25248. */
  25249. static readonly FLIP_N_ROTATE_TILE: number;
  25250. /**
  25251. * Mesh pattern setting : rotate pattern and rotate
  25252. */
  25253. static readonly FLIP_N_ROTATE_ROW: number;
  25254. /**
  25255. * Mesh tile positioning : part tiles same on left/right or top/bottom
  25256. */
  25257. static readonly CENTER: number;
  25258. /**
  25259. * Mesh tile positioning : part tiles on left
  25260. */
  25261. static readonly LEFT: number;
  25262. /**
  25263. * Mesh tile positioning : part tiles on right
  25264. */
  25265. static readonly RIGHT: number;
  25266. /**
  25267. * Mesh tile positioning : part tiles on top
  25268. */
  25269. static readonly TOP: number;
  25270. /**
  25271. * Mesh tile positioning : part tiles on bottom
  25272. */
  25273. static readonly BOTTOM: number;
  25274. /**
  25275. * Gets the default side orientation.
  25276. * @param orientation the orientation to value to attempt to get
  25277. * @returns the default orientation
  25278. * @hidden
  25279. */
  25280. static _GetDefaultSideOrientation(orientation?: number): number;
  25281. private _internalMeshDataInfo;
  25282. /**
  25283. * An event triggered before rendering the mesh
  25284. */
  25285. get onBeforeRenderObservable(): Observable<Mesh>;
  25286. /**
  25287. * An event triggered before binding the mesh
  25288. */
  25289. get onBeforeBindObservable(): Observable<Mesh>;
  25290. /**
  25291. * An event triggered after rendering the mesh
  25292. */
  25293. get onAfterRenderObservable(): Observable<Mesh>;
  25294. /**
  25295. * An event triggered before drawing the mesh
  25296. */
  25297. get onBeforeDrawObservable(): Observable<Mesh>;
  25298. private _onBeforeDrawObserver;
  25299. /**
  25300. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  25301. */
  25302. set onBeforeDraw(callback: () => void);
  25303. get hasInstances(): boolean;
  25304. /**
  25305. * Gets the delay loading state of the mesh (when delay loading is turned on)
  25306. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  25307. */
  25308. delayLoadState: number;
  25309. /**
  25310. * Gets the list of instances created from this mesh
  25311. * it is not supposed to be modified manually.
  25312. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  25313. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  25314. */
  25315. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  25316. /**
  25317. * Gets the file containing delay loading data for this mesh
  25318. */
  25319. delayLoadingFile: string;
  25320. /** @hidden */
  25321. _binaryInfo: any;
  25322. /**
  25323. * User defined function used to change how LOD level selection is done
  25324. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  25325. */
  25326. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  25327. /**
  25328. * Gets or sets the morph target manager
  25329. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  25330. */
  25331. get morphTargetManager(): Nullable<MorphTargetManager>;
  25332. set morphTargetManager(value: Nullable<MorphTargetManager>);
  25333. /** @hidden */
  25334. _creationDataStorage: Nullable<_CreationDataStorage>;
  25335. /** @hidden */
  25336. _geometry: Nullable<Geometry>;
  25337. /** @hidden */
  25338. _delayInfo: Array<string>;
  25339. /** @hidden */
  25340. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  25341. /** @hidden */
  25342. _instanceDataStorage: _InstanceDataStorage;
  25343. private _effectiveMaterial;
  25344. /** @hidden */
  25345. _shouldGenerateFlatShading: boolean;
  25346. /** @hidden */
  25347. _originalBuilderSideOrientation: number;
  25348. /**
  25349. * Use this property to change the original side orientation defined at construction time
  25350. */
  25351. overrideMaterialSideOrientation: Nullable<number>;
  25352. /**
  25353. * Gets the source mesh (the one used to clone this one from)
  25354. */
  25355. get source(): Nullable<Mesh>;
  25356. /**
  25357. * Gets or sets a boolean indicating that this mesh does not use index buffer
  25358. */
  25359. get isUnIndexed(): boolean;
  25360. set isUnIndexed(value: boolean);
  25361. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  25362. get worldMatrixInstancedBuffer(): Float32Array;
  25363. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  25364. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  25365. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  25366. /**
  25367. * @constructor
  25368. * @param name The value used by scene.getMeshByName() to do a lookup.
  25369. * @param scene The scene to add this mesh to.
  25370. * @param parent The parent of this mesh, if it has one
  25371. * @param source An optional Mesh from which geometry is shared, cloned.
  25372. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  25373. * When false, achieved by calling a clone(), also passing False.
  25374. * This will make creation of children, recursive.
  25375. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  25376. */
  25377. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  25378. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  25379. doNotInstantiate: boolean;
  25380. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  25381. /**
  25382. * Gets the class name
  25383. * @returns the string "Mesh".
  25384. */
  25385. getClassName(): string;
  25386. /** @hidden */
  25387. get _isMesh(): boolean;
  25388. /**
  25389. * Returns a description of this mesh
  25390. * @param fullDetails define if full details about this mesh must be used
  25391. * @returns a descriptive string representing this mesh
  25392. */
  25393. toString(fullDetails?: boolean): string;
  25394. /** @hidden */
  25395. _unBindEffect(): void;
  25396. /**
  25397. * Gets a boolean indicating if this mesh has LOD
  25398. */
  25399. get hasLODLevels(): boolean;
  25400. /**
  25401. * Gets the list of MeshLODLevel associated with the current mesh
  25402. * @returns an array of MeshLODLevel
  25403. */
  25404. getLODLevels(): MeshLODLevel[];
  25405. private _sortLODLevels;
  25406. /**
  25407. * Add a mesh as LOD level triggered at the given distance.
  25408. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  25409. * @param distance The distance from the center of the object to show this level
  25410. * @param mesh The mesh to be added as LOD level (can be null)
  25411. * @return This mesh (for chaining)
  25412. */
  25413. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  25414. /**
  25415. * Returns the LOD level mesh at the passed distance or null if not found.
  25416. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  25417. * @param distance The distance from the center of the object to show this level
  25418. * @returns a Mesh or `null`
  25419. */
  25420. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  25421. /**
  25422. * Remove a mesh from the LOD array
  25423. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  25424. * @param mesh defines the mesh to be removed
  25425. * @return This mesh (for chaining)
  25426. */
  25427. removeLODLevel(mesh: Mesh): Mesh;
  25428. /**
  25429. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  25430. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  25431. * @param camera defines the camera to use to compute distance
  25432. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  25433. * @return This mesh (for chaining)
  25434. */
  25435. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  25436. /**
  25437. * Gets the mesh internal Geometry object
  25438. */
  25439. get geometry(): Nullable<Geometry>;
  25440. /**
  25441. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  25442. * @returns the total number of vertices
  25443. */
  25444. getTotalVertices(): number;
  25445. /**
  25446. * Returns the content of an associated vertex buffer
  25447. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  25448. * - VertexBuffer.PositionKind
  25449. * - VertexBuffer.UVKind
  25450. * - VertexBuffer.UV2Kind
  25451. * - VertexBuffer.UV3Kind
  25452. * - VertexBuffer.UV4Kind
  25453. * - VertexBuffer.UV5Kind
  25454. * - VertexBuffer.UV6Kind
  25455. * - VertexBuffer.ColorKind
  25456. * - VertexBuffer.MatricesIndicesKind
  25457. * - VertexBuffer.MatricesIndicesExtraKind
  25458. * - VertexBuffer.MatricesWeightsKind
  25459. * - VertexBuffer.MatricesWeightsExtraKind
  25460. * @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
  25461. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  25462. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  25463. */
  25464. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  25465. /**
  25466. * Returns the mesh VertexBuffer object from the requested `kind`
  25467. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  25468. * - VertexBuffer.PositionKind
  25469. * - VertexBuffer.NormalKind
  25470. * - VertexBuffer.UVKind
  25471. * - VertexBuffer.UV2Kind
  25472. * - VertexBuffer.UV3Kind
  25473. * - VertexBuffer.UV4Kind
  25474. * - VertexBuffer.UV5Kind
  25475. * - VertexBuffer.UV6Kind
  25476. * - VertexBuffer.ColorKind
  25477. * - VertexBuffer.MatricesIndicesKind
  25478. * - VertexBuffer.MatricesIndicesExtraKind
  25479. * - VertexBuffer.MatricesWeightsKind
  25480. * - VertexBuffer.MatricesWeightsExtraKind
  25481. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  25482. */
  25483. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  25484. /**
  25485. * Tests if a specific vertex buffer is associated with this mesh
  25486. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  25487. * - VertexBuffer.PositionKind
  25488. * - VertexBuffer.NormalKind
  25489. * - VertexBuffer.UVKind
  25490. * - VertexBuffer.UV2Kind
  25491. * - VertexBuffer.UV3Kind
  25492. * - VertexBuffer.UV4Kind
  25493. * - VertexBuffer.UV5Kind
  25494. * - VertexBuffer.UV6Kind
  25495. * - VertexBuffer.ColorKind
  25496. * - VertexBuffer.MatricesIndicesKind
  25497. * - VertexBuffer.MatricesIndicesExtraKind
  25498. * - VertexBuffer.MatricesWeightsKind
  25499. * - VertexBuffer.MatricesWeightsExtraKind
  25500. * @returns a boolean
  25501. */
  25502. isVerticesDataPresent(kind: string): boolean;
  25503. /**
  25504. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  25505. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  25506. * - VertexBuffer.PositionKind
  25507. * - VertexBuffer.UVKind
  25508. * - VertexBuffer.UV2Kind
  25509. * - VertexBuffer.UV3Kind
  25510. * - VertexBuffer.UV4Kind
  25511. * - VertexBuffer.UV5Kind
  25512. * - VertexBuffer.UV6Kind
  25513. * - VertexBuffer.ColorKind
  25514. * - VertexBuffer.MatricesIndicesKind
  25515. * - VertexBuffer.MatricesIndicesExtraKind
  25516. * - VertexBuffer.MatricesWeightsKind
  25517. * - VertexBuffer.MatricesWeightsExtraKind
  25518. * @returns a boolean
  25519. */
  25520. isVertexBufferUpdatable(kind: string): boolean;
  25521. /**
  25522. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  25523. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  25524. * - VertexBuffer.PositionKind
  25525. * - VertexBuffer.NormalKind
  25526. * - VertexBuffer.UVKind
  25527. * - VertexBuffer.UV2Kind
  25528. * - VertexBuffer.UV3Kind
  25529. * - VertexBuffer.UV4Kind
  25530. * - VertexBuffer.UV5Kind
  25531. * - VertexBuffer.UV6Kind
  25532. * - VertexBuffer.ColorKind
  25533. * - VertexBuffer.MatricesIndicesKind
  25534. * - VertexBuffer.MatricesIndicesExtraKind
  25535. * - VertexBuffer.MatricesWeightsKind
  25536. * - VertexBuffer.MatricesWeightsExtraKind
  25537. * @returns an array of strings
  25538. */
  25539. getVerticesDataKinds(): string[];
  25540. /**
  25541. * Returns a positive integer : the total number of indices in this mesh geometry.
  25542. * @returns the numner of indices or zero if the mesh has no geometry.
  25543. */
  25544. getTotalIndices(): number;
  25545. /**
  25546. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  25547. * @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.
  25548. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25549. * @returns the indices array or an empty array if the mesh has no geometry
  25550. */
  25551. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  25552. get isBlocked(): boolean;
  25553. /**
  25554. * Determine if the current mesh is ready to be rendered
  25555. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  25556. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  25557. * @returns true if all associated assets are ready (material, textures, shaders)
  25558. */
  25559. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  25560. /**
  25561. * 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.
  25562. */
  25563. get areNormalsFrozen(): boolean;
  25564. /**
  25565. * 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.
  25566. * @returns the current mesh
  25567. */
  25568. freezeNormals(): Mesh;
  25569. /**
  25570. * 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
  25571. * @returns the current mesh
  25572. */
  25573. unfreezeNormals(): Mesh;
  25574. /**
  25575. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  25576. */
  25577. set overridenInstanceCount(count: number);
  25578. /** @hidden */
  25579. _preActivate(): Mesh;
  25580. /** @hidden */
  25581. _preActivateForIntermediateRendering(renderId: number): Mesh;
  25582. /** @hidden */
  25583. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  25584. /**
  25585. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  25586. * This means the mesh underlying bounding box and sphere are recomputed.
  25587. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  25588. * @returns the current mesh
  25589. */
  25590. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  25591. /** @hidden */
  25592. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  25593. /**
  25594. * This function will subdivide the mesh into multiple submeshes
  25595. * @param count defines the expected number of submeshes
  25596. */
  25597. subdivide(count: number): void;
  25598. /**
  25599. * Copy a FloatArray into a specific associated vertex buffer
  25600. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  25601. * - VertexBuffer.PositionKind
  25602. * - VertexBuffer.UVKind
  25603. * - VertexBuffer.UV2Kind
  25604. * - VertexBuffer.UV3Kind
  25605. * - VertexBuffer.UV4Kind
  25606. * - VertexBuffer.UV5Kind
  25607. * - VertexBuffer.UV6Kind
  25608. * - VertexBuffer.ColorKind
  25609. * - VertexBuffer.MatricesIndicesKind
  25610. * - VertexBuffer.MatricesIndicesExtraKind
  25611. * - VertexBuffer.MatricesWeightsKind
  25612. * - VertexBuffer.MatricesWeightsExtraKind
  25613. * @param data defines the data source
  25614. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  25615. * @param stride defines the data stride size (can be null)
  25616. * @returns the current mesh
  25617. */
  25618. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  25619. /**
  25620. * Delete a vertex buffer associated with this mesh
  25621. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  25622. * - VertexBuffer.PositionKind
  25623. * - VertexBuffer.UVKind
  25624. * - VertexBuffer.UV2Kind
  25625. * - VertexBuffer.UV3Kind
  25626. * - VertexBuffer.UV4Kind
  25627. * - VertexBuffer.UV5Kind
  25628. * - VertexBuffer.UV6Kind
  25629. * - VertexBuffer.ColorKind
  25630. * - VertexBuffer.MatricesIndicesKind
  25631. * - VertexBuffer.MatricesIndicesExtraKind
  25632. * - VertexBuffer.MatricesWeightsKind
  25633. * - VertexBuffer.MatricesWeightsExtraKind
  25634. */
  25635. removeVerticesData(kind: string): void;
  25636. /**
  25637. * Flags an associated vertex buffer as updatable
  25638. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  25639. * - VertexBuffer.PositionKind
  25640. * - VertexBuffer.UVKind
  25641. * - VertexBuffer.UV2Kind
  25642. * - VertexBuffer.UV3Kind
  25643. * - VertexBuffer.UV4Kind
  25644. * - VertexBuffer.UV5Kind
  25645. * - VertexBuffer.UV6Kind
  25646. * - VertexBuffer.ColorKind
  25647. * - VertexBuffer.MatricesIndicesKind
  25648. * - VertexBuffer.MatricesIndicesExtraKind
  25649. * - VertexBuffer.MatricesWeightsKind
  25650. * - VertexBuffer.MatricesWeightsExtraKind
  25651. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  25652. */
  25653. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  25654. /**
  25655. * Sets the mesh global Vertex Buffer
  25656. * @param buffer defines the buffer to use
  25657. * @returns the current mesh
  25658. */
  25659. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  25660. /**
  25661. * Update a specific associated vertex buffer
  25662. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  25663. * - VertexBuffer.PositionKind
  25664. * - VertexBuffer.UVKind
  25665. * - VertexBuffer.UV2Kind
  25666. * - VertexBuffer.UV3Kind
  25667. * - VertexBuffer.UV4Kind
  25668. * - VertexBuffer.UV5Kind
  25669. * - VertexBuffer.UV6Kind
  25670. * - VertexBuffer.ColorKind
  25671. * - VertexBuffer.MatricesIndicesKind
  25672. * - VertexBuffer.MatricesIndicesExtraKind
  25673. * - VertexBuffer.MatricesWeightsKind
  25674. * - VertexBuffer.MatricesWeightsExtraKind
  25675. * @param data defines the data source
  25676. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  25677. * @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)
  25678. * @returns the current mesh
  25679. */
  25680. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  25681. /**
  25682. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  25683. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  25684. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  25685. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  25686. * @returns the current mesh
  25687. */
  25688. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  25689. /**
  25690. * Creates a un-shared specific occurence of the geometry for the mesh.
  25691. * @returns the current mesh
  25692. */
  25693. makeGeometryUnique(): Mesh;
  25694. /**
  25695. * Set the index buffer of this mesh
  25696. * @param indices defines the source data
  25697. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  25698. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  25699. * @returns the current mesh
  25700. */
  25701. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  25702. /**
  25703. * Update the current index buffer
  25704. * @param indices defines the source data
  25705. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  25706. * @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)
  25707. * @returns the current mesh
  25708. */
  25709. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  25710. /**
  25711. * Invert the geometry to move from a right handed system to a left handed one.
  25712. * @returns the current mesh
  25713. */
  25714. toLeftHanded(): Mesh;
  25715. /** @hidden */
  25716. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  25717. /** @hidden */
  25718. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  25719. /**
  25720. * Registers for this mesh a javascript function called just before the rendering process
  25721. * @param func defines the function to call before rendering this mesh
  25722. * @returns the current mesh
  25723. */
  25724. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  25725. /**
  25726. * Disposes a previously registered javascript function called before the rendering
  25727. * @param func defines the function to remove
  25728. * @returns the current mesh
  25729. */
  25730. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  25731. /**
  25732. * Registers for this mesh a javascript function called just after the rendering is complete
  25733. * @param func defines the function to call after rendering this mesh
  25734. * @returns the current mesh
  25735. */
  25736. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  25737. /**
  25738. * Disposes a previously registered javascript function called after the rendering.
  25739. * @param func defines the function to remove
  25740. * @returns the current mesh
  25741. */
  25742. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  25743. /** @hidden */
  25744. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  25745. /** @hidden */
  25746. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  25747. /** @hidden */
  25748. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  25749. /** @hidden */
  25750. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  25751. /** @hidden */
  25752. _rebuild(): void;
  25753. /** @hidden */
  25754. _freeze(): void;
  25755. /** @hidden */
  25756. _unFreeze(): void;
  25757. /**
  25758. * 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
  25759. * @param subMesh defines the subMesh to render
  25760. * @param enableAlphaMode defines if alpha mode can be changed
  25761. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  25762. * @returns the current mesh
  25763. */
  25764. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  25765. private _onBeforeDraw;
  25766. /**
  25767. * Renormalize the mesh and patch it up if there are no weights
  25768. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  25769. * However in the case of zero weights then we set just a single influence to 1.
  25770. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  25771. */
  25772. cleanMatrixWeights(): void;
  25773. private normalizeSkinFourWeights;
  25774. private normalizeSkinWeightsAndExtra;
  25775. /**
  25776. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  25777. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  25778. * the user know there was an issue with importing the mesh
  25779. * @returns a validation object with skinned, valid and report string
  25780. */
  25781. validateSkinning(): {
  25782. skinned: boolean;
  25783. valid: boolean;
  25784. report: string;
  25785. };
  25786. /** @hidden */
  25787. _checkDelayState(): Mesh;
  25788. private _queueLoad;
  25789. /**
  25790. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  25791. * A mesh is in the frustum if its bounding box intersects the frustum
  25792. * @param frustumPlanes defines the frustum to test
  25793. * @returns true if the mesh is in the frustum planes
  25794. */
  25795. isInFrustum(frustumPlanes: Plane[]): boolean;
  25796. /**
  25797. * Sets the mesh material by the material or multiMaterial `id` property
  25798. * @param id is a string identifying the material or the multiMaterial
  25799. * @returns the current mesh
  25800. */
  25801. setMaterialByID(id: string): Mesh;
  25802. /**
  25803. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  25804. * @returns an array of IAnimatable
  25805. */
  25806. getAnimatables(): IAnimatable[];
  25807. /**
  25808. * Modifies the mesh geometry according to the passed transformation matrix.
  25809. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  25810. * The mesh normals are modified using the same transformation.
  25811. * Note that, under the hood, this method sets a new VertexBuffer each call.
  25812. * @param transform defines the transform matrix to use
  25813. * @see http://doc.babylonjs.com/resources/baking_transformations
  25814. * @returns the current mesh
  25815. */
  25816. bakeTransformIntoVertices(transform: Matrix): Mesh;
  25817. /**
  25818. * Modifies the mesh geometry according to its own current World Matrix.
  25819. * The mesh World Matrix is then reset.
  25820. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  25821. * Note that, under the hood, this method sets a new VertexBuffer each call.
  25822. * @see http://doc.babylonjs.com/resources/baking_transformations
  25823. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  25824. * @returns the current mesh
  25825. */
  25826. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  25827. /** @hidden */
  25828. get _positions(): Nullable<Vector3[]>;
  25829. /** @hidden */
  25830. _resetPointsArrayCache(): Mesh;
  25831. /** @hidden */
  25832. _generatePointsArray(): boolean;
  25833. /**
  25834. * Returns a new Mesh object generated from the current mesh properties.
  25835. * This method must not get confused with createInstance()
  25836. * @param name is a string, the name given to the new mesh
  25837. * @param newParent can be any Node object (default `null`)
  25838. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  25839. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  25840. * @returns a new mesh
  25841. */
  25842. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  25843. /**
  25844. * Releases resources associated with this mesh.
  25845. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25846. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25847. */
  25848. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25849. /** @hidden */
  25850. _disposeInstanceSpecificData(): void;
  25851. /**
  25852. * Modifies the mesh geometry according to a displacement map.
  25853. * 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.
  25854. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  25855. * @param url is a string, the URL from the image file is to be downloaded.
  25856. * @param minHeight is the lower limit of the displacement.
  25857. * @param maxHeight is the upper limit of the displacement.
  25858. * @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.
  25859. * @param uvOffset is an optional vector2 used to offset UV.
  25860. * @param uvScale is an optional vector2 used to scale UV.
  25861. * @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.
  25862. * @returns the Mesh.
  25863. */
  25864. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  25865. /**
  25866. * Modifies the mesh geometry according to a displacementMap buffer.
  25867. * 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.
  25868. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  25869. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  25870. * @param heightMapWidth is the width of the buffer image.
  25871. * @param heightMapHeight is the height of the buffer image.
  25872. * @param minHeight is the lower limit of the displacement.
  25873. * @param maxHeight is the upper limit of the displacement.
  25874. * @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.
  25875. * @param uvOffset is an optional vector2 used to offset UV.
  25876. * @param uvScale is an optional vector2 used to scale UV.
  25877. * @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.
  25878. * @returns the Mesh.
  25879. */
  25880. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  25881. /**
  25882. * Modify the mesh to get a flat shading rendering.
  25883. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  25884. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  25885. * @returns current mesh
  25886. */
  25887. convertToFlatShadedMesh(): Mesh;
  25888. /**
  25889. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  25890. * In other words, more vertices, no more indices and a single bigger VBO.
  25891. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  25892. * @returns current mesh
  25893. */
  25894. convertToUnIndexedMesh(): Mesh;
  25895. /**
  25896. * Inverses facet orientations.
  25897. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25898. * @param flipNormals will also inverts the normals
  25899. * @returns current mesh
  25900. */
  25901. flipFaces(flipNormals?: boolean): Mesh;
  25902. /**
  25903. * Increase the number of facets and hence vertices in a mesh
  25904. * Vertex normals are interpolated from existing vertex normals
  25905. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25906. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  25907. */
  25908. increaseVertices(numberPerEdge: number): void;
  25909. /**
  25910. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  25911. * This will undo any application of covertToFlatShadedMesh
  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. */
  25914. forceSharedVertices(): void;
  25915. /** @hidden */
  25916. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  25917. /** @hidden */
  25918. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  25919. /**
  25920. * Creates a new InstancedMesh object from the mesh model.
  25921. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  25922. * @param name defines the name of the new instance
  25923. * @returns a new InstancedMesh
  25924. */
  25925. createInstance(name: string): InstancedMesh;
  25926. /**
  25927. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  25928. * After this call, all the mesh instances have the same submeshes than the current mesh.
  25929. * @returns the current mesh
  25930. */
  25931. synchronizeInstances(): Mesh;
  25932. /**
  25933. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  25934. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  25935. * This should be used together with the simplification to avoid disappearing triangles.
  25936. * @param successCallback an optional success callback to be called after the optimization finished.
  25937. * @returns the current mesh
  25938. */
  25939. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  25940. /**
  25941. * Serialize current mesh
  25942. * @param serializationObject defines the object which will receive the serialization data
  25943. */
  25944. serialize(serializationObject: any): void;
  25945. /** @hidden */
  25946. _syncGeometryWithMorphTargetManager(): void;
  25947. /** @hidden */
  25948. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  25949. /**
  25950. * Returns a new Mesh object parsed from the source provided.
  25951. * @param parsedMesh is the source
  25952. * @param scene defines the hosting scene
  25953. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  25954. * @returns a new Mesh
  25955. */
  25956. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  25957. /**
  25958. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  25959. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25960. * @param name defines the name of the mesh to create
  25961. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  25962. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  25963. * @param closePath creates a seam between the first and the last points of each path of the path array
  25964. * @param offset is taken in account only if the `pathArray` is containing a single path
  25965. * @param scene defines the hosting scene
  25966. * @param updatable defines if the mesh must be flagged as updatable
  25967. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25968. * @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)
  25969. * @returns a new Mesh
  25970. */
  25971. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25972. /**
  25973. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  25974. * @param name defines the name of the mesh to create
  25975. * @param radius sets the radius size (float) of the polygon (default 0.5)
  25976. * @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
  25977. * @param scene defines the hosting scene
  25978. * @param updatable defines if the mesh must be flagged as updatable
  25979. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25980. * @returns a new Mesh
  25981. */
  25982. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25983. /**
  25984. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  25985. * @param name defines the name of the mesh to create
  25986. * @param size sets the size (float) of each box side (default 1)
  25987. * @param scene defines the hosting scene
  25988. * @param updatable defines if the mesh must be flagged as updatable
  25989. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25990. * @returns a new Mesh
  25991. */
  25992. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25993. /**
  25994. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  25995. * @param name defines the name of the mesh to create
  25996. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25997. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25998. * @param scene defines the hosting scene
  25999. * @param updatable defines if the mesh must be flagged as updatable
  26000. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26001. * @returns a new Mesh
  26002. */
  26003. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  26004. /**
  26005. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  26006. * @param name defines the name of the mesh to create
  26007. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  26008. * @param diameter sets the diameter size (float) of the sphere (default 1)
  26009. * @param scene defines the hosting scene
  26010. * @returns a new Mesh
  26011. */
  26012. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  26013. /**
  26014. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  26015. * @param name defines the name of the mesh to create
  26016. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  26017. * @param diameterTop set the top cap diameter (floats, default 1)
  26018. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  26019. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  26020. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  26021. * @param scene defines the hosting scene
  26022. * @param updatable defines if the mesh must be flagged as updatable
  26023. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26024. * @returns a new Mesh
  26025. */
  26026. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  26027. /**
  26028. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  26029. * @param name defines the name of the mesh to create
  26030. * @param diameter sets the diameter size (float) of the torus (default 1)
  26031. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  26032. * @param tessellation sets the number of torus sides (postive integer, default 16)
  26033. * @param scene defines the hosting scene
  26034. * @param updatable defines if the mesh must be flagged as updatable
  26035. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26036. * @returns a new Mesh
  26037. */
  26038. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  26039. /**
  26040. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  26041. * @param name defines the name of the mesh to create
  26042. * @param radius sets the global radius size (float) of the torus knot (default 2)
  26043. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  26044. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  26045. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  26046. * @param p the number of windings on X axis (positive integers, default 2)
  26047. * @param q the number of windings on Y axis (positive integers, default 3)
  26048. * @param scene defines the hosting scene
  26049. * @param updatable defines if the mesh must be flagged as updatable
  26050. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26051. * @returns a new Mesh
  26052. */
  26053. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  26054. /**
  26055. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  26056. * @param name defines the name of the mesh to create
  26057. * @param points is an array successive Vector3
  26058. * @param scene defines the hosting scene
  26059. * @param updatable defines if the mesh must be flagged as updatable
  26060. * @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).
  26061. * @returns a new Mesh
  26062. */
  26063. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  26064. /**
  26065. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  26066. * @param name defines the name of the mesh to create
  26067. * @param points is an array successive Vector3
  26068. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  26069. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  26070. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  26071. * @param scene defines the hosting scene
  26072. * @param updatable defines if the mesh must be flagged as updatable
  26073. * @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)
  26074. * @returns a new Mesh
  26075. */
  26076. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  26077. /**
  26078. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  26079. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  26080. * 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.
  26081. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26082. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  26083. * Remember you can only change the shape positions, not their number when updating a polygon.
  26084. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  26085. * @param name defines the name of the mesh to create
  26086. * @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
  26087. * @param scene defines the hosting scene
  26088. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  26089. * @param updatable defines if the mesh must be flagged as updatable
  26090. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26091. * @param earcutInjection can be used to inject your own earcut reference
  26092. * @returns a new Mesh
  26093. */
  26094. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  26095. /**
  26096. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  26097. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  26098. * @param name defines the name of the mesh to create
  26099. * @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
  26100. * @param depth defines the height of extrusion
  26101. * @param scene defines the hosting scene
  26102. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  26103. * @param updatable defines if the mesh must be flagged as updatable
  26104. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26105. * @param earcutInjection can be used to inject your own earcut reference
  26106. * @returns a new Mesh
  26107. */
  26108. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  26109. /**
  26110. * Creates an extruded shape mesh.
  26111. * 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
  26112. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  26113. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  26114. * @param name defines the name of the mesh to create
  26115. * @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
  26116. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  26117. * @param scale is the value to scale the shape
  26118. * @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
  26119. * @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
  26120. * @param scene defines the hosting scene
  26121. * @param updatable defines if the mesh must be flagged as updatable
  26122. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26123. * @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)
  26124. * @returns a new Mesh
  26125. */
  26126. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  26127. /**
  26128. * Creates an custom extruded shape mesh.
  26129. * The custom extrusion is a parametric shape.
  26130. * It has no predefined shape. Its final shape will depend on the input parameters.
  26131. * Please consider using the same method from the MeshBuilder class instead
  26132. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  26133. * @param name defines the name of the mesh to create
  26134. * @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
  26135. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  26136. * @param scaleFunction is a custom Javascript function called on each path point
  26137. * @param rotationFunction is a custom Javascript function called on each path point
  26138. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  26139. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  26140. * @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
  26141. * @param scene defines the hosting scene
  26142. * @param updatable defines if the mesh must be flagged as updatable
  26143. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26144. * @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)
  26145. * @returns a new Mesh
  26146. */
  26147. 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;
  26148. /**
  26149. * Creates lathe mesh.
  26150. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  26151. * Please consider using the same method from the MeshBuilder class instead
  26152. * @param name defines the name of the mesh to create
  26153. * @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
  26154. * @param radius is the radius value of the lathe
  26155. * @param tessellation is the side number of the lathe.
  26156. * @param scene defines the hosting scene
  26157. * @param updatable defines if the mesh must be flagged as updatable
  26158. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26159. * @returns a new Mesh
  26160. */
  26161. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  26162. /**
  26163. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  26164. * @param name defines the name of the mesh to create
  26165. * @param size sets the size (float) of both sides of the plane at once (default 1)
  26166. * @param scene defines the hosting scene
  26167. * @param updatable defines if the mesh must be flagged as updatable
  26168. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26169. * @returns a new Mesh
  26170. */
  26171. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  26172. /**
  26173. * Creates a ground mesh.
  26174. * Please consider using the same method from the MeshBuilder class instead
  26175. * @param name defines the name of the mesh to create
  26176. * @param width set the width of the ground
  26177. * @param height set the height of the ground
  26178. * @param subdivisions sets the number of subdivisions per side
  26179. * @param scene defines the hosting scene
  26180. * @param updatable defines if the mesh must be flagged as updatable
  26181. * @returns a new Mesh
  26182. */
  26183. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  26184. /**
  26185. * Creates a tiled ground mesh.
  26186. * Please consider using the same method from the MeshBuilder class instead
  26187. * @param name defines the name of the mesh to create
  26188. * @param xmin set the ground minimum X coordinate
  26189. * @param zmin set the ground minimum Y coordinate
  26190. * @param xmax set the ground maximum X coordinate
  26191. * @param zmax set the ground maximum Z coordinate
  26192. * @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
  26193. * @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
  26194. * @param scene defines the hosting scene
  26195. * @param updatable defines if the mesh must be flagged as updatable
  26196. * @returns a new Mesh
  26197. */
  26198. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  26199. w: number;
  26200. h: number;
  26201. }, precision: {
  26202. w: number;
  26203. h: number;
  26204. }, scene: Scene, updatable?: boolean): Mesh;
  26205. /**
  26206. * Creates a ground mesh from a height map.
  26207. * Please consider using the same method from the MeshBuilder class instead
  26208. * @see http://doc.babylonjs.com/babylon101/height_map
  26209. * @param name defines the name of the mesh to create
  26210. * @param url sets the URL of the height map image resource
  26211. * @param width set the ground width size
  26212. * @param height set the ground height size
  26213. * @param subdivisions sets the number of subdivision per side
  26214. * @param minHeight is the minimum altitude on the ground
  26215. * @param maxHeight is the maximum altitude on the ground
  26216. * @param scene defines the hosting scene
  26217. * @param updatable defines if the mesh must be flagged as updatable
  26218. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  26219. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  26220. * @returns a new Mesh
  26221. */
  26222. 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;
  26223. /**
  26224. * Creates a tube mesh.
  26225. * The tube is a parametric shape.
  26226. * It has no predefined shape. Its final shape will depend on the input parameters.
  26227. * Please consider using the same method from the MeshBuilder class instead
  26228. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  26229. * @param name defines the name of the mesh to create
  26230. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  26231. * @param radius sets the tube radius size
  26232. * @param tessellation is the number of sides on the tubular surface
  26233. * @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
  26234. * @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
  26235. * @param scene defines the hosting scene
  26236. * @param updatable defines if the mesh must be flagged as updatable
  26237. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26238. * @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)
  26239. * @returns a new Mesh
  26240. */
  26241. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  26242. (i: number, distance: number): number;
  26243. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  26244. /**
  26245. * Creates a polyhedron mesh.
  26246. * Please consider using the same method from the MeshBuilder class instead.
  26247. * * 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
  26248. * * The parameter `size` (positive float, default 1) sets the polygon size
  26249. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  26250. * * 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`
  26251. * * 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
  26252. * * 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)`)
  26253. * * 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
  26254. * * 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
  26255. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26256. * * If you create a double-sided mesh, you can choose what parts of 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
  26257. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  26258. * @param name defines the name of the mesh to create
  26259. * @param options defines the options used to create the mesh
  26260. * @param scene defines the hosting scene
  26261. * @returns a new Mesh
  26262. */
  26263. static CreatePolyhedron(name: string, options: {
  26264. type?: number;
  26265. size?: number;
  26266. sizeX?: number;
  26267. sizeY?: number;
  26268. sizeZ?: number;
  26269. custom?: any;
  26270. faceUV?: Vector4[];
  26271. faceColors?: Color4[];
  26272. updatable?: boolean;
  26273. sideOrientation?: number;
  26274. }, scene: Scene): Mesh;
  26275. /**
  26276. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  26277. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  26278. * * 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`)
  26279. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  26280. * * 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
  26281. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26282. * * If you create a double-sided mesh, you can choose what parts of 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
  26283. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  26284. * @param name defines the name of the mesh
  26285. * @param options defines the options used to create the mesh
  26286. * @param scene defines the hosting scene
  26287. * @returns a new Mesh
  26288. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  26289. */
  26290. static CreateIcoSphere(name: string, options: {
  26291. radius?: number;
  26292. flat?: boolean;
  26293. subdivisions?: number;
  26294. sideOrientation?: number;
  26295. updatable?: boolean;
  26296. }, scene: Scene): Mesh;
  26297. /**
  26298. * Creates a decal mesh.
  26299. * Please consider using the same method from the MeshBuilder class instead.
  26300. * A decal is a mesh usually applied as a model onto the surface of another mesh
  26301. * @param name defines the name of the mesh
  26302. * @param sourceMesh defines the mesh receiving the decal
  26303. * @param position sets the position of the decal in world coordinates
  26304. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  26305. * @param size sets the decal scaling
  26306. * @param angle sets the angle to rotate the decal
  26307. * @returns a new Mesh
  26308. */
  26309. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  26310. /**
  26311. * Prepare internal position array for software CPU skinning
  26312. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  26313. */
  26314. setPositionsForCPUSkinning(): Float32Array;
  26315. /**
  26316. * Prepare internal normal array for software CPU skinning
  26317. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  26318. */
  26319. setNormalsForCPUSkinning(): Float32Array;
  26320. /**
  26321. * Updates the vertex buffer by applying transformation from the bones
  26322. * @param skeleton defines the skeleton to apply to current mesh
  26323. * @returns the current mesh
  26324. */
  26325. applySkeleton(skeleton: Skeleton): Mesh;
  26326. /**
  26327. * 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
  26328. * @param meshes defines the list of meshes to scan
  26329. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  26330. */
  26331. static MinMax(meshes: AbstractMesh[]): {
  26332. min: Vector3;
  26333. max: Vector3;
  26334. };
  26335. /**
  26336. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  26337. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  26338. * @returns a vector3
  26339. */
  26340. static Center(meshesOrMinMaxVector: {
  26341. min: Vector3;
  26342. max: Vector3;
  26343. } | AbstractMesh[]): Vector3;
  26344. /**
  26345. * Merge the array of meshes into a single mesh for performance reasons.
  26346. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  26347. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  26348. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  26349. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  26350. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  26351. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  26352. * @returns a new mesh
  26353. */
  26354. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  26355. /** @hidden */
  26356. addInstance(instance: InstancedMesh): void;
  26357. /** @hidden */
  26358. removeInstance(instance: InstancedMesh): void;
  26359. }
  26360. }
  26361. declare module "babylonjs/Cameras/camera" {
  26362. import { SmartArray } from "babylonjs/Misc/smartArray";
  26363. import { Observable } from "babylonjs/Misc/observable";
  26364. import { Nullable } from "babylonjs/types";
  26365. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  26366. import { Scene } from "babylonjs/scene";
  26367. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  26368. import { Node } from "babylonjs/node";
  26369. import { Mesh } from "babylonjs/Meshes/mesh";
  26370. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26371. import { ICullable } from "babylonjs/Culling/boundingInfo";
  26372. import { Viewport } from "babylonjs/Maths/math.viewport";
  26373. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  26374. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  26375. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  26376. import { Ray } from "babylonjs/Culling/ray";
  26377. /**
  26378. * This is the base class of all the camera used in the application.
  26379. * @see http://doc.babylonjs.com/features/cameras
  26380. */
  26381. export class Camera extends Node {
  26382. /** @hidden */
  26383. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  26384. /**
  26385. * This is the default projection mode used by the cameras.
  26386. * It helps recreating a feeling of perspective and better appreciate depth.
  26387. * This is the best way to simulate real life cameras.
  26388. */
  26389. static readonly PERSPECTIVE_CAMERA: number;
  26390. /**
  26391. * This helps creating camera with an orthographic mode.
  26392. * 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.
  26393. */
  26394. static readonly ORTHOGRAPHIC_CAMERA: number;
  26395. /**
  26396. * This is the default FOV mode for perspective cameras.
  26397. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  26398. */
  26399. static readonly FOVMODE_VERTICAL_FIXED: number;
  26400. /**
  26401. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  26402. */
  26403. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  26404. /**
  26405. * This specifies ther is no need for a camera rig.
  26406. * Basically only one eye is rendered corresponding to the camera.
  26407. */
  26408. static readonly RIG_MODE_NONE: number;
  26409. /**
  26410. * Simulates a camera Rig with one blue eye and one red eye.
  26411. * This can be use with 3d blue and red glasses.
  26412. */
  26413. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  26414. /**
  26415. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  26416. */
  26417. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  26418. /**
  26419. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  26420. */
  26421. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  26422. /**
  26423. * Defines that both eyes of the camera will be rendered over under each other.
  26424. */
  26425. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  26426. /**
  26427. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  26428. */
  26429. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  26430. /**
  26431. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  26432. */
  26433. static readonly RIG_MODE_VR: number;
  26434. /**
  26435. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  26436. */
  26437. static readonly RIG_MODE_WEBVR: number;
  26438. /**
  26439. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  26440. */
  26441. static readonly RIG_MODE_CUSTOM: number;
  26442. /**
  26443. * Defines if by default attaching controls should prevent the default javascript event to continue.
  26444. */
  26445. static ForceAttachControlToAlwaysPreventDefault: boolean;
  26446. /**
  26447. * Define the input manager associated with the camera.
  26448. */
  26449. inputs: CameraInputsManager<Camera>;
  26450. /** @hidden */
  26451. _position: Vector3;
  26452. /**
  26453. * Define the current local position of the camera in the scene
  26454. */
  26455. get position(): Vector3;
  26456. set position(newPosition: Vector3);
  26457. /**
  26458. * The vector the camera should consider as up.
  26459. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  26460. */
  26461. upVector: Vector3;
  26462. /**
  26463. * Define the current limit on the left side for an orthographic camera
  26464. * In scene unit
  26465. */
  26466. orthoLeft: Nullable<number>;
  26467. /**
  26468. * Define the current limit on the right side for an orthographic camera
  26469. * In scene unit
  26470. */
  26471. orthoRight: Nullable<number>;
  26472. /**
  26473. * Define the current limit on the bottom side for an orthographic camera
  26474. * In scene unit
  26475. */
  26476. orthoBottom: Nullable<number>;
  26477. /**
  26478. * Define the current limit on the top side for an orthographic camera
  26479. * In scene unit
  26480. */
  26481. orthoTop: Nullable<number>;
  26482. /**
  26483. * Field Of View is set in Radians. (default is 0.8)
  26484. */
  26485. fov: number;
  26486. /**
  26487. * Define the minimum distance the camera can see from.
  26488. * This is important to note that the depth buffer are not infinite and the closer it starts
  26489. * the more your scene might encounter depth fighting issue.
  26490. */
  26491. minZ: number;
  26492. /**
  26493. * Define the maximum distance the camera can see to.
  26494. * This is important to note that the depth buffer are not infinite and the further it end
  26495. * the more your scene might encounter depth fighting issue.
  26496. */
  26497. maxZ: number;
  26498. /**
  26499. * Define the default inertia of the camera.
  26500. * This helps giving a smooth feeling to the camera movement.
  26501. */
  26502. inertia: number;
  26503. /**
  26504. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  26505. */
  26506. mode: number;
  26507. /**
  26508. * Define whether the camera is intermediate.
  26509. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  26510. */
  26511. isIntermediate: boolean;
  26512. /**
  26513. * Define the viewport of the camera.
  26514. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  26515. */
  26516. viewport: Viewport;
  26517. /**
  26518. * Restricts the camera to viewing objects with the same layerMask.
  26519. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  26520. */
  26521. layerMask: number;
  26522. /**
  26523. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  26524. */
  26525. fovMode: number;
  26526. /**
  26527. * Rig mode of the camera.
  26528. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  26529. * This is normally controlled byt the camera themselves as internal use.
  26530. */
  26531. cameraRigMode: number;
  26532. /**
  26533. * Defines the distance between both "eyes" in case of a RIG
  26534. */
  26535. interaxialDistance: number;
  26536. /**
  26537. * Defines if stereoscopic rendering is done side by side or over under.
  26538. */
  26539. isStereoscopicSideBySide: boolean;
  26540. /**
  26541. * 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
  26542. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  26543. * else in the scene. (Eg. security camera)
  26544. *
  26545. * 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)
  26546. */
  26547. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  26548. /**
  26549. * When set, the camera will render to this render target instead of the default canvas
  26550. *
  26551. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  26552. */
  26553. outputRenderTarget: Nullable<RenderTargetTexture>;
  26554. /**
  26555. * Observable triggered when the camera view matrix has changed.
  26556. */
  26557. onViewMatrixChangedObservable: Observable<Camera>;
  26558. /**
  26559. * Observable triggered when the camera Projection matrix has changed.
  26560. */
  26561. onProjectionMatrixChangedObservable: Observable<Camera>;
  26562. /**
  26563. * Observable triggered when the inputs have been processed.
  26564. */
  26565. onAfterCheckInputsObservable: Observable<Camera>;
  26566. /**
  26567. * Observable triggered when reset has been called and applied to the camera.
  26568. */
  26569. onRestoreStateObservable: Observable<Camera>;
  26570. /**
  26571. * Is this camera a part of a rig system?
  26572. */
  26573. isRigCamera: boolean;
  26574. /**
  26575. * If isRigCamera set to true this will be set with the parent camera.
  26576. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  26577. */
  26578. rigParent?: Camera;
  26579. /** @hidden */
  26580. _cameraRigParams: any;
  26581. /** @hidden */
  26582. _rigCameras: Camera[];
  26583. /** @hidden */
  26584. _rigPostProcess: Nullable<PostProcess>;
  26585. protected _webvrViewMatrix: Matrix;
  26586. /** @hidden */
  26587. _skipRendering: boolean;
  26588. /** @hidden */
  26589. _projectionMatrix: Matrix;
  26590. /** @hidden */
  26591. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  26592. /** @hidden */
  26593. _activeMeshes: SmartArray<AbstractMesh>;
  26594. protected _globalPosition: Vector3;
  26595. /** @hidden */
  26596. _computedViewMatrix: Matrix;
  26597. private _doNotComputeProjectionMatrix;
  26598. private _transformMatrix;
  26599. private _frustumPlanes;
  26600. private _refreshFrustumPlanes;
  26601. private _storedFov;
  26602. private _stateStored;
  26603. /**
  26604. * Instantiates a new camera object.
  26605. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  26606. * @see http://doc.babylonjs.com/features/cameras
  26607. * @param name Defines the name of the camera in the scene
  26608. * @param position Defines the position of the camera
  26609. * @param scene Defines the scene the camera belongs too
  26610. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  26611. */
  26612. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  26613. /**
  26614. * Store current camera state (fov, position, etc..)
  26615. * @returns the camera
  26616. */
  26617. storeState(): Camera;
  26618. /**
  26619. * Restores the camera state values if it has been stored. You must call storeState() first
  26620. */
  26621. protected _restoreStateValues(): boolean;
  26622. /**
  26623. * Restored camera state. You must call storeState() first.
  26624. * @returns true if restored and false otherwise
  26625. */
  26626. restoreState(): boolean;
  26627. /**
  26628. * Gets the class name of the camera.
  26629. * @returns the class name
  26630. */
  26631. getClassName(): string;
  26632. /** @hidden */
  26633. readonly _isCamera: boolean;
  26634. /**
  26635. * Gets a string representation of the camera useful for debug purpose.
  26636. * @param fullDetails Defines that a more verboe level of logging is required
  26637. * @returns the string representation
  26638. */
  26639. toString(fullDetails?: boolean): string;
  26640. /**
  26641. * Gets the current world space position of the camera.
  26642. */
  26643. get globalPosition(): Vector3;
  26644. /**
  26645. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  26646. * @returns the active meshe list
  26647. */
  26648. getActiveMeshes(): SmartArray<AbstractMesh>;
  26649. /**
  26650. * Check whether a mesh is part of the current active mesh list of the camera
  26651. * @param mesh Defines the mesh to check
  26652. * @returns true if active, false otherwise
  26653. */
  26654. isActiveMesh(mesh: Mesh): boolean;
  26655. /**
  26656. * Is this camera ready to be used/rendered
  26657. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  26658. * @return true if the camera is ready
  26659. */
  26660. isReady(completeCheck?: boolean): boolean;
  26661. /** @hidden */
  26662. _initCache(): void;
  26663. /** @hidden */
  26664. _updateCache(ignoreParentClass?: boolean): void;
  26665. /** @hidden */
  26666. _isSynchronized(): boolean;
  26667. /** @hidden */
  26668. _isSynchronizedViewMatrix(): boolean;
  26669. /** @hidden */
  26670. _isSynchronizedProjectionMatrix(): boolean;
  26671. /**
  26672. * Attach the input controls to a specific dom element to get the input from.
  26673. * @param element Defines the element the controls should be listened from
  26674. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  26675. */
  26676. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  26677. /**
  26678. * Detach the current controls from the specified dom element.
  26679. * @param element Defines the element to stop listening the inputs from
  26680. */
  26681. detachControl(element: HTMLElement): void;
  26682. /**
  26683. * Update the camera state according to the different inputs gathered during the frame.
  26684. */
  26685. update(): void;
  26686. /** @hidden */
  26687. _checkInputs(): void;
  26688. /** @hidden */
  26689. get rigCameras(): Camera[];
  26690. /**
  26691. * Gets the post process used by the rig cameras
  26692. */
  26693. get rigPostProcess(): Nullable<PostProcess>;
  26694. /**
  26695. * Internal, gets the first post proces.
  26696. * @returns the first post process to be run on this camera.
  26697. */
  26698. _getFirstPostProcess(): Nullable<PostProcess>;
  26699. private _cascadePostProcessesToRigCams;
  26700. /**
  26701. * Attach a post process to the camera.
  26702. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  26703. * @param postProcess The post process to attach to the camera
  26704. * @param insertAt The position of the post process in case several of them are in use in the scene
  26705. * @returns the position the post process has been inserted at
  26706. */
  26707. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  26708. /**
  26709. * Detach a post process to the camera.
  26710. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  26711. * @param postProcess The post process to detach from the camera
  26712. */
  26713. detachPostProcess(postProcess: PostProcess): void;
  26714. /**
  26715. * Gets the current world matrix of the camera
  26716. */
  26717. getWorldMatrix(): Matrix;
  26718. /** @hidden */
  26719. _getViewMatrix(): Matrix;
  26720. /**
  26721. * Gets the current view matrix of the camera.
  26722. * @param force forces the camera to recompute the matrix without looking at the cached state
  26723. * @returns the view matrix
  26724. */
  26725. getViewMatrix(force?: boolean): Matrix;
  26726. /**
  26727. * Freeze the projection matrix.
  26728. * It will prevent the cache check of the camera projection compute and can speed up perf
  26729. * if no parameter of the camera are meant to change
  26730. * @param projection Defines manually a projection if necessary
  26731. */
  26732. freezeProjectionMatrix(projection?: Matrix): void;
  26733. /**
  26734. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  26735. */
  26736. unfreezeProjectionMatrix(): void;
  26737. /**
  26738. * Gets the current projection matrix of the camera.
  26739. * @param force forces the camera to recompute the matrix without looking at the cached state
  26740. * @returns the projection matrix
  26741. */
  26742. getProjectionMatrix(force?: boolean): Matrix;
  26743. /**
  26744. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  26745. * @returns a Matrix
  26746. */
  26747. getTransformationMatrix(): Matrix;
  26748. private _updateFrustumPlanes;
  26749. /**
  26750. * Checks if a cullable object (mesh...) is in the camera frustum
  26751. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  26752. * @param target The object to check
  26753. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  26754. * @returns true if the object is in frustum otherwise false
  26755. */
  26756. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  26757. /**
  26758. * Checks if a cullable object (mesh...) is in the camera frustum
  26759. * Unlike isInFrustum this cheks the full bounding box
  26760. * @param target The object to check
  26761. * @returns true if the object is in frustum otherwise false
  26762. */
  26763. isCompletelyInFrustum(target: ICullable): boolean;
  26764. /**
  26765. * Gets a ray in the forward direction from the camera.
  26766. * @param length Defines the length of the ray to create
  26767. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  26768. * @param origin Defines the start point of the ray which defaults to the camera position
  26769. * @returns the forward ray
  26770. */
  26771. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  26772. /**
  26773. * Releases resources associated with this node.
  26774. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26775. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26776. */
  26777. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26778. /** @hidden */
  26779. _isLeftCamera: boolean;
  26780. /**
  26781. * Gets the left camera of a rig setup in case of Rigged Camera
  26782. */
  26783. get isLeftCamera(): boolean;
  26784. /** @hidden */
  26785. _isRightCamera: boolean;
  26786. /**
  26787. * Gets the right camera of a rig setup in case of Rigged Camera
  26788. */
  26789. get isRightCamera(): boolean;
  26790. /**
  26791. * Gets the left camera of a rig setup in case of Rigged Camera
  26792. */
  26793. get leftCamera(): Nullable<FreeCamera>;
  26794. /**
  26795. * Gets the right camera of a rig setup in case of Rigged Camera
  26796. */
  26797. get rightCamera(): Nullable<FreeCamera>;
  26798. /**
  26799. * Gets the left camera target of a rig setup in case of Rigged Camera
  26800. * @returns the target position
  26801. */
  26802. getLeftTarget(): Nullable<Vector3>;
  26803. /**
  26804. * Gets the right camera target of a rig setup in case of Rigged Camera
  26805. * @returns the target position
  26806. */
  26807. getRightTarget(): Nullable<Vector3>;
  26808. /**
  26809. * @hidden
  26810. */
  26811. setCameraRigMode(mode: number, rigParams: any): void;
  26812. /** @hidden */
  26813. static _setStereoscopicRigMode(camera: Camera): void;
  26814. /** @hidden */
  26815. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  26816. /** @hidden */
  26817. static _setVRRigMode(camera: Camera, rigParams: any): void;
  26818. /** @hidden */
  26819. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  26820. /** @hidden */
  26821. _getVRProjectionMatrix(): Matrix;
  26822. protected _updateCameraRotationMatrix(): void;
  26823. protected _updateWebVRCameraRotationMatrix(): void;
  26824. /**
  26825. * This function MUST be overwritten by the different WebVR cameras available.
  26826. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  26827. * @hidden
  26828. */
  26829. _getWebVRProjectionMatrix(): Matrix;
  26830. /**
  26831. * This function MUST be overwritten by the different WebVR cameras available.
  26832. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  26833. * @hidden
  26834. */
  26835. _getWebVRViewMatrix(): Matrix;
  26836. /** @hidden */
  26837. setCameraRigParameter(name: string, value: any): void;
  26838. /**
  26839. * needs to be overridden by children so sub has required properties to be copied
  26840. * @hidden
  26841. */
  26842. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  26843. /**
  26844. * May need to be overridden by children
  26845. * @hidden
  26846. */
  26847. _updateRigCameras(): void;
  26848. /** @hidden */
  26849. _setupInputs(): void;
  26850. /**
  26851. * Serialiaze the camera setup to a json represention
  26852. * @returns the JSON representation
  26853. */
  26854. serialize(): any;
  26855. /**
  26856. * Clones the current camera.
  26857. * @param name The cloned camera name
  26858. * @returns the cloned camera
  26859. */
  26860. clone(name: string): Camera;
  26861. /**
  26862. * Gets the direction of the camera relative to a given local axis.
  26863. * @param localAxis Defines the reference axis to provide a relative direction.
  26864. * @return the direction
  26865. */
  26866. getDirection(localAxis: Vector3): Vector3;
  26867. /**
  26868. * Returns the current camera absolute rotation
  26869. */
  26870. get absoluteRotation(): Quaternion;
  26871. /**
  26872. * Gets the direction of the camera relative to a given local axis into a passed vector.
  26873. * @param localAxis Defines the reference axis to provide a relative direction.
  26874. * @param result Defines the vector to store the result in
  26875. */
  26876. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  26877. /**
  26878. * Gets a camera constructor for a given camera type
  26879. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  26880. * @param name The name of the camera the result will be able to instantiate
  26881. * @param scene The scene the result will construct the camera in
  26882. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  26883. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  26884. * @returns a factory method to construc the camera
  26885. */
  26886. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  26887. /**
  26888. * Compute the world matrix of the camera.
  26889. * @returns the camera world matrix
  26890. */
  26891. computeWorldMatrix(): Matrix;
  26892. /**
  26893. * Parse a JSON and creates the camera from the parsed information
  26894. * @param parsedCamera The JSON to parse
  26895. * @param scene The scene to instantiate the camera in
  26896. * @returns the newly constructed camera
  26897. */
  26898. static Parse(parsedCamera: any, scene: Scene): Camera;
  26899. }
  26900. }
  26901. declare module "babylonjs/Meshes/Builders/discBuilder" {
  26902. import { Nullable } from "babylonjs/types";
  26903. import { Scene } from "babylonjs/scene";
  26904. import { Vector4 } from "babylonjs/Maths/math.vector";
  26905. import { Mesh } from "babylonjs/Meshes/mesh";
  26906. /**
  26907. * Class containing static functions to help procedurally build meshes
  26908. */
  26909. export class DiscBuilder {
  26910. /**
  26911. * Creates a plane polygonal mesh. By default, this is a disc
  26912. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  26913. * * 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
  26914. * * 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
  26915. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  26916. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  26917. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  26918. * @param name defines the name of the mesh
  26919. * @param options defines the options used to create the mesh
  26920. * @param scene defines the hosting scene
  26921. * @returns the plane polygonal mesh
  26922. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  26923. */
  26924. static CreateDisc(name: string, options: {
  26925. radius?: number;
  26926. tessellation?: number;
  26927. arc?: number;
  26928. updatable?: boolean;
  26929. sideOrientation?: number;
  26930. frontUVs?: Vector4;
  26931. backUVs?: Vector4;
  26932. }, scene?: Nullable<Scene>): Mesh;
  26933. }
  26934. }
  26935. declare module "babylonjs/Materials/fresnelParameters" {
  26936. import { DeepImmutable } from "babylonjs/types";
  26937. import { Color3 } from "babylonjs/Maths/math.color";
  26938. /**
  26939. * Options to be used when creating a FresnelParameters.
  26940. */
  26941. export type IFresnelParametersCreationOptions = {
  26942. /**
  26943. * Define the color used on edges (grazing angle)
  26944. */
  26945. leftColor?: Color3;
  26946. /**
  26947. * Define the color used on center
  26948. */
  26949. rightColor?: Color3;
  26950. /**
  26951. * Define bias applied to computed fresnel term
  26952. */
  26953. bias?: number;
  26954. /**
  26955. * Defined the power exponent applied to fresnel term
  26956. */
  26957. power?: number;
  26958. /**
  26959. * Define if the fresnel effect is enable or not.
  26960. */
  26961. isEnabled?: boolean;
  26962. };
  26963. /**
  26964. * Serialized format for FresnelParameters.
  26965. */
  26966. export type IFresnelParametersSerialized = {
  26967. /**
  26968. * Define the color used on edges (grazing angle) [as an array]
  26969. */
  26970. leftColor: number[];
  26971. /**
  26972. * Define the color used on center [as an array]
  26973. */
  26974. rightColor: number[];
  26975. /**
  26976. * Define bias applied to computed fresnel term
  26977. */
  26978. bias: number;
  26979. /**
  26980. * Defined the power exponent applied to fresnel term
  26981. */
  26982. power?: number;
  26983. /**
  26984. * Define if the fresnel effect is enable or not.
  26985. */
  26986. isEnabled: boolean;
  26987. };
  26988. /**
  26989. * This represents all the required information to add a fresnel effect on a material:
  26990. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26991. */
  26992. export class FresnelParameters {
  26993. private _isEnabled;
  26994. /**
  26995. * Define if the fresnel effect is enable or not.
  26996. */
  26997. get isEnabled(): boolean;
  26998. set isEnabled(value: boolean);
  26999. /**
  27000. * Define the color used on edges (grazing angle)
  27001. */
  27002. leftColor: Color3;
  27003. /**
  27004. * Define the color used on center
  27005. */
  27006. rightColor: Color3;
  27007. /**
  27008. * Define bias applied to computed fresnel term
  27009. */
  27010. bias: number;
  27011. /**
  27012. * Defined the power exponent applied to fresnel term
  27013. */
  27014. power: number;
  27015. /**
  27016. * Creates a new FresnelParameters object.
  27017. *
  27018. * @param options provide your own settings to optionally to override defaults
  27019. */
  27020. constructor(options?: IFresnelParametersCreationOptions);
  27021. /**
  27022. * Clones the current fresnel and its valuues
  27023. * @returns a clone fresnel configuration
  27024. */
  27025. clone(): FresnelParameters;
  27026. /**
  27027. * Determines equality between FresnelParameters objects
  27028. * @param otherFresnelParameters defines the second operand
  27029. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  27030. */
  27031. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  27032. /**
  27033. * Serializes the current fresnel parameters to a JSON representation.
  27034. * @return the JSON serialization
  27035. */
  27036. serialize(): IFresnelParametersSerialized;
  27037. /**
  27038. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  27039. * @param parsedFresnelParameters Define the JSON representation
  27040. * @returns the parsed parameters
  27041. */
  27042. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  27043. }
  27044. }
  27045. declare module "babylonjs/Materials/pushMaterial" {
  27046. import { Nullable } from "babylonjs/types";
  27047. import { Scene } from "babylonjs/scene";
  27048. import { Matrix } from "babylonjs/Maths/math.vector";
  27049. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27050. import { Mesh } from "babylonjs/Meshes/mesh";
  27051. import { Material } from "babylonjs/Materials/material";
  27052. import { Effect } from "babylonjs/Materials/effect";
  27053. /**
  27054. * Base class of materials working in push mode in babylon JS
  27055. * @hidden
  27056. */
  27057. export class PushMaterial extends Material {
  27058. protected _activeEffect: Effect;
  27059. protected _normalMatrix: Matrix;
  27060. /**
  27061. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  27062. * This means that the material can keep using a previous shader while a new one is being compiled.
  27063. * This is mostly used when shader parallel compilation is supported (true by default)
  27064. */
  27065. allowShaderHotSwapping: boolean;
  27066. constructor(name: string, scene: Scene);
  27067. getEffect(): Effect;
  27068. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  27069. /**
  27070. * Binds the given world matrix to the active effect
  27071. *
  27072. * @param world the matrix to bind
  27073. */
  27074. bindOnlyWorldMatrix(world: Matrix): void;
  27075. /**
  27076. * Binds the given normal matrix to the active effect
  27077. *
  27078. * @param normalMatrix the matrix to bind
  27079. */
  27080. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  27081. bind(world: Matrix, mesh?: Mesh): void;
  27082. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  27083. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  27084. }
  27085. }
  27086. declare module "babylonjs/Materials/materialFlags" {
  27087. /**
  27088. * This groups all the flags used to control the materials channel.
  27089. */
  27090. export class MaterialFlags {
  27091. private static _DiffuseTextureEnabled;
  27092. /**
  27093. * Are diffuse textures enabled in the application.
  27094. */
  27095. static get DiffuseTextureEnabled(): boolean;
  27096. static set DiffuseTextureEnabled(value: boolean);
  27097. private static _AmbientTextureEnabled;
  27098. /**
  27099. * Are ambient textures enabled in the application.
  27100. */
  27101. static get AmbientTextureEnabled(): boolean;
  27102. static set AmbientTextureEnabled(value: boolean);
  27103. private static _OpacityTextureEnabled;
  27104. /**
  27105. * Are opacity textures enabled in the application.
  27106. */
  27107. static get OpacityTextureEnabled(): boolean;
  27108. static set OpacityTextureEnabled(value: boolean);
  27109. private static _ReflectionTextureEnabled;
  27110. /**
  27111. * Are reflection textures enabled in the application.
  27112. */
  27113. static get ReflectionTextureEnabled(): boolean;
  27114. static set ReflectionTextureEnabled(value: boolean);
  27115. private static _EmissiveTextureEnabled;
  27116. /**
  27117. * Are emissive textures enabled in the application.
  27118. */
  27119. static get EmissiveTextureEnabled(): boolean;
  27120. static set EmissiveTextureEnabled(value: boolean);
  27121. private static _SpecularTextureEnabled;
  27122. /**
  27123. * Are specular textures enabled in the application.
  27124. */
  27125. static get SpecularTextureEnabled(): boolean;
  27126. static set SpecularTextureEnabled(value: boolean);
  27127. private static _BumpTextureEnabled;
  27128. /**
  27129. * Are bump textures enabled in the application.
  27130. */
  27131. static get BumpTextureEnabled(): boolean;
  27132. static set BumpTextureEnabled(value: boolean);
  27133. private static _LightmapTextureEnabled;
  27134. /**
  27135. * Are lightmap textures enabled in the application.
  27136. */
  27137. static get LightmapTextureEnabled(): boolean;
  27138. static set LightmapTextureEnabled(value: boolean);
  27139. private static _RefractionTextureEnabled;
  27140. /**
  27141. * Are refraction textures enabled in the application.
  27142. */
  27143. static get RefractionTextureEnabled(): boolean;
  27144. static set RefractionTextureEnabled(value: boolean);
  27145. private static _ColorGradingTextureEnabled;
  27146. /**
  27147. * Are color grading textures enabled in the application.
  27148. */
  27149. static get ColorGradingTextureEnabled(): boolean;
  27150. static set ColorGradingTextureEnabled(value: boolean);
  27151. private static _FresnelEnabled;
  27152. /**
  27153. * Are fresnels enabled in the application.
  27154. */
  27155. static get FresnelEnabled(): boolean;
  27156. static set FresnelEnabled(value: boolean);
  27157. private static _ClearCoatTextureEnabled;
  27158. /**
  27159. * Are clear coat textures enabled in the application.
  27160. */
  27161. static get ClearCoatTextureEnabled(): boolean;
  27162. static set ClearCoatTextureEnabled(value: boolean);
  27163. private static _ClearCoatBumpTextureEnabled;
  27164. /**
  27165. * Are clear coat bump textures enabled in the application.
  27166. */
  27167. static get ClearCoatBumpTextureEnabled(): boolean;
  27168. static set ClearCoatBumpTextureEnabled(value: boolean);
  27169. private static _ClearCoatTintTextureEnabled;
  27170. /**
  27171. * Are clear coat tint textures enabled in the application.
  27172. */
  27173. static get ClearCoatTintTextureEnabled(): boolean;
  27174. static set ClearCoatTintTextureEnabled(value: boolean);
  27175. private static _SheenTextureEnabled;
  27176. /**
  27177. * Are sheen textures enabled in the application.
  27178. */
  27179. static get SheenTextureEnabled(): boolean;
  27180. static set SheenTextureEnabled(value: boolean);
  27181. private static _AnisotropicTextureEnabled;
  27182. /**
  27183. * Are anisotropic textures enabled in the application.
  27184. */
  27185. static get AnisotropicTextureEnabled(): boolean;
  27186. static set AnisotropicTextureEnabled(value: boolean);
  27187. private static _ThicknessTextureEnabled;
  27188. /**
  27189. * Are thickness textures enabled in the application.
  27190. */
  27191. static get ThicknessTextureEnabled(): boolean;
  27192. static set ThicknessTextureEnabled(value: boolean);
  27193. }
  27194. }
  27195. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  27196. /** @hidden */
  27197. export var defaultFragmentDeclaration: {
  27198. name: string;
  27199. shader: string;
  27200. };
  27201. }
  27202. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  27203. /** @hidden */
  27204. export var defaultUboDeclaration: {
  27205. name: string;
  27206. shader: string;
  27207. };
  27208. }
  27209. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  27210. /** @hidden */
  27211. export var lightFragmentDeclaration: {
  27212. name: string;
  27213. shader: string;
  27214. };
  27215. }
  27216. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  27217. /** @hidden */
  27218. export var lightUboDeclaration: {
  27219. name: string;
  27220. shader: string;
  27221. };
  27222. }
  27223. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  27224. /** @hidden */
  27225. export var lightsFragmentFunctions: {
  27226. name: string;
  27227. shader: string;
  27228. };
  27229. }
  27230. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  27231. /** @hidden */
  27232. export var shadowsFragmentFunctions: {
  27233. name: string;
  27234. shader: string;
  27235. };
  27236. }
  27237. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  27238. /** @hidden */
  27239. export var fresnelFunction: {
  27240. name: string;
  27241. shader: string;
  27242. };
  27243. }
  27244. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  27245. /** @hidden */
  27246. export var reflectionFunction: {
  27247. name: string;
  27248. shader: string;
  27249. };
  27250. }
  27251. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  27252. /** @hidden */
  27253. export var bumpFragmentFunctions: {
  27254. name: string;
  27255. shader: string;
  27256. };
  27257. }
  27258. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  27259. /** @hidden */
  27260. export var logDepthDeclaration: {
  27261. name: string;
  27262. shader: string;
  27263. };
  27264. }
  27265. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  27266. /** @hidden */
  27267. export var bumpFragment: {
  27268. name: string;
  27269. shader: string;
  27270. };
  27271. }
  27272. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  27273. /** @hidden */
  27274. export var depthPrePass: {
  27275. name: string;
  27276. shader: string;
  27277. };
  27278. }
  27279. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  27280. /** @hidden */
  27281. export var lightFragment: {
  27282. name: string;
  27283. shader: string;
  27284. };
  27285. }
  27286. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  27287. /** @hidden */
  27288. export var logDepthFragment: {
  27289. name: string;
  27290. shader: string;
  27291. };
  27292. }
  27293. declare module "babylonjs/Shaders/default.fragment" {
  27294. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  27295. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  27296. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  27297. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  27298. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  27299. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  27300. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  27301. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  27302. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  27303. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  27304. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  27305. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  27306. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  27307. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  27308. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  27309. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  27310. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  27311. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  27312. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  27313. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  27314. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  27315. /** @hidden */
  27316. export var defaultPixelShader: {
  27317. name: string;
  27318. shader: string;
  27319. };
  27320. }
  27321. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  27322. /** @hidden */
  27323. export var defaultVertexDeclaration: {
  27324. name: string;
  27325. shader: string;
  27326. };
  27327. }
  27328. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  27329. /** @hidden */
  27330. export var bumpVertexDeclaration: {
  27331. name: string;
  27332. shader: string;
  27333. };
  27334. }
  27335. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  27336. /** @hidden */
  27337. export var bumpVertex: {
  27338. name: string;
  27339. shader: string;
  27340. };
  27341. }
  27342. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  27343. /** @hidden */
  27344. export var fogVertex: {
  27345. name: string;
  27346. shader: string;
  27347. };
  27348. }
  27349. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  27350. /** @hidden */
  27351. export var shadowsVertex: {
  27352. name: string;
  27353. shader: string;
  27354. };
  27355. }
  27356. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  27357. /** @hidden */
  27358. export var pointCloudVertex: {
  27359. name: string;
  27360. shader: string;
  27361. };
  27362. }
  27363. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  27364. /** @hidden */
  27365. export var logDepthVertex: {
  27366. name: string;
  27367. shader: string;
  27368. };
  27369. }
  27370. declare module "babylonjs/Shaders/default.vertex" {
  27371. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  27372. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  27373. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  27374. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  27375. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  27376. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  27377. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  27378. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  27379. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  27380. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  27381. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  27382. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  27383. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  27384. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  27385. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  27386. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  27387. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  27388. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  27389. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  27390. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  27391. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  27392. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  27393. /** @hidden */
  27394. export var defaultVertexShader: {
  27395. name: string;
  27396. shader: string;
  27397. };
  27398. }
  27399. declare module "babylonjs/Materials/standardMaterial" {
  27400. import { SmartArray } from "babylonjs/Misc/smartArray";
  27401. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  27402. import { Nullable } from "babylonjs/types";
  27403. import { Scene } from "babylonjs/scene";
  27404. import { Matrix } from "babylonjs/Maths/math.vector";
  27405. import { Color3 } from "babylonjs/Maths/math.color";
  27406. import { SubMesh } from "babylonjs/Meshes/subMesh";
  27407. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27408. import { Mesh } from "babylonjs/Meshes/mesh";
  27409. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  27410. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  27411. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  27412. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  27413. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  27414. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  27415. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  27416. import "babylonjs/Shaders/default.fragment";
  27417. import "babylonjs/Shaders/default.vertex";
  27418. /** @hidden */
  27419. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  27420. MAINUV1: boolean;
  27421. MAINUV2: boolean;
  27422. DIFFUSE: boolean;
  27423. DIFFUSEDIRECTUV: number;
  27424. AMBIENT: boolean;
  27425. AMBIENTDIRECTUV: number;
  27426. OPACITY: boolean;
  27427. OPACITYDIRECTUV: number;
  27428. OPACITYRGB: boolean;
  27429. REFLECTION: boolean;
  27430. EMISSIVE: boolean;
  27431. EMISSIVEDIRECTUV: number;
  27432. SPECULAR: boolean;
  27433. SPECULARDIRECTUV: number;
  27434. BUMP: boolean;
  27435. BUMPDIRECTUV: number;
  27436. PARALLAX: boolean;
  27437. PARALLAXOCCLUSION: boolean;
  27438. SPECULAROVERALPHA: boolean;
  27439. CLIPPLANE: boolean;
  27440. CLIPPLANE2: boolean;
  27441. CLIPPLANE3: boolean;
  27442. CLIPPLANE4: boolean;
  27443. CLIPPLANE5: boolean;
  27444. CLIPPLANE6: boolean;
  27445. ALPHATEST: boolean;
  27446. DEPTHPREPASS: boolean;
  27447. ALPHAFROMDIFFUSE: boolean;
  27448. POINTSIZE: boolean;
  27449. FOG: boolean;
  27450. SPECULARTERM: boolean;
  27451. DIFFUSEFRESNEL: boolean;
  27452. OPACITYFRESNEL: boolean;
  27453. REFLECTIONFRESNEL: boolean;
  27454. REFRACTIONFRESNEL: boolean;
  27455. EMISSIVEFRESNEL: boolean;
  27456. FRESNEL: boolean;
  27457. NORMAL: boolean;
  27458. UV1: boolean;
  27459. UV2: boolean;
  27460. VERTEXCOLOR: boolean;
  27461. VERTEXALPHA: boolean;
  27462. NUM_BONE_INFLUENCERS: number;
  27463. BonesPerMesh: number;
  27464. BONETEXTURE: boolean;
  27465. INSTANCES: boolean;
  27466. GLOSSINESS: boolean;
  27467. ROUGHNESS: boolean;
  27468. EMISSIVEASILLUMINATION: boolean;
  27469. LINKEMISSIVEWITHDIFFUSE: boolean;
  27470. REFLECTIONFRESNELFROMSPECULAR: boolean;
  27471. LIGHTMAP: boolean;
  27472. LIGHTMAPDIRECTUV: number;
  27473. OBJECTSPACE_NORMALMAP: boolean;
  27474. USELIGHTMAPASSHADOWMAP: boolean;
  27475. REFLECTIONMAP_3D: boolean;
  27476. REFLECTIONMAP_SPHERICAL: boolean;
  27477. REFLECTIONMAP_PLANAR: boolean;
  27478. REFLECTIONMAP_CUBIC: boolean;
  27479. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  27480. REFLECTIONMAP_PROJECTION: boolean;
  27481. REFLECTIONMAP_SKYBOX: boolean;
  27482. REFLECTIONMAP_EXPLICIT: boolean;
  27483. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  27484. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  27485. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  27486. INVERTCUBICMAP: boolean;
  27487. LOGARITHMICDEPTH: boolean;
  27488. REFRACTION: boolean;
  27489. REFRACTIONMAP_3D: boolean;
  27490. REFLECTIONOVERALPHA: boolean;
  27491. TWOSIDEDLIGHTING: boolean;
  27492. SHADOWFLOAT: boolean;
  27493. MORPHTARGETS: boolean;
  27494. MORPHTARGETS_NORMAL: boolean;
  27495. MORPHTARGETS_TANGENT: boolean;
  27496. MORPHTARGETS_UV: boolean;
  27497. NUM_MORPH_INFLUENCERS: number;
  27498. NONUNIFORMSCALING: boolean;
  27499. PREMULTIPLYALPHA: boolean;
  27500. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  27501. ALPHABLEND: boolean;
  27502. IMAGEPROCESSING: boolean;
  27503. VIGNETTE: boolean;
  27504. VIGNETTEBLENDMODEMULTIPLY: boolean;
  27505. VIGNETTEBLENDMODEOPAQUE: boolean;
  27506. TONEMAPPING: boolean;
  27507. TONEMAPPING_ACES: boolean;
  27508. CONTRAST: boolean;
  27509. COLORCURVES: boolean;
  27510. COLORGRADING: boolean;
  27511. COLORGRADING3D: boolean;
  27512. SAMPLER3DGREENDEPTH: boolean;
  27513. SAMPLER3DBGRMAP: boolean;
  27514. IMAGEPROCESSINGPOSTPROCESS: boolean;
  27515. MULTIVIEW: boolean;
  27516. /**
  27517. * If the reflection texture on this material is in linear color space
  27518. * @hidden
  27519. */
  27520. IS_REFLECTION_LINEAR: boolean;
  27521. /**
  27522. * If the refraction texture on this material is in linear color space
  27523. * @hidden
  27524. */
  27525. IS_REFRACTION_LINEAR: boolean;
  27526. EXPOSURE: boolean;
  27527. constructor();
  27528. setReflectionMode(modeToEnable: string): void;
  27529. }
  27530. /**
  27531. * This is the default material used in Babylon. It is the best trade off between quality
  27532. * and performances.
  27533. * @see http://doc.babylonjs.com/babylon101/materials
  27534. */
  27535. export class StandardMaterial extends PushMaterial {
  27536. private _diffuseTexture;
  27537. /**
  27538. * The basic texture of the material as viewed under a light.
  27539. */
  27540. diffuseTexture: Nullable<BaseTexture>;
  27541. private _ambientTexture;
  27542. /**
  27543. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  27544. */
  27545. ambientTexture: Nullable<BaseTexture>;
  27546. private _opacityTexture;
  27547. /**
  27548. * Define the transparency of the material from a texture.
  27549. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  27550. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  27551. */
  27552. opacityTexture: Nullable<BaseTexture>;
  27553. private _reflectionTexture;
  27554. /**
  27555. * Define the texture used to display the reflection.
  27556. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27557. */
  27558. reflectionTexture: Nullable<BaseTexture>;
  27559. private _emissiveTexture;
  27560. /**
  27561. * Define texture of the material as if self lit.
  27562. * This will be mixed in the final result even in the absence of light.
  27563. */
  27564. emissiveTexture: Nullable<BaseTexture>;
  27565. private _specularTexture;
  27566. /**
  27567. * Define how the color and intensity of the highlight given by the light in the material.
  27568. */
  27569. specularTexture: Nullable<BaseTexture>;
  27570. private _bumpTexture;
  27571. /**
  27572. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  27573. * 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.
  27574. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  27575. */
  27576. bumpTexture: Nullable<BaseTexture>;
  27577. private _lightmapTexture;
  27578. /**
  27579. * Complex lighting can be computationally expensive to compute at runtime.
  27580. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  27581. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  27582. */
  27583. lightmapTexture: Nullable<BaseTexture>;
  27584. private _refractionTexture;
  27585. /**
  27586. * Define the texture used to display the refraction.
  27587. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27588. */
  27589. refractionTexture: Nullable<BaseTexture>;
  27590. /**
  27591. * The color of the material lit by the environmental background lighting.
  27592. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  27593. */
  27594. ambientColor: Color3;
  27595. /**
  27596. * The basic color of the material as viewed under a light.
  27597. */
  27598. diffuseColor: Color3;
  27599. /**
  27600. * Define how the color and intensity of the highlight given by the light in the material.
  27601. */
  27602. specularColor: Color3;
  27603. /**
  27604. * Define the color of the material as if self lit.
  27605. * This will be mixed in the final result even in the absence of light.
  27606. */
  27607. emissiveColor: Color3;
  27608. /**
  27609. * Defines how sharp are the highlights in the material.
  27610. * The bigger the value the sharper giving a more glossy feeling to the result.
  27611. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  27612. */
  27613. specularPower: number;
  27614. private _useAlphaFromDiffuseTexture;
  27615. /**
  27616. * Does the transparency come from the diffuse texture alpha channel.
  27617. */
  27618. useAlphaFromDiffuseTexture: boolean;
  27619. private _useEmissiveAsIllumination;
  27620. /**
  27621. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  27622. */
  27623. useEmissiveAsIllumination: boolean;
  27624. private _linkEmissiveWithDiffuse;
  27625. /**
  27626. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  27627. * the emissive level when the final color is close to one.
  27628. */
  27629. linkEmissiveWithDiffuse: boolean;
  27630. private _useSpecularOverAlpha;
  27631. /**
  27632. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  27633. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  27634. */
  27635. useSpecularOverAlpha: boolean;
  27636. private _useReflectionOverAlpha;
  27637. /**
  27638. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  27639. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  27640. */
  27641. useReflectionOverAlpha: boolean;
  27642. private _disableLighting;
  27643. /**
  27644. * Does lights from the scene impacts this material.
  27645. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  27646. */
  27647. disableLighting: boolean;
  27648. private _useObjectSpaceNormalMap;
  27649. /**
  27650. * Allows using an object space normal map (instead of tangent space).
  27651. */
  27652. useObjectSpaceNormalMap: boolean;
  27653. private _useParallax;
  27654. /**
  27655. * Is parallax enabled or not.
  27656. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  27657. */
  27658. useParallax: boolean;
  27659. private _useParallaxOcclusion;
  27660. /**
  27661. * Is parallax occlusion enabled or not.
  27662. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  27663. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  27664. */
  27665. useParallaxOcclusion: boolean;
  27666. /**
  27667. * 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.
  27668. */
  27669. parallaxScaleBias: number;
  27670. private _roughness;
  27671. /**
  27672. * Helps to define how blurry the reflections should appears in the material.
  27673. */
  27674. roughness: number;
  27675. /**
  27676. * In case of refraction, define the value of the index of refraction.
  27677. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27678. */
  27679. indexOfRefraction: number;
  27680. /**
  27681. * Invert the refraction texture alongside the y axis.
  27682. * It can be useful with procedural textures or probe for instance.
  27683. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27684. */
  27685. invertRefractionY: boolean;
  27686. /**
  27687. * Defines the alpha limits in alpha test mode.
  27688. */
  27689. alphaCutOff: number;
  27690. private _useLightmapAsShadowmap;
  27691. /**
  27692. * In case of light mapping, define whether the map contains light or shadow informations.
  27693. */
  27694. useLightmapAsShadowmap: boolean;
  27695. private _diffuseFresnelParameters;
  27696. /**
  27697. * Define the diffuse fresnel parameters of the material.
  27698. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27699. */
  27700. diffuseFresnelParameters: FresnelParameters;
  27701. private _opacityFresnelParameters;
  27702. /**
  27703. * Define the opacity fresnel parameters of the material.
  27704. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27705. */
  27706. opacityFresnelParameters: FresnelParameters;
  27707. private _reflectionFresnelParameters;
  27708. /**
  27709. * Define the reflection fresnel parameters of the material.
  27710. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27711. */
  27712. reflectionFresnelParameters: FresnelParameters;
  27713. private _refractionFresnelParameters;
  27714. /**
  27715. * Define the refraction fresnel parameters of the material.
  27716. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27717. */
  27718. refractionFresnelParameters: FresnelParameters;
  27719. private _emissiveFresnelParameters;
  27720. /**
  27721. * Define the emissive fresnel parameters of the material.
  27722. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27723. */
  27724. emissiveFresnelParameters: FresnelParameters;
  27725. private _useReflectionFresnelFromSpecular;
  27726. /**
  27727. * If true automatically deducts the fresnels values from the material specularity.
  27728. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27729. */
  27730. useReflectionFresnelFromSpecular: boolean;
  27731. private _useGlossinessFromSpecularMapAlpha;
  27732. /**
  27733. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  27734. */
  27735. useGlossinessFromSpecularMapAlpha: boolean;
  27736. private _maxSimultaneousLights;
  27737. /**
  27738. * Defines the maximum number of lights that can be used in the material
  27739. */
  27740. maxSimultaneousLights: number;
  27741. private _invertNormalMapX;
  27742. /**
  27743. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  27744. */
  27745. invertNormalMapX: boolean;
  27746. private _invertNormalMapY;
  27747. /**
  27748. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  27749. */
  27750. invertNormalMapY: boolean;
  27751. private _twoSidedLighting;
  27752. /**
  27753. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  27754. */
  27755. twoSidedLighting: boolean;
  27756. /**
  27757. * Default configuration related to image processing available in the standard Material.
  27758. */
  27759. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  27760. /**
  27761. * Gets the image processing configuration used either in this material.
  27762. */
  27763. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  27764. /**
  27765. * Sets the Default image processing configuration used either in the this material.
  27766. *
  27767. * If sets to null, the scene one is in use.
  27768. */
  27769. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  27770. /**
  27771. * Keep track of the image processing observer to allow dispose and replace.
  27772. */
  27773. private _imageProcessingObserver;
  27774. /**
  27775. * Attaches a new image processing configuration to the Standard Material.
  27776. * @param configuration
  27777. */
  27778. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  27779. /**
  27780. * Gets wether the color curves effect is enabled.
  27781. */
  27782. get cameraColorCurvesEnabled(): boolean;
  27783. /**
  27784. * Sets wether the color curves effect is enabled.
  27785. */
  27786. set cameraColorCurvesEnabled(value: boolean);
  27787. /**
  27788. * Gets wether the color grading effect is enabled.
  27789. */
  27790. get cameraColorGradingEnabled(): boolean;
  27791. /**
  27792. * Gets wether the color grading effect is enabled.
  27793. */
  27794. set cameraColorGradingEnabled(value: boolean);
  27795. /**
  27796. * Gets wether tonemapping is enabled or not.
  27797. */
  27798. get cameraToneMappingEnabled(): boolean;
  27799. /**
  27800. * Sets wether tonemapping is enabled or not
  27801. */
  27802. set cameraToneMappingEnabled(value: boolean);
  27803. /**
  27804. * The camera exposure used on this material.
  27805. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  27806. * This corresponds to a photographic exposure.
  27807. */
  27808. get cameraExposure(): number;
  27809. /**
  27810. * The camera exposure used on this material.
  27811. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  27812. * This corresponds to a photographic exposure.
  27813. */
  27814. set cameraExposure(value: number);
  27815. /**
  27816. * Gets The camera contrast used on this material.
  27817. */
  27818. get cameraContrast(): number;
  27819. /**
  27820. * Sets The camera contrast used on this material.
  27821. */
  27822. set cameraContrast(value: number);
  27823. /**
  27824. * Gets the Color Grading 2D Lookup Texture.
  27825. */
  27826. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  27827. /**
  27828. * Sets the Color Grading 2D Lookup Texture.
  27829. */
  27830. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  27831. /**
  27832. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  27833. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  27834. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  27835. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  27836. */
  27837. get cameraColorCurves(): Nullable<ColorCurves>;
  27838. /**
  27839. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  27840. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  27841. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  27842. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  27843. */
  27844. set cameraColorCurves(value: Nullable<ColorCurves>);
  27845. /**
  27846. * Custom callback helping to override the default shader used in the material.
  27847. */
  27848. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines, attributes?: string[]) => string;
  27849. protected _renderTargets: SmartArray<RenderTargetTexture>;
  27850. protected _worldViewProjectionMatrix: Matrix;
  27851. protected _globalAmbientColor: Color3;
  27852. protected _useLogarithmicDepth: boolean;
  27853. protected _rebuildInParallel: boolean;
  27854. /**
  27855. * Instantiates a new standard material.
  27856. * This is the default material used in Babylon. It is the best trade off between quality
  27857. * and performances.
  27858. * @see http://doc.babylonjs.com/babylon101/materials
  27859. * @param name Define the name of the material in the scene
  27860. * @param scene Define the scene the material belong to
  27861. */
  27862. constructor(name: string, scene: Scene);
  27863. /**
  27864. * Gets a boolean indicating that current material needs to register RTT
  27865. */
  27866. get hasRenderTargetTextures(): boolean;
  27867. /**
  27868. * Gets the current class name of the material e.g. "StandardMaterial"
  27869. * Mainly use in serialization.
  27870. * @returns the class name
  27871. */
  27872. getClassName(): string;
  27873. /**
  27874. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  27875. * You can try switching to logarithmic depth.
  27876. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  27877. */
  27878. get useLogarithmicDepth(): boolean;
  27879. set useLogarithmicDepth(value: boolean);
  27880. /**
  27881. * Specifies if the material will require alpha blending
  27882. * @returns a boolean specifying if alpha blending is needed
  27883. */
  27884. needAlphaBlending(): boolean;
  27885. /**
  27886. * Specifies if this material should be rendered in alpha test mode
  27887. * @returns a boolean specifying if an alpha test is needed.
  27888. */
  27889. needAlphaTesting(): boolean;
  27890. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  27891. /**
  27892. * Get the texture used for alpha test purpose.
  27893. * @returns the diffuse texture in case of the standard material.
  27894. */
  27895. getAlphaTestTexture(): Nullable<BaseTexture>;
  27896. /**
  27897. * Get if the submesh is ready to be used and all its information available.
  27898. * Child classes can use it to update shaders
  27899. * @param mesh defines the mesh to check
  27900. * @param subMesh defines which submesh to check
  27901. * @param useInstances specifies that instances should be used
  27902. * @returns a boolean indicating that the submesh is ready or not
  27903. */
  27904. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  27905. /**
  27906. * Builds the material UBO layouts.
  27907. * Used internally during the effect preparation.
  27908. */
  27909. buildUniformLayout(): void;
  27910. /**
  27911. * Unbinds the material from the mesh
  27912. */
  27913. unbind(): void;
  27914. /**
  27915. * Binds the submesh to this material by preparing the effect and shader to draw
  27916. * @param world defines the world transformation matrix
  27917. * @param mesh defines the mesh containing the submesh
  27918. * @param subMesh defines the submesh to bind the material to
  27919. */
  27920. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  27921. /**
  27922. * Get the list of animatables in the material.
  27923. * @returns the list of animatables object used in the material
  27924. */
  27925. getAnimatables(): IAnimatable[];
  27926. /**
  27927. * Gets the active textures from the material
  27928. * @returns an array of textures
  27929. */
  27930. getActiveTextures(): BaseTexture[];
  27931. /**
  27932. * Specifies if the material uses a texture
  27933. * @param texture defines the texture to check against the material
  27934. * @returns a boolean specifying if the material uses the texture
  27935. */
  27936. hasTexture(texture: BaseTexture): boolean;
  27937. /**
  27938. * Disposes the material
  27939. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  27940. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  27941. */
  27942. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  27943. /**
  27944. * Makes a duplicate of the material, and gives it a new name
  27945. * @param name defines the new name for the duplicated material
  27946. * @returns the cloned material
  27947. */
  27948. clone(name: string): StandardMaterial;
  27949. /**
  27950. * Serializes this material in a JSON representation
  27951. * @returns the serialized material object
  27952. */
  27953. serialize(): any;
  27954. /**
  27955. * Creates a standard material from parsed material data
  27956. * @param source defines the JSON representation of the material
  27957. * @param scene defines the hosting scene
  27958. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  27959. * @returns a new standard material
  27960. */
  27961. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  27962. /**
  27963. * Are diffuse textures enabled in the application.
  27964. */
  27965. static get DiffuseTextureEnabled(): boolean;
  27966. static set DiffuseTextureEnabled(value: boolean);
  27967. /**
  27968. * Are ambient textures enabled in the application.
  27969. */
  27970. static get AmbientTextureEnabled(): boolean;
  27971. static set AmbientTextureEnabled(value: boolean);
  27972. /**
  27973. * Are opacity textures enabled in the application.
  27974. */
  27975. static get OpacityTextureEnabled(): boolean;
  27976. static set OpacityTextureEnabled(value: boolean);
  27977. /**
  27978. * Are reflection textures enabled in the application.
  27979. */
  27980. static get ReflectionTextureEnabled(): boolean;
  27981. static set ReflectionTextureEnabled(value: boolean);
  27982. /**
  27983. * Are emissive textures enabled in the application.
  27984. */
  27985. static get EmissiveTextureEnabled(): boolean;
  27986. static set EmissiveTextureEnabled(value: boolean);
  27987. /**
  27988. * Are specular textures enabled in the application.
  27989. */
  27990. static get SpecularTextureEnabled(): boolean;
  27991. static set SpecularTextureEnabled(value: boolean);
  27992. /**
  27993. * Are bump textures enabled in the application.
  27994. */
  27995. static get BumpTextureEnabled(): boolean;
  27996. static set BumpTextureEnabled(value: boolean);
  27997. /**
  27998. * Are lightmap textures enabled in the application.
  27999. */
  28000. static get LightmapTextureEnabled(): boolean;
  28001. static set LightmapTextureEnabled(value: boolean);
  28002. /**
  28003. * Are refraction textures enabled in the application.
  28004. */
  28005. static get RefractionTextureEnabled(): boolean;
  28006. static set RefractionTextureEnabled(value: boolean);
  28007. /**
  28008. * Are color grading textures enabled in the application.
  28009. */
  28010. static get ColorGradingTextureEnabled(): boolean;
  28011. static set ColorGradingTextureEnabled(value: boolean);
  28012. /**
  28013. * Are fresnels enabled in the application.
  28014. */
  28015. static get FresnelEnabled(): boolean;
  28016. static set FresnelEnabled(value: boolean);
  28017. }
  28018. }
  28019. declare module "babylonjs/Particles/solidParticleSystem" {
  28020. import { Nullable } from "babylonjs/types";
  28021. import { Vector3 } from "babylonjs/Maths/math.vector";
  28022. import { Mesh } from "babylonjs/Meshes/mesh";
  28023. import { Scene, IDisposable } from "babylonjs/scene";
  28024. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  28025. import { Material } from "babylonjs/Materials/material";
  28026. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  28027. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  28028. /**
  28029. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  28030. *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.
  28031. * The SPS is also a particle system. It provides some methods to manage the particles.
  28032. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  28033. *
  28034. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  28035. */
  28036. export class SolidParticleSystem implements IDisposable {
  28037. /**
  28038. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  28039. * Example : var p = SPS.particles[i];
  28040. */
  28041. particles: SolidParticle[];
  28042. /**
  28043. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  28044. */
  28045. nbParticles: number;
  28046. /**
  28047. * If the particles must ever face the camera (default false). Useful for planar particles.
  28048. */
  28049. billboard: boolean;
  28050. /**
  28051. * Recompute normals when adding a shape
  28052. */
  28053. recomputeNormals: boolean;
  28054. /**
  28055. * This a counter ofr your own usage. It's not set by any SPS functions.
  28056. */
  28057. counter: number;
  28058. /**
  28059. * The SPS name. This name is also given to the underlying mesh.
  28060. */
  28061. name: string;
  28062. /**
  28063. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  28064. */
  28065. mesh: Mesh;
  28066. /**
  28067. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  28068. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  28069. */
  28070. vars: any;
  28071. /**
  28072. * This array is populated when the SPS is set as 'pickable'.
  28073. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  28074. * Each element of this array is an object `{idx: int, faceId: int}`.
  28075. * `idx` is the picked particle index in the `SPS.particles` array
  28076. * `faceId` is the picked face index counted within this particle.
  28077. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  28078. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  28079. * Use the method SPS.pickedParticle(pickingInfo) instead.
  28080. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  28081. */
  28082. pickedParticles: {
  28083. idx: number;
  28084. faceId: number;
  28085. }[];
  28086. /**
  28087. * This array is populated when the SPS is set as 'pickable'
  28088. * Each key of this array is a submesh index.
  28089. * Each element of this array is a second array defined like this :
  28090. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  28091. * Each element of this second array is an object `{idx: int, faceId: int}`.
  28092. * `idx` is the picked particle index in the `SPS.particles` array
  28093. * `faceId` is the picked face index counted within this particle.
  28094. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  28095. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  28096. */
  28097. pickedBySubMesh: {
  28098. idx: number;
  28099. faceId: number;
  28100. }[][];
  28101. /**
  28102. * This array is populated when `enableDepthSort` is set to true.
  28103. * Each element of this array is an instance of the class DepthSortedParticle.
  28104. */
  28105. depthSortedParticles: DepthSortedParticle[];
  28106. /**
  28107. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  28108. * @hidden
  28109. */
  28110. _bSphereOnly: boolean;
  28111. /**
  28112. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  28113. * @hidden
  28114. */
  28115. _bSphereRadiusFactor: number;
  28116. private _scene;
  28117. private _positions;
  28118. private _indices;
  28119. private _normals;
  28120. private _colors;
  28121. private _uvs;
  28122. private _indices32;
  28123. private _positions32;
  28124. private _normals32;
  28125. private _fixedNormal32;
  28126. private _colors32;
  28127. private _uvs32;
  28128. private _index;
  28129. private _updatable;
  28130. private _pickable;
  28131. private _isVisibilityBoxLocked;
  28132. private _alwaysVisible;
  28133. private _depthSort;
  28134. private _expandable;
  28135. private _shapeCounter;
  28136. private _copy;
  28137. private _color;
  28138. private _computeParticleColor;
  28139. private _computeParticleTexture;
  28140. private _computeParticleRotation;
  28141. private _computeParticleVertex;
  28142. private _computeBoundingBox;
  28143. private _depthSortParticles;
  28144. private _camera;
  28145. private _mustUnrotateFixedNormals;
  28146. private _particlesIntersect;
  28147. private _needs32Bits;
  28148. private _isNotBuilt;
  28149. private _lastParticleId;
  28150. private _idxOfId;
  28151. private _multimaterialEnabled;
  28152. private _useModelMaterial;
  28153. private _indicesByMaterial;
  28154. private _materialIndexes;
  28155. private _depthSortFunction;
  28156. private _materialSortFunction;
  28157. private _materials;
  28158. private _multimaterial;
  28159. private _materialIndexesById;
  28160. private _defaultMaterial;
  28161. private _autoUpdateSubMeshes;
  28162. /**
  28163. * Creates a SPS (Solid Particle System) object.
  28164. * @param name (String) is the SPS name, this will be the underlying mesh name.
  28165. * @param scene (Scene) is the scene in which the SPS is added.
  28166. * @param options defines the options of the sps e.g.
  28167. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  28168. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  28169. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  28170. * * 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.
  28171. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  28172. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  28173. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  28174. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  28175. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  28176. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  28177. */
  28178. constructor(name: string, scene: Scene, options?: {
  28179. updatable?: boolean;
  28180. isPickable?: boolean;
  28181. enableDepthSort?: boolean;
  28182. particleIntersection?: boolean;
  28183. boundingSphereOnly?: boolean;
  28184. bSphereRadiusFactor?: number;
  28185. expandable?: boolean;
  28186. useModelMaterial?: boolean;
  28187. enableMultiMaterial?: boolean;
  28188. });
  28189. /**
  28190. * Builds the SPS underlying mesh. Returns a standard Mesh.
  28191. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  28192. * @returns the created mesh
  28193. */
  28194. buildMesh(): Mesh;
  28195. /**
  28196. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  28197. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  28198. * Thus the particles generated from `digest()` have their property `position` set yet.
  28199. * @param mesh ( Mesh ) is the mesh to be digested
  28200. * @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
  28201. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  28202. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  28203. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  28204. * @returns the current SPS
  28205. */
  28206. digest(mesh: Mesh, options?: {
  28207. facetNb?: number;
  28208. number?: number;
  28209. delta?: number;
  28210. storage?: [];
  28211. }): SolidParticleSystem;
  28212. /**
  28213. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  28214. * @hidden
  28215. */
  28216. private _unrotateFixedNormals;
  28217. /**
  28218. * Resets the temporary working copy particle
  28219. * @hidden
  28220. */
  28221. private _resetCopy;
  28222. /**
  28223. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  28224. * @param p the current index in the positions array to be updated
  28225. * @param ind the current index in the indices array
  28226. * @param shape a Vector3 array, the shape geometry
  28227. * @param positions the positions array to be updated
  28228. * @param meshInd the shape indices array
  28229. * @param indices the indices array to be updated
  28230. * @param meshUV the shape uv array
  28231. * @param uvs the uv array to be updated
  28232. * @param meshCol the shape color array
  28233. * @param colors the color array to be updated
  28234. * @param meshNor the shape normals array
  28235. * @param normals the normals array to be updated
  28236. * @param idx the particle index
  28237. * @param idxInShape the particle index in its shape
  28238. * @param options the addShape() method passed options
  28239. * @model the particle model
  28240. * @hidden
  28241. */
  28242. private _meshBuilder;
  28243. /**
  28244. * Returns a shape Vector3 array from positions float array
  28245. * @param positions float array
  28246. * @returns a vector3 array
  28247. * @hidden
  28248. */
  28249. private _posToShape;
  28250. /**
  28251. * Returns a shapeUV array from a float uvs (array deep copy)
  28252. * @param uvs as a float array
  28253. * @returns a shapeUV array
  28254. * @hidden
  28255. */
  28256. private _uvsToShapeUV;
  28257. /**
  28258. * Adds a new particle object in the particles array
  28259. * @param idx particle index in particles array
  28260. * @param id particle id
  28261. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  28262. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  28263. * @param model particle ModelShape object
  28264. * @param shapeId model shape identifier
  28265. * @param idxInShape index of the particle in the current model
  28266. * @param bInfo model bounding info object
  28267. * @param storage target storage array, if any
  28268. * @hidden
  28269. */
  28270. private _addParticle;
  28271. /**
  28272. * Adds some particles to the SPS from the model shape. Returns the shape id.
  28273. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  28274. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  28275. * @param nb (positive integer) the number of particles to be created from this model
  28276. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  28277. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  28278. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  28279. * @returns the number of shapes in the system
  28280. */
  28281. addShape(mesh: Mesh, nb: number, options?: {
  28282. positionFunction?: any;
  28283. vertexFunction?: any;
  28284. storage?: [];
  28285. }): number;
  28286. /**
  28287. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  28288. * @hidden
  28289. */
  28290. private _rebuildParticle;
  28291. /**
  28292. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  28293. * @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.
  28294. * @returns the SPS.
  28295. */
  28296. rebuildMesh(reset?: boolean): SolidParticleSystem;
  28297. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  28298. * Returns an array with the removed particles.
  28299. * 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.
  28300. * The SPS can't be empty so at least one particle needs to remain in place.
  28301. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  28302. * @param start index of the first particle to remove
  28303. * @param end index of the last particle to remove (included)
  28304. * @returns an array populated with the removed particles
  28305. */
  28306. removeParticles(start: number, end: number): SolidParticle[];
  28307. /**
  28308. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  28309. * @param solidParticleArray an array populated with Solid Particles objects
  28310. * @returns the SPS
  28311. */
  28312. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  28313. /**
  28314. * Creates a new particle and modifies the SPS mesh geometry :
  28315. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  28316. * - calls _addParticle() to populate the particle array
  28317. * factorized code from addShape() and insertParticlesFromArray()
  28318. * @param idx particle index in the particles array
  28319. * @param i particle index in its shape
  28320. * @param modelShape particle ModelShape object
  28321. * @param shape shape vertex array
  28322. * @param meshInd shape indices array
  28323. * @param meshUV shape uv array
  28324. * @param meshCol shape color array
  28325. * @param meshNor shape normals array
  28326. * @param bbInfo shape bounding info
  28327. * @param storage target particle storage
  28328. * @options addShape() passed options
  28329. * @hidden
  28330. */
  28331. private _insertNewParticle;
  28332. /**
  28333. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  28334. * This method calls `updateParticle()` for each particle of the SPS.
  28335. * For an animated SPS, it is usually called within the render loop.
  28336. * 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.
  28337. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  28338. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  28339. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  28340. * @returns the SPS.
  28341. */
  28342. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  28343. /**
  28344. * Disposes the SPS.
  28345. */
  28346. dispose(): void;
  28347. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  28348. * idx is the particle index in the SPS
  28349. * faceId is the picked face index counted within this particle.
  28350. * Returns null if the pickInfo can't identify a picked particle.
  28351. * @param pickingInfo (PickingInfo object)
  28352. * @returns {idx: number, faceId: number} or null
  28353. */
  28354. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  28355. idx: number;
  28356. faceId: number;
  28357. }>;
  28358. /**
  28359. * Returns a SolidParticle object from its identifier : particle.id
  28360. * @param id (integer) the particle Id
  28361. * @returns the searched particle or null if not found in the SPS.
  28362. */
  28363. getParticleById(id: number): Nullable<SolidParticle>;
  28364. /**
  28365. * Returns a new array populated with the particles having the passed shapeId.
  28366. * @param shapeId (integer) the shape identifier
  28367. * @returns a new solid particle array
  28368. */
  28369. getParticlesByShapeId(shapeId: number): SolidParticle[];
  28370. /**
  28371. * Populates the passed array "ref" with the particles having the passed shapeId.
  28372. * @param shapeId the shape identifier
  28373. * @returns the SPS
  28374. * @param ref
  28375. */
  28376. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  28377. /**
  28378. * Computes the required SubMeshes according the materials assigned to the particles.
  28379. * @returns the solid particle system.
  28380. * Does nothing if called before the SPS mesh is built.
  28381. */
  28382. computeSubMeshes(): SolidParticleSystem;
  28383. /**
  28384. * Sorts the solid particles by material when MultiMaterial is enabled.
  28385. * Updates the indices32 array.
  28386. * Updates the indicesByMaterial array.
  28387. * Updates the mesh indices array.
  28388. * @returns the SPS
  28389. * @hidden
  28390. */
  28391. private _sortParticlesByMaterial;
  28392. /**
  28393. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  28394. * @hidden
  28395. */
  28396. private _setMaterialIndexesById;
  28397. /**
  28398. * Returns an array with unique values of Materials from the passed array
  28399. * @param array the material array to be checked and filtered
  28400. * @hidden
  28401. */
  28402. private _filterUniqueMaterialId;
  28403. /**
  28404. * Sets a new Standard Material as _defaultMaterial if not already set.
  28405. * @hidden
  28406. */
  28407. private _setDefaultMaterial;
  28408. /**
  28409. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  28410. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28411. * @returns the SPS.
  28412. */
  28413. refreshVisibleSize(): SolidParticleSystem;
  28414. /**
  28415. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  28416. * @param size the size (float) of the visibility box
  28417. * note : this doesn't lock the SPS mesh bounding box.
  28418. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28419. */
  28420. setVisibilityBox(size: number): void;
  28421. /**
  28422. * Gets whether the SPS as always visible or not
  28423. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28424. */
  28425. get isAlwaysVisible(): boolean;
  28426. /**
  28427. * Sets the SPS as always visible or not
  28428. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28429. */
  28430. set isAlwaysVisible(val: boolean);
  28431. /**
  28432. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  28433. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28434. */
  28435. set isVisibilityBoxLocked(val: boolean);
  28436. /**
  28437. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  28438. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28439. */
  28440. get isVisibilityBoxLocked(): boolean;
  28441. /**
  28442. * Tells to `setParticles()` to compute the particle rotations or not.
  28443. * Default value : true. The SPS is faster when it's set to false.
  28444. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  28445. */
  28446. set computeParticleRotation(val: boolean);
  28447. /**
  28448. * Tells to `setParticles()` to compute the particle colors or not.
  28449. * Default value : true. The SPS is faster when it's set to false.
  28450. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  28451. */
  28452. set computeParticleColor(val: boolean);
  28453. set computeParticleTexture(val: boolean);
  28454. /**
  28455. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  28456. * Default value : false. The SPS is faster when it's set to false.
  28457. * Note : the particle custom vertex positions aren't stored values.
  28458. */
  28459. set computeParticleVertex(val: boolean);
  28460. /**
  28461. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  28462. */
  28463. set computeBoundingBox(val: boolean);
  28464. /**
  28465. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  28466. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  28467. * Default : `true`
  28468. */
  28469. set depthSortParticles(val: boolean);
  28470. /**
  28471. * Gets if `setParticles()` computes the particle rotations or not.
  28472. * Default value : true. The SPS is faster when it's set to false.
  28473. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  28474. */
  28475. get computeParticleRotation(): boolean;
  28476. /**
  28477. * Gets if `setParticles()` computes the particle colors or not.
  28478. * Default value : true. The SPS is faster when it's set to false.
  28479. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  28480. */
  28481. get computeParticleColor(): boolean;
  28482. /**
  28483. * Gets if `setParticles()` computes the particle textures or not.
  28484. * Default value : true. The SPS is faster when it's set to false.
  28485. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  28486. */
  28487. get computeParticleTexture(): boolean;
  28488. /**
  28489. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  28490. * Default value : false. The SPS is faster when it's set to false.
  28491. * Note : the particle custom vertex positions aren't stored values.
  28492. */
  28493. get computeParticleVertex(): boolean;
  28494. /**
  28495. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  28496. */
  28497. get computeBoundingBox(): boolean;
  28498. /**
  28499. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  28500. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  28501. * Default : `true`
  28502. */
  28503. get depthSortParticles(): boolean;
  28504. /**
  28505. * Gets if the SPS is created as expandable at construction time.
  28506. * Default : `false`
  28507. */
  28508. get expandable(): boolean;
  28509. /**
  28510. * Gets if the SPS supports the Multi Materials
  28511. */
  28512. get multimaterialEnabled(): boolean;
  28513. /**
  28514. * Gets if the SPS uses the model materials for its own multimaterial.
  28515. */
  28516. get useModelMaterial(): boolean;
  28517. /**
  28518. * The SPS used material array.
  28519. */
  28520. get materials(): Material[];
  28521. /**
  28522. * Sets the SPS MultiMaterial from the passed materials.
  28523. * Note : the passed array is internally copied and not used then by reference.
  28524. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  28525. */
  28526. setMultiMaterial(materials: Material[]): void;
  28527. /**
  28528. * The SPS computed multimaterial object
  28529. */
  28530. get multimaterial(): MultiMaterial;
  28531. set multimaterial(mm: MultiMaterial);
  28532. /**
  28533. * If the subMeshes must be updated on the next call to setParticles()
  28534. */
  28535. get autoUpdateSubMeshes(): boolean;
  28536. set autoUpdateSubMeshes(val: boolean);
  28537. /**
  28538. * This function does nothing. It may be overwritten to set all the particle first values.
  28539. * The SPS doesn't call this function, you may have to call it by your own.
  28540. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  28541. */
  28542. initParticles(): void;
  28543. /**
  28544. * This function does nothing. It may be overwritten to recycle a particle.
  28545. * The SPS doesn't call this function, you may have to call it by your own.
  28546. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  28547. * @param particle The particle to recycle
  28548. * @returns the recycled particle
  28549. */
  28550. recycleParticle(particle: SolidParticle): SolidParticle;
  28551. /**
  28552. * Updates a particle : this function should be overwritten by the user.
  28553. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  28554. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  28555. * @example : just set a particle position or velocity and recycle conditions
  28556. * @param particle The particle to update
  28557. * @returns the updated particle
  28558. */
  28559. updateParticle(particle: SolidParticle): SolidParticle;
  28560. /**
  28561. * Updates a vertex of a particle : it can be overwritten by the user.
  28562. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  28563. * @param particle the current particle
  28564. * @param vertex the current index of the current particle
  28565. * @param pt the index of the current vertex in the particle shape
  28566. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  28567. * @example : just set a vertex particle position
  28568. * @returns the updated vertex
  28569. */
  28570. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  28571. /**
  28572. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  28573. * This does nothing and may be overwritten by the user.
  28574. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  28575. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  28576. * @param update the boolean update value actually passed to setParticles()
  28577. */
  28578. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  28579. /**
  28580. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  28581. * This 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. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  28588. }
  28589. }
  28590. declare module "babylonjs/Particles/solidParticle" {
  28591. import { Nullable } from "babylonjs/types";
  28592. import { Vector3, Matrix, Quaternion, Vector4 } from "babylonjs/Maths/math.vector";
  28593. import { Color4 } from "babylonjs/Maths/math.color";
  28594. import { Mesh } from "babylonjs/Meshes/mesh";
  28595. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  28596. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  28597. import { Plane } from "babylonjs/Maths/math.plane";
  28598. import { Material } from "babylonjs/Materials/material";
  28599. /**
  28600. * Represents one particle of a solid particle system.
  28601. */
  28602. export class SolidParticle {
  28603. /**
  28604. * particle global index
  28605. */
  28606. idx: number;
  28607. /**
  28608. * particle identifier
  28609. */
  28610. id: number;
  28611. /**
  28612. * The color of the particle
  28613. */
  28614. color: Nullable<Color4>;
  28615. /**
  28616. * The world space position of the particle.
  28617. */
  28618. position: Vector3;
  28619. /**
  28620. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  28621. */
  28622. rotation: Vector3;
  28623. /**
  28624. * The world space rotation quaternion of the particle.
  28625. */
  28626. rotationQuaternion: Nullable<Quaternion>;
  28627. /**
  28628. * The scaling of the particle.
  28629. */
  28630. scaling: Vector3;
  28631. /**
  28632. * The uvs of the particle.
  28633. */
  28634. uvs: Vector4;
  28635. /**
  28636. * The current speed of the particle.
  28637. */
  28638. velocity: Vector3;
  28639. /**
  28640. * The pivot point in the particle local space.
  28641. */
  28642. pivot: Vector3;
  28643. /**
  28644. * Must the particle be translated from its pivot point in its local space ?
  28645. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  28646. * Default : false
  28647. */
  28648. translateFromPivot: boolean;
  28649. /**
  28650. * Is the particle active or not ?
  28651. */
  28652. alive: boolean;
  28653. /**
  28654. * Is the particle visible or not ?
  28655. */
  28656. isVisible: boolean;
  28657. /**
  28658. * Index of this particle in the global "positions" array (Internal use)
  28659. * @hidden
  28660. */
  28661. _pos: number;
  28662. /**
  28663. * @hidden Index of this particle in the global "indices" array (Internal use)
  28664. */
  28665. _ind: number;
  28666. /**
  28667. * @hidden ModelShape of this particle (Internal use)
  28668. */
  28669. _model: ModelShape;
  28670. /**
  28671. * ModelShape id of this particle
  28672. */
  28673. shapeId: number;
  28674. /**
  28675. * Index of the particle in its shape id
  28676. */
  28677. idxInShape: number;
  28678. /**
  28679. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  28680. */
  28681. _modelBoundingInfo: BoundingInfo;
  28682. /**
  28683. * @hidden Particle BoundingInfo object (Internal use)
  28684. */
  28685. _boundingInfo: BoundingInfo;
  28686. /**
  28687. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  28688. */
  28689. _sps: SolidParticleSystem;
  28690. /**
  28691. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  28692. */
  28693. _stillInvisible: boolean;
  28694. /**
  28695. * @hidden Last computed particle rotation matrix
  28696. */
  28697. _rotationMatrix: number[];
  28698. /**
  28699. * Parent particle Id, if any.
  28700. * Default null.
  28701. */
  28702. parentId: Nullable<number>;
  28703. /**
  28704. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  28705. */
  28706. materialIndex: Nullable<number>;
  28707. /**
  28708. * Custom object or properties.
  28709. */
  28710. props: Nullable<any>;
  28711. /**
  28712. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  28713. * The possible values are :
  28714. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  28715. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  28716. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  28717. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  28718. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  28719. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  28720. * */
  28721. cullingStrategy: number;
  28722. /**
  28723. * @hidden Internal global position in the SPS.
  28724. */
  28725. _globalPosition: Vector3;
  28726. /**
  28727. * Creates a Solid Particle object.
  28728. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  28729. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  28730. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  28731. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  28732. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  28733. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  28734. * @param shapeId (integer) is the model shape identifier in the SPS.
  28735. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  28736. * @param sps defines the sps it is associated to
  28737. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  28738. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  28739. */
  28740. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  28741. /**
  28742. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  28743. * @param target the particle target
  28744. * @returns the current particle
  28745. */
  28746. copyToRef(target: SolidParticle): SolidParticle;
  28747. /**
  28748. * Legacy support, changed scale to scaling
  28749. */
  28750. get scale(): Vector3;
  28751. /**
  28752. * Legacy support, changed scale to scaling
  28753. */
  28754. set scale(scale: Vector3);
  28755. /**
  28756. * Legacy support, changed quaternion to rotationQuaternion
  28757. */
  28758. get quaternion(): Nullable<Quaternion>;
  28759. /**
  28760. * Legacy support, changed quaternion to rotationQuaternion
  28761. */
  28762. set quaternion(q: Nullable<Quaternion>);
  28763. /**
  28764. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  28765. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  28766. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  28767. * @returns true if it intersects
  28768. */
  28769. intersectsMesh(target: Mesh | SolidParticle): boolean;
  28770. /**
  28771. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  28772. * A particle is in the frustum if its bounding box intersects the frustum
  28773. * @param frustumPlanes defines the frustum to test
  28774. * @returns true if the particle is in the frustum planes
  28775. */
  28776. isInFrustum(frustumPlanes: Plane[]): boolean;
  28777. /**
  28778. * get the rotation matrix of the particle
  28779. * @hidden
  28780. */
  28781. getRotationMatrix(m: Matrix): void;
  28782. }
  28783. /**
  28784. * Represents the shape of the model used by one particle of a solid particle system.
  28785. * SPS internal tool, don't use it manually.
  28786. */
  28787. export class ModelShape {
  28788. /**
  28789. * The shape id
  28790. * @hidden
  28791. */
  28792. shapeID: number;
  28793. /**
  28794. * flat array of model positions (internal use)
  28795. * @hidden
  28796. */
  28797. _shape: Vector3[];
  28798. /**
  28799. * flat array of model UVs (internal use)
  28800. * @hidden
  28801. */
  28802. _shapeUV: number[];
  28803. /**
  28804. * color array of the model
  28805. * @hidden
  28806. */
  28807. _shapeColors: number[];
  28808. /**
  28809. * indices array of the model
  28810. * @hidden
  28811. */
  28812. _indices: number[];
  28813. /**
  28814. * normals array of the model
  28815. * @hidden
  28816. */
  28817. _normals: number[];
  28818. /**
  28819. * length of the shape in the model indices array (internal use)
  28820. * @hidden
  28821. */
  28822. _indicesLength: number;
  28823. /**
  28824. * Custom position function (internal use)
  28825. * @hidden
  28826. */
  28827. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  28828. /**
  28829. * Custom vertex function (internal use)
  28830. * @hidden
  28831. */
  28832. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  28833. /**
  28834. * Model material (internal use)
  28835. * @hidden
  28836. */
  28837. _material: Nullable<Material>;
  28838. /**
  28839. * 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.
  28840. * SPS internal tool, don't use it manually.
  28841. * @hidden
  28842. */
  28843. 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>);
  28844. }
  28845. /**
  28846. * Represents a Depth Sorted Particle in the solid particle system.
  28847. * @hidden
  28848. */
  28849. export class DepthSortedParticle {
  28850. /**
  28851. * Particle index
  28852. */
  28853. idx: number;
  28854. /**
  28855. * Index of the particle in the "indices" array
  28856. */
  28857. ind: number;
  28858. /**
  28859. * Length of the particle shape in the "indices" array
  28860. */
  28861. indicesLength: number;
  28862. /**
  28863. * Squared distance from the particle to the camera
  28864. */
  28865. sqDistance: number;
  28866. /**
  28867. * Material index when used with MultiMaterials
  28868. */
  28869. materialIndex: number;
  28870. /**
  28871. * Creates a new sorted particle
  28872. * @param materialIndex
  28873. */
  28874. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  28875. }
  28876. }
  28877. declare module "babylonjs/Collisions/meshCollisionData" {
  28878. import { Collider } from "babylonjs/Collisions/collider";
  28879. import { Vector3 } from "babylonjs/Maths/math.vector";
  28880. import { Nullable } from "babylonjs/types";
  28881. import { Observer } from "babylonjs/Misc/observable";
  28882. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28883. /**
  28884. * @hidden
  28885. */
  28886. export class _MeshCollisionData {
  28887. _checkCollisions: boolean;
  28888. _collisionMask: number;
  28889. _collisionGroup: number;
  28890. _surroundingMeshes: Nullable<AbstractMesh[]>;
  28891. _collider: Nullable<Collider>;
  28892. _oldPositionForCollisions: Vector3;
  28893. _diffPositionForCollisions: Vector3;
  28894. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  28895. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  28896. }
  28897. }
  28898. declare module "babylonjs/Meshes/abstractMesh" {
  28899. import { Observable } from "babylonjs/Misc/observable";
  28900. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  28901. import { Camera } from "babylonjs/Cameras/camera";
  28902. import { Scene, IDisposable } from "babylonjs/scene";
  28903. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  28904. import { Node } from "babylonjs/node";
  28905. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  28906. import { TransformNode } from "babylonjs/Meshes/transformNode";
  28907. import { SubMesh } from "babylonjs/Meshes/subMesh";
  28908. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  28909. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  28910. import { Material } from "babylonjs/Materials/material";
  28911. import { Light } from "babylonjs/Lights/light";
  28912. import { Skeleton } from "babylonjs/Bones/skeleton";
  28913. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  28914. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  28915. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  28916. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  28917. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  28918. import { Plane } from "babylonjs/Maths/math.plane";
  28919. import { Ray } from "babylonjs/Culling/ray";
  28920. import { Collider } from "babylonjs/Collisions/collider";
  28921. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  28922. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  28923. /** @hidden */
  28924. class _FacetDataStorage {
  28925. facetPositions: Vector3[];
  28926. facetNormals: Vector3[];
  28927. facetPartitioning: number[][];
  28928. facetNb: number;
  28929. partitioningSubdivisions: number;
  28930. partitioningBBoxRatio: number;
  28931. facetDataEnabled: boolean;
  28932. facetParameters: any;
  28933. bbSize: Vector3;
  28934. subDiv: {
  28935. max: number;
  28936. X: number;
  28937. Y: number;
  28938. Z: number;
  28939. };
  28940. facetDepthSort: boolean;
  28941. facetDepthSortEnabled: boolean;
  28942. depthSortedIndices: IndicesArray;
  28943. depthSortedFacets: {
  28944. ind: number;
  28945. sqDistance: number;
  28946. }[];
  28947. facetDepthSortFunction: (f1: {
  28948. ind: number;
  28949. sqDistance: number;
  28950. }, f2: {
  28951. ind: number;
  28952. sqDistance: number;
  28953. }) => number;
  28954. facetDepthSortFrom: Vector3;
  28955. facetDepthSortOrigin: Vector3;
  28956. invertedMatrix: Matrix;
  28957. }
  28958. /**
  28959. * @hidden
  28960. **/
  28961. class _InternalAbstractMeshDataInfo {
  28962. _hasVertexAlpha: boolean;
  28963. _useVertexColors: boolean;
  28964. _numBoneInfluencers: number;
  28965. _applyFog: boolean;
  28966. _receiveShadows: boolean;
  28967. _facetData: _FacetDataStorage;
  28968. _visibility: number;
  28969. _skeleton: Nullable<Skeleton>;
  28970. _layerMask: number;
  28971. _computeBonesUsingShaders: boolean;
  28972. _isActive: boolean;
  28973. _onlyForInstances: boolean;
  28974. _isActiveIntermediate: boolean;
  28975. _onlyForInstancesIntermediate: boolean;
  28976. _actAsRegularMesh: boolean;
  28977. }
  28978. /**
  28979. * Class used to store all common mesh properties
  28980. */
  28981. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  28982. /** No occlusion */
  28983. static OCCLUSION_TYPE_NONE: number;
  28984. /** Occlusion set to optimisitic */
  28985. static OCCLUSION_TYPE_OPTIMISTIC: number;
  28986. /** Occlusion set to strict */
  28987. static OCCLUSION_TYPE_STRICT: number;
  28988. /** Use an accurante occlusion algorithm */
  28989. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  28990. /** Use a conservative occlusion algorithm */
  28991. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  28992. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  28993. * Test order :
  28994. * Is the bounding sphere outside the frustum ?
  28995. * If not, are the bounding box vertices outside the frustum ?
  28996. * It not, then the cullable object is in the frustum.
  28997. */
  28998. static readonly CULLINGSTRATEGY_STANDARD: number;
  28999. /** Culling strategy : Bounding Sphere Only.
  29000. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  29001. * It's also less accurate than the standard because some not visible objects can still be selected.
  29002. * Test : is the bounding sphere outside the frustum ?
  29003. * If not, then the cullable object is in the frustum.
  29004. */
  29005. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  29006. /** Culling strategy : Optimistic Inclusion.
  29007. * This in an inclusion test first, then the standard exclusion test.
  29008. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  29009. * 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.
  29010. * Anyway, it's as accurate as the standard strategy.
  29011. * Test :
  29012. * Is the cullable object bounding sphere center in the frustum ?
  29013. * If not, apply the default culling strategy.
  29014. */
  29015. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  29016. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  29017. * This in an inclusion test first, then the bounding sphere only exclusion test.
  29018. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  29019. * 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.
  29020. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  29021. * Test :
  29022. * Is the cullable object bounding sphere center in the frustum ?
  29023. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  29024. */
  29025. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  29026. /**
  29027. * No billboard
  29028. */
  29029. static get BILLBOARDMODE_NONE(): number;
  29030. /** Billboard on X axis */
  29031. static get BILLBOARDMODE_X(): number;
  29032. /** Billboard on Y axis */
  29033. static get BILLBOARDMODE_Y(): number;
  29034. /** Billboard on Z axis */
  29035. static get BILLBOARDMODE_Z(): number;
  29036. /** Billboard on all axes */
  29037. static get BILLBOARDMODE_ALL(): number;
  29038. /** Billboard on using position instead of orientation */
  29039. static get BILLBOARDMODE_USE_POSITION(): number;
  29040. /** @hidden */
  29041. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  29042. /**
  29043. * The culling strategy to use to check whether the mesh must be rendered or not.
  29044. * This value can be changed at any time and will be used on the next render mesh selection.
  29045. * The possible values are :
  29046. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  29047. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  29048. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  29049. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  29050. * Please read each static variable documentation to get details about the culling process.
  29051. * */
  29052. cullingStrategy: number;
  29053. /**
  29054. * Gets the number of facets in the mesh
  29055. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  29056. */
  29057. get facetNb(): number;
  29058. /**
  29059. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  29060. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  29061. */
  29062. get partitioningSubdivisions(): number;
  29063. set partitioningSubdivisions(nb: number);
  29064. /**
  29065. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  29066. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  29067. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  29068. */
  29069. get partitioningBBoxRatio(): number;
  29070. set partitioningBBoxRatio(ratio: number);
  29071. /**
  29072. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  29073. * Works only for updatable meshes.
  29074. * Doesn't work with multi-materials
  29075. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  29076. */
  29077. get mustDepthSortFacets(): boolean;
  29078. set mustDepthSortFacets(sort: boolean);
  29079. /**
  29080. * The location (Vector3) where the facet depth sort must be computed from.
  29081. * By default, the active camera position.
  29082. * Used only when facet depth sort is enabled
  29083. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  29084. */
  29085. get facetDepthSortFrom(): Vector3;
  29086. set facetDepthSortFrom(location: Vector3);
  29087. /**
  29088. * gets a boolean indicating if facetData is enabled
  29089. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  29090. */
  29091. get isFacetDataEnabled(): boolean;
  29092. /** @hidden */
  29093. _updateNonUniformScalingState(value: boolean): boolean;
  29094. /**
  29095. * An event triggered when this mesh collides with another one
  29096. */
  29097. onCollideObservable: Observable<AbstractMesh>;
  29098. /** Set a function to call when this mesh collides with another one */
  29099. set onCollide(callback: () => void);
  29100. /**
  29101. * An event triggered when the collision's position changes
  29102. */
  29103. onCollisionPositionChangeObservable: Observable<Vector3>;
  29104. /** Set a function to call when the collision's position changes */
  29105. set onCollisionPositionChange(callback: () => void);
  29106. /**
  29107. * An event triggered when material is changed
  29108. */
  29109. onMaterialChangedObservable: Observable<AbstractMesh>;
  29110. /**
  29111. * Gets or sets the orientation for POV movement & rotation
  29112. */
  29113. definedFacingForward: boolean;
  29114. /** @hidden */
  29115. _occlusionQuery: Nullable<WebGLQuery>;
  29116. /** @hidden */
  29117. _renderingGroup: Nullable<RenderingGroup>;
  29118. /**
  29119. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  29120. */
  29121. get visibility(): number;
  29122. /**
  29123. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  29124. */
  29125. set visibility(value: number);
  29126. /** Gets or sets the alpha index used to sort transparent meshes
  29127. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  29128. */
  29129. alphaIndex: number;
  29130. /**
  29131. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  29132. */
  29133. isVisible: boolean;
  29134. /**
  29135. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  29136. */
  29137. isPickable: boolean;
  29138. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  29139. showSubMeshesBoundingBox: boolean;
  29140. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  29141. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  29142. */
  29143. isBlocker: boolean;
  29144. /**
  29145. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  29146. */
  29147. enablePointerMoveEvents: boolean;
  29148. /**
  29149. * Specifies the rendering group id for this mesh (0 by default)
  29150. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  29151. */
  29152. renderingGroupId: number;
  29153. private _material;
  29154. /** Gets or sets current material */
  29155. get material(): Nullable<Material>;
  29156. set material(value: Nullable<Material>);
  29157. /**
  29158. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  29159. * @see http://doc.babylonjs.com/babylon101/shadows
  29160. */
  29161. get receiveShadows(): boolean;
  29162. set receiveShadows(value: boolean);
  29163. /** Defines color to use when rendering outline */
  29164. outlineColor: Color3;
  29165. /** Define width to use when rendering outline */
  29166. outlineWidth: number;
  29167. /** Defines color to use when rendering overlay */
  29168. overlayColor: Color3;
  29169. /** Defines alpha to use when rendering overlay */
  29170. overlayAlpha: number;
  29171. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  29172. get hasVertexAlpha(): boolean;
  29173. set hasVertexAlpha(value: boolean);
  29174. /** 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) */
  29175. get useVertexColors(): boolean;
  29176. set useVertexColors(value: boolean);
  29177. /**
  29178. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  29179. */
  29180. get computeBonesUsingShaders(): boolean;
  29181. set computeBonesUsingShaders(value: boolean);
  29182. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  29183. get numBoneInfluencers(): number;
  29184. set numBoneInfluencers(value: number);
  29185. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  29186. get applyFog(): boolean;
  29187. set applyFog(value: boolean);
  29188. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  29189. useOctreeForRenderingSelection: boolean;
  29190. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  29191. useOctreeForPicking: boolean;
  29192. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  29193. useOctreeForCollisions: boolean;
  29194. /**
  29195. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  29196. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  29197. */
  29198. get layerMask(): number;
  29199. set layerMask(value: number);
  29200. /**
  29201. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  29202. */
  29203. alwaysSelectAsActiveMesh: boolean;
  29204. /**
  29205. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  29206. */
  29207. doNotSyncBoundingInfo: boolean;
  29208. /**
  29209. * Gets or sets the current action manager
  29210. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  29211. */
  29212. actionManager: Nullable<AbstractActionManager>;
  29213. private _meshCollisionData;
  29214. /**
  29215. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  29216. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  29217. */
  29218. ellipsoid: Vector3;
  29219. /**
  29220. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  29221. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  29222. */
  29223. ellipsoidOffset: Vector3;
  29224. /**
  29225. * Gets or sets a collision mask used to mask collisions (default is -1).
  29226. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  29227. */
  29228. get collisionMask(): number;
  29229. set collisionMask(mask: number);
  29230. /**
  29231. * Gets or sets the current collision group mask (-1 by default).
  29232. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  29233. */
  29234. get collisionGroup(): number;
  29235. set collisionGroup(mask: number);
  29236. /**
  29237. * Gets or sets current surrounding meshes (null by default).
  29238. *
  29239. * By default collision detection is tested against every mesh in the scene.
  29240. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  29241. * meshes will be tested for the collision.
  29242. *
  29243. * Note: if set to an empty array no collision will happen when this mesh is moved.
  29244. */
  29245. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  29246. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  29247. /**
  29248. * Defines edge width used when edgesRenderer is enabled
  29249. * @see https://www.babylonjs-playground.com/#10OJSG#13
  29250. */
  29251. edgesWidth: number;
  29252. /**
  29253. * Defines edge color used when edgesRenderer is enabled
  29254. * @see https://www.babylonjs-playground.com/#10OJSG#13
  29255. */
  29256. edgesColor: Color4;
  29257. /** @hidden */
  29258. _edgesRenderer: Nullable<IEdgesRenderer>;
  29259. /** @hidden */
  29260. _masterMesh: Nullable<AbstractMesh>;
  29261. /** @hidden */
  29262. _boundingInfo: Nullable<BoundingInfo>;
  29263. /** @hidden */
  29264. _renderId: number;
  29265. /**
  29266. * Gets or sets the list of subMeshes
  29267. * @see http://doc.babylonjs.com/how_to/multi_materials
  29268. */
  29269. subMeshes: SubMesh[];
  29270. /** @hidden */
  29271. _intersectionsInProgress: AbstractMesh[];
  29272. /** @hidden */
  29273. _unIndexed: boolean;
  29274. /** @hidden */
  29275. _lightSources: Light[];
  29276. /** Gets the list of lights affecting that mesh */
  29277. get lightSources(): Light[];
  29278. /** @hidden */
  29279. get _positions(): Nullable<Vector3[]>;
  29280. /** @hidden */
  29281. _waitingData: {
  29282. lods: Nullable<any>;
  29283. actions: Nullable<any>;
  29284. freezeWorldMatrix: Nullable<boolean>;
  29285. };
  29286. /** @hidden */
  29287. _bonesTransformMatrices: Nullable<Float32Array>;
  29288. /** @hidden */
  29289. _transformMatrixTexture: Nullable<RawTexture>;
  29290. /**
  29291. * Gets or sets a skeleton to apply skining transformations
  29292. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  29293. */
  29294. set skeleton(value: Nullable<Skeleton>);
  29295. get skeleton(): Nullable<Skeleton>;
  29296. /**
  29297. * An event triggered when the mesh is rebuilt.
  29298. */
  29299. onRebuildObservable: Observable<AbstractMesh>;
  29300. /**
  29301. * Creates a new AbstractMesh
  29302. * @param name defines the name of the mesh
  29303. * @param scene defines the hosting scene
  29304. */
  29305. constructor(name: string, scene?: Nullable<Scene>);
  29306. /**
  29307. * Returns the string "AbstractMesh"
  29308. * @returns "AbstractMesh"
  29309. */
  29310. getClassName(): string;
  29311. /**
  29312. * Gets a string representation of the current mesh
  29313. * @param fullDetails defines a boolean indicating if full details must be included
  29314. * @returns a string representation of the current mesh
  29315. */
  29316. toString(fullDetails?: boolean): string;
  29317. /**
  29318. * @hidden
  29319. */
  29320. protected _getEffectiveParent(): Nullable<Node>;
  29321. /** @hidden */
  29322. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  29323. /** @hidden */
  29324. _rebuild(): void;
  29325. /** @hidden */
  29326. _resyncLightSources(): void;
  29327. /** @hidden */
  29328. _resyncLightSource(light: Light): void;
  29329. /** @hidden */
  29330. _unBindEffect(): void;
  29331. /** @hidden */
  29332. _removeLightSource(light: Light, dispose: boolean): void;
  29333. private _markSubMeshesAsDirty;
  29334. /** @hidden */
  29335. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  29336. /** @hidden */
  29337. _markSubMeshesAsAttributesDirty(): void;
  29338. /** @hidden */
  29339. _markSubMeshesAsMiscDirty(): void;
  29340. /**
  29341. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  29342. */
  29343. get scaling(): Vector3;
  29344. set scaling(newScaling: Vector3);
  29345. /**
  29346. * Returns true if the mesh is blocked. Implemented by child classes
  29347. */
  29348. get isBlocked(): boolean;
  29349. /**
  29350. * Returns the mesh itself by default. Implemented by child classes
  29351. * @param camera defines the camera to use to pick the right LOD level
  29352. * @returns the currentAbstractMesh
  29353. */
  29354. getLOD(camera: Camera): Nullable<AbstractMesh>;
  29355. /**
  29356. * Returns 0 by default. Implemented by child classes
  29357. * @returns an integer
  29358. */
  29359. getTotalVertices(): number;
  29360. /**
  29361. * Returns a positive integer : the total number of indices in this mesh geometry.
  29362. * @returns the numner of indices or zero if the mesh has no geometry.
  29363. */
  29364. getTotalIndices(): number;
  29365. /**
  29366. * Returns null by default. Implemented by child classes
  29367. * @returns null
  29368. */
  29369. getIndices(): Nullable<IndicesArray>;
  29370. /**
  29371. * Returns the array of the requested vertex data kind. Implemented by child classes
  29372. * @param kind defines the vertex data kind to use
  29373. * @returns null
  29374. */
  29375. getVerticesData(kind: string): Nullable<FloatArray>;
  29376. /**
  29377. * Sets the vertex data of the mesh geometry for the requested `kind`.
  29378. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  29379. * Note that a new underlying VertexBuffer object is created each call.
  29380. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  29381. * @param kind defines vertex data kind:
  29382. * * VertexBuffer.PositionKind
  29383. * * VertexBuffer.UVKind
  29384. * * VertexBuffer.UV2Kind
  29385. * * VertexBuffer.UV3Kind
  29386. * * VertexBuffer.UV4Kind
  29387. * * VertexBuffer.UV5Kind
  29388. * * VertexBuffer.UV6Kind
  29389. * * VertexBuffer.ColorKind
  29390. * * VertexBuffer.MatricesIndicesKind
  29391. * * VertexBuffer.MatricesIndicesExtraKind
  29392. * * VertexBuffer.MatricesWeightsKind
  29393. * * VertexBuffer.MatricesWeightsExtraKind
  29394. * @param data defines the data source
  29395. * @param updatable defines if the data must be flagged as updatable (or static)
  29396. * @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
  29397. * @returns the current mesh
  29398. */
  29399. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  29400. /**
  29401. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  29402. * If the mesh has no geometry, it is simply returned as it is.
  29403. * @param kind defines vertex data kind:
  29404. * * VertexBuffer.PositionKind
  29405. * * VertexBuffer.UVKind
  29406. * * VertexBuffer.UV2Kind
  29407. * * VertexBuffer.UV3Kind
  29408. * * VertexBuffer.UV4Kind
  29409. * * VertexBuffer.UV5Kind
  29410. * * VertexBuffer.UV6Kind
  29411. * * VertexBuffer.ColorKind
  29412. * * VertexBuffer.MatricesIndicesKind
  29413. * * VertexBuffer.MatricesIndicesExtraKind
  29414. * * VertexBuffer.MatricesWeightsKind
  29415. * * VertexBuffer.MatricesWeightsExtraKind
  29416. * @param data defines the data source
  29417. * @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
  29418. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  29419. * @returns the current mesh
  29420. */
  29421. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  29422. /**
  29423. * Sets the mesh indices,
  29424. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  29425. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  29426. * @param totalVertices Defines the total number of vertices
  29427. * @returns the current mesh
  29428. */
  29429. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  29430. /**
  29431. * Gets a boolean indicating if specific vertex data is present
  29432. * @param kind defines the vertex data kind to use
  29433. * @returns true is data kind is present
  29434. */
  29435. isVerticesDataPresent(kind: string): boolean;
  29436. /**
  29437. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  29438. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  29439. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  29440. * @returns a BoundingInfo
  29441. */
  29442. getBoundingInfo(): BoundingInfo;
  29443. /**
  29444. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  29445. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  29446. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  29447. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  29448. * @returns the current mesh
  29449. */
  29450. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  29451. /**
  29452. * Overwrite the current bounding info
  29453. * @param boundingInfo defines the new bounding info
  29454. * @returns the current mesh
  29455. */
  29456. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  29457. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  29458. get useBones(): boolean;
  29459. /** @hidden */
  29460. _preActivate(): void;
  29461. /** @hidden */
  29462. _preActivateForIntermediateRendering(renderId: number): void;
  29463. /** @hidden */
  29464. _activate(renderId: number, intermediateRendering: boolean): boolean;
  29465. /** @hidden */
  29466. _postActivate(): void;
  29467. /** @hidden */
  29468. _freeze(): void;
  29469. /** @hidden */
  29470. _unFreeze(): void;
  29471. /**
  29472. * Gets the current world matrix
  29473. * @returns a Matrix
  29474. */
  29475. getWorldMatrix(): Matrix;
  29476. /** @hidden */
  29477. _getWorldMatrixDeterminant(): number;
  29478. /**
  29479. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  29480. */
  29481. get isAnInstance(): boolean;
  29482. /**
  29483. * Gets a boolean indicating if this mesh has instances
  29484. */
  29485. get hasInstances(): boolean;
  29486. /**
  29487. * Perform relative position change from the point of view of behind the front of the mesh.
  29488. * This is performed taking into account the meshes current rotation, so you do not have to care.
  29489. * Supports definition of mesh facing forward or backward
  29490. * @param amountRight defines the distance on the right axis
  29491. * @param amountUp defines the distance on the up axis
  29492. * @param amountForward defines the distance on the forward axis
  29493. * @returns the current mesh
  29494. */
  29495. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  29496. /**
  29497. * Calculate relative position change from the point of view of behind the front of the mesh.
  29498. * This is performed taking into account the meshes current rotation, so you do not have to care.
  29499. * Supports definition of mesh facing forward or backward
  29500. * @param amountRight defines the distance on the right axis
  29501. * @param amountUp defines the distance on the up axis
  29502. * @param amountForward defines the distance on the forward axis
  29503. * @returns the new displacement vector
  29504. */
  29505. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  29506. /**
  29507. * Perform relative rotation change from the point of view of behind the front of the mesh.
  29508. * Supports definition of mesh facing forward or backward
  29509. * @param flipBack defines the flip
  29510. * @param twirlClockwise defines the twirl
  29511. * @param tiltRight defines the tilt
  29512. * @returns the current mesh
  29513. */
  29514. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  29515. /**
  29516. * Calculate 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 new rotation vector
  29522. */
  29523. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  29524. /**
  29525. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  29526. * This means the mesh underlying bounding box and sphere are recomputed.
  29527. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  29528. * @returns the current mesh
  29529. */
  29530. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  29531. /** @hidden */
  29532. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  29533. /** @hidden */
  29534. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  29535. /** @hidden */
  29536. _updateBoundingInfo(): AbstractMesh;
  29537. /** @hidden */
  29538. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  29539. /** @hidden */
  29540. protected _afterComputeWorldMatrix(): void;
  29541. /** @hidden */
  29542. get _effectiveMesh(): AbstractMesh;
  29543. /**
  29544. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  29545. * A mesh is in the frustum if its bounding box intersects the frustum
  29546. * @param frustumPlanes defines the frustum to test
  29547. * @returns true if the mesh is in the frustum planes
  29548. */
  29549. isInFrustum(frustumPlanes: Plane[]): boolean;
  29550. /**
  29551. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  29552. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  29553. * @param frustumPlanes defines the frustum to test
  29554. * @returns true if the mesh is completely in the frustum planes
  29555. */
  29556. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  29557. /**
  29558. * True if the mesh intersects another mesh or a SolidParticle object
  29559. * @param mesh defines a target mesh or SolidParticle to test
  29560. * @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)
  29561. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  29562. * @returns true if there is an intersection
  29563. */
  29564. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  29565. /**
  29566. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  29567. * @param point defines the point to test
  29568. * @returns true if there is an intersection
  29569. */
  29570. intersectsPoint(point: Vector3): boolean;
  29571. /**
  29572. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  29573. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  29574. */
  29575. get checkCollisions(): boolean;
  29576. set checkCollisions(collisionEnabled: boolean);
  29577. /**
  29578. * Gets Collider object used to compute collisions (not physics)
  29579. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  29580. */
  29581. get collider(): Nullable<Collider>;
  29582. /**
  29583. * Move the mesh using collision engine
  29584. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  29585. * @param displacement defines the requested displacement vector
  29586. * @returns the current mesh
  29587. */
  29588. moveWithCollisions(displacement: Vector3): AbstractMesh;
  29589. private _onCollisionPositionChange;
  29590. /** @hidden */
  29591. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  29592. /** @hidden */
  29593. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  29594. /** @hidden */
  29595. _checkCollision(collider: Collider): AbstractMesh;
  29596. /** @hidden */
  29597. _generatePointsArray(): boolean;
  29598. /**
  29599. * Checks if the passed Ray intersects with the mesh
  29600. * @param ray defines the ray to use
  29601. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  29602. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  29603. * @returns the picking info
  29604. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  29605. */
  29606. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  29607. /**
  29608. * Clones the current mesh
  29609. * @param name defines the mesh name
  29610. * @param newParent defines the new mesh parent
  29611. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  29612. * @returns the new mesh
  29613. */
  29614. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  29615. /**
  29616. * Disposes all the submeshes of the current meshnp
  29617. * @returns the current mesh
  29618. */
  29619. releaseSubMeshes(): AbstractMesh;
  29620. /**
  29621. * Releases resources associated with this abstract mesh.
  29622. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29623. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29624. */
  29625. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29626. /**
  29627. * Adds the passed mesh as a child to the current mesh
  29628. * @param mesh defines the child mesh
  29629. * @returns the current mesh
  29630. */
  29631. addChild(mesh: AbstractMesh): AbstractMesh;
  29632. /**
  29633. * Removes the passed mesh from the current mesh children list
  29634. * @param mesh defines the child mesh
  29635. * @returns the current mesh
  29636. */
  29637. removeChild(mesh: AbstractMesh): AbstractMesh;
  29638. /** @hidden */
  29639. private _initFacetData;
  29640. /**
  29641. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  29642. * This method can be called within the render loop.
  29643. * 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
  29644. * @returns the current mesh
  29645. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29646. */
  29647. updateFacetData(): AbstractMesh;
  29648. /**
  29649. * Returns the facetLocalNormals array.
  29650. * The normals are expressed in the mesh local spac
  29651. * @returns an array of Vector3
  29652. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29653. */
  29654. getFacetLocalNormals(): Vector3[];
  29655. /**
  29656. * Returns the facetLocalPositions array.
  29657. * The facet positions are expressed in the mesh local space
  29658. * @returns an array of Vector3
  29659. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29660. */
  29661. getFacetLocalPositions(): Vector3[];
  29662. /**
  29663. * Returns the facetLocalPartioning array
  29664. * @returns an array of array of numbers
  29665. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29666. */
  29667. getFacetLocalPartitioning(): number[][];
  29668. /**
  29669. * Returns the i-th facet position in the world system.
  29670. * This method allocates a new Vector3 per call
  29671. * @param i defines the facet index
  29672. * @returns a new Vector3
  29673. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29674. */
  29675. getFacetPosition(i: number): Vector3;
  29676. /**
  29677. * Sets the reference Vector3 with the i-th facet position in the world system
  29678. * @param i defines the facet index
  29679. * @param ref defines the target vector
  29680. * @returns the current mesh
  29681. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29682. */
  29683. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  29684. /**
  29685. * Returns the i-th facet normal in the world system.
  29686. * This method allocates a new Vector3 per call
  29687. * @param i defines the facet index
  29688. * @returns a new Vector3
  29689. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29690. */
  29691. getFacetNormal(i: number): Vector3;
  29692. /**
  29693. * Sets the reference Vector3 with the i-th facet normal in the world system
  29694. * @param i defines the facet index
  29695. * @param ref defines the target vector
  29696. * @returns the current mesh
  29697. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29698. */
  29699. getFacetNormalToRef(i: number, ref: Vector3): this;
  29700. /**
  29701. * 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)
  29702. * @param x defines x coordinate
  29703. * @param y defines y coordinate
  29704. * @param z defines z coordinate
  29705. * @returns the array of facet indexes
  29706. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29707. */
  29708. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  29709. /**
  29710. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  29711. * @param projected sets as the (x,y,z) world projection on the facet
  29712. * @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
  29713. * @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
  29714. * @param x defines x coordinate
  29715. * @param y defines y coordinate
  29716. * @param z defines z coordinate
  29717. * @returns the face index if found (or null instead)
  29718. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29719. */
  29720. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  29721. /**
  29722. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  29723. * @param projected sets as the (x,y,z) local projection on the facet
  29724. * @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
  29725. * @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
  29726. * @param x defines x coordinate
  29727. * @param y defines y coordinate
  29728. * @param z defines z coordinate
  29729. * @returns the face index if found (or null instead)
  29730. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29731. */
  29732. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  29733. /**
  29734. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  29735. * @returns the parameters
  29736. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29737. */
  29738. getFacetDataParameters(): any;
  29739. /**
  29740. * Disables the feature FacetData and frees the related memory
  29741. * @returns the current mesh
  29742. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29743. */
  29744. disableFacetData(): AbstractMesh;
  29745. /**
  29746. * Updates the AbstractMesh indices array
  29747. * @param indices defines the data source
  29748. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  29749. * @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)
  29750. * @returns the current mesh
  29751. */
  29752. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  29753. /**
  29754. * Creates new normals data for the mesh
  29755. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  29756. * @returns the current mesh
  29757. */
  29758. createNormals(updatable: boolean): AbstractMesh;
  29759. /**
  29760. * Align the mesh with a normal
  29761. * @param normal defines the normal to use
  29762. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  29763. * @returns the current mesh
  29764. */
  29765. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  29766. /** @hidden */
  29767. _checkOcclusionQuery(): boolean;
  29768. /**
  29769. * Disables the mesh edge rendering mode
  29770. * @returns the currentAbstractMesh
  29771. */
  29772. disableEdgesRendering(): AbstractMesh;
  29773. /**
  29774. * Enables the edge rendering mode on the mesh.
  29775. * This mode makes the mesh edges visible
  29776. * @param epsilon defines the maximal distance between two angles to detect a face
  29777. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  29778. * @returns the currentAbstractMesh
  29779. * @see https://www.babylonjs-playground.com/#19O9TU#0
  29780. */
  29781. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  29782. }
  29783. }
  29784. declare module "babylonjs/Actions/actionEvent" {
  29785. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29786. import { Nullable } from "babylonjs/types";
  29787. import { Sprite } from "babylonjs/Sprites/sprite";
  29788. import { Scene } from "babylonjs/scene";
  29789. import { Vector2 } from "babylonjs/Maths/math.vector";
  29790. /**
  29791. * Interface used to define ActionEvent
  29792. */
  29793. export interface IActionEvent {
  29794. /** The mesh or sprite that triggered the action */
  29795. source: any;
  29796. /** The X mouse cursor position at the time of the event */
  29797. pointerX: number;
  29798. /** The Y mouse cursor position at the time of the event */
  29799. pointerY: number;
  29800. /** The mesh that is currently pointed at (can be null) */
  29801. meshUnderPointer: Nullable<AbstractMesh>;
  29802. /** the original (browser) event that triggered the ActionEvent */
  29803. sourceEvent?: any;
  29804. /** additional data for the event */
  29805. additionalData?: any;
  29806. }
  29807. /**
  29808. * ActionEvent is the event being sent when an action is triggered.
  29809. */
  29810. export class ActionEvent implements IActionEvent {
  29811. /** The mesh or sprite that triggered the action */
  29812. source: any;
  29813. /** The X mouse cursor position at the time of the event */
  29814. pointerX: number;
  29815. /** The Y mouse cursor position at the time of the event */
  29816. pointerY: number;
  29817. /** The mesh that is currently pointed at (can be null) */
  29818. meshUnderPointer: Nullable<AbstractMesh>;
  29819. /** the original (browser) event that triggered the ActionEvent */
  29820. sourceEvent?: any;
  29821. /** additional data for the event */
  29822. additionalData?: any;
  29823. /**
  29824. * Creates a new ActionEvent
  29825. * @param source The mesh or sprite that triggered the action
  29826. * @param pointerX The X mouse cursor position at the time of the event
  29827. * @param pointerY The Y mouse cursor position at the time of the event
  29828. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  29829. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  29830. * @param additionalData additional data for the event
  29831. */
  29832. constructor(
  29833. /** The mesh or sprite that triggered the action */
  29834. source: any,
  29835. /** The X mouse cursor position at the time of the event */
  29836. pointerX: number,
  29837. /** The Y mouse cursor position at the time of the event */
  29838. pointerY: number,
  29839. /** The mesh that is currently pointed at (can be null) */
  29840. meshUnderPointer: Nullable<AbstractMesh>,
  29841. /** the original (browser) event that triggered the ActionEvent */
  29842. sourceEvent?: any,
  29843. /** additional data for the event */
  29844. additionalData?: any);
  29845. /**
  29846. * Helper function to auto-create an ActionEvent from a source mesh.
  29847. * @param source The source mesh that triggered the event
  29848. * @param evt The original (browser) event
  29849. * @param additionalData additional data for the event
  29850. * @returns the new ActionEvent
  29851. */
  29852. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  29853. /**
  29854. * Helper function to auto-create an ActionEvent from a source sprite
  29855. * @param source The source sprite that triggered the event
  29856. * @param scene Scene associated with the sprite
  29857. * @param evt The original (browser) event
  29858. * @param additionalData additional data for the event
  29859. * @returns the new ActionEvent
  29860. */
  29861. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  29862. /**
  29863. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  29864. * @param scene the scene where the event occurred
  29865. * @param evt The original (browser) event
  29866. * @returns the new ActionEvent
  29867. */
  29868. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  29869. /**
  29870. * Helper function to auto-create an ActionEvent from a primitive
  29871. * @param prim defines the target primitive
  29872. * @param pointerPos defines the pointer position
  29873. * @param evt The original (browser) event
  29874. * @param additionalData additional data for the event
  29875. * @returns the new ActionEvent
  29876. */
  29877. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  29878. }
  29879. }
  29880. declare module "babylonjs/Actions/abstractActionManager" {
  29881. import { IDisposable } from "babylonjs/scene";
  29882. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  29883. import { IAction } from "babylonjs/Actions/action";
  29884. import { Nullable } from "babylonjs/types";
  29885. /**
  29886. * Abstract class used to decouple action Manager from scene and meshes.
  29887. * Do not instantiate.
  29888. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  29889. */
  29890. export abstract class AbstractActionManager implements IDisposable {
  29891. /** Gets the list of active triggers */
  29892. static Triggers: {
  29893. [key: string]: number;
  29894. };
  29895. /** Gets the cursor to use when hovering items */
  29896. hoverCursor: string;
  29897. /** Gets the list of actions */
  29898. actions: IAction[];
  29899. /**
  29900. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  29901. */
  29902. isRecursive: boolean;
  29903. /**
  29904. * Releases all associated resources
  29905. */
  29906. abstract dispose(): void;
  29907. /**
  29908. * Does this action manager has pointer triggers
  29909. */
  29910. abstract get hasPointerTriggers(): boolean;
  29911. /**
  29912. * Does this action manager has pick triggers
  29913. */
  29914. abstract get hasPickTriggers(): boolean;
  29915. /**
  29916. * Process a specific trigger
  29917. * @param trigger defines the trigger to process
  29918. * @param evt defines the event details to be processed
  29919. */
  29920. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  29921. /**
  29922. * Does this action manager handles actions of any of the given triggers
  29923. * @param triggers defines the triggers to be tested
  29924. * @return a boolean indicating whether one (or more) of the triggers is handled
  29925. */
  29926. abstract hasSpecificTriggers(triggers: number[]): boolean;
  29927. /**
  29928. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  29929. * speed.
  29930. * @param triggerA defines the trigger to be tested
  29931. * @param triggerB defines the trigger to be tested
  29932. * @return a boolean indicating whether one (or more) of the triggers is handled
  29933. */
  29934. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  29935. /**
  29936. * Does this action manager handles actions of a given trigger
  29937. * @param trigger defines the trigger to be tested
  29938. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  29939. * @return whether the trigger is handled
  29940. */
  29941. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  29942. /**
  29943. * Serialize this manager to a JSON object
  29944. * @param name defines the property name to store this manager
  29945. * @returns a JSON representation of this manager
  29946. */
  29947. abstract serialize(name: string): any;
  29948. /**
  29949. * Registers an action to this action manager
  29950. * @param action defines the action to be registered
  29951. * @return the action amended (prepared) after registration
  29952. */
  29953. abstract registerAction(action: IAction): Nullable<IAction>;
  29954. /**
  29955. * Unregisters an action to this action manager
  29956. * @param action defines the action to be unregistered
  29957. * @return a boolean indicating whether the action has been unregistered
  29958. */
  29959. abstract unregisterAction(action: IAction): Boolean;
  29960. /**
  29961. * Does exist one action manager with at least one trigger
  29962. **/
  29963. static get HasTriggers(): boolean;
  29964. /**
  29965. * Does exist one action manager with at least one pick trigger
  29966. **/
  29967. static get HasPickTriggers(): boolean;
  29968. /**
  29969. * Does exist one action manager that handles actions of a given trigger
  29970. * @param trigger defines the trigger to be tested
  29971. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  29972. **/
  29973. static HasSpecificTrigger(trigger: number): boolean;
  29974. }
  29975. }
  29976. declare module "babylonjs/node" {
  29977. import { Scene } from "babylonjs/scene";
  29978. import { Nullable } from "babylonjs/types";
  29979. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  29980. import { Engine } from "babylonjs/Engines/engine";
  29981. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  29982. import { Observable } from "babylonjs/Misc/observable";
  29983. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  29984. import { IInspectable } from "babylonjs/Misc/iInspectable";
  29985. import { Animatable } from "babylonjs/Animations/animatable";
  29986. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  29987. import { Animation } from "babylonjs/Animations/animation";
  29988. import { AnimationRange } from "babylonjs/Animations/animationRange";
  29989. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29990. /**
  29991. * Defines how a node can be built from a string name.
  29992. */
  29993. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  29994. /**
  29995. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  29996. */
  29997. export class Node implements IBehaviorAware<Node> {
  29998. /** @hidden */
  29999. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  30000. private static _NodeConstructors;
  30001. /**
  30002. * Add a new node constructor
  30003. * @param type defines the type name of the node to construct
  30004. * @param constructorFunc defines the constructor function
  30005. */
  30006. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  30007. /**
  30008. * Returns a node constructor based on type name
  30009. * @param type defines the type name
  30010. * @param name defines the new node name
  30011. * @param scene defines the hosting scene
  30012. * @param options defines optional options to transmit to constructors
  30013. * @returns the new constructor or null
  30014. */
  30015. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  30016. /**
  30017. * Gets or sets the name of the node
  30018. */
  30019. name: string;
  30020. /**
  30021. * Gets or sets the id of the node
  30022. */
  30023. id: string;
  30024. /**
  30025. * Gets or sets the unique id of the node
  30026. */
  30027. uniqueId: number;
  30028. /**
  30029. * Gets or sets a string used to store user defined state for the node
  30030. */
  30031. state: string;
  30032. /**
  30033. * Gets or sets an object used to store user defined information for the node
  30034. */
  30035. metadata: any;
  30036. /**
  30037. * For internal use only. Please do not use.
  30038. */
  30039. reservedDataStore: any;
  30040. /**
  30041. * List of inspectable custom properties (used by the Inspector)
  30042. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  30043. */
  30044. inspectableCustomProperties: IInspectable[];
  30045. private _doNotSerialize;
  30046. /**
  30047. * Gets or sets a boolean used to define if the node must be serialized
  30048. */
  30049. get doNotSerialize(): boolean;
  30050. set doNotSerialize(value: boolean);
  30051. /** @hidden */
  30052. _isDisposed: boolean;
  30053. /**
  30054. * Gets a list of Animations associated with the node
  30055. */
  30056. animations: import("babylonjs/Animations/animation").Animation[];
  30057. protected _ranges: {
  30058. [name: string]: Nullable<AnimationRange>;
  30059. };
  30060. /**
  30061. * Callback raised when the node is ready to be used
  30062. */
  30063. onReady: Nullable<(node: Node) => void>;
  30064. private _isEnabled;
  30065. private _isParentEnabled;
  30066. private _isReady;
  30067. /** @hidden */
  30068. _currentRenderId: number;
  30069. private _parentUpdateId;
  30070. /** @hidden */
  30071. _childUpdateId: number;
  30072. /** @hidden */
  30073. _waitingParentId: Nullable<string>;
  30074. /** @hidden */
  30075. _scene: Scene;
  30076. /** @hidden */
  30077. _cache: any;
  30078. private _parentNode;
  30079. private _children;
  30080. /** @hidden */
  30081. _worldMatrix: Matrix;
  30082. /** @hidden */
  30083. _worldMatrixDeterminant: number;
  30084. /** @hidden */
  30085. _worldMatrixDeterminantIsDirty: boolean;
  30086. /** @hidden */
  30087. private _sceneRootNodesIndex;
  30088. /**
  30089. * Gets a boolean indicating if the node has been disposed
  30090. * @returns true if the node was disposed
  30091. */
  30092. isDisposed(): boolean;
  30093. /**
  30094. * Gets or sets the parent of the node (without keeping the current position in the scene)
  30095. * @see https://doc.babylonjs.com/how_to/parenting
  30096. */
  30097. set parent(parent: Nullable<Node>);
  30098. get parent(): Nullable<Node>;
  30099. /** @hidden */
  30100. _addToSceneRootNodes(): void;
  30101. /** @hidden */
  30102. _removeFromSceneRootNodes(): void;
  30103. private _animationPropertiesOverride;
  30104. /**
  30105. * Gets or sets the animation properties override
  30106. */
  30107. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  30108. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  30109. /**
  30110. * Gets a string idenfifying the name of the class
  30111. * @returns "Node" string
  30112. */
  30113. getClassName(): string;
  30114. /** @hidden */
  30115. readonly _isNode: boolean;
  30116. /**
  30117. * An event triggered when the mesh is disposed
  30118. */
  30119. onDisposeObservable: Observable<Node>;
  30120. private _onDisposeObserver;
  30121. /**
  30122. * Sets a callback that will be raised when the node will be disposed
  30123. */
  30124. set onDispose(callback: () => void);
  30125. /**
  30126. * Creates a new Node
  30127. * @param name the name and id to be given to this node
  30128. * @param scene the scene this node will be added to
  30129. */
  30130. constructor(name: string, scene?: Nullable<Scene>);
  30131. /**
  30132. * Gets the scene of the node
  30133. * @returns a scene
  30134. */
  30135. getScene(): Scene;
  30136. /**
  30137. * Gets the engine of the node
  30138. * @returns a Engine
  30139. */
  30140. getEngine(): Engine;
  30141. private _behaviors;
  30142. /**
  30143. * Attach a behavior to the node
  30144. * @see http://doc.babylonjs.com/features/behaviour
  30145. * @param behavior defines the behavior to attach
  30146. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  30147. * @returns the current Node
  30148. */
  30149. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  30150. /**
  30151. * Remove an attached behavior
  30152. * @see http://doc.babylonjs.com/features/behaviour
  30153. * @param behavior defines the behavior to attach
  30154. * @returns the current Node
  30155. */
  30156. removeBehavior(behavior: Behavior<Node>): Node;
  30157. /**
  30158. * Gets the list of attached behaviors
  30159. * @see http://doc.babylonjs.com/features/behaviour
  30160. */
  30161. get behaviors(): Behavior<Node>[];
  30162. /**
  30163. * Gets an attached behavior by name
  30164. * @param name defines the name of the behavior to look for
  30165. * @see http://doc.babylonjs.com/features/behaviour
  30166. * @returns null if behavior was not found else the requested behavior
  30167. */
  30168. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  30169. /**
  30170. * Returns the latest update of the World matrix
  30171. * @returns a Matrix
  30172. */
  30173. getWorldMatrix(): Matrix;
  30174. /** @hidden */
  30175. _getWorldMatrixDeterminant(): number;
  30176. /**
  30177. * Returns directly the latest state of the mesh World matrix.
  30178. * A Matrix is returned.
  30179. */
  30180. get worldMatrixFromCache(): Matrix;
  30181. /** @hidden */
  30182. _initCache(): void;
  30183. /** @hidden */
  30184. updateCache(force?: boolean): void;
  30185. /** @hidden */
  30186. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  30187. /** @hidden */
  30188. _updateCache(ignoreParentClass?: boolean): void;
  30189. /** @hidden */
  30190. _isSynchronized(): boolean;
  30191. /** @hidden */
  30192. _markSyncedWithParent(): void;
  30193. /** @hidden */
  30194. isSynchronizedWithParent(): boolean;
  30195. /** @hidden */
  30196. isSynchronized(): boolean;
  30197. /**
  30198. * Is this node ready to be used/rendered
  30199. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  30200. * @return true if the node is ready
  30201. */
  30202. isReady(completeCheck?: boolean): boolean;
  30203. /**
  30204. * Is this node enabled?
  30205. * 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
  30206. * @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
  30207. * @return whether this node (and its parent) is enabled
  30208. */
  30209. isEnabled(checkAncestors?: boolean): boolean;
  30210. /** @hidden */
  30211. protected _syncParentEnabledState(): void;
  30212. /**
  30213. * Set the enabled state of this node
  30214. * @param value defines the new enabled state
  30215. */
  30216. setEnabled(value: boolean): void;
  30217. /**
  30218. * Is this node a descendant of the given node?
  30219. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  30220. * @param ancestor defines the parent node to inspect
  30221. * @returns a boolean indicating if this node is a descendant of the given node
  30222. */
  30223. isDescendantOf(ancestor: Node): boolean;
  30224. /** @hidden */
  30225. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  30226. /**
  30227. * Will return all nodes that have this node as ascendant
  30228. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered
  30229. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  30230. * @return all children nodes of all types
  30231. */
  30232. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  30233. /**
  30234. * Get all child-meshes of this node
  30235. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered (Default: false)
  30236. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  30237. * @returns an array of AbstractMesh
  30238. */
  30239. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  30240. /**
  30241. * Get all direct children of this node
  30242. * @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
  30243. * @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)
  30244. * @returns an array of Node
  30245. */
  30246. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  30247. /** @hidden */
  30248. _setReady(state: boolean): void;
  30249. /**
  30250. * Get an animation by name
  30251. * @param name defines the name of the animation to look for
  30252. * @returns null if not found else the requested animation
  30253. */
  30254. getAnimationByName(name: string): Nullable<Animation>;
  30255. /**
  30256. * Creates an animation range for this node
  30257. * @param name defines the name of the range
  30258. * @param from defines the starting key
  30259. * @param to defines the end key
  30260. */
  30261. createAnimationRange(name: string, from: number, to: number): void;
  30262. /**
  30263. * Delete a specific animation range
  30264. * @param name defines the name of the range to delete
  30265. * @param deleteFrames defines if animation frames from the range must be deleted as well
  30266. */
  30267. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  30268. /**
  30269. * Get an animation range by name
  30270. * @param name defines the name of the animation range to look for
  30271. * @returns null if not found else the requested animation range
  30272. */
  30273. getAnimationRange(name: string): Nullable<AnimationRange>;
  30274. /**
  30275. * Gets the list of all animation ranges defined on this node
  30276. * @returns an array
  30277. */
  30278. getAnimationRanges(): Nullable<AnimationRange>[];
  30279. /**
  30280. * Will start the animation sequence
  30281. * @param name defines the range frames for animation sequence
  30282. * @param loop defines if the animation should loop (false by default)
  30283. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  30284. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  30285. * @returns the object created for this animation. If range does not exist, it will return null
  30286. */
  30287. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  30288. /**
  30289. * Serialize animation ranges into a JSON compatible object
  30290. * @returns serialization object
  30291. */
  30292. serializeAnimationRanges(): any;
  30293. /**
  30294. * Computes the world matrix of the node
  30295. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  30296. * @returns the world matrix
  30297. */
  30298. computeWorldMatrix(force?: boolean): Matrix;
  30299. /**
  30300. * Releases resources associated with this node.
  30301. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  30302. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  30303. */
  30304. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  30305. /**
  30306. * Parse animation range data from a serialization object and store them into a given node
  30307. * @param node defines where to store the animation ranges
  30308. * @param parsedNode defines the serialization object to read data from
  30309. * @param scene defines the hosting scene
  30310. */
  30311. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  30312. /**
  30313. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  30314. * @param includeDescendants Include bounding info from descendants as well (true by default)
  30315. * @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
  30316. * @returns the new bounding vectors
  30317. */
  30318. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  30319. min: Vector3;
  30320. max: Vector3;
  30321. };
  30322. }
  30323. }
  30324. declare module "babylonjs/Animations/animation" {
  30325. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  30326. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  30327. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  30328. import { Nullable } from "babylonjs/types";
  30329. import { Scene } from "babylonjs/scene";
  30330. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  30331. import { AnimationRange } from "babylonjs/Animations/animationRange";
  30332. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  30333. import { Node } from "babylonjs/node";
  30334. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  30335. import { Size } from "babylonjs/Maths/math.size";
  30336. import { Animatable } from "babylonjs/Animations/animatable";
  30337. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  30338. /**
  30339. * @hidden
  30340. */
  30341. export class _IAnimationState {
  30342. key: number;
  30343. repeatCount: number;
  30344. workValue?: any;
  30345. loopMode?: number;
  30346. offsetValue?: any;
  30347. highLimitValue?: any;
  30348. }
  30349. /**
  30350. * Class used to store any kind of animation
  30351. */
  30352. export class Animation {
  30353. /**Name of the animation */
  30354. name: string;
  30355. /**Property to animate */
  30356. targetProperty: string;
  30357. /**The frames per second of the animation */
  30358. framePerSecond: number;
  30359. /**The data type of the animation */
  30360. dataType: number;
  30361. /**The loop mode of the animation */
  30362. loopMode?: number | undefined;
  30363. /**Specifies if blending should be enabled */
  30364. enableBlending?: boolean | undefined;
  30365. /**
  30366. * Use matrix interpolation instead of using direct key value when animating matrices
  30367. */
  30368. static AllowMatricesInterpolation: boolean;
  30369. /**
  30370. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  30371. */
  30372. static AllowMatrixDecomposeForInterpolation: boolean;
  30373. /**
  30374. * Stores the key frames of the animation
  30375. */
  30376. private _keys;
  30377. /**
  30378. * Stores the easing function of the animation
  30379. */
  30380. private _easingFunction;
  30381. /**
  30382. * @hidden Internal use only
  30383. */
  30384. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  30385. /**
  30386. * The set of event that will be linked to this animation
  30387. */
  30388. private _events;
  30389. /**
  30390. * Stores an array of target property paths
  30391. */
  30392. targetPropertyPath: string[];
  30393. /**
  30394. * Stores the blending speed of the animation
  30395. */
  30396. blendingSpeed: number;
  30397. /**
  30398. * Stores the animation ranges for the animation
  30399. */
  30400. private _ranges;
  30401. /**
  30402. * @hidden Internal use
  30403. */
  30404. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  30405. /**
  30406. * Sets up an animation
  30407. * @param property The property to animate
  30408. * @param animationType The animation type to apply
  30409. * @param framePerSecond The frames per second of the animation
  30410. * @param easingFunction The easing function used in the animation
  30411. * @returns The created animation
  30412. */
  30413. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  30414. /**
  30415. * Create and start an animation on a node
  30416. * @param name defines the name of the global animation that will be run on all nodes
  30417. * @param node defines the root node where the animation will take place
  30418. * @param targetProperty defines property to animate
  30419. * @param framePerSecond defines the number of frame per second yo use
  30420. * @param totalFrame defines the number of frames in total
  30421. * @param from defines the initial value
  30422. * @param to defines the final value
  30423. * @param loopMode defines which loop mode you want to use (off by default)
  30424. * @param easingFunction defines the easing function to use (linear by default)
  30425. * @param onAnimationEnd defines the callback to call when animation end
  30426. * @returns the animatable created for this animation
  30427. */
  30428. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  30429. /**
  30430. * Create and start an animation on a node and its descendants
  30431. * @param name defines the name of the global animation that will be run on all nodes
  30432. * @param node defines the root node where the animation will take place
  30433. * @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
  30434. * @param targetProperty defines property to animate
  30435. * @param framePerSecond defines the number of frame per second to use
  30436. * @param totalFrame defines the number of frames in total
  30437. * @param from defines the initial value
  30438. * @param to defines the final value
  30439. * @param loopMode defines which loop mode you want to use (off by default)
  30440. * @param easingFunction defines the easing function to use (linear by default)
  30441. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  30442. * @returns the list of animatables created for all nodes
  30443. * @example https://www.babylonjs-playground.com/#MH0VLI
  30444. */
  30445. 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[]>;
  30446. /**
  30447. * Creates a new animation, merges it with the existing animations and starts it
  30448. * @param name Name of the animation
  30449. * @param node Node which contains the scene that begins the animations
  30450. * @param targetProperty Specifies which property to animate
  30451. * @param framePerSecond The frames per second of the animation
  30452. * @param totalFrame The total number of frames
  30453. * @param from The frame at the beginning of the animation
  30454. * @param to The frame at the end of the animation
  30455. * @param loopMode Specifies the loop mode of the animation
  30456. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  30457. * @param onAnimationEnd Callback to run once the animation is complete
  30458. * @returns Nullable animation
  30459. */
  30460. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  30461. /**
  30462. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  30463. * @param sourceAnimation defines the Animation containing keyframes to convert
  30464. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  30465. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  30466. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  30467. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  30468. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  30469. */
  30470. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  30471. /**
  30472. * Transition property of an host to the target Value
  30473. * @param property The property to transition
  30474. * @param targetValue The target Value of the property
  30475. * @param host The object where the property to animate belongs
  30476. * @param scene Scene used to run the animation
  30477. * @param frameRate Framerate (in frame/s) to use
  30478. * @param transition The transition type we want to use
  30479. * @param duration The duration of the animation, in milliseconds
  30480. * @param onAnimationEnd Callback trigger at the end of the animation
  30481. * @returns Nullable animation
  30482. */
  30483. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  30484. /**
  30485. * Return the array of runtime animations currently using this animation
  30486. */
  30487. get runtimeAnimations(): RuntimeAnimation[];
  30488. /**
  30489. * Specifies if any of the runtime animations are currently running
  30490. */
  30491. get hasRunningRuntimeAnimations(): boolean;
  30492. /**
  30493. * Initializes the animation
  30494. * @param name Name of the animation
  30495. * @param targetProperty Property to animate
  30496. * @param framePerSecond The frames per second of the animation
  30497. * @param dataType The data type of the animation
  30498. * @param loopMode The loop mode of the animation
  30499. * @param enableBlending Specifies if blending should be enabled
  30500. */
  30501. constructor(
  30502. /**Name of the animation */
  30503. name: string,
  30504. /**Property to animate */
  30505. targetProperty: string,
  30506. /**The frames per second of the animation */
  30507. framePerSecond: number,
  30508. /**The data type of the animation */
  30509. dataType: number,
  30510. /**The loop mode of the animation */
  30511. loopMode?: number | undefined,
  30512. /**Specifies if blending should be enabled */
  30513. enableBlending?: boolean | undefined);
  30514. /**
  30515. * Converts the animation to a string
  30516. * @param fullDetails support for multiple levels of logging within scene loading
  30517. * @returns String form of the animation
  30518. */
  30519. toString(fullDetails?: boolean): string;
  30520. /**
  30521. * Add an event to this animation
  30522. * @param event Event to add
  30523. */
  30524. addEvent(event: AnimationEvent): void;
  30525. /**
  30526. * Remove all events found at the given frame
  30527. * @param frame The frame to remove events from
  30528. */
  30529. removeEvents(frame: number): void;
  30530. /**
  30531. * Retrieves all the events from the animation
  30532. * @returns Events from the animation
  30533. */
  30534. getEvents(): AnimationEvent[];
  30535. /**
  30536. * Creates an animation range
  30537. * @param name Name of the animation range
  30538. * @param from Starting frame of the animation range
  30539. * @param to Ending frame of the animation
  30540. */
  30541. createRange(name: string, from: number, to: number): void;
  30542. /**
  30543. * Deletes an animation range by name
  30544. * @param name Name of the animation range to delete
  30545. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  30546. */
  30547. deleteRange(name: string, deleteFrames?: boolean): void;
  30548. /**
  30549. * Gets the animation range by name, or null if not defined
  30550. * @param name Name of the animation range
  30551. * @returns Nullable animation range
  30552. */
  30553. getRange(name: string): Nullable<AnimationRange>;
  30554. /**
  30555. * Gets the key frames from the animation
  30556. * @returns The key frames of the animation
  30557. */
  30558. getKeys(): Array<IAnimationKey>;
  30559. /**
  30560. * Gets the highest frame rate of the animation
  30561. * @returns Highest frame rate of the animation
  30562. */
  30563. getHighestFrame(): number;
  30564. /**
  30565. * Gets the easing function of the animation
  30566. * @returns Easing function of the animation
  30567. */
  30568. getEasingFunction(): IEasingFunction;
  30569. /**
  30570. * Sets the easing function of the animation
  30571. * @param easingFunction A custom mathematical formula for animation
  30572. */
  30573. setEasingFunction(easingFunction: EasingFunction): void;
  30574. /**
  30575. * Interpolates a scalar linearly
  30576. * @param startValue Start value of the animation curve
  30577. * @param endValue End value of the animation curve
  30578. * @param gradient Scalar amount to interpolate
  30579. * @returns Interpolated scalar value
  30580. */
  30581. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  30582. /**
  30583. * Interpolates a scalar cubically
  30584. * @param startValue Start value of the animation curve
  30585. * @param outTangent End tangent of the animation
  30586. * @param endValue End value of the animation curve
  30587. * @param inTangent Start tangent of the animation curve
  30588. * @param gradient Scalar amount to interpolate
  30589. * @returns Interpolated scalar value
  30590. */
  30591. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  30592. /**
  30593. * Interpolates a quaternion using a spherical linear interpolation
  30594. * @param startValue Start value of the animation curve
  30595. * @param endValue End value of the animation curve
  30596. * @param gradient Scalar amount to interpolate
  30597. * @returns Interpolated quaternion value
  30598. */
  30599. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  30600. /**
  30601. * Interpolates a quaternion cubically
  30602. * @param startValue Start value of the animation curve
  30603. * @param outTangent End tangent of the animation curve
  30604. * @param endValue End value of the animation curve
  30605. * @param inTangent Start tangent of the animation curve
  30606. * @param gradient Scalar amount to interpolate
  30607. * @returns Interpolated quaternion value
  30608. */
  30609. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  30610. /**
  30611. * Interpolates a Vector3 linearl
  30612. * @param startValue Start value of the animation curve
  30613. * @param endValue End value of the animation curve
  30614. * @param gradient Scalar amount to interpolate
  30615. * @returns Interpolated scalar value
  30616. */
  30617. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  30618. /**
  30619. * Interpolates a Vector3 cubically
  30620. * @param startValue Start value of the animation curve
  30621. * @param outTangent End tangent of the animation
  30622. * @param endValue End value of the animation curve
  30623. * @param inTangent Start tangent of the animation curve
  30624. * @param gradient Scalar amount to interpolate
  30625. * @returns InterpolatedVector3 value
  30626. */
  30627. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  30628. /**
  30629. * Interpolates a Vector2 linearly
  30630. * @param startValue Start value of the animation curve
  30631. * @param endValue End value of the animation curve
  30632. * @param gradient Scalar amount to interpolate
  30633. * @returns Interpolated Vector2 value
  30634. */
  30635. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  30636. /**
  30637. * Interpolates a Vector2 cubically
  30638. * @param startValue Start value of the animation curve
  30639. * @param outTangent End tangent of the animation
  30640. * @param endValue End value of the animation curve
  30641. * @param inTangent Start tangent of the animation curve
  30642. * @param gradient Scalar amount to interpolate
  30643. * @returns Interpolated Vector2 value
  30644. */
  30645. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  30646. /**
  30647. * Interpolates a size linearly
  30648. * @param startValue Start value of the animation curve
  30649. * @param endValue End value of the animation curve
  30650. * @param gradient Scalar amount to interpolate
  30651. * @returns Interpolated Size value
  30652. */
  30653. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  30654. /**
  30655. * Interpolates a Color3 linearly
  30656. * @param startValue Start value of the animation curve
  30657. * @param endValue End value of the animation curve
  30658. * @param gradient Scalar amount to interpolate
  30659. * @returns Interpolated Color3 value
  30660. */
  30661. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  30662. /**
  30663. * Interpolates a Color4 linearly
  30664. * @param startValue Start value of the animation curve
  30665. * @param endValue End value of the animation curve
  30666. * @param gradient Scalar amount to interpolate
  30667. * @returns Interpolated Color3 value
  30668. */
  30669. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  30670. /**
  30671. * @hidden Internal use only
  30672. */
  30673. _getKeyValue(value: any): any;
  30674. /**
  30675. * @hidden Internal use only
  30676. */
  30677. _interpolate(currentFrame: number, state: _IAnimationState): any;
  30678. /**
  30679. * Defines the function to use to interpolate matrices
  30680. * @param startValue defines the start matrix
  30681. * @param endValue defines the end matrix
  30682. * @param gradient defines the gradient between both matrices
  30683. * @param result defines an optional target matrix where to store the interpolation
  30684. * @returns the interpolated matrix
  30685. */
  30686. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  30687. /**
  30688. * Makes a copy of the animation
  30689. * @returns Cloned animation
  30690. */
  30691. clone(): Animation;
  30692. /**
  30693. * Sets the key frames of the animation
  30694. * @param values The animation key frames to set
  30695. */
  30696. setKeys(values: Array<IAnimationKey>): void;
  30697. /**
  30698. * Serializes the animation to an object
  30699. * @returns Serialized object
  30700. */
  30701. serialize(): any;
  30702. /**
  30703. * Float animation type
  30704. */
  30705. static readonly ANIMATIONTYPE_FLOAT: number;
  30706. /**
  30707. * Vector3 animation type
  30708. */
  30709. static readonly ANIMATIONTYPE_VECTOR3: number;
  30710. /**
  30711. * Quaternion animation type
  30712. */
  30713. static readonly ANIMATIONTYPE_QUATERNION: number;
  30714. /**
  30715. * Matrix animation type
  30716. */
  30717. static readonly ANIMATIONTYPE_MATRIX: number;
  30718. /**
  30719. * Color3 animation type
  30720. */
  30721. static readonly ANIMATIONTYPE_COLOR3: number;
  30722. /**
  30723. * Color3 animation type
  30724. */
  30725. static readonly ANIMATIONTYPE_COLOR4: number;
  30726. /**
  30727. * Vector2 animation type
  30728. */
  30729. static readonly ANIMATIONTYPE_VECTOR2: number;
  30730. /**
  30731. * Size animation type
  30732. */
  30733. static readonly ANIMATIONTYPE_SIZE: number;
  30734. /**
  30735. * Relative Loop Mode
  30736. */
  30737. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  30738. /**
  30739. * Cycle Loop Mode
  30740. */
  30741. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  30742. /**
  30743. * Constant Loop Mode
  30744. */
  30745. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  30746. /** @hidden */
  30747. static _UniversalLerp(left: any, right: any, amount: number): any;
  30748. /**
  30749. * Parses an animation object and creates an animation
  30750. * @param parsedAnimation Parsed animation object
  30751. * @returns Animation object
  30752. */
  30753. static Parse(parsedAnimation: any): Animation;
  30754. /**
  30755. * Appends the serialized animations from the source animations
  30756. * @param source Source containing the animations
  30757. * @param destination Target to store the animations
  30758. */
  30759. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  30760. }
  30761. }
  30762. declare module "babylonjs/Animations/animatable.interface" {
  30763. import { Nullable } from "babylonjs/types";
  30764. import { Animation } from "babylonjs/Animations/animation";
  30765. /**
  30766. * Interface containing an array of animations
  30767. */
  30768. export interface IAnimatable {
  30769. /**
  30770. * Array of animations
  30771. */
  30772. animations: Nullable<Array<Animation>>;
  30773. }
  30774. }
  30775. declare module "babylonjs/Misc/decorators" {
  30776. import { Nullable } from "babylonjs/types";
  30777. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  30778. import { Scene } from "babylonjs/scene";
  30779. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  30780. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30781. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30782. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30783. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30784. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30785. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30786. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30787. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30788. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30789. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30790. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30791. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30792. /**
  30793. * Decorator used to define property that can be serialized as reference to a camera
  30794. * @param sourceName defines the name of the property to decorate
  30795. */
  30796. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30797. /**
  30798. * Class used to help serialization objects
  30799. */
  30800. export class SerializationHelper {
  30801. /** @hidden */
  30802. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  30803. /** @hidden */
  30804. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  30805. /** @hidden */
  30806. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  30807. /** @hidden */
  30808. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  30809. /**
  30810. * Appends the serialized animations from the source animations
  30811. * @param source Source containing the animations
  30812. * @param destination Target to store the animations
  30813. */
  30814. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  30815. /**
  30816. * Static function used to serialized a specific entity
  30817. * @param entity defines the entity to serialize
  30818. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  30819. * @returns a JSON compatible object representing the serialization of the entity
  30820. */
  30821. static Serialize<T>(entity: T, serializationObject?: any): any;
  30822. /**
  30823. * Creates a new entity from a serialization data object
  30824. * @param creationFunction defines a function used to instanciated the new entity
  30825. * @param source defines the source serialization data
  30826. * @param scene defines the hosting scene
  30827. * @param rootUrl defines the root url for resources
  30828. * @returns a new entity
  30829. */
  30830. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  30831. /**
  30832. * Clones an object
  30833. * @param creationFunction defines the function used to instanciate the new object
  30834. * @param source defines the source object
  30835. * @returns the cloned object
  30836. */
  30837. static Clone<T>(creationFunction: () => T, source: T): T;
  30838. /**
  30839. * Instanciates a new object based on a source one (some data will be shared between both object)
  30840. * @param creationFunction defines the function used to instanciate the new object
  30841. * @param source defines the source object
  30842. * @returns the new object
  30843. */
  30844. static Instanciate<T>(creationFunction: () => T, source: T): T;
  30845. }
  30846. }
  30847. declare module "babylonjs/Misc/guid" {
  30848. /**
  30849. * Class used to manipulate GUIDs
  30850. */
  30851. export class GUID {
  30852. /**
  30853. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  30854. * Be aware Math.random() could cause collisions, but:
  30855. * "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"
  30856. * @returns a pseudo random id
  30857. */
  30858. static RandomId(): string;
  30859. }
  30860. }
  30861. declare module "babylonjs/Materials/Textures/baseTexture" {
  30862. import { Observable } from "babylonjs/Misc/observable";
  30863. import { Nullable } from "babylonjs/types";
  30864. import { Scene } from "babylonjs/scene";
  30865. import { Matrix } from "babylonjs/Maths/math.vector";
  30866. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  30867. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  30868. import { ISize } from "babylonjs/Maths/math.size";
  30869. import "babylonjs/Misc/fileTools";
  30870. /**
  30871. * Base class of all the textures in babylon.
  30872. * It groups all the common properties the materials, post process, lights... might need
  30873. * in order to make a correct use of the texture.
  30874. */
  30875. export class BaseTexture implements IAnimatable {
  30876. /**
  30877. * Default anisotropic filtering level for the application.
  30878. * It is set to 4 as a good tradeoff between perf and quality.
  30879. */
  30880. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  30881. /**
  30882. * Gets or sets the unique id of the texture
  30883. */
  30884. uniqueId: number;
  30885. /**
  30886. * Define the name of the texture.
  30887. */
  30888. name: string;
  30889. /**
  30890. * Gets or sets an object used to store user defined information.
  30891. */
  30892. metadata: any;
  30893. /**
  30894. * For internal use only. Please do not use.
  30895. */
  30896. reservedDataStore: any;
  30897. private _hasAlpha;
  30898. /**
  30899. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  30900. */
  30901. set hasAlpha(value: boolean);
  30902. get hasAlpha(): boolean;
  30903. /**
  30904. * Defines if the alpha value should be determined via the rgb values.
  30905. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  30906. */
  30907. getAlphaFromRGB: boolean;
  30908. /**
  30909. * Intensity or strength of the texture.
  30910. * It is commonly used by materials to fine tune the intensity of the texture
  30911. */
  30912. level: number;
  30913. /**
  30914. * Define the UV chanel to use starting from 0 and defaulting to 0.
  30915. * This is part of the texture as textures usually maps to one uv set.
  30916. */
  30917. coordinatesIndex: number;
  30918. private _coordinatesMode;
  30919. /**
  30920. * How a texture is mapped.
  30921. *
  30922. * | Value | Type | Description |
  30923. * | ----- | ----------------------------------- | ----------- |
  30924. * | 0 | EXPLICIT_MODE | |
  30925. * | 1 | SPHERICAL_MODE | |
  30926. * | 2 | PLANAR_MODE | |
  30927. * | 3 | CUBIC_MODE | |
  30928. * | 4 | PROJECTION_MODE | |
  30929. * | 5 | SKYBOX_MODE | |
  30930. * | 6 | INVCUBIC_MODE | |
  30931. * | 7 | EQUIRECTANGULAR_MODE | |
  30932. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  30933. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  30934. */
  30935. set coordinatesMode(value: number);
  30936. get coordinatesMode(): number;
  30937. /**
  30938. * | Value | Type | Description |
  30939. * | ----- | ------------------ | ----------- |
  30940. * | 0 | CLAMP_ADDRESSMODE | |
  30941. * | 1 | WRAP_ADDRESSMODE | |
  30942. * | 2 | MIRROR_ADDRESSMODE | |
  30943. */
  30944. wrapU: number;
  30945. /**
  30946. * | Value | Type | Description |
  30947. * | ----- | ------------------ | ----------- |
  30948. * | 0 | CLAMP_ADDRESSMODE | |
  30949. * | 1 | WRAP_ADDRESSMODE | |
  30950. * | 2 | MIRROR_ADDRESSMODE | |
  30951. */
  30952. wrapV: number;
  30953. /**
  30954. * | Value | Type | Description |
  30955. * | ----- | ------------------ | ----------- |
  30956. * | 0 | CLAMP_ADDRESSMODE | |
  30957. * | 1 | WRAP_ADDRESSMODE | |
  30958. * | 2 | MIRROR_ADDRESSMODE | |
  30959. */
  30960. wrapR: number;
  30961. /**
  30962. * With compliant hardware and browser (supporting anisotropic filtering)
  30963. * this defines the level of anisotropic filtering in the texture.
  30964. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  30965. */
  30966. anisotropicFilteringLevel: number;
  30967. /**
  30968. * Define if the texture is a cube texture or if false a 2d texture.
  30969. */
  30970. get isCube(): boolean;
  30971. set isCube(value: boolean);
  30972. /**
  30973. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  30974. */
  30975. get is3D(): boolean;
  30976. set is3D(value: boolean);
  30977. /**
  30978. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  30979. */
  30980. get is2DArray(): boolean;
  30981. set is2DArray(value: boolean);
  30982. /**
  30983. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  30984. * HDR texture are usually stored in linear space.
  30985. * This only impacts the PBR and Background materials
  30986. */
  30987. gammaSpace: boolean;
  30988. /**
  30989. * Gets or sets whether or not the texture contains RGBD data.
  30990. */
  30991. get isRGBD(): boolean;
  30992. set isRGBD(value: boolean);
  30993. /**
  30994. * Is Z inverted in the texture (useful in a cube texture).
  30995. */
  30996. invertZ: boolean;
  30997. /**
  30998. * Are mip maps generated for this texture or not.
  30999. */
  31000. get noMipmap(): boolean;
  31001. /**
  31002. * @hidden
  31003. */
  31004. lodLevelInAlpha: boolean;
  31005. /**
  31006. * With prefiltered texture, defined the offset used during the prefiltering steps.
  31007. */
  31008. get lodGenerationOffset(): number;
  31009. set lodGenerationOffset(value: number);
  31010. /**
  31011. * With prefiltered texture, defined the scale used during the prefiltering steps.
  31012. */
  31013. get lodGenerationScale(): number;
  31014. set lodGenerationScale(value: number);
  31015. /**
  31016. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  31017. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  31018. * average roughness values.
  31019. */
  31020. get linearSpecularLOD(): boolean;
  31021. set linearSpecularLOD(value: boolean);
  31022. /**
  31023. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  31024. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  31025. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  31026. */
  31027. get irradianceTexture(): Nullable<BaseTexture>;
  31028. set irradianceTexture(value: Nullable<BaseTexture>);
  31029. /**
  31030. * Define if the texture is a render target.
  31031. */
  31032. isRenderTarget: boolean;
  31033. /**
  31034. * Define the unique id of the texture in the scene.
  31035. */
  31036. get uid(): string;
  31037. /**
  31038. * Return a string representation of the texture.
  31039. * @returns the texture as a string
  31040. */
  31041. toString(): string;
  31042. /**
  31043. * Get the class name of the texture.
  31044. * @returns "BaseTexture"
  31045. */
  31046. getClassName(): string;
  31047. /**
  31048. * Define the list of animation attached to the texture.
  31049. */
  31050. animations: import("babylonjs/Animations/animation").Animation[];
  31051. /**
  31052. * An event triggered when the texture is disposed.
  31053. */
  31054. onDisposeObservable: Observable<BaseTexture>;
  31055. private _onDisposeObserver;
  31056. /**
  31057. * Callback triggered when the texture has been disposed.
  31058. * Kept for back compatibility, you can use the onDisposeObservable instead.
  31059. */
  31060. set onDispose(callback: () => void);
  31061. /**
  31062. * Define the current state of the loading sequence when in delayed load mode.
  31063. */
  31064. delayLoadState: number;
  31065. private _scene;
  31066. /** @hidden */
  31067. _texture: Nullable<InternalTexture>;
  31068. private _uid;
  31069. /**
  31070. * Define if the texture is preventinga material to render or not.
  31071. * If not and the texture is not ready, the engine will use a default black texture instead.
  31072. */
  31073. get isBlocking(): boolean;
  31074. /**
  31075. * Instantiates a new BaseTexture.
  31076. * Base class of all the textures in babylon.
  31077. * It groups all the common properties the materials, post process, lights... might need
  31078. * in order to make a correct use of the texture.
  31079. * @param scene Define the scene the texture blongs to
  31080. */
  31081. constructor(scene: Nullable<Scene>);
  31082. /**
  31083. * Get the scene the texture belongs to.
  31084. * @returns the scene or null if undefined
  31085. */
  31086. getScene(): Nullable<Scene>;
  31087. /**
  31088. * Get the texture transform matrix used to offset tile the texture for istance.
  31089. * @returns the transformation matrix
  31090. */
  31091. getTextureMatrix(): Matrix;
  31092. /**
  31093. * Get the texture reflection matrix used to rotate/transform the reflection.
  31094. * @returns the reflection matrix
  31095. */
  31096. getReflectionTextureMatrix(): Matrix;
  31097. /**
  31098. * Get the underlying lower level texture from Babylon.
  31099. * @returns the insternal texture
  31100. */
  31101. getInternalTexture(): Nullable<InternalTexture>;
  31102. /**
  31103. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  31104. * @returns true if ready or not blocking
  31105. */
  31106. isReadyOrNotBlocking(): boolean;
  31107. /**
  31108. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  31109. * @returns true if fully ready
  31110. */
  31111. isReady(): boolean;
  31112. private _cachedSize;
  31113. /**
  31114. * Get the size of the texture.
  31115. * @returns the texture size.
  31116. */
  31117. getSize(): ISize;
  31118. /**
  31119. * Get the base size of the texture.
  31120. * It can be different from the size if the texture has been resized for POT for instance
  31121. * @returns the base size
  31122. */
  31123. getBaseSize(): ISize;
  31124. /**
  31125. * Update the sampling mode of the texture.
  31126. * Default is Trilinear mode.
  31127. *
  31128. * | Value | Type | Description |
  31129. * | ----- | ------------------ | ----------- |
  31130. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  31131. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  31132. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  31133. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  31134. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  31135. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  31136. * | 7 | NEAREST_LINEAR | |
  31137. * | 8 | NEAREST_NEAREST | |
  31138. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  31139. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  31140. * | 11 | LINEAR_LINEAR | |
  31141. * | 12 | LINEAR_NEAREST | |
  31142. *
  31143. * > _mag_: magnification filter (close to the viewer)
  31144. * > _min_: minification filter (far from the viewer)
  31145. * > _mip_: filter used between mip map levels
  31146. *@param samplingMode Define the new sampling mode of the texture
  31147. */
  31148. updateSamplingMode(samplingMode: number): void;
  31149. /**
  31150. * Scales the texture if is `canRescale()`
  31151. * @param ratio the resize factor we want to use to rescale
  31152. */
  31153. scale(ratio: number): void;
  31154. /**
  31155. * Get if the texture can rescale.
  31156. */
  31157. get canRescale(): boolean;
  31158. /** @hidden */
  31159. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  31160. /** @hidden */
  31161. _rebuild(): void;
  31162. /**
  31163. * Triggers the load sequence in delayed load mode.
  31164. */
  31165. delayLoad(): void;
  31166. /**
  31167. * Clones the texture.
  31168. * @returns the cloned texture
  31169. */
  31170. clone(): Nullable<BaseTexture>;
  31171. /**
  31172. * Get the texture underlying type (INT, FLOAT...)
  31173. */
  31174. get textureType(): number;
  31175. /**
  31176. * Get the texture underlying format (RGB, RGBA...)
  31177. */
  31178. get textureFormat(): number;
  31179. /**
  31180. * Indicates that textures need to be re-calculated for all materials
  31181. */
  31182. protected _markAllSubMeshesAsTexturesDirty(): void;
  31183. /**
  31184. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  31185. * This will returns an RGBA array buffer containing either in values (0-255) or
  31186. * float values (0-1) depending of the underlying buffer type.
  31187. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  31188. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  31189. * @param buffer defines a user defined buffer to fill with data (can be null)
  31190. * @returns The Array buffer containing the pixels data.
  31191. */
  31192. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  31193. /**
  31194. * Release and destroy the underlying lower level texture aka internalTexture.
  31195. */
  31196. releaseInternalTexture(): void;
  31197. /** @hidden */
  31198. get _lodTextureHigh(): Nullable<BaseTexture>;
  31199. /** @hidden */
  31200. get _lodTextureMid(): Nullable<BaseTexture>;
  31201. /** @hidden */
  31202. get _lodTextureLow(): Nullable<BaseTexture>;
  31203. /**
  31204. * Dispose the texture and release its associated resources.
  31205. */
  31206. dispose(): void;
  31207. /**
  31208. * Serialize the texture into a JSON representation that can be parsed later on.
  31209. * @returns the JSON representation of the texture
  31210. */
  31211. serialize(): any;
  31212. /**
  31213. * Helper function to be called back once a list of texture contains only ready textures.
  31214. * @param textures Define the list of textures to wait for
  31215. * @param callback Define the callback triggered once the entire list will be ready
  31216. */
  31217. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  31218. }
  31219. }
  31220. declare module "babylonjs/Materials/effect" {
  31221. import { Observable } from "babylonjs/Misc/observable";
  31222. import { Nullable } from "babylonjs/types";
  31223. import { IDisposable } from "babylonjs/scene";
  31224. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  31225. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  31226. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  31227. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  31228. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  31229. import { Engine } from "babylonjs/Engines/engine";
  31230. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  31231. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  31232. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  31233. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  31234. /**
  31235. * Options to be used when creating an effect.
  31236. */
  31237. export interface IEffectCreationOptions {
  31238. /**
  31239. * Atrributes that will be used in the shader.
  31240. */
  31241. attributes: string[];
  31242. /**
  31243. * Uniform varible names that will be set in the shader.
  31244. */
  31245. uniformsNames: string[];
  31246. /**
  31247. * Uniform buffer variable names that will be set in the shader.
  31248. */
  31249. uniformBuffersNames: string[];
  31250. /**
  31251. * Sampler texture variable names that will be set in the shader.
  31252. */
  31253. samplers: string[];
  31254. /**
  31255. * Define statements that will be set in the shader.
  31256. */
  31257. defines: any;
  31258. /**
  31259. * Possible fallbacks for this effect to improve performance when needed.
  31260. */
  31261. fallbacks: Nullable<IEffectFallbacks>;
  31262. /**
  31263. * Callback that will be called when the shader is compiled.
  31264. */
  31265. onCompiled: Nullable<(effect: Effect) => void>;
  31266. /**
  31267. * Callback that will be called if an error occurs during shader compilation.
  31268. */
  31269. onError: Nullable<(effect: Effect, errors: string) => void>;
  31270. /**
  31271. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  31272. */
  31273. indexParameters?: any;
  31274. /**
  31275. * Max number of lights that can be used in the shader.
  31276. */
  31277. maxSimultaneousLights?: number;
  31278. /**
  31279. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  31280. */
  31281. transformFeedbackVaryings?: Nullable<string[]>;
  31282. }
  31283. /**
  31284. * Effect containing vertex and fragment shader that can be executed on an object.
  31285. */
  31286. export class Effect implements IDisposable {
  31287. /**
  31288. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  31289. */
  31290. static ShadersRepository: string;
  31291. /**
  31292. * Enable logging of the shader code when a compilation error occurs
  31293. */
  31294. static LogShaderCodeOnCompilationError: boolean;
  31295. /**
  31296. * Name of the effect.
  31297. */
  31298. name: any;
  31299. /**
  31300. * String container all the define statements that should be set on the shader.
  31301. */
  31302. defines: string;
  31303. /**
  31304. * Callback that will be called when the shader is compiled.
  31305. */
  31306. onCompiled: Nullable<(effect: Effect) => void>;
  31307. /**
  31308. * Callback that will be called if an error occurs during shader compilation.
  31309. */
  31310. onError: Nullable<(effect: Effect, errors: string) => void>;
  31311. /**
  31312. * Callback that will be called when effect is bound.
  31313. */
  31314. onBind: Nullable<(effect: Effect) => void>;
  31315. /**
  31316. * Unique ID of the effect.
  31317. */
  31318. uniqueId: number;
  31319. /**
  31320. * Observable that will be called when the shader is compiled.
  31321. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  31322. */
  31323. onCompileObservable: Observable<Effect>;
  31324. /**
  31325. * Observable that will be called if an error occurs during shader compilation.
  31326. */
  31327. onErrorObservable: Observable<Effect>;
  31328. /** @hidden */
  31329. _onBindObservable: Nullable<Observable<Effect>>;
  31330. /**
  31331. * @hidden
  31332. * Specifies if the effect was previously ready
  31333. */
  31334. _wasPreviouslyReady: boolean;
  31335. /**
  31336. * Observable that will be called when effect is bound.
  31337. */
  31338. get onBindObservable(): Observable<Effect>;
  31339. /** @hidden */
  31340. _bonesComputationForcedToCPU: boolean;
  31341. private static _uniqueIdSeed;
  31342. private _engine;
  31343. private _uniformBuffersNames;
  31344. private _uniformsNames;
  31345. private _samplerList;
  31346. private _samplers;
  31347. private _isReady;
  31348. private _compilationError;
  31349. private _allFallbacksProcessed;
  31350. private _attributesNames;
  31351. private _attributes;
  31352. private _attributeLocationByName;
  31353. private _uniforms;
  31354. /**
  31355. * Key for the effect.
  31356. * @hidden
  31357. */
  31358. _key: string;
  31359. private _indexParameters;
  31360. private _fallbacks;
  31361. private _vertexSourceCode;
  31362. private _fragmentSourceCode;
  31363. private _vertexSourceCodeOverride;
  31364. private _fragmentSourceCodeOverride;
  31365. private _transformFeedbackVaryings;
  31366. /**
  31367. * Compiled shader to webGL program.
  31368. * @hidden
  31369. */
  31370. _pipelineContext: Nullable<IPipelineContext>;
  31371. private _valueCache;
  31372. private static _baseCache;
  31373. /**
  31374. * Instantiates an effect.
  31375. * An effect can be used to create/manage/execute vertex and fragment shaders.
  31376. * @param baseName Name of the effect.
  31377. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  31378. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  31379. * @param samplers List of sampler variables that will be passed to the shader.
  31380. * @param engine Engine to be used to render the effect
  31381. * @param defines Define statements to be added to the shader.
  31382. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  31383. * @param onCompiled Callback that will be called when the shader is compiled.
  31384. * @param onError Callback that will be called if an error occurs during shader compilation.
  31385. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  31386. */
  31387. 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);
  31388. private _useFinalCode;
  31389. /**
  31390. * Unique key for this effect
  31391. */
  31392. get key(): string;
  31393. /**
  31394. * If the effect has been compiled and prepared.
  31395. * @returns if the effect is compiled and prepared.
  31396. */
  31397. isReady(): boolean;
  31398. private _isReadyInternal;
  31399. /**
  31400. * The engine the effect was initialized with.
  31401. * @returns the engine.
  31402. */
  31403. getEngine(): Engine;
  31404. /**
  31405. * The pipeline context for this effect
  31406. * @returns the associated pipeline context
  31407. */
  31408. getPipelineContext(): Nullable<IPipelineContext>;
  31409. /**
  31410. * The set of names of attribute variables for the shader.
  31411. * @returns An array of attribute names.
  31412. */
  31413. getAttributesNames(): string[];
  31414. /**
  31415. * Returns the attribute at the given index.
  31416. * @param index The index of the attribute.
  31417. * @returns The location of the attribute.
  31418. */
  31419. getAttributeLocation(index: number): number;
  31420. /**
  31421. * Returns the attribute based on the name of the variable.
  31422. * @param name of the attribute to look up.
  31423. * @returns the attribute location.
  31424. */
  31425. getAttributeLocationByName(name: string): number;
  31426. /**
  31427. * The number of attributes.
  31428. * @returns the numnber of attributes.
  31429. */
  31430. getAttributesCount(): number;
  31431. /**
  31432. * Gets the index of a uniform variable.
  31433. * @param uniformName of the uniform to look up.
  31434. * @returns the index.
  31435. */
  31436. getUniformIndex(uniformName: string): number;
  31437. /**
  31438. * Returns the attribute based on the name of the variable.
  31439. * @param uniformName of the uniform to look up.
  31440. * @returns the location of the uniform.
  31441. */
  31442. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  31443. /**
  31444. * Returns an array of sampler variable names
  31445. * @returns The array of sampler variable neames.
  31446. */
  31447. getSamplers(): string[];
  31448. /**
  31449. * The error from the last compilation.
  31450. * @returns the error string.
  31451. */
  31452. getCompilationError(): string;
  31453. /**
  31454. * Gets a boolean indicating that all fallbacks were used during compilation
  31455. * @returns true if all fallbacks were used
  31456. */
  31457. allFallbacksProcessed(): boolean;
  31458. /**
  31459. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  31460. * @param func The callback to be used.
  31461. */
  31462. executeWhenCompiled(func: (effect: Effect) => void): void;
  31463. private _checkIsReady;
  31464. private _loadShader;
  31465. /**
  31466. * Recompiles the webGL program
  31467. * @param vertexSourceCode The source code for the vertex shader.
  31468. * @param fragmentSourceCode The source code for the fragment shader.
  31469. * @param onCompiled Callback called when completed.
  31470. * @param onError Callback called on error.
  31471. * @hidden
  31472. */
  31473. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  31474. /**
  31475. * Prepares the effect
  31476. * @hidden
  31477. */
  31478. _prepareEffect(): void;
  31479. private _getShaderCodeAndErrorLine;
  31480. private _processCompilationErrors;
  31481. /**
  31482. * Checks if the effect is supported. (Must be called after compilation)
  31483. */
  31484. get isSupported(): boolean;
  31485. /**
  31486. * Binds a texture to the engine to be used as output of the shader.
  31487. * @param channel Name of the output variable.
  31488. * @param texture Texture to bind.
  31489. * @hidden
  31490. */
  31491. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  31492. /**
  31493. * Sets a texture on the engine to be used in the shader.
  31494. * @param channel Name of the sampler variable.
  31495. * @param texture Texture to set.
  31496. */
  31497. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  31498. /**
  31499. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  31500. * @param channel Name of the sampler variable.
  31501. * @param texture Texture to set.
  31502. */
  31503. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  31504. /**
  31505. * Sets an array of textures on the engine to be used in the shader.
  31506. * @param channel Name of the variable.
  31507. * @param textures Textures to set.
  31508. */
  31509. setTextureArray(channel: string, textures: BaseTexture[]): void;
  31510. /**
  31511. * 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)
  31512. * @param channel Name of the sampler variable.
  31513. * @param postProcess Post process to get the input texture from.
  31514. */
  31515. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  31516. /**
  31517. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  31518. * 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)
  31519. * @param channel Name of the sampler variable.
  31520. * @param postProcess Post process to get the output texture from.
  31521. */
  31522. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  31523. /** @hidden */
  31524. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  31525. /** @hidden */
  31526. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  31527. /** @hidden */
  31528. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  31529. /** @hidden */
  31530. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  31531. /**
  31532. * Binds a buffer to a uniform.
  31533. * @param buffer Buffer to bind.
  31534. * @param name Name of the uniform variable to bind to.
  31535. */
  31536. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  31537. /**
  31538. * Binds block to a uniform.
  31539. * @param blockName Name of the block to bind.
  31540. * @param index Index to bind.
  31541. */
  31542. bindUniformBlock(blockName: string, index: number): void;
  31543. /**
  31544. * Sets an interger value on a uniform variable.
  31545. * @param uniformName Name of the variable.
  31546. * @param value Value to be set.
  31547. * @returns this effect.
  31548. */
  31549. setInt(uniformName: string, value: number): Effect;
  31550. /**
  31551. * Sets an int array on a uniform variable.
  31552. * @param uniformName Name of the variable.
  31553. * @param array array to be set.
  31554. * @returns this effect.
  31555. */
  31556. setIntArray(uniformName: string, array: Int32Array): Effect;
  31557. /**
  31558. * 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)
  31559. * @param uniformName Name of the variable.
  31560. * @param array array to be set.
  31561. * @returns this effect.
  31562. */
  31563. setIntArray2(uniformName: string, array: Int32Array): Effect;
  31564. /**
  31565. * 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)
  31566. * @param uniformName Name of the variable.
  31567. * @param array array to be set.
  31568. * @returns this effect.
  31569. */
  31570. setIntArray3(uniformName: string, array: Int32Array): Effect;
  31571. /**
  31572. * 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)
  31573. * @param uniformName Name of the variable.
  31574. * @param array array to be set.
  31575. * @returns this effect.
  31576. */
  31577. setIntArray4(uniformName: string, array: Int32Array): Effect;
  31578. /**
  31579. * Sets an float array on a uniform variable.
  31580. * @param uniformName Name of the variable.
  31581. * @param array array to be set.
  31582. * @returns this effect.
  31583. */
  31584. setFloatArray(uniformName: string, array: Float32Array): Effect;
  31585. /**
  31586. * 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)
  31587. * @param uniformName Name of the variable.
  31588. * @param array array to be set.
  31589. * @returns this effect.
  31590. */
  31591. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  31592. /**
  31593. * 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)
  31594. * @param uniformName Name of the variable.
  31595. * @param array array to be set.
  31596. * @returns this effect.
  31597. */
  31598. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  31599. /**
  31600. * 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)
  31601. * @param uniformName Name of the variable.
  31602. * @param array array to be set.
  31603. * @returns this effect.
  31604. */
  31605. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  31606. /**
  31607. * Sets an array on a uniform variable.
  31608. * @param uniformName Name of the variable.
  31609. * @param array array to be set.
  31610. * @returns this effect.
  31611. */
  31612. setArray(uniformName: string, array: number[]): Effect;
  31613. /**
  31614. * 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)
  31615. * @param uniformName Name of the variable.
  31616. * @param array array to be set.
  31617. * @returns this effect.
  31618. */
  31619. setArray2(uniformName: string, array: number[]): Effect;
  31620. /**
  31621. * 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)
  31622. * @param uniformName Name of the variable.
  31623. * @param array array to be set.
  31624. * @returns this effect.
  31625. */
  31626. setArray3(uniformName: string, array: number[]): Effect;
  31627. /**
  31628. * 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)
  31629. * @param uniformName Name of the variable.
  31630. * @param array array to be set.
  31631. * @returns this effect.
  31632. */
  31633. setArray4(uniformName: string, array: number[]): Effect;
  31634. /**
  31635. * Sets matrices on a uniform variable.
  31636. * @param uniformName Name of the variable.
  31637. * @param matrices matrices to be set.
  31638. * @returns this effect.
  31639. */
  31640. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  31641. /**
  31642. * Sets matrix on a uniform variable.
  31643. * @param uniformName Name of the variable.
  31644. * @param matrix matrix to be set.
  31645. * @returns this effect.
  31646. */
  31647. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  31648. /**
  31649. * 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)
  31650. * @param uniformName Name of the variable.
  31651. * @param matrix matrix to be set.
  31652. * @returns this effect.
  31653. */
  31654. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  31655. /**
  31656. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  31657. * @param uniformName Name of the variable.
  31658. * @param matrix matrix to be set.
  31659. * @returns this effect.
  31660. */
  31661. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  31662. /**
  31663. * Sets a float on a uniform variable.
  31664. * @param uniformName Name of the variable.
  31665. * @param value value to be set.
  31666. * @returns this effect.
  31667. */
  31668. setFloat(uniformName: string, value: number): Effect;
  31669. /**
  31670. * Sets a boolean on a uniform variable.
  31671. * @param uniformName Name of the variable.
  31672. * @param bool value to be set.
  31673. * @returns this effect.
  31674. */
  31675. setBool(uniformName: string, bool: boolean): Effect;
  31676. /**
  31677. * Sets a Vector2 on a uniform variable.
  31678. * @param uniformName Name of the variable.
  31679. * @param vector2 vector2 to be set.
  31680. * @returns this effect.
  31681. */
  31682. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  31683. /**
  31684. * Sets a float2 on a uniform variable.
  31685. * @param uniformName Name of the variable.
  31686. * @param x First float in float2.
  31687. * @param y Second float in float2.
  31688. * @returns this effect.
  31689. */
  31690. setFloat2(uniformName: string, x: number, y: number): Effect;
  31691. /**
  31692. * Sets a Vector3 on a uniform variable.
  31693. * @param uniformName Name of the variable.
  31694. * @param vector3 Value to be set.
  31695. * @returns this effect.
  31696. */
  31697. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  31698. /**
  31699. * Sets a float3 on a uniform variable.
  31700. * @param uniformName Name of the variable.
  31701. * @param x First float in float3.
  31702. * @param y Second float in float3.
  31703. * @param z Third float in float3.
  31704. * @returns this effect.
  31705. */
  31706. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  31707. /**
  31708. * Sets a Vector4 on a uniform variable.
  31709. * @param uniformName Name of the variable.
  31710. * @param vector4 Value to be set.
  31711. * @returns this effect.
  31712. */
  31713. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  31714. /**
  31715. * Sets a float4 on a uniform variable.
  31716. * @param uniformName Name of the variable.
  31717. * @param x First float in float4.
  31718. * @param y Second float in float4.
  31719. * @param z Third float in float4.
  31720. * @param w Fourth float in float4.
  31721. * @returns this effect.
  31722. */
  31723. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  31724. /**
  31725. * Sets a Color3 on a uniform variable.
  31726. * @param uniformName Name of the variable.
  31727. * @param color3 Value to be set.
  31728. * @returns this effect.
  31729. */
  31730. setColor3(uniformName: string, color3: IColor3Like): Effect;
  31731. /**
  31732. * Sets a Color4 on a uniform variable.
  31733. * @param uniformName Name of the variable.
  31734. * @param color3 Value to be set.
  31735. * @param alpha Alpha value to be set.
  31736. * @returns this effect.
  31737. */
  31738. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  31739. /**
  31740. * Sets a Color4 on a uniform variable
  31741. * @param uniformName defines the name of the variable
  31742. * @param color4 defines the value to be set
  31743. * @returns this effect.
  31744. */
  31745. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  31746. /** Release all associated resources */
  31747. dispose(): void;
  31748. /**
  31749. * This function will add a new shader to the shader store
  31750. * @param name the name of the shader
  31751. * @param pixelShader optional pixel shader content
  31752. * @param vertexShader optional vertex shader content
  31753. */
  31754. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  31755. /**
  31756. * Store of each shader (The can be looked up using effect.key)
  31757. */
  31758. static ShadersStore: {
  31759. [key: string]: string;
  31760. };
  31761. /**
  31762. * Store of each included file for a shader (The can be looked up using effect.key)
  31763. */
  31764. static IncludesShadersStore: {
  31765. [key: string]: string;
  31766. };
  31767. /**
  31768. * Resets the cache of effects.
  31769. */
  31770. static ResetCache(): void;
  31771. }
  31772. }
  31773. declare module "babylonjs/Engines/engineCapabilities" {
  31774. /**
  31775. * Interface used to describe the capabilities of the engine relatively to the current browser
  31776. */
  31777. export interface EngineCapabilities {
  31778. /** Maximum textures units per fragment shader */
  31779. maxTexturesImageUnits: number;
  31780. /** Maximum texture units per vertex shader */
  31781. maxVertexTextureImageUnits: number;
  31782. /** Maximum textures units in the entire pipeline */
  31783. maxCombinedTexturesImageUnits: number;
  31784. /** Maximum texture size */
  31785. maxTextureSize: number;
  31786. /** Maximum texture samples */
  31787. maxSamples?: number;
  31788. /** Maximum cube texture size */
  31789. maxCubemapTextureSize: number;
  31790. /** Maximum render texture size */
  31791. maxRenderTextureSize: number;
  31792. /** Maximum number of vertex attributes */
  31793. maxVertexAttribs: number;
  31794. /** Maximum number of varyings */
  31795. maxVaryingVectors: number;
  31796. /** Maximum number of uniforms per vertex shader */
  31797. maxVertexUniformVectors: number;
  31798. /** Maximum number of uniforms per fragment shader */
  31799. maxFragmentUniformVectors: number;
  31800. /** Defines if standard derivates (dx/dy) are supported */
  31801. standardDerivatives: boolean;
  31802. /** Defines if s3tc texture compression is supported */
  31803. s3tc?: WEBGL_compressed_texture_s3tc;
  31804. /** Defines if pvrtc texture compression is supported */
  31805. pvrtc: any;
  31806. /** Defines if etc1 texture compression is supported */
  31807. etc1: any;
  31808. /** Defines if etc2 texture compression is supported */
  31809. etc2: any;
  31810. /** Defines if astc texture compression is supported */
  31811. astc: any;
  31812. /** Defines if float textures are supported */
  31813. textureFloat: boolean;
  31814. /** Defines if vertex array objects are supported */
  31815. vertexArrayObject: boolean;
  31816. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  31817. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  31818. /** Gets the maximum level of anisotropy supported */
  31819. maxAnisotropy: number;
  31820. /** Defines if instancing is supported */
  31821. instancedArrays: boolean;
  31822. /** Defines if 32 bits indices are supported */
  31823. uintIndices: boolean;
  31824. /** Defines if high precision shaders are supported */
  31825. highPrecisionShaderSupported: boolean;
  31826. /** Defines if depth reading in the fragment shader is supported */
  31827. fragmentDepthSupported: boolean;
  31828. /** Defines if float texture linear filtering is supported*/
  31829. textureFloatLinearFiltering: boolean;
  31830. /** Defines if rendering to float textures is supported */
  31831. textureFloatRender: boolean;
  31832. /** Defines if half float textures are supported*/
  31833. textureHalfFloat: boolean;
  31834. /** Defines if half float texture linear filtering is supported*/
  31835. textureHalfFloatLinearFiltering: boolean;
  31836. /** Defines if rendering to half float textures is supported */
  31837. textureHalfFloatRender: boolean;
  31838. /** Defines if textureLOD shader command is supported */
  31839. textureLOD: boolean;
  31840. /** Defines if draw buffers extension is supported */
  31841. drawBuffersExtension: boolean;
  31842. /** Defines if depth textures are supported */
  31843. depthTextureExtension: boolean;
  31844. /** Defines if float color buffer are supported */
  31845. colorBufferFloat: boolean;
  31846. /** Gets disjoint timer query extension (null if not supported) */
  31847. timerQuery?: EXT_disjoint_timer_query;
  31848. /** Defines if timestamp can be used with timer query */
  31849. canUseTimestampForTimerQuery: boolean;
  31850. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  31851. multiview?: any;
  31852. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  31853. oculusMultiview?: any;
  31854. /** Function used to let the system compiles shaders in background */
  31855. parallelShaderCompile?: {
  31856. COMPLETION_STATUS_KHR: number;
  31857. };
  31858. /** Max number of texture samples for MSAA */
  31859. maxMSAASamples: number;
  31860. /** Defines if the blend min max extension is supported */
  31861. blendMinMax: boolean;
  31862. }
  31863. }
  31864. declare module "babylonjs/States/depthCullingState" {
  31865. import { Nullable } from "babylonjs/types";
  31866. /**
  31867. * @hidden
  31868. **/
  31869. export class DepthCullingState {
  31870. private _isDepthTestDirty;
  31871. private _isDepthMaskDirty;
  31872. private _isDepthFuncDirty;
  31873. private _isCullFaceDirty;
  31874. private _isCullDirty;
  31875. private _isZOffsetDirty;
  31876. private _isFrontFaceDirty;
  31877. private _depthTest;
  31878. private _depthMask;
  31879. private _depthFunc;
  31880. private _cull;
  31881. private _cullFace;
  31882. private _zOffset;
  31883. private _frontFace;
  31884. /**
  31885. * Initializes the state.
  31886. */
  31887. constructor();
  31888. get isDirty(): boolean;
  31889. get zOffset(): number;
  31890. set zOffset(value: number);
  31891. get cullFace(): Nullable<number>;
  31892. set cullFace(value: Nullable<number>);
  31893. get cull(): Nullable<boolean>;
  31894. set cull(value: Nullable<boolean>);
  31895. get depthFunc(): Nullable<number>;
  31896. set depthFunc(value: Nullable<number>);
  31897. get depthMask(): boolean;
  31898. set depthMask(value: boolean);
  31899. get depthTest(): boolean;
  31900. set depthTest(value: boolean);
  31901. get frontFace(): Nullable<number>;
  31902. set frontFace(value: Nullable<number>);
  31903. reset(): void;
  31904. apply(gl: WebGLRenderingContext): void;
  31905. }
  31906. }
  31907. declare module "babylonjs/States/stencilState" {
  31908. /**
  31909. * @hidden
  31910. **/
  31911. export class StencilState {
  31912. /** 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 */
  31913. static readonly ALWAYS: number;
  31914. /** Passed to stencilOperation to specify that stencil value must be kept */
  31915. static readonly KEEP: number;
  31916. /** Passed to stencilOperation to specify that stencil value must be replaced */
  31917. static readonly REPLACE: number;
  31918. private _isStencilTestDirty;
  31919. private _isStencilMaskDirty;
  31920. private _isStencilFuncDirty;
  31921. private _isStencilOpDirty;
  31922. private _stencilTest;
  31923. private _stencilMask;
  31924. private _stencilFunc;
  31925. private _stencilFuncRef;
  31926. private _stencilFuncMask;
  31927. private _stencilOpStencilFail;
  31928. private _stencilOpDepthFail;
  31929. private _stencilOpStencilDepthPass;
  31930. get isDirty(): boolean;
  31931. get stencilFunc(): number;
  31932. set stencilFunc(value: number);
  31933. get stencilFuncRef(): number;
  31934. set stencilFuncRef(value: number);
  31935. get stencilFuncMask(): number;
  31936. set stencilFuncMask(value: number);
  31937. get stencilOpStencilFail(): number;
  31938. set stencilOpStencilFail(value: number);
  31939. get stencilOpDepthFail(): number;
  31940. set stencilOpDepthFail(value: number);
  31941. get stencilOpStencilDepthPass(): number;
  31942. set stencilOpStencilDepthPass(value: number);
  31943. get stencilMask(): number;
  31944. set stencilMask(value: number);
  31945. get stencilTest(): boolean;
  31946. set stencilTest(value: boolean);
  31947. constructor();
  31948. reset(): void;
  31949. apply(gl: WebGLRenderingContext): void;
  31950. }
  31951. }
  31952. declare module "babylonjs/States/alphaCullingState" {
  31953. /**
  31954. * @hidden
  31955. **/
  31956. export class AlphaState {
  31957. private _isAlphaBlendDirty;
  31958. private _isBlendFunctionParametersDirty;
  31959. private _isBlendEquationParametersDirty;
  31960. private _isBlendConstantsDirty;
  31961. private _alphaBlend;
  31962. private _blendFunctionParameters;
  31963. private _blendEquationParameters;
  31964. private _blendConstants;
  31965. /**
  31966. * Initializes the state.
  31967. */
  31968. constructor();
  31969. get isDirty(): boolean;
  31970. get alphaBlend(): boolean;
  31971. set alphaBlend(value: boolean);
  31972. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  31973. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  31974. setAlphaEquationParameters(rgb: number, alpha: number): void;
  31975. reset(): void;
  31976. apply(gl: WebGLRenderingContext): void;
  31977. }
  31978. }
  31979. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  31980. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  31981. /** @hidden */
  31982. export class WebGL2ShaderProcessor implements IShaderProcessor {
  31983. attributeProcessor(attribute: string): string;
  31984. varyingProcessor(varying: string, isFragment: boolean): string;
  31985. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  31986. }
  31987. }
  31988. declare module "babylonjs/Engines/instancingAttributeInfo" {
  31989. /**
  31990. * Interface for attribute information associated with buffer instanciation
  31991. */
  31992. export interface InstancingAttributeInfo {
  31993. /**
  31994. * Name of the GLSL attribute
  31995. * if attribute index is not specified, this is used to retrieve the index from the effect
  31996. */
  31997. attributeName: string;
  31998. /**
  31999. * Index/offset of the attribute in the vertex shader
  32000. * if not specified, this will be computes from the name.
  32001. */
  32002. index?: number;
  32003. /**
  32004. * size of the attribute, 1, 2, 3 or 4
  32005. */
  32006. attributeSize: number;
  32007. /**
  32008. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  32009. */
  32010. offset: number;
  32011. /**
  32012. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  32013. * default to 1
  32014. */
  32015. divisor?: number;
  32016. /**
  32017. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  32018. * default is FLOAT
  32019. */
  32020. attributeType?: number;
  32021. /**
  32022. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  32023. */
  32024. normalized?: boolean;
  32025. }
  32026. }
  32027. declare module "babylonjs/Engines/Extensions/engine.videoTexture" {
  32028. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  32029. import { Nullable } from "babylonjs/types";
  32030. module "babylonjs/Engines/thinEngine" {
  32031. interface ThinEngine {
  32032. /**
  32033. * Update a video texture
  32034. * @param texture defines the texture to update
  32035. * @param video defines the video element to use
  32036. * @param invertY defines if data must be stored with Y axis inverted
  32037. */
  32038. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  32039. }
  32040. }
  32041. }
  32042. declare module "babylonjs/Materials/Textures/videoTexture" {
  32043. import { Observable } from "babylonjs/Misc/observable";
  32044. import { Nullable } from "babylonjs/types";
  32045. import { Scene } from "babylonjs/scene";
  32046. import { Texture } from "babylonjs/Materials/Textures/texture";
  32047. import "babylonjs/Engines/Extensions/engine.videoTexture";
  32048. /**
  32049. * Settings for finer control over video usage
  32050. */
  32051. export interface VideoTextureSettings {
  32052. /**
  32053. * Applies `autoplay` to video, if specified
  32054. */
  32055. autoPlay?: boolean;
  32056. /**
  32057. * Applies `loop` to video, if specified
  32058. */
  32059. loop?: boolean;
  32060. /**
  32061. * Automatically updates internal texture from video at every frame in the render loop
  32062. */
  32063. autoUpdateTexture: boolean;
  32064. /**
  32065. * Image src displayed during the video loading or until the user interacts with the video.
  32066. */
  32067. poster?: string;
  32068. }
  32069. /**
  32070. * If you want to display a video in your scene, this is the special texture for that.
  32071. * This special texture works similar to other textures, with the exception of a few parameters.
  32072. * @see https://doc.babylonjs.com/how_to/video_texture
  32073. */
  32074. export class VideoTexture extends Texture {
  32075. /**
  32076. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  32077. */
  32078. readonly autoUpdateTexture: boolean;
  32079. /**
  32080. * The video instance used by the texture internally
  32081. */
  32082. readonly video: HTMLVideoElement;
  32083. private _onUserActionRequestedObservable;
  32084. /**
  32085. * Event triggerd when a dom action is required by the user to play the video.
  32086. * This happens due to recent changes in browser policies preventing video to auto start.
  32087. */
  32088. get onUserActionRequestedObservable(): Observable<Texture>;
  32089. private _generateMipMaps;
  32090. private _engine;
  32091. private _stillImageCaptured;
  32092. private _displayingPosterTexture;
  32093. private _settings;
  32094. private _createInternalTextureOnEvent;
  32095. private _frameId;
  32096. private _currentSrc;
  32097. /**
  32098. * Creates a video texture.
  32099. * If you want to display a video in your scene, this is the special texture for that.
  32100. * This special texture works similar to other textures, with the exception of a few parameters.
  32101. * @see https://doc.babylonjs.com/how_to/video_texture
  32102. * @param name optional name, will detect from video source, if not defined
  32103. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  32104. * @param scene is obviously the current scene.
  32105. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  32106. * @param invertY is false by default but can be used to invert video on Y axis
  32107. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  32108. * @param settings allows finer control over video usage
  32109. */
  32110. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  32111. private _getName;
  32112. private _getVideo;
  32113. private _createInternalTexture;
  32114. private reset;
  32115. /**
  32116. * @hidden Internal method to initiate `update`.
  32117. */
  32118. _rebuild(): void;
  32119. /**
  32120. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  32121. */
  32122. update(): void;
  32123. /**
  32124. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  32125. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  32126. */
  32127. updateTexture(isVisible: boolean): void;
  32128. protected _updateInternalTexture: () => void;
  32129. /**
  32130. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  32131. * @param url New url.
  32132. */
  32133. updateURL(url: string): void;
  32134. /**
  32135. * Clones the texture.
  32136. * @returns the cloned texture
  32137. */
  32138. clone(): VideoTexture;
  32139. /**
  32140. * Dispose the texture and release its associated resources.
  32141. */
  32142. dispose(): void;
  32143. /**
  32144. * Creates a video texture straight from a stream.
  32145. * @param scene Define the scene the texture should be created in
  32146. * @param stream Define the stream the texture should be created from
  32147. * @returns The created video texture as a promise
  32148. */
  32149. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  32150. /**
  32151. * Creates a video texture straight from your WebCam video feed.
  32152. * @param scene Define the scene the texture should be created in
  32153. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  32154. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  32155. * @returns The created video texture as a promise
  32156. */
  32157. static CreateFromWebCamAsync(scene: Scene, constraints: {
  32158. minWidth: number;
  32159. maxWidth: number;
  32160. minHeight: number;
  32161. maxHeight: number;
  32162. deviceId: string;
  32163. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  32164. /**
  32165. * Creates a video texture straight from your WebCam video feed.
  32166. * @param scene Define the scene the texture should be created in
  32167. * @param onReady Define a callback to triggered once the texture will be ready
  32168. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  32169. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  32170. */
  32171. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  32172. minWidth: number;
  32173. maxWidth: number;
  32174. minHeight: number;
  32175. maxHeight: number;
  32176. deviceId: string;
  32177. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  32178. }
  32179. }
  32180. declare module "babylonjs/Engines/thinEngine" {
  32181. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  32182. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  32183. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  32184. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  32185. import { Nullable, DataArray, IndicesArray } from "babylonjs/types";
  32186. import { EngineCapabilities } from "babylonjs/Engines/engineCapabilities";
  32187. import { Observable } from "babylonjs/Misc/observable";
  32188. import { DepthCullingState } from "babylonjs/States/depthCullingState";
  32189. import { StencilState } from "babylonjs/States/stencilState";
  32190. import { AlphaState } from "babylonjs/States/alphaCullingState";
  32191. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  32192. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  32193. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  32194. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  32195. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  32196. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  32197. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  32198. import { InstancingAttributeInfo } from "babylonjs/Engines/instancingAttributeInfo";
  32199. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  32200. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  32201. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  32202. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  32203. import { WebRequest } from "babylonjs/Misc/webRequest";
  32204. import { LoadFileError } from "babylonjs/Misc/fileTools";
  32205. /**
  32206. * Defines the interface used by objects working like Scene
  32207. * @hidden
  32208. */
  32209. export interface ISceneLike {
  32210. _addPendingData(data: any): void;
  32211. _removePendingData(data: any): void;
  32212. offlineProvider: IOfflineProvider;
  32213. }
  32214. /** Interface defining initialization parameters for Engine class */
  32215. export interface EngineOptions extends WebGLContextAttributes {
  32216. /**
  32217. * Defines if the engine should no exceed a specified device ratio
  32218. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  32219. */
  32220. limitDeviceRatio?: number;
  32221. /**
  32222. * Defines if webvr should be enabled automatically
  32223. * @see http://doc.babylonjs.com/how_to/webvr_camera
  32224. */
  32225. autoEnableWebVR?: boolean;
  32226. /**
  32227. * Defines if webgl2 should be turned off even if supported
  32228. * @see http://doc.babylonjs.com/features/webgl2
  32229. */
  32230. disableWebGL2Support?: boolean;
  32231. /**
  32232. * Defines if webaudio should be initialized as well
  32233. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32234. */
  32235. audioEngine?: boolean;
  32236. /**
  32237. * Defines if animations should run using a deterministic lock step
  32238. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32239. */
  32240. deterministicLockstep?: boolean;
  32241. /** Defines the maximum steps to use with deterministic lock step mode */
  32242. lockstepMaxSteps?: number;
  32243. /** Defines the seconds between each deterministic lock step */
  32244. timeStep?: number;
  32245. /**
  32246. * Defines that engine should ignore context lost events
  32247. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  32248. */
  32249. doNotHandleContextLost?: boolean;
  32250. /**
  32251. * Defines that engine should ignore modifying touch action attribute and style
  32252. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  32253. */
  32254. doNotHandleTouchAction?: boolean;
  32255. /**
  32256. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  32257. */
  32258. useHighPrecisionFloats?: boolean;
  32259. }
  32260. /**
  32261. * The base engine class (root of all engines)
  32262. */
  32263. export class ThinEngine {
  32264. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  32265. static ExceptionList: ({
  32266. key: string;
  32267. capture: string;
  32268. captureConstraint: number;
  32269. targets: string[];
  32270. } | {
  32271. key: string;
  32272. capture: null;
  32273. captureConstraint: null;
  32274. targets: string[];
  32275. })[];
  32276. /** @hidden */
  32277. static _TextureLoaders: IInternalTextureLoader[];
  32278. /**
  32279. * Returns the current npm package of the sdk
  32280. */
  32281. static get NpmPackage(): string;
  32282. /**
  32283. * Returns the current version of the framework
  32284. */
  32285. static get Version(): string;
  32286. /**
  32287. * Returns a string describing the current engine
  32288. */
  32289. get description(): string;
  32290. /**
  32291. * Gets or sets the epsilon value used by collision engine
  32292. */
  32293. static CollisionsEpsilon: number;
  32294. /**
  32295. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  32296. */
  32297. static get ShadersRepository(): string;
  32298. static set ShadersRepository(value: string);
  32299. /** @hidden */
  32300. _shaderProcessor: IShaderProcessor;
  32301. /**
  32302. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  32303. */
  32304. forcePOTTextures: boolean;
  32305. /**
  32306. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  32307. */
  32308. isFullscreen: boolean;
  32309. /**
  32310. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  32311. */
  32312. cullBackFaces: boolean;
  32313. /**
  32314. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  32315. */
  32316. renderEvenInBackground: boolean;
  32317. /**
  32318. * Gets or sets a boolean indicating that cache can be kept between frames
  32319. */
  32320. preventCacheWipeBetweenFrames: boolean;
  32321. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  32322. validateShaderPrograms: boolean;
  32323. /**
  32324. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  32325. * This can provide greater z depth for distant objects.
  32326. */
  32327. useReverseDepthBuffer: boolean;
  32328. /**
  32329. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  32330. */
  32331. disableUniformBuffers: boolean;
  32332. /** @hidden */
  32333. _uniformBuffers: UniformBuffer[];
  32334. /**
  32335. * Gets a boolean indicating that the engine supports uniform buffers
  32336. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  32337. */
  32338. get supportsUniformBuffers(): boolean;
  32339. /** @hidden */
  32340. _gl: WebGLRenderingContext;
  32341. /** @hidden */
  32342. _webGLVersion: number;
  32343. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  32344. protected _windowIsBackground: boolean;
  32345. protected _creationOptions: EngineOptions;
  32346. protected _highPrecisionShadersAllowed: boolean;
  32347. /** @hidden */
  32348. get _shouldUseHighPrecisionShader(): boolean;
  32349. /**
  32350. * Gets a boolean indicating that only power of 2 textures are supported
  32351. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  32352. */
  32353. get needPOTTextures(): boolean;
  32354. /** @hidden */
  32355. _badOS: boolean;
  32356. /** @hidden */
  32357. _badDesktopOS: boolean;
  32358. private _hardwareScalingLevel;
  32359. /** @hidden */
  32360. _caps: EngineCapabilities;
  32361. private _isStencilEnable;
  32362. private _glVersion;
  32363. private _glRenderer;
  32364. private _glVendor;
  32365. /** @hidden */
  32366. _videoTextureSupported: boolean;
  32367. protected _renderingQueueLaunched: boolean;
  32368. protected _activeRenderLoops: (() => void)[];
  32369. /**
  32370. * Observable signaled when a context lost event is raised
  32371. */
  32372. onContextLostObservable: Observable<ThinEngine>;
  32373. /**
  32374. * Observable signaled when a context restored event is raised
  32375. */
  32376. onContextRestoredObservable: Observable<ThinEngine>;
  32377. private _onContextLost;
  32378. private _onContextRestored;
  32379. protected _contextWasLost: boolean;
  32380. /** @hidden */
  32381. _doNotHandleContextLost: boolean;
  32382. /**
  32383. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  32384. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  32385. */
  32386. get doNotHandleContextLost(): boolean;
  32387. set doNotHandleContextLost(value: boolean);
  32388. /**
  32389. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  32390. */
  32391. disableVertexArrayObjects: boolean;
  32392. /** @hidden */
  32393. protected _colorWrite: boolean;
  32394. /** @hidden */
  32395. protected _colorWriteChanged: boolean;
  32396. /** @hidden */
  32397. protected _depthCullingState: DepthCullingState;
  32398. /** @hidden */
  32399. protected _stencilState: StencilState;
  32400. /** @hidden */
  32401. _alphaState: AlphaState;
  32402. /** @hidden */
  32403. _alphaMode: number;
  32404. /** @hidden */
  32405. _alphaEquation: number;
  32406. /** @hidden */
  32407. _internalTexturesCache: InternalTexture[];
  32408. /** @hidden */
  32409. protected _activeChannel: number;
  32410. private _currentTextureChannel;
  32411. /** @hidden */
  32412. protected _boundTexturesCache: {
  32413. [key: string]: Nullable<InternalTexture>;
  32414. };
  32415. /** @hidden */
  32416. protected _currentEffect: Nullable<Effect>;
  32417. /** @hidden */
  32418. protected _currentProgram: Nullable<WebGLProgram>;
  32419. private _compiledEffects;
  32420. private _vertexAttribArraysEnabled;
  32421. /** @hidden */
  32422. protected _cachedViewport: Nullable<IViewportLike>;
  32423. private _cachedVertexArrayObject;
  32424. /** @hidden */
  32425. protected _cachedVertexBuffers: any;
  32426. /** @hidden */
  32427. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  32428. /** @hidden */
  32429. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  32430. /** @hidden */
  32431. _currentRenderTarget: Nullable<InternalTexture>;
  32432. private _uintIndicesCurrentlySet;
  32433. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  32434. /** @hidden */
  32435. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  32436. private _currentBufferPointers;
  32437. private _currentInstanceLocations;
  32438. private _currentInstanceBuffers;
  32439. private _textureUnits;
  32440. /** @hidden */
  32441. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  32442. /** @hidden */
  32443. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  32444. /** @hidden */
  32445. _boundRenderFunction: any;
  32446. private _vaoRecordInProgress;
  32447. private _mustWipeVertexAttributes;
  32448. private _emptyTexture;
  32449. private _emptyCubeTexture;
  32450. private _emptyTexture3D;
  32451. private _emptyTexture2DArray;
  32452. /** @hidden */
  32453. _frameHandler: number;
  32454. private _nextFreeTextureSlots;
  32455. private _maxSimultaneousTextures;
  32456. private _activeRequests;
  32457. /** @hidden */
  32458. _transformTextureUrl: Nullable<(url: string) => string>;
  32459. protected get _supportsHardwareTextureRescaling(): boolean;
  32460. private _framebufferDimensionsObject;
  32461. /**
  32462. * sets the object from which width and height will be taken from when getting render width and height
  32463. * Will fallback to the gl object
  32464. * @param dimensions the framebuffer width and height that will be used.
  32465. */
  32466. set framebufferDimensionsObject(dimensions: Nullable<{
  32467. framebufferWidth: number;
  32468. framebufferHeight: number;
  32469. }>);
  32470. /**
  32471. * Gets the current viewport
  32472. */
  32473. get currentViewport(): Nullable<IViewportLike>;
  32474. /**
  32475. * Gets the default empty texture
  32476. */
  32477. get emptyTexture(): InternalTexture;
  32478. /**
  32479. * Gets the default empty 3D texture
  32480. */
  32481. get emptyTexture3D(): InternalTexture;
  32482. /**
  32483. * Gets the default empty 2D array texture
  32484. */
  32485. get emptyTexture2DArray(): InternalTexture;
  32486. /**
  32487. * Gets the default empty cube texture
  32488. */
  32489. get emptyCubeTexture(): InternalTexture;
  32490. /**
  32491. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  32492. */
  32493. readonly premultipliedAlpha: boolean;
  32494. /**
  32495. * Observable event triggered before each texture is initialized
  32496. */
  32497. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  32498. /**
  32499. * Creates a new engine
  32500. * @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
  32501. * @param antialias defines enable antialiasing (default: false)
  32502. * @param options defines further options to be sent to the getContext() function
  32503. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  32504. */
  32505. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  32506. private _rebuildInternalTextures;
  32507. private _rebuildEffects;
  32508. /**
  32509. * Gets a boolean indicating if all created effects are ready
  32510. * @returns true if all effects are ready
  32511. */
  32512. areAllEffectsReady(): boolean;
  32513. protected _rebuildBuffers(): void;
  32514. protected _initGLContext(): void;
  32515. /**
  32516. * Gets version of the current webGL context
  32517. */
  32518. get webGLVersion(): number;
  32519. /**
  32520. * Gets a string idenfifying the name of the class
  32521. * @returns "Engine" string
  32522. */
  32523. getClassName(): string;
  32524. /**
  32525. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  32526. */
  32527. get isStencilEnable(): boolean;
  32528. /** @hidden */
  32529. _prepareWorkingCanvas(): void;
  32530. /**
  32531. * Reset the texture cache to empty state
  32532. */
  32533. resetTextureCache(): void;
  32534. /**
  32535. * Gets an object containing information about the current webGL context
  32536. * @returns an object containing the vender, the renderer and the version of the current webGL context
  32537. */
  32538. getGlInfo(): {
  32539. vendor: string;
  32540. renderer: string;
  32541. version: string;
  32542. };
  32543. /**
  32544. * Defines the hardware scaling level.
  32545. * By default the hardware scaling level is computed from the window device ratio.
  32546. * if level = 1 then the engine will render at the exact resolution of the canvas. If level = 0.5 then the engine will render at twice the size of the canvas.
  32547. * @param level defines the level to use
  32548. */
  32549. setHardwareScalingLevel(level: number): void;
  32550. /**
  32551. * Gets the current hardware scaling level.
  32552. * By default the hardware scaling level is computed from the window device ratio.
  32553. * if level = 1 then the engine will render at the exact resolution of the canvas. If level = 0.5 then the engine will render at twice the size of the canvas.
  32554. * @returns a number indicating the current hardware scaling level
  32555. */
  32556. getHardwareScalingLevel(): number;
  32557. /**
  32558. * Gets the list of loaded textures
  32559. * @returns an array containing all loaded textures
  32560. */
  32561. getLoadedTexturesCache(): InternalTexture[];
  32562. /**
  32563. * Gets the object containing all engine capabilities
  32564. * @returns the EngineCapabilities object
  32565. */
  32566. getCaps(): EngineCapabilities;
  32567. /**
  32568. * stop executing a render loop function and remove it from the execution array
  32569. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  32570. */
  32571. stopRenderLoop(renderFunction?: () => void): void;
  32572. /** @hidden */
  32573. _renderLoop(): void;
  32574. /**
  32575. * Gets the HTML canvas attached with the current webGL context
  32576. * @returns a HTML canvas
  32577. */
  32578. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  32579. /**
  32580. * Gets host window
  32581. * @returns the host window object
  32582. */
  32583. getHostWindow(): Nullable<Window>;
  32584. /**
  32585. * Gets the current render width
  32586. * @param useScreen defines if screen size must be used (or the current render target if any)
  32587. * @returns a number defining the current render width
  32588. */
  32589. getRenderWidth(useScreen?: boolean): number;
  32590. /**
  32591. * Gets the current render height
  32592. * @param useScreen defines if screen size must be used (or the current render target if any)
  32593. * @returns a number defining the current render height
  32594. */
  32595. getRenderHeight(useScreen?: boolean): number;
  32596. /**
  32597. * Can be used to override the current requestAnimationFrame requester.
  32598. * @hidden
  32599. */
  32600. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  32601. /**
  32602. * Register and execute a render loop. The engine can have more than one render function
  32603. * @param renderFunction defines the function to continuously execute
  32604. */
  32605. runRenderLoop(renderFunction: () => void): void;
  32606. /**
  32607. * Clear the current render buffer or the current render target (if any is set up)
  32608. * @param color defines the color to use
  32609. * @param backBuffer defines if the back buffer must be cleared
  32610. * @param depth defines if the depth buffer must be cleared
  32611. * @param stencil defines if the stencil buffer must be cleared
  32612. */
  32613. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  32614. private _viewportCached;
  32615. /** @hidden */
  32616. _viewport(x: number, y: number, width: number, height: number): void;
  32617. /**
  32618. * Set the WebGL's viewport
  32619. * @param viewport defines the viewport element to be used
  32620. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  32621. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  32622. */
  32623. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  32624. /**
  32625. * Begin a new frame
  32626. */
  32627. beginFrame(): void;
  32628. /**
  32629. * Enf the current frame
  32630. */
  32631. endFrame(): void;
  32632. /**
  32633. * Resize the view according to the canvas' size
  32634. */
  32635. resize(): void;
  32636. /**
  32637. * Force a specific size of the canvas
  32638. * @param width defines the new canvas' width
  32639. * @param height defines the new canvas' height
  32640. */
  32641. setSize(width: number, height: number): void;
  32642. /**
  32643. * Binds the frame buffer to the specified texture.
  32644. * @param texture The texture to render to or null for the default canvas
  32645. * @param faceIndex The face of the texture to render to in case of cube texture
  32646. * @param requiredWidth The width of the target to render to
  32647. * @param requiredHeight The height of the target to render to
  32648. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  32649. * @param lodLevel defines the lod level to bind to the frame buffer
  32650. * @param layer defines the 2d array index to bind to frame buffer to
  32651. */
  32652. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  32653. /** @hidden */
  32654. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  32655. /**
  32656. * Unbind the current render target texture from the webGL context
  32657. * @param texture defines the render target texture to unbind
  32658. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  32659. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  32660. */
  32661. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  32662. /**
  32663. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  32664. */
  32665. flushFramebuffer(): void;
  32666. /**
  32667. * Unbind the current render target and bind the default framebuffer
  32668. */
  32669. restoreDefaultFramebuffer(): void;
  32670. /** @hidden */
  32671. protected _resetVertexBufferBinding(): void;
  32672. /**
  32673. * Creates a vertex buffer
  32674. * @param data the data for the vertex buffer
  32675. * @returns the new WebGL static buffer
  32676. */
  32677. createVertexBuffer(data: DataArray): DataBuffer;
  32678. private _createVertexBuffer;
  32679. /**
  32680. * Creates a dynamic vertex buffer
  32681. * @param data the data for the dynamic vertex buffer
  32682. * @returns the new WebGL dynamic buffer
  32683. */
  32684. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  32685. protected _resetIndexBufferBinding(): void;
  32686. /**
  32687. * Creates a new index buffer
  32688. * @param indices defines the content of the index buffer
  32689. * @param updatable defines if the index buffer must be updatable
  32690. * @returns a new webGL buffer
  32691. */
  32692. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  32693. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  32694. /**
  32695. * Bind a webGL buffer to the webGL context
  32696. * @param buffer defines the buffer to bind
  32697. */
  32698. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  32699. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  32700. private bindBuffer;
  32701. /**
  32702. * update the bound buffer with the given data
  32703. * @param data defines the data to update
  32704. */
  32705. updateArrayBuffer(data: Float32Array): void;
  32706. private _vertexAttribPointer;
  32707. /** @hidden */
  32708. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  32709. private _bindVertexBuffersAttributes;
  32710. /**
  32711. * Records a vertex array object
  32712. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  32713. * @param vertexBuffers defines the list of vertex buffers to store
  32714. * @param indexBuffer defines the index buffer to store
  32715. * @param effect defines the effect to store
  32716. * @returns the new vertex array object
  32717. */
  32718. recordVertexArrayObject(vertexBuffers: {
  32719. [key: string]: VertexBuffer;
  32720. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  32721. /**
  32722. * Bind a specific vertex array object
  32723. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  32724. * @param vertexArrayObject defines the vertex array object to bind
  32725. * @param indexBuffer defines the index buffer to bind
  32726. */
  32727. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  32728. /**
  32729. * Bind webGl buffers directly to the webGL context
  32730. * @param vertexBuffer defines the vertex buffer to bind
  32731. * @param indexBuffer defines the index buffer to bind
  32732. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  32733. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  32734. * @param effect defines the effect associated with the vertex buffer
  32735. */
  32736. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  32737. private _unbindVertexArrayObject;
  32738. /**
  32739. * Bind a list of vertex buffers to the webGL context
  32740. * @param vertexBuffers defines the list of vertex buffers to bind
  32741. * @param indexBuffer defines the index buffer to bind
  32742. * @param effect defines the effect associated with the vertex buffers
  32743. */
  32744. bindBuffers(vertexBuffers: {
  32745. [key: string]: Nullable<VertexBuffer>;
  32746. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  32747. /**
  32748. * Unbind all instance attributes
  32749. */
  32750. unbindInstanceAttributes(): void;
  32751. /**
  32752. * Release and free the memory of a vertex array object
  32753. * @param vao defines the vertex array object to delete
  32754. */
  32755. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  32756. /** @hidden */
  32757. _releaseBuffer(buffer: DataBuffer): boolean;
  32758. protected _deleteBuffer(buffer: DataBuffer): void;
  32759. /**
  32760. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  32761. * @param instancesBuffer defines the webGL buffer to update and bind
  32762. * @param data defines the data to store in the buffer
  32763. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  32764. */
  32765. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  32766. /**
  32767. * Bind the content of a webGL buffer used with instantiation
  32768. * @param instancesBuffer defines the webGL buffer to bind
  32769. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  32770. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  32771. */
  32772. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  32773. /**
  32774. * Disable the instance attribute corresponding to the name in parameter
  32775. * @param name defines the name of the attribute to disable
  32776. */
  32777. disableInstanceAttributeByName(name: string): void;
  32778. /**
  32779. * Disable the instance attribute corresponding to the location in parameter
  32780. * @param attributeLocation defines the attribute location of the attribute to disable
  32781. */
  32782. disableInstanceAttribute(attributeLocation: number): void;
  32783. /**
  32784. * Disable the attribute corresponding to the location in parameter
  32785. * @param attributeLocation defines the attribute location of the attribute to disable
  32786. */
  32787. disableAttributeByIndex(attributeLocation: number): void;
  32788. /**
  32789. * Send a draw order
  32790. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  32791. * @param indexStart defines the starting index
  32792. * @param indexCount defines the number of index to draw
  32793. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32794. */
  32795. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  32796. /**
  32797. * Draw a list of points
  32798. * @param verticesStart defines the index of first vertex to draw
  32799. * @param verticesCount defines the count of vertices to draw
  32800. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32801. */
  32802. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  32803. /**
  32804. * Draw a list of unindexed primitives
  32805. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  32806. * @param verticesStart defines the index of first vertex to draw
  32807. * @param verticesCount defines the count of vertices to draw
  32808. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32809. */
  32810. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  32811. /**
  32812. * Draw a list of indexed primitives
  32813. * @param fillMode defines the primitive to use
  32814. * @param indexStart defines the starting index
  32815. * @param indexCount defines the number of index to draw
  32816. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32817. */
  32818. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  32819. /**
  32820. * Draw a list of unindexed primitives
  32821. * @param fillMode defines the primitive to use
  32822. * @param verticesStart defines the index of first vertex to draw
  32823. * @param verticesCount defines the count of vertices to draw
  32824. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32825. */
  32826. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  32827. private _drawMode;
  32828. /** @hidden */
  32829. protected _reportDrawCall(): void;
  32830. /** @hidden */
  32831. _releaseEffect(effect: Effect): void;
  32832. /** @hidden */
  32833. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  32834. /**
  32835. * Create a new effect (used to store vertex/fragment shaders)
  32836. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  32837. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  32838. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  32839. * @param samplers defines an array of string used to represent textures
  32840. * @param defines defines the string containing the defines to use to compile the shaders
  32841. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  32842. * @param onCompiled defines a function to call when the effect creation is successful
  32843. * @param onError defines a function to call when the effect creation has failed
  32844. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  32845. * @returns the new Effect
  32846. */
  32847. 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;
  32848. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  32849. private _compileShader;
  32850. private _compileRawShader;
  32851. /** @hidden */
  32852. _getShaderSource(shader: WebGLShader): Nullable<string>;
  32853. /**
  32854. * Directly creates a webGL program
  32855. * @param pipelineContext defines the pipeline context to attach to
  32856. * @param vertexCode defines the vertex shader code to use
  32857. * @param fragmentCode defines the fragment shader code to use
  32858. * @param context defines the webGL context to use (if not set, the current one will be used)
  32859. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  32860. * @returns the new webGL program
  32861. */
  32862. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32863. /**
  32864. * Creates a webGL program
  32865. * @param pipelineContext defines the pipeline context to attach to
  32866. * @param vertexCode defines the vertex shader code to use
  32867. * @param fragmentCode defines the fragment shader code to use
  32868. * @param defines defines the string containing the defines to use to compile the shaders
  32869. * @param context defines the webGL context to use (if not set, the current one will be used)
  32870. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  32871. * @returns the new webGL program
  32872. */
  32873. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32874. /**
  32875. * Creates a new pipeline context
  32876. * @returns the new pipeline
  32877. */
  32878. createPipelineContext(): IPipelineContext;
  32879. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32880. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  32881. /** @hidden */
  32882. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  32883. /** @hidden */
  32884. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  32885. /** @hidden */
  32886. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  32887. /**
  32888. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  32889. * @param pipelineContext defines the pipeline context to use
  32890. * @param uniformsNames defines the list of uniform names
  32891. * @returns an array of webGL uniform locations
  32892. */
  32893. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  32894. /**
  32895. * Gets the lsit of active attributes for a given webGL program
  32896. * @param pipelineContext defines the pipeline context to use
  32897. * @param attributesNames defines the list of attribute names to get
  32898. * @returns an array of indices indicating the offset of each attribute
  32899. */
  32900. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  32901. /**
  32902. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  32903. * @param effect defines the effect to activate
  32904. */
  32905. enableEffect(effect: Nullable<Effect>): void;
  32906. /**
  32907. * Set the value of an uniform to a number (int)
  32908. * @param uniform defines the webGL uniform location where to store the value
  32909. * @param value defines the int number to store
  32910. */
  32911. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  32912. /**
  32913. * Set the value of an uniform to an array of int32
  32914. * @param uniform defines the webGL uniform location where to store the value
  32915. * @param array defines the array of int32 to store
  32916. */
  32917. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32918. /**
  32919. * Set the value of an uniform to an array of int32 (stored as vec2)
  32920. * @param uniform defines the webGL uniform location where to store the value
  32921. * @param array defines the array of int32 to store
  32922. */
  32923. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32924. /**
  32925. * Set the value of an uniform to an array of int32 (stored as vec3)
  32926. * @param uniform defines the webGL uniform location where to store the value
  32927. * @param array defines the array of int32 to store
  32928. */
  32929. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32930. /**
  32931. * Set the value of an uniform to an array of int32 (stored as vec4)
  32932. * @param uniform defines the webGL uniform location where to store the value
  32933. * @param array defines the array of int32 to store
  32934. */
  32935. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32936. /**
  32937. * Set the value of an uniform to an array of number
  32938. * @param uniform defines the webGL uniform location where to store the value
  32939. * @param array defines the array of number to store
  32940. */
  32941. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32942. /**
  32943. * Set the value of an uniform to an array of number (stored as vec2)
  32944. * @param uniform defines the webGL uniform location where to store the value
  32945. * @param array defines the array of number to store
  32946. */
  32947. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32948. /**
  32949. * Set the value of an uniform to an array of number (stored as vec3)
  32950. * @param uniform defines the webGL uniform location where to store the value
  32951. * @param array defines the array of number to store
  32952. */
  32953. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32954. /**
  32955. * Set the value of an uniform to an array of number (stored as vec4)
  32956. * @param uniform defines the webGL uniform location where to store the value
  32957. * @param array defines the array of number to store
  32958. */
  32959. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32960. /**
  32961. * Set the value of an uniform to an array of float32 (stored as matrices)
  32962. * @param uniform defines the webGL uniform location where to store the value
  32963. * @param matrices defines the array of float32 to store
  32964. */
  32965. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  32966. /**
  32967. * Set the value of an uniform to a matrix (3x3)
  32968. * @param uniform defines the webGL uniform location where to store the value
  32969. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  32970. */
  32971. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  32972. /**
  32973. * Set the value of an uniform to a matrix (2x2)
  32974. * @param uniform defines the webGL uniform location where to store the value
  32975. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  32976. */
  32977. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  32978. /**
  32979. * Set the value of an uniform to a number (float)
  32980. * @param uniform defines the webGL uniform location where to store the value
  32981. * @param value defines the float number to store
  32982. */
  32983. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  32984. /**
  32985. * Set the value of an uniform to a vec2
  32986. * @param uniform defines the webGL uniform location where to store the value
  32987. * @param x defines the 1st component of the value
  32988. * @param y defines the 2nd component of the value
  32989. */
  32990. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  32991. /**
  32992. * Set the value of an uniform to a vec3
  32993. * @param uniform defines the webGL uniform location where to store the value
  32994. * @param x defines the 1st component of the value
  32995. * @param y defines the 2nd component of the value
  32996. * @param z defines the 3rd component of the value
  32997. */
  32998. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  32999. /**
  33000. * Set the value of an uniform to a vec4
  33001. * @param uniform defines the webGL uniform location where to store the value
  33002. * @param x defines the 1st component of the value
  33003. * @param y defines the 2nd component of the value
  33004. * @param z defines the 3rd component of the value
  33005. * @param w defines the 4th component of the value
  33006. */
  33007. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  33008. /**
  33009. * Apply all cached states (depth, culling, stencil and alpha)
  33010. */
  33011. applyStates(): void;
  33012. /**
  33013. * Enable or disable color writing
  33014. * @param enable defines the state to set
  33015. */
  33016. setColorWrite(enable: boolean): void;
  33017. /**
  33018. * Gets a boolean indicating if color writing is enabled
  33019. * @returns the current color writing state
  33020. */
  33021. getColorWrite(): boolean;
  33022. /**
  33023. * Gets the depth culling state manager
  33024. */
  33025. get depthCullingState(): DepthCullingState;
  33026. /**
  33027. * Gets the alpha state manager
  33028. */
  33029. get alphaState(): AlphaState;
  33030. /**
  33031. * Gets the stencil state manager
  33032. */
  33033. get stencilState(): StencilState;
  33034. /**
  33035. * Clears the list of texture accessible through engine.
  33036. * This can help preventing texture load conflict due to name collision.
  33037. */
  33038. clearInternalTexturesCache(): void;
  33039. /**
  33040. * Force the entire cache to be cleared
  33041. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  33042. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  33043. */
  33044. wipeCaches(bruteForce?: boolean): void;
  33045. /** @hidden */
  33046. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  33047. min: number;
  33048. mag: number;
  33049. };
  33050. /** @hidden */
  33051. _createTexture(): WebGLTexture;
  33052. /**
  33053. * Usually called from Texture.ts.
  33054. * Passed information to create a WebGLTexture
  33055. * @param url defines a value which contains one of the following:
  33056. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  33057. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  33058. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  33059. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  33060. * @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)
  33061. * @param scene needed for loading to the correct scene
  33062. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  33063. * @param onLoad optional callback to be called upon successful completion
  33064. * @param onError optional callback to be called upon failure
  33065. * @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
  33066. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  33067. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  33068. * @param forcedExtension defines the extension to use to pick the right loader
  33069. * @param mimeType defines an optional mime type
  33070. * @returns a InternalTexture for assignment back into BABYLON.Texture
  33071. */
  33072. 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;
  33073. /**
  33074. * Loads an image as an HTMLImageElement.
  33075. * @param input url string, ArrayBuffer, or Blob to load
  33076. * @param onLoad callback called when the image successfully loads
  33077. * @param onError callback called when the image fails to load
  33078. * @param offlineProvider offline provider for caching
  33079. * @param mimeType optional mime type
  33080. * @returns the HTMLImageElement of the loaded image
  33081. * @hidden
  33082. */
  33083. 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>;
  33084. /**
  33085. * @hidden
  33086. */
  33087. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  33088. /**
  33089. * Creates a raw texture
  33090. * @param data defines the data to store in the texture
  33091. * @param width defines the width of the texture
  33092. * @param height defines the height of the texture
  33093. * @param format defines the format of the data
  33094. * @param generateMipMaps defines if the engine should generate the mip levels
  33095. * @param invertY defines if data must be stored with Y axis inverted
  33096. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  33097. * @param compression defines the compression used (null by default)
  33098. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  33099. * @returns the raw texture inside an InternalTexture
  33100. */
  33101. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  33102. /**
  33103. * Creates a new raw cube texture
  33104. * @param data defines the array of data to use to create each face
  33105. * @param size defines the size of the textures
  33106. * @param format defines the format of the data
  33107. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  33108. * @param generateMipMaps defines if the engine should generate the mip levels
  33109. * @param invertY defines if data must be stored with Y axis inverted
  33110. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  33111. * @param compression defines the compression used (null by default)
  33112. * @returns the cube texture as an InternalTexture
  33113. */
  33114. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  33115. /**
  33116. * Creates a new raw 3D texture
  33117. * @param data defines the data used to create the texture
  33118. * @param width defines the width of the texture
  33119. * @param height defines the height of the texture
  33120. * @param depth defines the depth of the texture
  33121. * @param format defines the format of the texture
  33122. * @param generateMipMaps defines if the engine must generate mip levels
  33123. * @param invertY defines if data must be stored with Y axis inverted
  33124. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  33125. * @param compression defines the compressed used (can be null)
  33126. * @param textureType defines the compressed used (can be null)
  33127. * @returns a new raw 3D texture (stored in an InternalTexture)
  33128. */
  33129. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  33130. /**
  33131. * Creates a new raw 2D array texture
  33132. * @param data defines the data used to create the texture
  33133. * @param width defines the width of the texture
  33134. * @param height defines the height of the texture
  33135. * @param depth defines the number of layers of the texture
  33136. * @param format defines the format of the texture
  33137. * @param generateMipMaps defines if the engine must generate mip levels
  33138. * @param invertY defines if data must be stored with Y axis inverted
  33139. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  33140. * @param compression defines the compressed used (can be null)
  33141. * @param textureType defines the compressed used (can be null)
  33142. * @returns a new raw 2D array texture (stored in an InternalTexture)
  33143. */
  33144. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  33145. private _unpackFlipYCached;
  33146. /**
  33147. * In case you are sharing the context with other applications, it might
  33148. * be interested to not cache the unpack flip y state to ensure a consistent
  33149. * value would be set.
  33150. */
  33151. enableUnpackFlipYCached: boolean;
  33152. /** @hidden */
  33153. _unpackFlipY(value: boolean): void;
  33154. /** @hidden */
  33155. _getUnpackAlignement(): number;
  33156. private _getTextureTarget;
  33157. /**
  33158. * Update the sampling mode of a given texture
  33159. * @param samplingMode defines the required sampling mode
  33160. * @param texture defines the texture to update
  33161. * @param generateMipMaps defines whether to generate mipmaps for the texture
  33162. */
  33163. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  33164. /**
  33165. * Update the sampling mode of a given texture
  33166. * @param texture defines the texture to update
  33167. * @param wrapU defines the texture wrap mode of the u coordinates
  33168. * @param wrapV defines the texture wrap mode of the v coordinates
  33169. * @param wrapR defines the texture wrap mode of the r coordinates
  33170. */
  33171. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  33172. /** @hidden */
  33173. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  33174. width: number;
  33175. height: number;
  33176. layers?: number;
  33177. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  33178. /** @hidden */
  33179. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  33180. /** @hidden */
  33181. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  33182. /**
  33183. * Update a portion of an internal texture
  33184. * @param texture defines the texture to update
  33185. * @param imageData defines the data to store into the texture
  33186. * @param xOffset defines the x coordinates of the update rectangle
  33187. * @param yOffset defines the y coordinates of the update rectangle
  33188. * @param width defines the width of the update rectangle
  33189. * @param height defines the height of the update rectangle
  33190. * @param faceIndex defines the face index if texture is a cube (0 by default)
  33191. * @param lod defines the lod level to update (0 by default)
  33192. */
  33193. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  33194. /** @hidden */
  33195. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  33196. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  33197. private _prepareWebGLTexture;
  33198. /** @hidden */
  33199. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  33200. private _getDepthStencilBuffer;
  33201. /** @hidden */
  33202. _releaseFramebufferObjects(texture: InternalTexture): void;
  33203. /** @hidden */
  33204. _releaseTexture(texture: InternalTexture): void;
  33205. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  33206. protected _setProgram(program: WebGLProgram): void;
  33207. protected _boundUniforms: {
  33208. [key: number]: WebGLUniformLocation;
  33209. };
  33210. /**
  33211. * Binds an effect to the webGL context
  33212. * @param effect defines the effect to bind
  33213. */
  33214. bindSamplers(effect: Effect): void;
  33215. private _activateCurrentTexture;
  33216. /** @hidden */
  33217. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  33218. /** @hidden */
  33219. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  33220. /**
  33221. * Unbind all textures from the webGL context
  33222. */
  33223. unbindAllTextures(): void;
  33224. /**
  33225. * Sets a texture to the according uniform.
  33226. * @param channel The texture channel
  33227. * @param uniform The uniform to set
  33228. * @param texture The texture to apply
  33229. */
  33230. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  33231. private _bindSamplerUniformToChannel;
  33232. private _getTextureWrapMode;
  33233. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  33234. /**
  33235. * Sets an array of texture to the webGL context
  33236. * @param channel defines the channel where the texture array must be set
  33237. * @param uniform defines the associated uniform location
  33238. * @param textures defines the array of textures to bind
  33239. */
  33240. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  33241. /** @hidden */
  33242. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  33243. private _setTextureParameterFloat;
  33244. private _setTextureParameterInteger;
  33245. /**
  33246. * Unbind all vertex attributes from the webGL context
  33247. */
  33248. unbindAllAttributes(): void;
  33249. /**
  33250. * 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
  33251. */
  33252. releaseEffects(): void;
  33253. /**
  33254. * Dispose and release all associated resources
  33255. */
  33256. dispose(): void;
  33257. /**
  33258. * Attach a new callback raised when context lost event is fired
  33259. * @param callback defines the callback to call
  33260. */
  33261. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  33262. /**
  33263. * Attach a new callback raised when context restored event is fired
  33264. * @param callback defines the callback to call
  33265. */
  33266. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  33267. /**
  33268. * Get the current error code of the webGL context
  33269. * @returns the error code
  33270. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  33271. */
  33272. getError(): number;
  33273. private _canRenderToFloatFramebuffer;
  33274. private _canRenderToHalfFloatFramebuffer;
  33275. private _canRenderToFramebuffer;
  33276. /** @hidden */
  33277. _getWebGLTextureType(type: number): number;
  33278. /** @hidden */
  33279. _getInternalFormat(format: number): number;
  33280. /** @hidden */
  33281. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  33282. /** @hidden */
  33283. _getRGBAMultiSampleBufferFormat(type: number): number;
  33284. /** @hidden */
  33285. _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;
  33286. /**
  33287. * Loads a file from a url
  33288. * @param url url to load
  33289. * @param onSuccess callback called when the file successfully loads
  33290. * @param onProgress callback called while file is loading (if the server supports this mode)
  33291. * @param offlineProvider defines the offline provider for caching
  33292. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  33293. * @param onError callback called when the file fails to load
  33294. * @returns a file request object
  33295. * @hidden
  33296. */
  33297. 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;
  33298. /**
  33299. * Reads pixels from the current frame buffer. Please note that this function can be slow
  33300. * @param x defines the x coordinate of the rectangle where pixels must be read
  33301. * @param y defines the y coordinate of the rectangle where pixels must be read
  33302. * @param width defines the width of the rectangle where pixels must be read
  33303. * @param height defines the height of the rectangle where pixels must be read
  33304. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  33305. * @returns a Uint8Array containing RGBA colors
  33306. */
  33307. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  33308. private static _isSupported;
  33309. /**
  33310. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  33311. * @returns true if the engine can be created
  33312. * @ignorenaming
  33313. */
  33314. static isSupported(): boolean;
  33315. /**
  33316. * Find the next highest power of two.
  33317. * @param x Number to start search from.
  33318. * @return Next highest power of two.
  33319. */
  33320. static CeilingPOT(x: number): number;
  33321. /**
  33322. * Find the next lowest power of two.
  33323. * @param x Number to start search from.
  33324. * @return Next lowest power of two.
  33325. */
  33326. static FloorPOT(x: number): number;
  33327. /**
  33328. * Find the nearest power of two.
  33329. * @param x Number to start search from.
  33330. * @return Next nearest power of two.
  33331. */
  33332. static NearestPOT(x: number): number;
  33333. /**
  33334. * Get the closest exponent of two
  33335. * @param value defines the value to approximate
  33336. * @param max defines the maximum value to return
  33337. * @param mode defines how to define the closest value
  33338. * @returns closest exponent of two of the given value
  33339. */
  33340. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  33341. /**
  33342. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  33343. * @param func - the function to be called
  33344. * @param requester - the object that will request the next frame. Falls back to window.
  33345. * @returns frame number
  33346. */
  33347. static QueueNewFrame(func: () => void, requester?: any): number;
  33348. /**
  33349. * Gets host document
  33350. * @returns the host document object
  33351. */
  33352. getHostDocument(): Nullable<Document>;
  33353. }
  33354. }
  33355. declare module "babylonjs/Maths/sphericalPolynomial" {
  33356. import { Vector3 } from "babylonjs/Maths/math.vector";
  33357. import { Color3 } from "babylonjs/Maths/math.color";
  33358. /**
  33359. * Class representing spherical harmonics coefficients to the 3rd degree
  33360. */
  33361. export class SphericalHarmonics {
  33362. /**
  33363. * Defines whether or not the harmonics have been prescaled for rendering.
  33364. */
  33365. preScaled: boolean;
  33366. /**
  33367. * The l0,0 coefficients of the spherical harmonics
  33368. */
  33369. l00: Vector3;
  33370. /**
  33371. * The l1,-1 coefficients of the spherical harmonics
  33372. */
  33373. l1_1: Vector3;
  33374. /**
  33375. * The l1,0 coefficients of the spherical harmonics
  33376. */
  33377. l10: Vector3;
  33378. /**
  33379. * The l1,1 coefficients of the spherical harmonics
  33380. */
  33381. l11: Vector3;
  33382. /**
  33383. * The l2,-2 coefficients of the spherical harmonics
  33384. */
  33385. l2_2: Vector3;
  33386. /**
  33387. * The l2,-1 coefficients of the spherical harmonics
  33388. */
  33389. l2_1: Vector3;
  33390. /**
  33391. * The l2,0 coefficients of the spherical harmonics
  33392. */
  33393. l20: Vector3;
  33394. /**
  33395. * The l2,1 coefficients of the spherical harmonics
  33396. */
  33397. l21: Vector3;
  33398. /**
  33399. * The l2,2 coefficients of the spherical harmonics
  33400. */
  33401. l22: Vector3;
  33402. /**
  33403. * Adds a light to the spherical harmonics
  33404. * @param direction the direction of the light
  33405. * @param color the color of the light
  33406. * @param deltaSolidAngle the delta solid angle of the light
  33407. */
  33408. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  33409. /**
  33410. * Scales the spherical harmonics by the given amount
  33411. * @param scale the amount to scale
  33412. */
  33413. scaleInPlace(scale: number): void;
  33414. /**
  33415. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  33416. *
  33417. * ```
  33418. * E_lm = A_l * L_lm
  33419. * ```
  33420. *
  33421. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  33422. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  33423. * the scaling factors are given in equation 9.
  33424. */
  33425. convertIncidentRadianceToIrradiance(): void;
  33426. /**
  33427. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  33428. *
  33429. * ```
  33430. * L = (1/pi) * E * rho
  33431. * ```
  33432. *
  33433. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  33434. */
  33435. convertIrradianceToLambertianRadiance(): void;
  33436. /**
  33437. * Integrates the reconstruction coefficients directly in to the SH preventing further
  33438. * required operations at run time.
  33439. *
  33440. * This is simply done by scaling back the SH with Ylm constants parameter.
  33441. * The trigonometric part being applied by the shader at run time.
  33442. */
  33443. preScaleForRendering(): void;
  33444. /**
  33445. * Constructs a spherical harmonics from an array.
  33446. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  33447. * @returns the spherical harmonics
  33448. */
  33449. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  33450. /**
  33451. * Gets the spherical harmonics from polynomial
  33452. * @param polynomial the spherical polynomial
  33453. * @returns the spherical harmonics
  33454. */
  33455. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  33456. }
  33457. /**
  33458. * Class representing spherical polynomial coefficients to the 3rd degree
  33459. */
  33460. export class SphericalPolynomial {
  33461. private _harmonics;
  33462. /**
  33463. * The spherical harmonics used to create the polynomials.
  33464. */
  33465. get preScaledHarmonics(): SphericalHarmonics;
  33466. /**
  33467. * The x coefficients of the spherical polynomial
  33468. */
  33469. x: Vector3;
  33470. /**
  33471. * The y coefficients of the spherical polynomial
  33472. */
  33473. y: Vector3;
  33474. /**
  33475. * The z coefficients of the spherical polynomial
  33476. */
  33477. z: Vector3;
  33478. /**
  33479. * The xx coefficients of the spherical polynomial
  33480. */
  33481. xx: Vector3;
  33482. /**
  33483. * The yy coefficients of the spherical polynomial
  33484. */
  33485. yy: Vector3;
  33486. /**
  33487. * The zz coefficients of the spherical polynomial
  33488. */
  33489. zz: Vector3;
  33490. /**
  33491. * The xy coefficients of the spherical polynomial
  33492. */
  33493. xy: Vector3;
  33494. /**
  33495. * The yz coefficients of the spherical polynomial
  33496. */
  33497. yz: Vector3;
  33498. /**
  33499. * The zx coefficients of the spherical polynomial
  33500. */
  33501. zx: Vector3;
  33502. /**
  33503. * Adds an ambient color to the spherical polynomial
  33504. * @param color the color to add
  33505. */
  33506. addAmbient(color: Color3): void;
  33507. /**
  33508. * Scales the spherical polynomial by the given amount
  33509. * @param scale the amount to scale
  33510. */
  33511. scaleInPlace(scale: number): void;
  33512. /**
  33513. * Gets the spherical polynomial from harmonics
  33514. * @param harmonics the spherical harmonics
  33515. * @returns the spherical polynomial
  33516. */
  33517. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  33518. /**
  33519. * Constructs a spherical polynomial from an array.
  33520. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  33521. * @returns the spherical polynomial
  33522. */
  33523. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  33524. }
  33525. }
  33526. declare module "babylonjs/Materials/Textures/internalTexture" {
  33527. import { Observable } from "babylonjs/Misc/observable";
  33528. import { Nullable, int } from "babylonjs/types";
  33529. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  33530. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  33531. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  33532. /**
  33533. * Defines the source of the internal texture
  33534. */
  33535. export enum InternalTextureSource {
  33536. /**
  33537. * The source of the texture data is unknown
  33538. */
  33539. Unknown = 0,
  33540. /**
  33541. * Texture data comes from an URL
  33542. */
  33543. Url = 1,
  33544. /**
  33545. * Texture data is only used for temporary storage
  33546. */
  33547. Temp = 2,
  33548. /**
  33549. * Texture data comes from raw data (ArrayBuffer)
  33550. */
  33551. Raw = 3,
  33552. /**
  33553. * Texture content is dynamic (video or dynamic texture)
  33554. */
  33555. Dynamic = 4,
  33556. /**
  33557. * Texture content is generated by rendering to it
  33558. */
  33559. RenderTarget = 5,
  33560. /**
  33561. * Texture content is part of a multi render target process
  33562. */
  33563. MultiRenderTarget = 6,
  33564. /**
  33565. * Texture data comes from a cube data file
  33566. */
  33567. Cube = 7,
  33568. /**
  33569. * Texture data comes from a raw cube data
  33570. */
  33571. CubeRaw = 8,
  33572. /**
  33573. * Texture data come from a prefiltered cube data file
  33574. */
  33575. CubePrefiltered = 9,
  33576. /**
  33577. * Texture content is raw 3D data
  33578. */
  33579. Raw3D = 10,
  33580. /**
  33581. * Texture content is raw 2D array data
  33582. */
  33583. Raw2DArray = 11,
  33584. /**
  33585. * Texture content is a depth texture
  33586. */
  33587. Depth = 12,
  33588. /**
  33589. * Texture data comes from a raw cube data encoded with RGBD
  33590. */
  33591. CubeRawRGBD = 13
  33592. }
  33593. /**
  33594. * Class used to store data associated with WebGL texture data for the engine
  33595. * This class should not be used directly
  33596. */
  33597. export class InternalTexture {
  33598. /** @hidden */
  33599. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<import("babylonjs/Maths/sphericalPolynomial").SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  33600. /**
  33601. * Defines if the texture is ready
  33602. */
  33603. isReady: boolean;
  33604. /**
  33605. * Defines if the texture is a cube texture
  33606. */
  33607. isCube: boolean;
  33608. /**
  33609. * Defines if the texture contains 3D data
  33610. */
  33611. is3D: boolean;
  33612. /**
  33613. * Defines if the texture contains 2D array data
  33614. */
  33615. is2DArray: boolean;
  33616. /**
  33617. * Defines if the texture contains multiview data
  33618. */
  33619. isMultiview: boolean;
  33620. /**
  33621. * Gets the URL used to load this texture
  33622. */
  33623. url: string;
  33624. /**
  33625. * Gets the sampling mode of the texture
  33626. */
  33627. samplingMode: number;
  33628. /**
  33629. * Gets a boolean indicating if the texture needs mipmaps generation
  33630. */
  33631. generateMipMaps: boolean;
  33632. /**
  33633. * Gets the number of samples used by the texture (WebGL2+ only)
  33634. */
  33635. samples: number;
  33636. /**
  33637. * Gets the type of the texture (int, float...)
  33638. */
  33639. type: number;
  33640. /**
  33641. * Gets the format of the texture (RGB, RGBA...)
  33642. */
  33643. format: number;
  33644. /**
  33645. * Observable called when the texture is loaded
  33646. */
  33647. onLoadedObservable: Observable<InternalTexture>;
  33648. /**
  33649. * Gets the width of the texture
  33650. */
  33651. width: number;
  33652. /**
  33653. * Gets the height of the texture
  33654. */
  33655. height: number;
  33656. /**
  33657. * Gets the depth of the texture
  33658. */
  33659. depth: number;
  33660. /**
  33661. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  33662. */
  33663. baseWidth: number;
  33664. /**
  33665. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  33666. */
  33667. baseHeight: number;
  33668. /**
  33669. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  33670. */
  33671. baseDepth: number;
  33672. /**
  33673. * Gets a boolean indicating if the texture is inverted on Y axis
  33674. */
  33675. invertY: boolean;
  33676. /** @hidden */
  33677. _invertVScale: boolean;
  33678. /** @hidden */
  33679. _associatedChannel: number;
  33680. /** @hidden */
  33681. _source: InternalTextureSource;
  33682. /** @hidden */
  33683. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  33684. /** @hidden */
  33685. _bufferView: Nullable<ArrayBufferView>;
  33686. /** @hidden */
  33687. _bufferViewArray: Nullable<ArrayBufferView[]>;
  33688. /** @hidden */
  33689. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  33690. /** @hidden */
  33691. _size: number;
  33692. /** @hidden */
  33693. _extension: string;
  33694. /** @hidden */
  33695. _files: Nullable<string[]>;
  33696. /** @hidden */
  33697. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  33698. /** @hidden */
  33699. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  33700. /** @hidden */
  33701. _framebuffer: Nullable<WebGLFramebuffer>;
  33702. /** @hidden */
  33703. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  33704. /** @hidden */
  33705. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  33706. /** @hidden */
  33707. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  33708. /** @hidden */
  33709. _attachments: Nullable<number[]>;
  33710. /** @hidden */
  33711. _cachedCoordinatesMode: Nullable<number>;
  33712. /** @hidden */
  33713. _cachedWrapU: Nullable<number>;
  33714. /** @hidden */
  33715. _cachedWrapV: Nullable<number>;
  33716. /** @hidden */
  33717. _cachedWrapR: Nullable<number>;
  33718. /** @hidden */
  33719. _cachedAnisotropicFilteringLevel: Nullable<number>;
  33720. /** @hidden */
  33721. _isDisabled: boolean;
  33722. /** @hidden */
  33723. _compression: Nullable<string>;
  33724. /** @hidden */
  33725. _generateStencilBuffer: boolean;
  33726. /** @hidden */
  33727. _generateDepthBuffer: boolean;
  33728. /** @hidden */
  33729. _comparisonFunction: number;
  33730. /** @hidden */
  33731. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  33732. /** @hidden */
  33733. _lodGenerationScale: number;
  33734. /** @hidden */
  33735. _lodGenerationOffset: number;
  33736. /** @hidden */
  33737. _depthStencilTexture: Nullable<InternalTexture>;
  33738. /** @hidden */
  33739. _colorTextureArray: Nullable<WebGLTexture>;
  33740. /** @hidden */
  33741. _depthStencilTextureArray: Nullable<WebGLTexture>;
  33742. /** @hidden */
  33743. _lodTextureHigh: Nullable<BaseTexture>;
  33744. /** @hidden */
  33745. _lodTextureMid: Nullable<BaseTexture>;
  33746. /** @hidden */
  33747. _lodTextureLow: Nullable<BaseTexture>;
  33748. /** @hidden */
  33749. _isRGBD: boolean;
  33750. /** @hidden */
  33751. _linearSpecularLOD: boolean;
  33752. /** @hidden */
  33753. _irradianceTexture: Nullable<BaseTexture>;
  33754. /** @hidden */
  33755. _webGLTexture: Nullable<WebGLTexture>;
  33756. /** @hidden */
  33757. _references: number;
  33758. private _engine;
  33759. /**
  33760. * Gets the Engine the texture belongs to.
  33761. * @returns The babylon engine
  33762. */
  33763. getEngine(): ThinEngine;
  33764. /**
  33765. * Gets the data source type of the texture
  33766. */
  33767. get source(): InternalTextureSource;
  33768. /**
  33769. * Creates a new InternalTexture
  33770. * @param engine defines the engine to use
  33771. * @param source defines the type of data that will be used
  33772. * @param delayAllocation if the texture allocation should be delayed (default: false)
  33773. */
  33774. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  33775. /**
  33776. * Increments the number of references (ie. the number of Texture that point to it)
  33777. */
  33778. incrementReferences(): void;
  33779. /**
  33780. * Change the size of the texture (not the size of the content)
  33781. * @param width defines the new width
  33782. * @param height defines the new height
  33783. * @param depth defines the new depth (1 by default)
  33784. */
  33785. updateSize(width: int, height: int, depth?: int): void;
  33786. /** @hidden */
  33787. _rebuild(): void;
  33788. /** @hidden */
  33789. _swapAndDie(target: InternalTexture): void;
  33790. /**
  33791. * Dispose the current allocated resources
  33792. */
  33793. dispose(): void;
  33794. }
  33795. }
  33796. declare module "babylonjs/Audio/analyser" {
  33797. import { Scene } from "babylonjs/scene";
  33798. /**
  33799. * Class used to work with sound analyzer using fast fourier transform (FFT)
  33800. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33801. */
  33802. export class Analyser {
  33803. /**
  33804. * Gets or sets the smoothing
  33805. * @ignorenaming
  33806. */
  33807. SMOOTHING: number;
  33808. /**
  33809. * Gets or sets the FFT table size
  33810. * @ignorenaming
  33811. */
  33812. FFT_SIZE: number;
  33813. /**
  33814. * Gets or sets the bar graph amplitude
  33815. * @ignorenaming
  33816. */
  33817. BARGRAPHAMPLITUDE: number;
  33818. /**
  33819. * Gets or sets the position of the debug canvas
  33820. * @ignorenaming
  33821. */
  33822. DEBUGCANVASPOS: {
  33823. x: number;
  33824. y: number;
  33825. };
  33826. /**
  33827. * Gets or sets the debug canvas size
  33828. * @ignorenaming
  33829. */
  33830. DEBUGCANVASSIZE: {
  33831. width: number;
  33832. height: number;
  33833. };
  33834. private _byteFreqs;
  33835. private _byteTime;
  33836. private _floatFreqs;
  33837. private _webAudioAnalyser;
  33838. private _debugCanvas;
  33839. private _debugCanvasContext;
  33840. private _scene;
  33841. private _registerFunc;
  33842. private _audioEngine;
  33843. /**
  33844. * Creates a new analyser
  33845. * @param scene defines hosting scene
  33846. */
  33847. constructor(scene: Scene);
  33848. /**
  33849. * Get the number of data values you will have to play with for the visualization
  33850. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  33851. * @returns a number
  33852. */
  33853. getFrequencyBinCount(): number;
  33854. /**
  33855. * Gets the current frequency data as a byte array
  33856. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  33857. * @returns a Uint8Array
  33858. */
  33859. getByteFrequencyData(): Uint8Array;
  33860. /**
  33861. * Gets the current waveform as a byte array
  33862. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  33863. * @returns a Uint8Array
  33864. */
  33865. getByteTimeDomainData(): Uint8Array;
  33866. /**
  33867. * Gets the current frequency data as a float array
  33868. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  33869. * @returns a Float32Array
  33870. */
  33871. getFloatFrequencyData(): Float32Array;
  33872. /**
  33873. * Renders the debug canvas
  33874. */
  33875. drawDebugCanvas(): void;
  33876. /**
  33877. * Stops rendering the debug canvas and removes it
  33878. */
  33879. stopDebugCanvas(): void;
  33880. /**
  33881. * Connects two audio nodes
  33882. * @param inputAudioNode defines first node to connect
  33883. * @param outputAudioNode defines second node to connect
  33884. */
  33885. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  33886. /**
  33887. * Releases all associated resources
  33888. */
  33889. dispose(): void;
  33890. }
  33891. }
  33892. declare module "babylonjs/Audio/audioEngine" {
  33893. import { IDisposable } from "babylonjs/scene";
  33894. import { Analyser } from "babylonjs/Audio/analyser";
  33895. import { Nullable } from "babylonjs/types";
  33896. import { Observable } from "babylonjs/Misc/observable";
  33897. /**
  33898. * This represents an audio engine and it is responsible
  33899. * to play, synchronize and analyse sounds throughout the application.
  33900. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33901. */
  33902. export interface IAudioEngine extends IDisposable {
  33903. /**
  33904. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  33905. */
  33906. readonly canUseWebAudio: boolean;
  33907. /**
  33908. * Gets the current AudioContext if available.
  33909. */
  33910. readonly audioContext: Nullable<AudioContext>;
  33911. /**
  33912. * The master gain node defines the global audio volume of your audio engine.
  33913. */
  33914. readonly masterGain: GainNode;
  33915. /**
  33916. * Gets whether or not mp3 are supported by your browser.
  33917. */
  33918. readonly isMP3supported: boolean;
  33919. /**
  33920. * Gets whether or not ogg are supported by your browser.
  33921. */
  33922. readonly isOGGsupported: boolean;
  33923. /**
  33924. * Defines if Babylon should emit a warning if WebAudio is not supported.
  33925. * @ignoreNaming
  33926. */
  33927. WarnedWebAudioUnsupported: boolean;
  33928. /**
  33929. * Defines if the audio engine relies on a custom unlocked button.
  33930. * In this case, the embedded button will not be displayed.
  33931. */
  33932. useCustomUnlockedButton: boolean;
  33933. /**
  33934. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  33935. */
  33936. readonly unlocked: boolean;
  33937. /**
  33938. * Event raised when audio has been unlocked on the browser.
  33939. */
  33940. onAudioUnlockedObservable: Observable<AudioEngine>;
  33941. /**
  33942. * Event raised when audio has been locked on the browser.
  33943. */
  33944. onAudioLockedObservable: Observable<AudioEngine>;
  33945. /**
  33946. * Flags the audio engine in Locked state.
  33947. * This happens due to new browser policies preventing audio to autoplay.
  33948. */
  33949. lock(): void;
  33950. /**
  33951. * Unlocks the audio engine once a user action has been done on the dom.
  33952. * This is helpful to resume play once browser policies have been satisfied.
  33953. */
  33954. unlock(): void;
  33955. /**
  33956. * Gets the global volume sets on the master gain.
  33957. * @returns the global volume if set or -1 otherwise
  33958. */
  33959. getGlobalVolume(): number;
  33960. /**
  33961. * Sets the global volume of your experience (sets on the master gain).
  33962. * @param newVolume Defines the new global volume of the application
  33963. */
  33964. setGlobalVolume(newVolume: number): void;
  33965. /**
  33966. * Connect the audio engine to an audio analyser allowing some amazing
  33967. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  33968. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  33969. * @param analyser The analyser to connect to the engine
  33970. */
  33971. connectToAnalyser(analyser: Analyser): void;
  33972. }
  33973. /**
  33974. * This represents the default audio engine used in babylon.
  33975. * It is responsible to play, synchronize and analyse sounds throughout the application.
  33976. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33977. */
  33978. export class AudioEngine implements IAudioEngine {
  33979. private _audioContext;
  33980. private _audioContextInitialized;
  33981. private _muteButton;
  33982. private _hostElement;
  33983. /**
  33984. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  33985. */
  33986. canUseWebAudio: boolean;
  33987. /**
  33988. * The master gain node defines the global audio volume of your audio engine.
  33989. */
  33990. masterGain: GainNode;
  33991. /**
  33992. * Defines if Babylon should emit a warning if WebAudio is not supported.
  33993. * @ignoreNaming
  33994. */
  33995. WarnedWebAudioUnsupported: boolean;
  33996. /**
  33997. * Gets whether or not mp3 are supported by your browser.
  33998. */
  33999. isMP3supported: boolean;
  34000. /**
  34001. * Gets whether or not ogg are supported by your browser.
  34002. */
  34003. isOGGsupported: boolean;
  34004. /**
  34005. * Gets whether audio has been unlocked on the device.
  34006. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  34007. * a user interaction has happened.
  34008. */
  34009. unlocked: boolean;
  34010. /**
  34011. * Defines if the audio engine relies on a custom unlocked button.
  34012. * In this case, the embedded button will not be displayed.
  34013. */
  34014. useCustomUnlockedButton: boolean;
  34015. /**
  34016. * Event raised when audio has been unlocked on the browser.
  34017. */
  34018. onAudioUnlockedObservable: Observable<AudioEngine>;
  34019. /**
  34020. * Event raised when audio has been locked on the browser.
  34021. */
  34022. onAudioLockedObservable: Observable<AudioEngine>;
  34023. /**
  34024. * Gets the current AudioContext if available.
  34025. */
  34026. get audioContext(): Nullable<AudioContext>;
  34027. private _connectedAnalyser;
  34028. /**
  34029. * Instantiates a new audio engine.
  34030. *
  34031. * There should be only one per page as some browsers restrict the number
  34032. * of audio contexts you can create.
  34033. * @param hostElement defines the host element where to display the mute icon if necessary
  34034. */
  34035. constructor(hostElement?: Nullable<HTMLElement>);
  34036. /**
  34037. * Flags the audio engine in Locked state.
  34038. * This happens due to new browser policies preventing audio to autoplay.
  34039. */
  34040. lock(): void;
  34041. /**
  34042. * Unlocks the audio engine once a user action has been done on the dom.
  34043. * This is helpful to resume play once browser policies have been satisfied.
  34044. */
  34045. unlock(): void;
  34046. private _resumeAudioContext;
  34047. private _initializeAudioContext;
  34048. private _tryToRun;
  34049. private _triggerRunningState;
  34050. private _triggerSuspendedState;
  34051. private _displayMuteButton;
  34052. private _moveButtonToTopLeft;
  34053. private _onResize;
  34054. private _hideMuteButton;
  34055. /**
  34056. * Destroy and release the resources associated with the audio ccontext.
  34057. */
  34058. dispose(): void;
  34059. /**
  34060. * Gets the global volume sets on the master gain.
  34061. * @returns the global volume if set or -1 otherwise
  34062. */
  34063. getGlobalVolume(): number;
  34064. /**
  34065. * Sets the global volume of your experience (sets on the master gain).
  34066. * @param newVolume Defines the new global volume of the application
  34067. */
  34068. setGlobalVolume(newVolume: number): void;
  34069. /**
  34070. * Connect the audio engine to an audio analyser allowing some amazing
  34071. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  34072. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  34073. * @param analyser The analyser to connect to the engine
  34074. */
  34075. connectToAnalyser(analyser: Analyser): void;
  34076. }
  34077. }
  34078. declare module "babylonjs/Loading/loadingScreen" {
  34079. /**
  34080. * Interface used to present a loading screen while loading a scene
  34081. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34082. */
  34083. export interface ILoadingScreen {
  34084. /**
  34085. * Function called to display the loading screen
  34086. */
  34087. displayLoadingUI: () => void;
  34088. /**
  34089. * Function called to hide the loading screen
  34090. */
  34091. hideLoadingUI: () => void;
  34092. /**
  34093. * Gets or sets the color to use for the background
  34094. */
  34095. loadingUIBackgroundColor: string;
  34096. /**
  34097. * Gets or sets the text to display while loading
  34098. */
  34099. loadingUIText: string;
  34100. }
  34101. /**
  34102. * Class used for the default loading screen
  34103. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34104. */
  34105. export class DefaultLoadingScreen implements ILoadingScreen {
  34106. private _renderingCanvas;
  34107. private _loadingText;
  34108. private _loadingDivBackgroundColor;
  34109. private _loadingDiv;
  34110. private _loadingTextDiv;
  34111. /** Gets or sets the logo url to use for the default loading screen */
  34112. static DefaultLogoUrl: string;
  34113. /** Gets or sets the spinner url to use for the default loading screen */
  34114. static DefaultSpinnerUrl: string;
  34115. /**
  34116. * Creates a new default loading screen
  34117. * @param _renderingCanvas defines the canvas used to render the scene
  34118. * @param _loadingText defines the default text to display
  34119. * @param _loadingDivBackgroundColor defines the default background color
  34120. */
  34121. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  34122. /**
  34123. * Function called to display the loading screen
  34124. */
  34125. displayLoadingUI(): void;
  34126. /**
  34127. * Function called to hide the loading screen
  34128. */
  34129. hideLoadingUI(): void;
  34130. /**
  34131. * Gets or sets the text to display while loading
  34132. */
  34133. set loadingUIText(text: string);
  34134. get loadingUIText(): string;
  34135. /**
  34136. * Gets or sets the color to use for the background
  34137. */
  34138. get loadingUIBackgroundColor(): string;
  34139. set loadingUIBackgroundColor(color: string);
  34140. private _resizeLoadingUI;
  34141. }
  34142. }
  34143. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  34144. /**
  34145. * Interface for any object that can request an animation frame
  34146. */
  34147. export interface ICustomAnimationFrameRequester {
  34148. /**
  34149. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  34150. */
  34151. renderFunction?: Function;
  34152. /**
  34153. * Called to request the next frame to render to
  34154. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  34155. */
  34156. requestAnimationFrame: Function;
  34157. /**
  34158. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  34159. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  34160. */
  34161. requestID?: number;
  34162. }
  34163. }
  34164. declare module "babylonjs/Misc/performanceMonitor" {
  34165. /**
  34166. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  34167. */
  34168. export class PerformanceMonitor {
  34169. private _enabled;
  34170. private _rollingFrameTime;
  34171. private _lastFrameTimeMs;
  34172. /**
  34173. * constructor
  34174. * @param frameSampleSize The number of samples required to saturate the sliding window
  34175. */
  34176. constructor(frameSampleSize?: number);
  34177. /**
  34178. * Samples current frame
  34179. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  34180. */
  34181. sampleFrame(timeMs?: number): void;
  34182. /**
  34183. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  34184. */
  34185. get averageFrameTime(): number;
  34186. /**
  34187. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  34188. */
  34189. get averageFrameTimeVariance(): number;
  34190. /**
  34191. * Returns the frame time of the most recent frame
  34192. */
  34193. get instantaneousFrameTime(): number;
  34194. /**
  34195. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  34196. */
  34197. get averageFPS(): number;
  34198. /**
  34199. * Returns the average framerate in frames per second using the most recent frame time
  34200. */
  34201. get instantaneousFPS(): number;
  34202. /**
  34203. * Returns true if enough samples have been taken to completely fill the sliding window
  34204. */
  34205. get isSaturated(): boolean;
  34206. /**
  34207. * Enables contributions to the sliding window sample set
  34208. */
  34209. enable(): void;
  34210. /**
  34211. * Disables contributions to the sliding window sample set
  34212. * Samples will not be interpolated over the disabled period
  34213. */
  34214. disable(): void;
  34215. /**
  34216. * Returns true if sampling is enabled
  34217. */
  34218. get isEnabled(): boolean;
  34219. /**
  34220. * Resets performance monitor
  34221. */
  34222. reset(): void;
  34223. }
  34224. /**
  34225. * RollingAverage
  34226. *
  34227. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  34228. */
  34229. export class RollingAverage {
  34230. /**
  34231. * Current average
  34232. */
  34233. average: number;
  34234. /**
  34235. * Current variance
  34236. */
  34237. variance: number;
  34238. protected _samples: Array<number>;
  34239. protected _sampleCount: number;
  34240. protected _pos: number;
  34241. protected _m2: number;
  34242. /**
  34243. * constructor
  34244. * @param length The number of samples required to saturate the sliding window
  34245. */
  34246. constructor(length: number);
  34247. /**
  34248. * Adds a sample to the sample set
  34249. * @param v The sample value
  34250. */
  34251. add(v: number): void;
  34252. /**
  34253. * Returns previously added values or null if outside of history or outside the sliding window domain
  34254. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  34255. * @return Value previously recorded with add() or null if outside of range
  34256. */
  34257. history(i: number): number;
  34258. /**
  34259. * Returns true if enough samples have been taken to completely fill the sliding window
  34260. * @return true if sample-set saturated
  34261. */
  34262. isSaturated(): boolean;
  34263. /**
  34264. * Resets the rolling average (equivalent to 0 samples taken so far)
  34265. */
  34266. reset(): void;
  34267. /**
  34268. * Wraps a value around the sample range boundaries
  34269. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  34270. * @return Wrapped position in sample range
  34271. */
  34272. protected _wrapPosition(i: number): number;
  34273. }
  34274. }
  34275. declare module "babylonjs/Misc/perfCounter" {
  34276. /**
  34277. * This class is used to track a performance counter which is number based.
  34278. * The user has access to many properties which give statistics of different nature.
  34279. *
  34280. * The implementer can track two kinds of Performance Counter: time and count.
  34281. * 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.
  34282. * 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.
  34283. */
  34284. export class PerfCounter {
  34285. /**
  34286. * Gets or sets a global boolean to turn on and off all the counters
  34287. */
  34288. static Enabled: boolean;
  34289. /**
  34290. * Returns the smallest value ever
  34291. */
  34292. get min(): number;
  34293. /**
  34294. * Returns the biggest value ever
  34295. */
  34296. get max(): number;
  34297. /**
  34298. * Returns the average value since the performance counter is running
  34299. */
  34300. get average(): number;
  34301. /**
  34302. * Returns the average value of the last second the counter was monitored
  34303. */
  34304. get lastSecAverage(): number;
  34305. /**
  34306. * Returns the current value
  34307. */
  34308. get current(): number;
  34309. /**
  34310. * Gets the accumulated total
  34311. */
  34312. get total(): number;
  34313. /**
  34314. * Gets the total value count
  34315. */
  34316. get count(): number;
  34317. /**
  34318. * Creates a new counter
  34319. */
  34320. constructor();
  34321. /**
  34322. * Call this method to start monitoring a new frame.
  34323. * 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.
  34324. */
  34325. fetchNewFrame(): void;
  34326. /**
  34327. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  34328. * @param newCount the count value to add to the monitored count
  34329. * @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.
  34330. */
  34331. addCount(newCount: number, fetchResult: boolean): void;
  34332. /**
  34333. * Start monitoring this performance counter
  34334. */
  34335. beginMonitoring(): void;
  34336. /**
  34337. * Compute the time lapsed since the previous beginMonitoring() call.
  34338. * @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
  34339. */
  34340. endMonitoring(newFrame?: boolean): void;
  34341. private _fetchResult;
  34342. private _startMonitoringTime;
  34343. private _min;
  34344. private _max;
  34345. private _average;
  34346. private _current;
  34347. private _totalValueCount;
  34348. private _totalAccumulated;
  34349. private _lastSecAverage;
  34350. private _lastSecAccumulated;
  34351. private _lastSecTime;
  34352. private _lastSecValueCount;
  34353. }
  34354. }
  34355. declare module "babylonjs/Engines/Extensions/engine.alpha" {
  34356. module "babylonjs/Engines/thinEngine" {
  34357. interface ThinEngine {
  34358. /**
  34359. * Sets alpha constants used by some alpha blending modes
  34360. * @param r defines the red component
  34361. * @param g defines the green component
  34362. * @param b defines the blue component
  34363. * @param a defines the alpha component
  34364. */
  34365. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  34366. /**
  34367. * Sets the current alpha mode
  34368. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  34369. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  34370. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  34371. */
  34372. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  34373. /**
  34374. * Gets the current alpha mode
  34375. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  34376. * @returns the current alpha mode
  34377. */
  34378. getAlphaMode(): number;
  34379. /**
  34380. * Sets the current alpha equation
  34381. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  34382. */
  34383. setAlphaEquation(equation: number): void;
  34384. /**
  34385. * Gets the current alpha equation.
  34386. * @returns the current alpha equation
  34387. */
  34388. getAlphaEquation(): number;
  34389. }
  34390. }
  34391. }
  34392. declare module "babylonjs/Engines/engine" {
  34393. import { Observable } from "babylonjs/Misc/observable";
  34394. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  34395. import { Scene } from "babylonjs/scene";
  34396. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  34397. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  34398. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  34399. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  34400. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  34401. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  34402. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  34403. import { ThinEngine, EngineOptions } from "babylonjs/Engines/thinEngine";
  34404. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  34405. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  34406. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  34407. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  34408. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  34409. import "babylonjs/Engines/Extensions/engine.alpha";
  34410. import { Material } from "babylonjs/Materials/material";
  34411. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  34412. /**
  34413. * Defines the interface used by display changed events
  34414. */
  34415. export interface IDisplayChangedEventArgs {
  34416. /** Gets the vrDisplay object (if any) */
  34417. vrDisplay: Nullable<any>;
  34418. /** Gets a boolean indicating if webVR is supported */
  34419. vrSupported: boolean;
  34420. }
  34421. /**
  34422. * Defines the interface used by objects containing a viewport (like a camera)
  34423. */
  34424. interface IViewportOwnerLike {
  34425. /**
  34426. * Gets or sets the viewport
  34427. */
  34428. viewport: IViewportLike;
  34429. }
  34430. /**
  34431. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  34432. */
  34433. export class Engine extends ThinEngine {
  34434. /** Defines that alpha blending is disabled */
  34435. static readonly ALPHA_DISABLE: number;
  34436. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  34437. static readonly ALPHA_ADD: number;
  34438. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  34439. static readonly ALPHA_COMBINE: number;
  34440. /** Defines that alpha blending to DEST - SRC * DEST */
  34441. static readonly ALPHA_SUBTRACT: number;
  34442. /** Defines that alpha blending to SRC * DEST */
  34443. static readonly ALPHA_MULTIPLY: number;
  34444. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  34445. static readonly ALPHA_MAXIMIZED: number;
  34446. /** Defines that alpha blending to SRC + DEST */
  34447. static readonly ALPHA_ONEONE: number;
  34448. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  34449. static readonly ALPHA_PREMULTIPLIED: number;
  34450. /**
  34451. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  34452. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  34453. */
  34454. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  34455. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  34456. static readonly ALPHA_INTERPOLATE: number;
  34457. /**
  34458. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  34459. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  34460. */
  34461. static readonly ALPHA_SCREENMODE: number;
  34462. /** Defines that the ressource is not delayed*/
  34463. static readonly DELAYLOADSTATE_NONE: number;
  34464. /** Defines that the ressource was successfully delay loaded */
  34465. static readonly DELAYLOADSTATE_LOADED: number;
  34466. /** Defines that the ressource is currently delay loading */
  34467. static readonly DELAYLOADSTATE_LOADING: number;
  34468. /** Defines that the ressource is delayed and has not started loading */
  34469. static readonly DELAYLOADSTATE_NOTLOADED: number;
  34470. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  34471. static readonly NEVER: number;
  34472. /** 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 */
  34473. static readonly ALWAYS: number;
  34474. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  34475. static readonly LESS: number;
  34476. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  34477. static readonly EQUAL: number;
  34478. /** 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 */
  34479. static readonly LEQUAL: number;
  34480. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  34481. static readonly GREATER: number;
  34482. /** 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 */
  34483. static readonly GEQUAL: number;
  34484. /** 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 */
  34485. static readonly NOTEQUAL: number;
  34486. /** Passed to stencilOperation to specify that stencil value must be kept */
  34487. static readonly KEEP: number;
  34488. /** Passed to stencilOperation to specify that stencil value must be replaced */
  34489. static readonly REPLACE: number;
  34490. /** Passed to stencilOperation to specify that stencil value must be incremented */
  34491. static readonly INCR: number;
  34492. /** Passed to stencilOperation to specify that stencil value must be decremented */
  34493. static readonly DECR: number;
  34494. /** Passed to stencilOperation to specify that stencil value must be inverted */
  34495. static readonly INVERT: number;
  34496. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  34497. static readonly INCR_WRAP: number;
  34498. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  34499. static readonly DECR_WRAP: number;
  34500. /** Texture is not repeating outside of 0..1 UVs */
  34501. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  34502. /** Texture is repeating outside of 0..1 UVs */
  34503. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  34504. /** Texture is repeating and mirrored */
  34505. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  34506. /** ALPHA */
  34507. static readonly TEXTUREFORMAT_ALPHA: number;
  34508. /** LUMINANCE */
  34509. static readonly TEXTUREFORMAT_LUMINANCE: number;
  34510. /** LUMINANCE_ALPHA */
  34511. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  34512. /** RGB */
  34513. static readonly TEXTUREFORMAT_RGB: number;
  34514. /** RGBA */
  34515. static readonly TEXTUREFORMAT_RGBA: number;
  34516. /** RED */
  34517. static readonly TEXTUREFORMAT_RED: number;
  34518. /** RED (2nd reference) */
  34519. static readonly TEXTUREFORMAT_R: number;
  34520. /** RG */
  34521. static readonly TEXTUREFORMAT_RG: number;
  34522. /** RED_INTEGER */
  34523. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  34524. /** RED_INTEGER (2nd reference) */
  34525. static readonly TEXTUREFORMAT_R_INTEGER: number;
  34526. /** RG_INTEGER */
  34527. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  34528. /** RGB_INTEGER */
  34529. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  34530. /** RGBA_INTEGER */
  34531. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  34532. /** UNSIGNED_BYTE */
  34533. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  34534. /** UNSIGNED_BYTE (2nd reference) */
  34535. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  34536. /** FLOAT */
  34537. static readonly TEXTURETYPE_FLOAT: number;
  34538. /** HALF_FLOAT */
  34539. static readonly TEXTURETYPE_HALF_FLOAT: number;
  34540. /** BYTE */
  34541. static readonly TEXTURETYPE_BYTE: number;
  34542. /** SHORT */
  34543. static readonly TEXTURETYPE_SHORT: number;
  34544. /** UNSIGNED_SHORT */
  34545. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  34546. /** INT */
  34547. static readonly TEXTURETYPE_INT: number;
  34548. /** UNSIGNED_INT */
  34549. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  34550. /** UNSIGNED_SHORT_4_4_4_4 */
  34551. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  34552. /** UNSIGNED_SHORT_5_5_5_1 */
  34553. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  34554. /** UNSIGNED_SHORT_5_6_5 */
  34555. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  34556. /** UNSIGNED_INT_2_10_10_10_REV */
  34557. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  34558. /** UNSIGNED_INT_24_8 */
  34559. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  34560. /** UNSIGNED_INT_10F_11F_11F_REV */
  34561. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  34562. /** UNSIGNED_INT_5_9_9_9_REV */
  34563. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  34564. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  34565. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  34566. /** nearest is mag = nearest and min = nearest and mip = linear */
  34567. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  34568. /** Bilinear is mag = linear and min = linear and mip = nearest */
  34569. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  34570. /** Trilinear is mag = linear and min = linear and mip = linear */
  34571. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  34572. /** nearest is mag = nearest and min = nearest and mip = linear */
  34573. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  34574. /** Bilinear is mag = linear and min = linear and mip = nearest */
  34575. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  34576. /** Trilinear is mag = linear and min = linear and mip = linear */
  34577. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  34578. /** mag = nearest and min = nearest and mip = nearest */
  34579. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  34580. /** mag = nearest and min = linear and mip = nearest */
  34581. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  34582. /** mag = nearest and min = linear and mip = linear */
  34583. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  34584. /** mag = nearest and min = linear and mip = none */
  34585. static readonly TEXTURE_NEAREST_LINEAR: number;
  34586. /** mag = nearest and min = nearest and mip = none */
  34587. static readonly TEXTURE_NEAREST_NEAREST: number;
  34588. /** mag = linear and min = nearest and mip = nearest */
  34589. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  34590. /** mag = linear and min = nearest and mip = linear */
  34591. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  34592. /** mag = linear and min = linear and mip = none */
  34593. static readonly TEXTURE_LINEAR_LINEAR: number;
  34594. /** mag = linear and min = nearest and mip = none */
  34595. static readonly TEXTURE_LINEAR_NEAREST: number;
  34596. /** Explicit coordinates mode */
  34597. static readonly TEXTURE_EXPLICIT_MODE: number;
  34598. /** Spherical coordinates mode */
  34599. static readonly TEXTURE_SPHERICAL_MODE: number;
  34600. /** Planar coordinates mode */
  34601. static readonly TEXTURE_PLANAR_MODE: number;
  34602. /** Cubic coordinates mode */
  34603. static readonly TEXTURE_CUBIC_MODE: number;
  34604. /** Projection coordinates mode */
  34605. static readonly TEXTURE_PROJECTION_MODE: number;
  34606. /** Skybox coordinates mode */
  34607. static readonly TEXTURE_SKYBOX_MODE: number;
  34608. /** Inverse Cubic coordinates mode */
  34609. static readonly TEXTURE_INVCUBIC_MODE: number;
  34610. /** Equirectangular coordinates mode */
  34611. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  34612. /** Equirectangular Fixed coordinates mode */
  34613. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  34614. /** Equirectangular Fixed Mirrored coordinates mode */
  34615. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  34616. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  34617. static readonly SCALEMODE_FLOOR: number;
  34618. /** Defines that texture rescaling will look for the nearest power of 2 size */
  34619. static readonly SCALEMODE_NEAREST: number;
  34620. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  34621. static readonly SCALEMODE_CEILING: number;
  34622. /**
  34623. * Returns the current npm package of the sdk
  34624. */
  34625. static get NpmPackage(): string;
  34626. /**
  34627. * Returns the current version of the framework
  34628. */
  34629. static get Version(): string;
  34630. /** Gets the list of created engines */
  34631. static get Instances(): Engine[];
  34632. /**
  34633. * Gets the latest created engine
  34634. */
  34635. static get LastCreatedEngine(): Nullable<Engine>;
  34636. /**
  34637. * Gets the latest created scene
  34638. */
  34639. static get LastCreatedScene(): Nullable<Scene>;
  34640. /**
  34641. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  34642. * @param flag defines which part of the materials must be marked as dirty
  34643. * @param predicate defines a predicate used to filter which materials should be affected
  34644. */
  34645. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  34646. /**
  34647. * Method called to create the default loading screen.
  34648. * This can be overriden in your own app.
  34649. * @param canvas The rendering canvas element
  34650. * @returns The loading screen
  34651. */
  34652. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  34653. /**
  34654. * Method called to create the default rescale post process on each engine.
  34655. */
  34656. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  34657. /**
  34658. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  34659. **/
  34660. enableOfflineSupport: boolean;
  34661. /**
  34662. * 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)
  34663. **/
  34664. disableManifestCheck: boolean;
  34665. /**
  34666. * Gets the list of created scenes
  34667. */
  34668. scenes: Scene[];
  34669. /**
  34670. * Event raised when a new scene is created
  34671. */
  34672. onNewSceneAddedObservable: Observable<Scene>;
  34673. /**
  34674. * Gets the list of created postprocesses
  34675. */
  34676. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  34677. /**
  34678. * Gets a boolean indicating if the pointer is currently locked
  34679. */
  34680. isPointerLock: boolean;
  34681. /**
  34682. * Observable event triggered each time the rendering canvas is resized
  34683. */
  34684. onResizeObservable: Observable<Engine>;
  34685. /**
  34686. * Observable event triggered each time the canvas loses focus
  34687. */
  34688. onCanvasBlurObservable: Observable<Engine>;
  34689. /**
  34690. * Observable event triggered each time the canvas gains focus
  34691. */
  34692. onCanvasFocusObservable: Observable<Engine>;
  34693. /**
  34694. * Observable event triggered each time the canvas receives pointerout event
  34695. */
  34696. onCanvasPointerOutObservable: Observable<PointerEvent>;
  34697. /**
  34698. * Observable raised when the engine begins a new frame
  34699. */
  34700. onBeginFrameObservable: Observable<Engine>;
  34701. /**
  34702. * If set, will be used to request the next animation frame for the render loop
  34703. */
  34704. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  34705. /**
  34706. * Observable raised when the engine ends the current frame
  34707. */
  34708. onEndFrameObservable: Observable<Engine>;
  34709. /**
  34710. * Observable raised when the engine is about to compile a shader
  34711. */
  34712. onBeforeShaderCompilationObservable: Observable<Engine>;
  34713. /**
  34714. * Observable raised when the engine has jsut compiled a shader
  34715. */
  34716. onAfterShaderCompilationObservable: Observable<Engine>;
  34717. /**
  34718. * Gets the audio engine
  34719. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34720. * @ignorenaming
  34721. */
  34722. static audioEngine: IAudioEngine;
  34723. /**
  34724. * Default AudioEngine factory responsible of creating the Audio Engine.
  34725. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  34726. */
  34727. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  34728. /**
  34729. * Default offline support factory responsible of creating a tool used to store data locally.
  34730. * By default, this will create a Database object if the workload has been embedded.
  34731. */
  34732. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  34733. private _loadingScreen;
  34734. private _pointerLockRequested;
  34735. private _dummyFramebuffer;
  34736. private _rescalePostProcess;
  34737. private _deterministicLockstep;
  34738. private _lockstepMaxSteps;
  34739. private _timeStep;
  34740. protected get _supportsHardwareTextureRescaling(): boolean;
  34741. private _fps;
  34742. private _deltaTime;
  34743. /** @hidden */
  34744. _drawCalls: PerfCounter;
  34745. /** 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 */
  34746. canvasTabIndex: number;
  34747. /**
  34748. * Turn this value on if you want to pause FPS computation when in background
  34749. */
  34750. disablePerformanceMonitorInBackground: boolean;
  34751. private _performanceMonitor;
  34752. /**
  34753. * Gets the performance monitor attached to this engine
  34754. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  34755. */
  34756. get performanceMonitor(): PerformanceMonitor;
  34757. private _onFocus;
  34758. private _onBlur;
  34759. private _onCanvasPointerOut;
  34760. private _onCanvasBlur;
  34761. private _onCanvasFocus;
  34762. private _onFullscreenChange;
  34763. private _onPointerLockChange;
  34764. /**
  34765. * Gets the HTML element used to attach event listeners
  34766. * @returns a HTML element
  34767. */
  34768. getInputElement(): Nullable<HTMLElement>;
  34769. /**
  34770. * Creates a new engine
  34771. * @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
  34772. * @param antialias defines enable antialiasing (default: false)
  34773. * @param options defines further options to be sent to the getContext() function
  34774. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  34775. */
  34776. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  34777. /**
  34778. * Gets current aspect ratio
  34779. * @param viewportOwner defines the camera to use to get the aspect ratio
  34780. * @param useScreen defines if screen size must be used (or the current render target if any)
  34781. * @returns a number defining the aspect ratio
  34782. */
  34783. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  34784. /**
  34785. * Gets current screen aspect ratio
  34786. * @returns a number defining the aspect ratio
  34787. */
  34788. getScreenAspectRatio(): number;
  34789. /**
  34790. * Gets the client rect of the HTML canvas attached with the current webGL context
  34791. * @returns a client rectanglee
  34792. */
  34793. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  34794. /**
  34795. * Gets the client rect of the HTML element used for events
  34796. * @returns a client rectanglee
  34797. */
  34798. getInputElementClientRect(): Nullable<ClientRect>;
  34799. /**
  34800. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  34801. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34802. * @returns true if engine is in deterministic lock step mode
  34803. */
  34804. isDeterministicLockStep(): boolean;
  34805. /**
  34806. * Gets the max steps when engine is running in deterministic lock step
  34807. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34808. * @returns the max steps
  34809. */
  34810. getLockstepMaxSteps(): number;
  34811. /**
  34812. * Returns the time in ms between steps when using deterministic lock step.
  34813. * @returns time step in (ms)
  34814. */
  34815. getTimeStep(): number;
  34816. /**
  34817. * Force the mipmap generation for the given render target texture
  34818. * @param texture defines the render target texture to use
  34819. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  34820. */
  34821. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  34822. /** States */
  34823. /**
  34824. * Set various states to the webGL context
  34825. * @param culling defines backface culling state
  34826. * @param zOffset defines the value to apply to zOffset (0 by default)
  34827. * @param force defines if states must be applied even if cache is up to date
  34828. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  34829. */
  34830. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  34831. /**
  34832. * Set the z offset to apply to current rendering
  34833. * @param value defines the offset to apply
  34834. */
  34835. setZOffset(value: number): void;
  34836. /**
  34837. * Gets the current value of the zOffset
  34838. * @returns the current zOffset state
  34839. */
  34840. getZOffset(): number;
  34841. /**
  34842. * Enable or disable depth buffering
  34843. * @param enable defines the state to set
  34844. */
  34845. setDepthBuffer(enable: boolean): void;
  34846. /**
  34847. * Gets a boolean indicating if depth writing is enabled
  34848. * @returns the current depth writing state
  34849. */
  34850. getDepthWrite(): boolean;
  34851. /**
  34852. * Enable or disable depth writing
  34853. * @param enable defines the state to set
  34854. */
  34855. setDepthWrite(enable: boolean): void;
  34856. /**
  34857. * Gets a boolean indicating if stencil buffer is enabled
  34858. * @returns the current stencil buffer state
  34859. */
  34860. getStencilBuffer(): boolean;
  34861. /**
  34862. * Enable or disable the stencil buffer
  34863. * @param enable defines if the stencil buffer must be enabled or disabled
  34864. */
  34865. setStencilBuffer(enable: boolean): void;
  34866. /**
  34867. * Gets the current stencil mask
  34868. * @returns a number defining the new stencil mask to use
  34869. */
  34870. getStencilMask(): number;
  34871. /**
  34872. * Sets the current stencil mask
  34873. * @param mask defines the new stencil mask to use
  34874. */
  34875. setStencilMask(mask: number): void;
  34876. /**
  34877. * Gets the current stencil function
  34878. * @returns a number defining the stencil function to use
  34879. */
  34880. getStencilFunction(): number;
  34881. /**
  34882. * Gets the current stencil reference value
  34883. * @returns a number defining the stencil reference value to use
  34884. */
  34885. getStencilFunctionReference(): number;
  34886. /**
  34887. * Gets the current stencil mask
  34888. * @returns a number defining the stencil mask to use
  34889. */
  34890. getStencilFunctionMask(): number;
  34891. /**
  34892. * Sets the current stencil function
  34893. * @param stencilFunc defines the new stencil function to use
  34894. */
  34895. setStencilFunction(stencilFunc: number): void;
  34896. /**
  34897. * Sets the current stencil reference
  34898. * @param reference defines the new stencil reference to use
  34899. */
  34900. setStencilFunctionReference(reference: number): void;
  34901. /**
  34902. * Sets the current stencil mask
  34903. * @param mask defines the new stencil mask to use
  34904. */
  34905. setStencilFunctionMask(mask: number): void;
  34906. /**
  34907. * Gets the current stencil operation when stencil fails
  34908. * @returns a number defining stencil operation to use when stencil fails
  34909. */
  34910. getStencilOperationFail(): number;
  34911. /**
  34912. * Gets the current stencil operation when depth fails
  34913. * @returns a number defining stencil operation to use when depth fails
  34914. */
  34915. getStencilOperationDepthFail(): number;
  34916. /**
  34917. * Gets the current stencil operation when stencil passes
  34918. * @returns a number defining stencil operation to use when stencil passes
  34919. */
  34920. getStencilOperationPass(): number;
  34921. /**
  34922. * Sets the stencil operation to use when stencil fails
  34923. * @param operation defines the stencil operation to use when stencil fails
  34924. */
  34925. setStencilOperationFail(operation: number): void;
  34926. /**
  34927. * Sets the stencil operation to use when depth fails
  34928. * @param operation defines the stencil operation to use when depth fails
  34929. */
  34930. setStencilOperationDepthFail(operation: number): void;
  34931. /**
  34932. * Sets the stencil operation to use when stencil passes
  34933. * @param operation defines the stencil operation to use when stencil passes
  34934. */
  34935. setStencilOperationPass(operation: number): void;
  34936. /**
  34937. * Sets a boolean indicating if the dithering state is enabled or disabled
  34938. * @param value defines the dithering state
  34939. */
  34940. setDitheringState(value: boolean): void;
  34941. /**
  34942. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  34943. * @param value defines the rasterizer state
  34944. */
  34945. setRasterizerState(value: boolean): void;
  34946. /**
  34947. * Gets the current depth function
  34948. * @returns a number defining the depth function
  34949. */
  34950. getDepthFunction(): Nullable<number>;
  34951. /**
  34952. * Sets the current depth function
  34953. * @param depthFunc defines the function to use
  34954. */
  34955. setDepthFunction(depthFunc: number): void;
  34956. /**
  34957. * Sets the current depth function to GREATER
  34958. */
  34959. setDepthFunctionToGreater(): void;
  34960. /**
  34961. * Sets the current depth function to GEQUAL
  34962. */
  34963. setDepthFunctionToGreaterOrEqual(): void;
  34964. /**
  34965. * Sets the current depth function to LESS
  34966. */
  34967. setDepthFunctionToLess(): void;
  34968. /**
  34969. * Sets the current depth function to LEQUAL
  34970. */
  34971. setDepthFunctionToLessOrEqual(): void;
  34972. private _cachedStencilBuffer;
  34973. private _cachedStencilFunction;
  34974. private _cachedStencilMask;
  34975. private _cachedStencilOperationPass;
  34976. private _cachedStencilOperationFail;
  34977. private _cachedStencilOperationDepthFail;
  34978. private _cachedStencilReference;
  34979. /**
  34980. * Caches the the state of the stencil buffer
  34981. */
  34982. cacheStencilState(): void;
  34983. /**
  34984. * Restores the state of the stencil buffer
  34985. */
  34986. restoreStencilState(): void;
  34987. /**
  34988. * Directly set the WebGL Viewport
  34989. * @param x defines the x coordinate of the viewport (in screen space)
  34990. * @param y defines the y coordinate of the viewport (in screen space)
  34991. * @param width defines the width of the viewport (in screen space)
  34992. * @param height defines the height of the viewport (in screen space)
  34993. * @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
  34994. */
  34995. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  34996. /**
  34997. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  34998. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  34999. * @param y defines the y-coordinate of the corner of the clear rectangle
  35000. * @param width defines the width of the clear rectangle
  35001. * @param height defines the height of the clear rectangle
  35002. * @param clearColor defines the clear color
  35003. */
  35004. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  35005. /**
  35006. * Enable scissor test on a specific rectangle (ie. render will only be executed 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. */
  35012. enableScissor(x: number, y: number, width: number, height: number): void;
  35013. /**
  35014. * Disable previously set scissor test rectangle
  35015. */
  35016. disableScissor(): void;
  35017. protected _reportDrawCall(): void;
  35018. /**
  35019. * Initializes a webVR display and starts listening to display change events
  35020. * The onVRDisplayChangedObservable will be notified upon these changes
  35021. * @returns The onVRDisplayChangedObservable
  35022. */
  35023. initWebVR(): Observable<IDisplayChangedEventArgs>;
  35024. /** @hidden */
  35025. _prepareVRComponent(): void;
  35026. /** @hidden */
  35027. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  35028. /** @hidden */
  35029. _submitVRFrame(): void;
  35030. /**
  35031. * Call this function to leave webVR mode
  35032. * Will do nothing if webVR is not supported or if there is no webVR device
  35033. * @see http://doc.babylonjs.com/how_to/webvr_camera
  35034. */
  35035. disableVR(): void;
  35036. /**
  35037. * Gets a boolean indicating that the system is in VR mode and is presenting
  35038. * @returns true if VR mode is engaged
  35039. */
  35040. isVRPresenting(): boolean;
  35041. /** @hidden */
  35042. _requestVRFrame(): void;
  35043. /** @hidden */
  35044. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  35045. /**
  35046. * Gets the source code of the vertex shader associated with a specific webGL program
  35047. * @param program defines the program to use
  35048. * @returns a string containing the source code of the vertex shader associated with the program
  35049. */
  35050. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  35051. /**
  35052. * Gets the source code of the fragment shader associated with a specific webGL program
  35053. * @param program defines the program to use
  35054. * @returns a string containing the source code of the fragment shader associated with the program
  35055. */
  35056. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  35057. /**
  35058. * Sets a depth stencil texture from a render target to the according uniform.
  35059. * @param channel The texture channel
  35060. * @param uniform The uniform to set
  35061. * @param texture The render target texture containing the depth stencil texture to apply
  35062. */
  35063. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  35064. /**
  35065. * Sets a texture to the webGL context from a postprocess
  35066. * @param channel defines the channel to use
  35067. * @param postProcess defines the source postprocess
  35068. */
  35069. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  35070. /**
  35071. * Binds the output of the passed in post process to the texture channel specified
  35072. * @param channel The channel the texture should be bound to
  35073. * @param postProcess The post process which's output should be bound
  35074. */
  35075. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  35076. /** @hidden */
  35077. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  35078. protected _rebuildBuffers(): void;
  35079. /** @hidden */
  35080. _renderFrame(): void;
  35081. _renderLoop(): void;
  35082. /** @hidden */
  35083. _renderViews(): boolean;
  35084. /**
  35085. * Toggle full screen mode
  35086. * @param requestPointerLock defines if a pointer lock should be requested from the user
  35087. */
  35088. switchFullscreen(requestPointerLock: boolean): void;
  35089. /**
  35090. * Enters full screen mode
  35091. * @param requestPointerLock defines if a pointer lock should be requested from the user
  35092. */
  35093. enterFullscreen(requestPointerLock: boolean): void;
  35094. /**
  35095. * Exits full screen mode
  35096. */
  35097. exitFullscreen(): void;
  35098. /**
  35099. * Enters Pointerlock mode
  35100. */
  35101. enterPointerlock(): void;
  35102. /**
  35103. * Exits Pointerlock mode
  35104. */
  35105. exitPointerlock(): void;
  35106. /**
  35107. * Begin a new frame
  35108. */
  35109. beginFrame(): void;
  35110. /**
  35111. * Enf the current frame
  35112. */
  35113. endFrame(): void;
  35114. resize(): void;
  35115. /**
  35116. * Force a specific size of the canvas
  35117. * @param width defines the new canvas' width
  35118. * @param height defines the new canvas' height
  35119. */
  35120. setSize(width: number, height: number): void;
  35121. /**
  35122. * Updates a dynamic vertex buffer.
  35123. * @param vertexBuffer the vertex buffer to update
  35124. * @param data the data used to update the vertex buffer
  35125. * @param byteOffset the byte offset of the data
  35126. * @param byteLength the byte length of the data
  35127. */
  35128. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  35129. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  35130. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  35131. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  35132. _releaseTexture(texture: InternalTexture): void;
  35133. /**
  35134. * @hidden
  35135. * Rescales a texture
  35136. * @param source input texutre
  35137. * @param destination destination texture
  35138. * @param scene scene to use to render the resize
  35139. * @param internalFormat format to use when resizing
  35140. * @param onComplete callback to be called when resize has completed
  35141. */
  35142. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  35143. /**
  35144. * Gets the current framerate
  35145. * @returns a number representing the framerate
  35146. */
  35147. getFps(): number;
  35148. /**
  35149. * Gets the time spent between current and previous frame
  35150. * @returns a number representing the delta time in ms
  35151. */
  35152. getDeltaTime(): number;
  35153. private _measureFps;
  35154. /** @hidden */
  35155. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  35156. /**
  35157. * Update a dynamic index buffer
  35158. * @param indexBuffer defines the target index buffer
  35159. * @param indices defines the data to update
  35160. * @param offset defines the offset in the target index buffer where update should start
  35161. */
  35162. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  35163. /**
  35164. * Updates the sample count of a render target texture
  35165. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  35166. * @param texture defines the texture to update
  35167. * @param samples defines the sample count to set
  35168. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  35169. */
  35170. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  35171. /**
  35172. * Updates a depth texture Comparison Mode and Function.
  35173. * If the comparison Function is equal to 0, the mode will be set to none.
  35174. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  35175. * @param texture The texture to set the comparison function for
  35176. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  35177. */
  35178. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  35179. /**
  35180. * Creates a webGL buffer to use with instanciation
  35181. * @param capacity defines the size of the buffer
  35182. * @returns the webGL buffer
  35183. */
  35184. createInstancesBuffer(capacity: number): DataBuffer;
  35185. /**
  35186. * Delete a webGL buffer used with instanciation
  35187. * @param buffer defines the webGL buffer to delete
  35188. */
  35189. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  35190. private _clientWaitAsync;
  35191. /** @hidden */
  35192. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  35193. /** @hidden */
  35194. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  35195. dispose(): void;
  35196. private _disableTouchAction;
  35197. /**
  35198. * Display the loading screen
  35199. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  35200. */
  35201. displayLoadingUI(): void;
  35202. /**
  35203. * Hide the loading screen
  35204. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  35205. */
  35206. hideLoadingUI(): void;
  35207. /**
  35208. * Gets the current loading screen object
  35209. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  35210. */
  35211. get loadingScreen(): ILoadingScreen;
  35212. /**
  35213. * Sets the current loading screen object
  35214. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  35215. */
  35216. set loadingScreen(loadingScreen: ILoadingScreen);
  35217. /**
  35218. * Sets the current loading screen text
  35219. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  35220. */
  35221. set loadingUIText(text: string);
  35222. /**
  35223. * Sets the current loading screen background color
  35224. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  35225. */
  35226. set loadingUIBackgroundColor(color: string);
  35227. /** Pointerlock and fullscreen */
  35228. /**
  35229. * Ask the browser to promote the current element to pointerlock mode
  35230. * @param element defines the DOM element to promote
  35231. */
  35232. static _RequestPointerlock(element: HTMLElement): void;
  35233. /**
  35234. * Asks the browser to exit pointerlock mode
  35235. */
  35236. static _ExitPointerlock(): void;
  35237. /**
  35238. * Ask the browser to promote the current element to fullscreen rendering mode
  35239. * @param element defines the DOM element to promote
  35240. */
  35241. static _RequestFullscreen(element: HTMLElement): void;
  35242. /**
  35243. * Asks the browser to exit fullscreen mode
  35244. */
  35245. static _ExitFullscreen(): void;
  35246. }
  35247. }
  35248. declare module "babylonjs/Engines/engineStore" {
  35249. import { Nullable } from "babylonjs/types";
  35250. import { Engine } from "babylonjs/Engines/engine";
  35251. import { Scene } from "babylonjs/scene";
  35252. /**
  35253. * The engine store class is responsible to hold all the instances of Engine and Scene created
  35254. * during the life time of the application.
  35255. */
  35256. export class EngineStore {
  35257. /** Gets the list of created engines */
  35258. static Instances: import("babylonjs/Engines/engine").Engine[];
  35259. /** @hidden */
  35260. static _LastCreatedScene: Nullable<Scene>;
  35261. /**
  35262. * Gets the latest created engine
  35263. */
  35264. static get LastCreatedEngine(): Nullable<Engine>;
  35265. /**
  35266. * Gets the latest created scene
  35267. */
  35268. static get LastCreatedScene(): Nullable<Scene>;
  35269. /**
  35270. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  35271. * @ignorenaming
  35272. */
  35273. static UseFallbackTexture: boolean;
  35274. /**
  35275. * Texture content used if a texture cannot loaded
  35276. * @ignorenaming
  35277. */
  35278. static FallbackTexture: string;
  35279. }
  35280. }
  35281. declare module "babylonjs/Misc/promise" {
  35282. /**
  35283. * Helper class that provides a small promise polyfill
  35284. */
  35285. export class PromisePolyfill {
  35286. /**
  35287. * Static function used to check if the polyfill is required
  35288. * If this is the case then the function will inject the polyfill to window.Promise
  35289. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  35290. */
  35291. static Apply(force?: boolean): void;
  35292. }
  35293. }
  35294. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  35295. /**
  35296. * Interface for screenshot methods with describe argument called `size` as object with options
  35297. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  35298. */
  35299. export interface IScreenshotSize {
  35300. /**
  35301. * number in pixels for canvas height
  35302. */
  35303. height?: number;
  35304. /**
  35305. * multiplier allowing render at a higher or lower resolution
  35306. * If value is defined then height and width will be ignored and taken from camera
  35307. */
  35308. precision?: number;
  35309. /**
  35310. * number in pixels for canvas width
  35311. */
  35312. width?: number;
  35313. }
  35314. }
  35315. declare module "babylonjs/Misc/tools" {
  35316. import { Nullable, float } from "babylonjs/types";
  35317. import { DomManagement } from "babylonjs/Misc/domManagement";
  35318. import { WebRequest } from "babylonjs/Misc/webRequest";
  35319. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  35320. import { ReadFileError } from "babylonjs/Misc/fileTools";
  35321. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  35322. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  35323. import { Camera } from "babylonjs/Cameras/camera";
  35324. import { Engine } from "babylonjs/Engines/engine";
  35325. interface IColor4Like {
  35326. r: float;
  35327. g: float;
  35328. b: float;
  35329. a: float;
  35330. }
  35331. /**
  35332. * Class containing a set of static utilities functions
  35333. */
  35334. export class Tools {
  35335. /**
  35336. * Gets or sets the base URL to use to load assets
  35337. */
  35338. static get BaseUrl(): string;
  35339. static set BaseUrl(value: string);
  35340. /**
  35341. * Enable/Disable Custom HTTP Request Headers globally.
  35342. * default = false
  35343. * @see CustomRequestHeaders
  35344. */
  35345. static UseCustomRequestHeaders: boolean;
  35346. /**
  35347. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  35348. * i.e. when loading files, where the server/service expects an Authorization header
  35349. */
  35350. static CustomRequestHeaders: {
  35351. [key: string]: string;
  35352. };
  35353. /**
  35354. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  35355. */
  35356. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  35357. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  35358. /**
  35359. * Default behaviour for cors in the application.
  35360. * It can be a string if the expected behavior is identical in the entire app.
  35361. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  35362. */
  35363. static get CorsBehavior(): string | ((url: string | string[]) => string);
  35364. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  35365. /**
  35366. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  35367. * @ignorenaming
  35368. */
  35369. static get UseFallbackTexture(): boolean;
  35370. static set UseFallbackTexture(value: boolean);
  35371. /**
  35372. * Use this object to register external classes like custom textures or material
  35373. * to allow the laoders to instantiate them
  35374. */
  35375. static get RegisteredExternalClasses(): {
  35376. [key: string]: Object;
  35377. };
  35378. static set RegisteredExternalClasses(classes: {
  35379. [key: string]: Object;
  35380. });
  35381. /**
  35382. * Texture content used if a texture cannot loaded
  35383. * @ignorenaming
  35384. */
  35385. static get fallbackTexture(): string;
  35386. static set fallbackTexture(value: string);
  35387. /**
  35388. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  35389. * @param u defines the coordinate on X axis
  35390. * @param v defines the coordinate on Y axis
  35391. * @param width defines the width of the source data
  35392. * @param height defines the height of the source data
  35393. * @param pixels defines the source byte array
  35394. * @param color defines the output color
  35395. */
  35396. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  35397. /**
  35398. * Interpolates between a and b via alpha
  35399. * @param a The lower value (returned when alpha = 0)
  35400. * @param b The upper value (returned when alpha = 1)
  35401. * @param alpha The interpolation-factor
  35402. * @return The mixed value
  35403. */
  35404. static Mix(a: number, b: number, alpha: number): number;
  35405. /**
  35406. * Tries to instantiate a new object from a given class name
  35407. * @param className defines the class name to instantiate
  35408. * @returns the new object or null if the system was not able to do the instantiation
  35409. */
  35410. static Instantiate(className: string): any;
  35411. /**
  35412. * Provides a slice function that will work even on IE
  35413. * @param data defines the array to slice
  35414. * @param start defines the start of the data (optional)
  35415. * @param end defines the end of the data (optional)
  35416. * @returns the new sliced array
  35417. */
  35418. static Slice<T>(data: T, start?: number, end?: number): T;
  35419. /**
  35420. * Polyfill for setImmediate
  35421. * @param action defines the action to execute after the current execution block
  35422. */
  35423. static SetImmediate(action: () => void): void;
  35424. /**
  35425. * Function indicating if a number is an exponent of 2
  35426. * @param value defines the value to test
  35427. * @returns true if the value is an exponent of 2
  35428. */
  35429. static IsExponentOfTwo(value: number): boolean;
  35430. private static _tmpFloatArray;
  35431. /**
  35432. * Returns the nearest 32-bit single precision float representation of a Number
  35433. * @param value A Number. If the parameter is of a different type, it will get converted
  35434. * to a number or to NaN if it cannot be converted
  35435. * @returns number
  35436. */
  35437. static FloatRound(value: number): number;
  35438. /**
  35439. * Extracts the filename from a path
  35440. * @param path defines the path to use
  35441. * @returns the filename
  35442. */
  35443. static GetFilename(path: string): string;
  35444. /**
  35445. * Extracts the "folder" part of a path (everything before the filename).
  35446. * @param uri The URI to extract the info from
  35447. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  35448. * @returns The "folder" part of the path
  35449. */
  35450. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  35451. /**
  35452. * Extracts text content from a DOM element hierarchy
  35453. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  35454. */
  35455. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  35456. /**
  35457. * Convert an angle in radians to degrees
  35458. * @param angle defines the angle to convert
  35459. * @returns the angle in degrees
  35460. */
  35461. static ToDegrees(angle: number): number;
  35462. /**
  35463. * Convert an angle in degrees to radians
  35464. * @param angle defines the angle to convert
  35465. * @returns the angle in radians
  35466. */
  35467. static ToRadians(angle: number): number;
  35468. /**
  35469. * Returns an array if obj is not an array
  35470. * @param obj defines the object to evaluate as an array
  35471. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  35472. * @returns either obj directly if obj is an array or a new array containing obj
  35473. */
  35474. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  35475. /**
  35476. * Gets the pointer prefix to use
  35477. * @returns "pointer" if touch is enabled. Else returns "mouse"
  35478. */
  35479. static GetPointerPrefix(): string;
  35480. /**
  35481. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  35482. * @param url define the url we are trying
  35483. * @param element define the dom element where to configure the cors policy
  35484. */
  35485. static SetCorsBehavior(url: string | string[], element: {
  35486. crossOrigin: string | null;
  35487. }): void;
  35488. /**
  35489. * Removes unwanted characters from an url
  35490. * @param url defines the url to clean
  35491. * @returns the cleaned url
  35492. */
  35493. static CleanUrl(url: string): string;
  35494. /**
  35495. * Gets or sets a function used to pre-process url before using them to load assets
  35496. */
  35497. static get PreprocessUrl(): (url: string) => string;
  35498. static set PreprocessUrl(processor: (url: string) => string);
  35499. /**
  35500. * Loads an image as an HTMLImageElement.
  35501. * @param input url string, ArrayBuffer, or Blob to load
  35502. * @param onLoad callback called when the image successfully loads
  35503. * @param onError callback called when the image fails to load
  35504. * @param offlineProvider offline provider for caching
  35505. * @param mimeType optional mime type
  35506. * @returns the HTMLImageElement of the loaded image
  35507. */
  35508. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  35509. /**
  35510. * Loads a file from a url
  35511. * @param url url string, ArrayBuffer, or Blob to load
  35512. * @param onSuccess callback called when the file successfully loads
  35513. * @param onProgress callback called while file is loading (if the server supports this mode)
  35514. * @param offlineProvider defines the offline provider for caching
  35515. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  35516. * @param onError callback called when the file fails to load
  35517. * @returns a file request object
  35518. */
  35519. 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;
  35520. /**
  35521. * Loads a file from a url
  35522. * @param url the file url to load
  35523. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  35524. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  35525. */
  35526. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  35527. /**
  35528. * Load a script (identified by an url). When the url returns, the
  35529. * content of this file is added into a new script element, attached to the DOM (body element)
  35530. * @param scriptUrl defines the url of the script to laod
  35531. * @param onSuccess defines the callback called when the script is loaded
  35532. * @param onError defines the callback to call if an error occurs
  35533. * @param scriptId defines the id of the script element
  35534. */
  35535. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  35536. /**
  35537. * Load an asynchronous 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 scriptId defines the id of the script element
  35541. * @returns a promise request object
  35542. */
  35543. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  35544. /**
  35545. * Loads a file from a blob
  35546. * @param fileToLoad defines the blob to use
  35547. * @param callback defines the callback to call when data is loaded
  35548. * @param progressCallback defines the callback to call during loading process
  35549. * @returns a file request object
  35550. */
  35551. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  35552. /**
  35553. * Reads a file from a File object
  35554. * @param file defines the file to load
  35555. * @param onSuccess defines the callback to call when data is loaded
  35556. * @param onProgress defines the callback to call during loading process
  35557. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  35558. * @param onError defines the callback to call when an error occurs
  35559. * @returns a file request object
  35560. */
  35561. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  35562. /**
  35563. * Creates a data url from a given string content
  35564. * @param content defines the content to convert
  35565. * @returns the new data url link
  35566. */
  35567. static FileAsURL(content: string): string;
  35568. /**
  35569. * Format the given number to a specific decimal format
  35570. * @param value defines the number to format
  35571. * @param decimals defines the number of decimals to use
  35572. * @returns the formatted string
  35573. */
  35574. static Format(value: number, decimals?: number): string;
  35575. /**
  35576. * Tries to copy an object by duplicating every property
  35577. * @param source defines the source object
  35578. * @param destination defines the target object
  35579. * @param doNotCopyList defines a list of properties to avoid
  35580. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  35581. */
  35582. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  35583. /**
  35584. * Gets a boolean indicating if the given object has no own property
  35585. * @param obj defines the object to test
  35586. * @returns true if object has no own property
  35587. */
  35588. static IsEmpty(obj: any): boolean;
  35589. /**
  35590. * Function used to register events at window level
  35591. * @param windowElement defines the Window object to use
  35592. * @param events defines the events to register
  35593. */
  35594. static RegisterTopRootEvents(windowElement: Window, events: {
  35595. name: string;
  35596. handler: Nullable<(e: FocusEvent) => any>;
  35597. }[]): void;
  35598. /**
  35599. * Function used to unregister events from window level
  35600. * @param windowElement defines the Window object to use
  35601. * @param events defines the events to unregister
  35602. */
  35603. static UnregisterTopRootEvents(windowElement: Window, events: {
  35604. name: string;
  35605. handler: Nullable<(e: FocusEvent) => any>;
  35606. }[]): void;
  35607. /**
  35608. * @ignore
  35609. */
  35610. static _ScreenshotCanvas: HTMLCanvasElement;
  35611. /**
  35612. * Dumps the current bound framebuffer
  35613. * @param width defines the rendering width
  35614. * @param height defines the rendering height
  35615. * @param engine defines the hosting engine
  35616. * @param successCallback defines the callback triggered once the data are available
  35617. * @param mimeType defines the mime type of the result
  35618. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  35619. */
  35620. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  35621. /**
  35622. * Converts the canvas data to blob.
  35623. * This acts as a polyfill for browsers not supporting the to blob function.
  35624. * @param canvas Defines the canvas to extract the data from
  35625. * @param successCallback Defines the callback triggered once the data are available
  35626. * @param mimeType Defines the mime type of the result
  35627. */
  35628. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  35629. /**
  35630. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  35631. * @param successCallback defines the callback triggered once the data are available
  35632. * @param mimeType defines the mime type of the result
  35633. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  35634. */
  35635. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  35636. /**
  35637. * Downloads a blob in the browser
  35638. * @param blob defines the blob to download
  35639. * @param fileName defines the name of the downloaded file
  35640. */
  35641. static Download(blob: Blob, fileName: string): void;
  35642. /**
  35643. * Captures a screenshot of the current rendering
  35644. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35645. * @param engine defines the rendering engine
  35646. * @param camera defines the source camera
  35647. * @param size This parameter can be set to a single number or to an object with the
  35648. * following (optional) properties: precision, width, height. If a single number is passed,
  35649. * it will be used for both width and height. If an object is passed, the screenshot size
  35650. * will be derived from the parameters. The precision property is a multiplier allowing
  35651. * rendering at a higher or lower resolution
  35652. * @param successCallback defines the callback receives a single parameter which contains the
  35653. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  35654. * src parameter of an <img> to display it
  35655. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  35656. * Check your browser for supported MIME types
  35657. */
  35658. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  35659. /**
  35660. * Captures a screenshot of the current rendering
  35661. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35662. * @param engine defines the rendering engine
  35663. * @param camera defines the source camera
  35664. * @param size This parameter can be set to a single number or to an object with the
  35665. * following (optional) properties: precision, width, height. If a single number is passed,
  35666. * it will be used for both width and height. If an object is passed, the screenshot size
  35667. * will be derived from the parameters. The precision property is a multiplier allowing
  35668. * rendering at a higher or lower resolution
  35669. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  35670. * Check your browser for supported MIME types
  35671. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  35672. * to the src parameter of an <img> to display it
  35673. */
  35674. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  35675. /**
  35676. * Generates an image screenshot from the specified camera.
  35677. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35678. * @param engine The engine to use for rendering
  35679. * @param camera The camera to use for rendering
  35680. * @param size This parameter can be set to a single number or to an object with the
  35681. * following (optional) properties: precision, width, height. If a single number is passed,
  35682. * it will be used for both width and height. If an object is passed, the screenshot size
  35683. * will be derived from the parameters. The precision property is a multiplier allowing
  35684. * rendering at a higher or lower resolution
  35685. * @param successCallback The callback receives a single parameter which contains the
  35686. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  35687. * src parameter of an <img> to display it
  35688. * @param mimeType The MIME type of the screenshot image (default: image/png).
  35689. * Check your browser for supported MIME types
  35690. * @param samples Texture samples (default: 1)
  35691. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  35692. * @param fileName A name for for the downloaded file.
  35693. */
  35694. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  35695. /**
  35696. * Generates an image screenshot from the specified camera.
  35697. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35698. * @param engine The engine to use for rendering
  35699. * @param camera The camera to use for rendering
  35700. * @param size This parameter can be set to a single number or to an object with the
  35701. * following (optional) properties: precision, width, height. If a single number is passed,
  35702. * it will be used for both width and height. If an object is passed, the screenshot size
  35703. * will be derived from the parameters. The precision property is a multiplier allowing
  35704. * rendering at a higher or lower resolution
  35705. * @param mimeType The MIME type of the screenshot image (default: image/png).
  35706. * Check your browser for supported MIME types
  35707. * @param samples Texture samples (default: 1)
  35708. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  35709. * @param fileName A name for for the downloaded file.
  35710. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  35711. * to the src parameter of an <img> to display it
  35712. */
  35713. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  35714. /**
  35715. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  35716. * Be aware Math.random() could cause collisions, but:
  35717. * "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"
  35718. * @returns a pseudo random id
  35719. */
  35720. static RandomId(): string;
  35721. /**
  35722. * Test if the given uri is a base64 string
  35723. * @param uri The uri to test
  35724. * @return True if the uri is a base64 string or false otherwise
  35725. */
  35726. static IsBase64(uri: string): boolean;
  35727. /**
  35728. * Decode the given base64 uri.
  35729. * @param uri The uri to decode
  35730. * @return The decoded base64 data.
  35731. */
  35732. static DecodeBase64(uri: string): ArrayBuffer;
  35733. /**
  35734. * Gets the absolute url.
  35735. * @param url the input url
  35736. * @return the absolute url
  35737. */
  35738. static GetAbsoluteUrl(url: string): string;
  35739. /**
  35740. * No log
  35741. */
  35742. static readonly NoneLogLevel: number;
  35743. /**
  35744. * Only message logs
  35745. */
  35746. static readonly MessageLogLevel: number;
  35747. /**
  35748. * Only warning logs
  35749. */
  35750. static readonly WarningLogLevel: number;
  35751. /**
  35752. * Only error logs
  35753. */
  35754. static readonly ErrorLogLevel: number;
  35755. /**
  35756. * All logs
  35757. */
  35758. static readonly AllLogLevel: number;
  35759. /**
  35760. * Gets a value indicating the number of loading errors
  35761. * @ignorenaming
  35762. */
  35763. static get errorsCount(): number;
  35764. /**
  35765. * Callback called when a new log is added
  35766. */
  35767. static OnNewCacheEntry: (entry: string) => void;
  35768. /**
  35769. * Log a message to the console
  35770. * @param message defines the message to log
  35771. */
  35772. static Log(message: string): void;
  35773. /**
  35774. * Write a warning message to the console
  35775. * @param message defines the message to log
  35776. */
  35777. static Warn(message: string): void;
  35778. /**
  35779. * Write an error message to the console
  35780. * @param message defines the message to log
  35781. */
  35782. static Error(message: string): void;
  35783. /**
  35784. * Gets current log cache (list of logs)
  35785. */
  35786. static get LogCache(): string;
  35787. /**
  35788. * Clears the log cache
  35789. */
  35790. static ClearLogCache(): void;
  35791. /**
  35792. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  35793. */
  35794. static set LogLevels(level: number);
  35795. /**
  35796. * Checks if the window object exists
  35797. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  35798. */
  35799. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  35800. /**
  35801. * No performance log
  35802. */
  35803. static readonly PerformanceNoneLogLevel: number;
  35804. /**
  35805. * Use user marks to log performance
  35806. */
  35807. static readonly PerformanceUserMarkLogLevel: number;
  35808. /**
  35809. * Log performance to the console
  35810. */
  35811. static readonly PerformanceConsoleLogLevel: number;
  35812. private static _performance;
  35813. /**
  35814. * Sets the current performance log level
  35815. */
  35816. static set PerformanceLogLevel(level: number);
  35817. private static _StartPerformanceCounterDisabled;
  35818. private static _EndPerformanceCounterDisabled;
  35819. private static _StartUserMark;
  35820. private static _EndUserMark;
  35821. private static _StartPerformanceConsole;
  35822. private static _EndPerformanceConsole;
  35823. /**
  35824. * Starts a performance counter
  35825. */
  35826. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  35827. /**
  35828. * Ends a specific performance coutner
  35829. */
  35830. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  35831. /**
  35832. * Gets either window.performance.now() if supported or Date.now() else
  35833. */
  35834. static get Now(): number;
  35835. /**
  35836. * This method will return the name of the class used to create the instance of the given object.
  35837. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  35838. * @param object the object to get the class name from
  35839. * @param isType defines if the object is actually a type
  35840. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  35841. */
  35842. static GetClassName(object: any, isType?: boolean): string;
  35843. /**
  35844. * Gets the first element of an array satisfying a given predicate
  35845. * @param array defines the array to browse
  35846. * @param predicate defines the predicate to use
  35847. * @returns null if not found or the element
  35848. */
  35849. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  35850. /**
  35851. * This method will return the name of the full name of the class, including its owning module (if any).
  35852. * 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).
  35853. * @param object the object to get the class name from
  35854. * @param isType defines if the object is actually a type
  35855. * @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.
  35856. * @ignorenaming
  35857. */
  35858. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  35859. /**
  35860. * Returns a promise that resolves after the given amount of time.
  35861. * @param delay Number of milliseconds to delay
  35862. * @returns Promise that resolves after the given amount of time
  35863. */
  35864. static DelayAsync(delay: number): Promise<void>;
  35865. /**
  35866. * Utility function to detect if the current user agent is Safari
  35867. * @returns whether or not the current user agent is safari
  35868. */
  35869. static IsSafari(): boolean;
  35870. }
  35871. /**
  35872. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  35873. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  35874. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  35875. * @param name The name of the class, case should be preserved
  35876. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  35877. */
  35878. export function className(name: string, module?: string): (target: Object) => void;
  35879. /**
  35880. * An implementation of a loop for asynchronous functions.
  35881. */
  35882. export class AsyncLoop {
  35883. /**
  35884. * Defines the number of iterations for the loop
  35885. */
  35886. iterations: number;
  35887. /**
  35888. * Defines the current index of the loop.
  35889. */
  35890. index: number;
  35891. private _done;
  35892. private _fn;
  35893. private _successCallback;
  35894. /**
  35895. * Constructor.
  35896. * @param iterations the number of iterations.
  35897. * @param func the function to run each iteration
  35898. * @param successCallback the callback that will be called upon succesful execution
  35899. * @param offset starting offset.
  35900. */
  35901. constructor(
  35902. /**
  35903. * Defines the number of iterations for the loop
  35904. */
  35905. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  35906. /**
  35907. * Execute the next iteration. Must be called after the last iteration was finished.
  35908. */
  35909. executeNext(): void;
  35910. /**
  35911. * Break the loop and run the success callback.
  35912. */
  35913. breakLoop(): void;
  35914. /**
  35915. * Create and run an async loop.
  35916. * @param iterations the number of iterations.
  35917. * @param fn the function to run each iteration
  35918. * @param successCallback the callback that will be called upon succesful execution
  35919. * @param offset starting offset.
  35920. * @returns the created async loop object
  35921. */
  35922. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  35923. /**
  35924. * A for-loop that will run a given number of iterations synchronous and the rest async.
  35925. * @param iterations total number of iterations
  35926. * @param syncedIterations number of synchronous iterations in each async iteration.
  35927. * @param fn the function to call each iteration.
  35928. * @param callback a success call back that will be called when iterating stops.
  35929. * @param breakFunction a break condition (optional)
  35930. * @param timeout timeout settings for the setTimeout function. default - 0.
  35931. * @returns the created async loop object
  35932. */
  35933. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  35934. }
  35935. }
  35936. declare module "babylonjs/Misc/stringDictionary" {
  35937. import { Nullable } from "babylonjs/types";
  35938. /**
  35939. * This class implement a typical dictionary using a string as key and the generic type T as value.
  35940. * The underlying implementation relies on an associative array to ensure the best performances.
  35941. * The value can be anything including 'null' but except 'undefined'
  35942. */
  35943. export class StringDictionary<T> {
  35944. /**
  35945. * This will clear this dictionary and copy the content from the 'source' one.
  35946. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  35947. * @param source the dictionary to take the content from and copy to this dictionary
  35948. */
  35949. copyFrom(source: StringDictionary<T>): void;
  35950. /**
  35951. * Get a value based from its key
  35952. * @param key the given key to get the matching value from
  35953. * @return the value if found, otherwise undefined is returned
  35954. */
  35955. get(key: string): T | undefined;
  35956. /**
  35957. * Get a value from its key or add it if it doesn't exist.
  35958. * This method will ensure you that a given key/data will be present in the dictionary.
  35959. * @param key the given key to get the matching value from
  35960. * @param factory the factory that will create the value if the key is not present in the dictionary.
  35961. * The factory will only be invoked if there's no data for the given key.
  35962. * @return the value corresponding to the key.
  35963. */
  35964. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  35965. /**
  35966. * Get a value from its key if present in the dictionary otherwise add it
  35967. * @param key the key to get the value from
  35968. * @param val if there's no such key/value pair in the dictionary add it with this value
  35969. * @return the value corresponding to the key
  35970. */
  35971. getOrAdd(key: string, val: T): T;
  35972. /**
  35973. * Check if there's a given key in the dictionary
  35974. * @param key the key to check for
  35975. * @return true if the key is present, false otherwise
  35976. */
  35977. contains(key: string): boolean;
  35978. /**
  35979. * Add a new key and its corresponding value
  35980. * @param key the key to add
  35981. * @param value the value corresponding to the key
  35982. * @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
  35983. */
  35984. add(key: string, value: T): boolean;
  35985. /**
  35986. * Update a specific value associated to a key
  35987. * @param key defines the key to use
  35988. * @param value defines the value to store
  35989. * @returns true if the value was updated (or false if the key was not found)
  35990. */
  35991. set(key: string, value: T): boolean;
  35992. /**
  35993. * Get the element of the given key and remove it from the dictionary
  35994. * @param key defines the key to search
  35995. * @returns the value associated with the key or null if not found
  35996. */
  35997. getAndRemove(key: string): Nullable<T>;
  35998. /**
  35999. * Remove a key/value from the dictionary.
  36000. * @param key the key to remove
  36001. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  36002. */
  36003. remove(key: string): boolean;
  36004. /**
  36005. * Clear the whole content of the dictionary
  36006. */
  36007. clear(): void;
  36008. /**
  36009. * Gets the current count
  36010. */
  36011. get count(): number;
  36012. /**
  36013. * Execute a callback on each key/val of the dictionary.
  36014. * Note that you can remove any element in this dictionary in the callback implementation
  36015. * @param callback the callback to execute on a given key/value pair
  36016. */
  36017. forEach(callback: (key: string, val: T) => void): void;
  36018. /**
  36019. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  36020. * If the callback returns null or undefined the method will iterate to the next key/value pair
  36021. * Note that you can remove any element in this dictionary in the callback implementation
  36022. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  36023. * @returns the first item
  36024. */
  36025. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  36026. private _count;
  36027. private _data;
  36028. }
  36029. }
  36030. declare module "babylonjs/Collisions/collisionCoordinator" {
  36031. import { Nullable } from "babylonjs/types";
  36032. import { Scene } from "babylonjs/scene";
  36033. import { Vector3 } from "babylonjs/Maths/math.vector";
  36034. import { Collider } from "babylonjs/Collisions/collider";
  36035. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36036. /** @hidden */
  36037. export interface ICollisionCoordinator {
  36038. createCollider(): Collider;
  36039. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  36040. init(scene: Scene): void;
  36041. }
  36042. /** @hidden */
  36043. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  36044. private _scene;
  36045. private _scaledPosition;
  36046. private _scaledVelocity;
  36047. private _finalPosition;
  36048. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  36049. createCollider(): Collider;
  36050. init(scene: Scene): void;
  36051. private _collideWithWorld;
  36052. }
  36053. }
  36054. declare module "babylonjs/Inputs/scene.inputManager" {
  36055. import { Nullable } from "babylonjs/types";
  36056. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  36057. import { Vector2 } from "babylonjs/Maths/math.vector";
  36058. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36059. import { Scene } from "babylonjs/scene";
  36060. /**
  36061. * Class used to manage all inputs for the scene.
  36062. */
  36063. export class InputManager {
  36064. /** The distance in pixel that you have to move to prevent some events */
  36065. static DragMovementThreshold: number;
  36066. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  36067. static LongPressDelay: number;
  36068. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  36069. static DoubleClickDelay: number;
  36070. /** If you need to check double click without raising a single click at first click, enable this flag */
  36071. static ExclusiveDoubleClickMode: boolean;
  36072. private _wheelEventName;
  36073. private _onPointerMove;
  36074. private _onPointerDown;
  36075. private _onPointerUp;
  36076. private _initClickEvent;
  36077. private _initActionManager;
  36078. private _delayedSimpleClick;
  36079. private _delayedSimpleClickTimeout;
  36080. private _previousDelayedSimpleClickTimeout;
  36081. private _meshPickProceed;
  36082. private _previousButtonPressed;
  36083. private _currentPickResult;
  36084. private _previousPickResult;
  36085. private _totalPointersPressed;
  36086. private _doubleClickOccured;
  36087. private _pointerOverMesh;
  36088. private _pickedDownMesh;
  36089. private _pickedUpMesh;
  36090. private _pointerX;
  36091. private _pointerY;
  36092. private _unTranslatedPointerX;
  36093. private _unTranslatedPointerY;
  36094. private _startingPointerPosition;
  36095. private _previousStartingPointerPosition;
  36096. private _startingPointerTime;
  36097. private _previousStartingPointerTime;
  36098. private _pointerCaptures;
  36099. private _onKeyDown;
  36100. private _onKeyUp;
  36101. private _onCanvasFocusObserver;
  36102. private _onCanvasBlurObserver;
  36103. private _scene;
  36104. /**
  36105. * Creates a new InputManager
  36106. * @param scene defines the hosting scene
  36107. */
  36108. constructor(scene: Scene);
  36109. /**
  36110. * Gets the mesh that is currently under the pointer
  36111. */
  36112. get meshUnderPointer(): Nullable<AbstractMesh>;
  36113. /**
  36114. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  36115. */
  36116. get unTranslatedPointer(): Vector2;
  36117. /**
  36118. * Gets or sets the current on-screen X position of the pointer
  36119. */
  36120. get pointerX(): number;
  36121. set pointerX(value: number);
  36122. /**
  36123. * Gets or sets the current on-screen Y position of the pointer
  36124. */
  36125. get pointerY(): number;
  36126. set pointerY(value: number);
  36127. private _updatePointerPosition;
  36128. private _processPointerMove;
  36129. private _setRayOnPointerInfo;
  36130. private _checkPrePointerObservable;
  36131. /**
  36132. * Use this method to simulate a pointer move on a mesh
  36133. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36134. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36135. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36136. */
  36137. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  36138. /**
  36139. * Use this method to simulate a pointer down on a mesh
  36140. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36141. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36142. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36143. */
  36144. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  36145. private _processPointerDown;
  36146. /** @hidden */
  36147. _isPointerSwiping(): boolean;
  36148. /**
  36149. * Use this method to simulate a pointer up on a mesh
  36150. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36151. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36152. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36153. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  36154. */
  36155. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  36156. private _processPointerUp;
  36157. /**
  36158. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  36159. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  36160. * @returns true if the pointer was captured
  36161. */
  36162. isPointerCaptured(pointerId?: number): boolean;
  36163. /**
  36164. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  36165. * @param attachUp defines if you want to attach events to pointerup
  36166. * @param attachDown defines if you want to attach events to pointerdown
  36167. * @param attachMove defines if you want to attach events to pointermove
  36168. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  36169. */
  36170. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  36171. /**
  36172. * Detaches all event handlers
  36173. */
  36174. detachControl(): void;
  36175. /**
  36176. * Force the value of meshUnderPointer
  36177. * @param mesh defines the mesh to use
  36178. */
  36179. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  36180. /**
  36181. * Gets the mesh under the pointer
  36182. * @returns a Mesh or null if no mesh is under the pointer
  36183. */
  36184. getPointerOverMesh(): Nullable<AbstractMesh>;
  36185. }
  36186. }
  36187. declare module "babylonjs/Misc/uniqueIdGenerator" {
  36188. /**
  36189. * Helper class used to generate session unique ID
  36190. */
  36191. export class UniqueIdGenerator {
  36192. private static _UniqueIdCounter;
  36193. /**
  36194. * Gets an unique (relatively to the current scene) Id
  36195. */
  36196. static get UniqueId(): number;
  36197. }
  36198. }
  36199. declare module "babylonjs/Animations/animationGroup" {
  36200. import { Animatable } from "babylonjs/Animations/animatable";
  36201. import { Animation } from "babylonjs/Animations/animation";
  36202. import { Scene, IDisposable } from "babylonjs/scene";
  36203. import { Observable } from "babylonjs/Misc/observable";
  36204. import { Nullable } from "babylonjs/types";
  36205. import "babylonjs/Animations/animatable";
  36206. /**
  36207. * This class defines the direct association between an animation and a target
  36208. */
  36209. export class TargetedAnimation {
  36210. /**
  36211. * Animation to perform
  36212. */
  36213. animation: Animation;
  36214. /**
  36215. * Target to animate
  36216. */
  36217. target: any;
  36218. /**
  36219. * Serialize the object
  36220. * @returns the JSON object representing the current entity
  36221. */
  36222. serialize(): any;
  36223. }
  36224. /**
  36225. * Use this class to create coordinated animations on multiple targets
  36226. */
  36227. export class AnimationGroup implements IDisposable {
  36228. /** The name of the animation group */
  36229. name: string;
  36230. private _scene;
  36231. private _targetedAnimations;
  36232. private _animatables;
  36233. private _from;
  36234. private _to;
  36235. private _isStarted;
  36236. private _isPaused;
  36237. private _speedRatio;
  36238. private _loopAnimation;
  36239. private _isAdditive;
  36240. /**
  36241. * Gets or sets the unique id of the node
  36242. */
  36243. uniqueId: number;
  36244. /**
  36245. * This observable will notify when one animation have ended
  36246. */
  36247. onAnimationEndObservable: Observable<TargetedAnimation>;
  36248. /**
  36249. * Observer raised when one animation loops
  36250. */
  36251. onAnimationLoopObservable: Observable<TargetedAnimation>;
  36252. /**
  36253. * Observer raised when all animations have looped
  36254. */
  36255. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  36256. /**
  36257. * This observable will notify when all animations have ended.
  36258. */
  36259. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  36260. /**
  36261. * This observable will notify when all animations have paused.
  36262. */
  36263. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  36264. /**
  36265. * This observable will notify when all animations are playing.
  36266. */
  36267. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  36268. /**
  36269. * Gets the first frame
  36270. */
  36271. get from(): number;
  36272. /**
  36273. * Gets the last frame
  36274. */
  36275. get to(): number;
  36276. /**
  36277. * Define if the animations are started
  36278. */
  36279. get isStarted(): boolean;
  36280. /**
  36281. * Gets a value indicating that the current group is playing
  36282. */
  36283. get isPlaying(): boolean;
  36284. /**
  36285. * Gets or sets the speed ratio to use for all animations
  36286. */
  36287. get speedRatio(): number;
  36288. /**
  36289. * Gets or sets the speed ratio to use for all animations
  36290. */
  36291. set speedRatio(value: number);
  36292. /**
  36293. * Gets or sets if all animations should loop or not
  36294. */
  36295. get loopAnimation(): boolean;
  36296. set loopAnimation(value: boolean);
  36297. /**
  36298. * Gets or sets if all animations should be evaluated additively
  36299. */
  36300. get isAdditive(): boolean;
  36301. set isAdditive(value: boolean);
  36302. /**
  36303. * Gets the targeted animations for this animation group
  36304. */
  36305. get targetedAnimations(): Array<TargetedAnimation>;
  36306. /**
  36307. * returning the list of animatables controlled by this animation group.
  36308. */
  36309. get animatables(): Array<Animatable>;
  36310. /**
  36311. * Instantiates a new Animation Group.
  36312. * This helps managing several animations at once.
  36313. * @see http://doc.babylonjs.com/how_to/group
  36314. * @param name Defines the name of the group
  36315. * @param scene Defines the scene the group belongs to
  36316. */
  36317. constructor(
  36318. /** The name of the animation group */
  36319. name: string, scene?: Nullable<Scene>);
  36320. /**
  36321. * Add an animation (with its target) in the group
  36322. * @param animation defines the animation we want to add
  36323. * @param target defines the target of the animation
  36324. * @returns the TargetedAnimation object
  36325. */
  36326. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  36327. /**
  36328. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  36329. * It can add constant keys at begin or end
  36330. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  36331. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  36332. * @returns the animation group
  36333. */
  36334. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  36335. private _animationLoopCount;
  36336. private _animationLoopFlags;
  36337. private _processLoop;
  36338. /**
  36339. * Start all animations on given targets
  36340. * @param loop defines if animations must loop
  36341. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  36342. * @param from defines the from key (optional)
  36343. * @param to defines the to key (optional)
  36344. * @param isAdditive defines the additive state for the resulting animatables (optional)
  36345. * @returns the current animation group
  36346. */
  36347. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  36348. /**
  36349. * Pause all animations
  36350. * @returns the animation group
  36351. */
  36352. pause(): AnimationGroup;
  36353. /**
  36354. * Play all animations to initial state
  36355. * This function will start() the animations if they were not started or will restart() them if they were paused
  36356. * @param loop defines if animations must loop
  36357. * @returns the animation group
  36358. */
  36359. play(loop?: boolean): AnimationGroup;
  36360. /**
  36361. * Reset all animations to initial state
  36362. * @returns the animation group
  36363. */
  36364. reset(): AnimationGroup;
  36365. /**
  36366. * Restart animations from key 0
  36367. * @returns the animation group
  36368. */
  36369. restart(): AnimationGroup;
  36370. /**
  36371. * Stop all animations
  36372. * @returns the animation group
  36373. */
  36374. stop(): AnimationGroup;
  36375. /**
  36376. * Set animation weight for all animatables
  36377. * @param weight defines the weight to use
  36378. * @return the animationGroup
  36379. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  36380. */
  36381. setWeightForAllAnimatables(weight: number): AnimationGroup;
  36382. /**
  36383. * Synchronize and normalize all animatables with a source animatable
  36384. * @param root defines the root animatable to synchronize with
  36385. * @return the animationGroup
  36386. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  36387. */
  36388. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  36389. /**
  36390. * Goes to a specific frame in this animation group
  36391. * @param frame the frame number to go to
  36392. * @return the animationGroup
  36393. */
  36394. goToFrame(frame: number): AnimationGroup;
  36395. /**
  36396. * Dispose all associated resources
  36397. */
  36398. dispose(): void;
  36399. private _checkAnimationGroupEnded;
  36400. /**
  36401. * Clone the current animation group and returns a copy
  36402. * @param newName defines the name of the new group
  36403. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  36404. * @returns the new aniamtion group
  36405. */
  36406. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  36407. /**
  36408. * Serializes the animationGroup to an object
  36409. * @returns Serialized object
  36410. */
  36411. serialize(): any;
  36412. /**
  36413. * Returns a new AnimationGroup object parsed from the source provided.
  36414. * @param parsedAnimationGroup defines the source
  36415. * @param scene defines the scene that will receive the animationGroup
  36416. * @returns a new AnimationGroup
  36417. */
  36418. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  36419. /**
  36420. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  36421. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  36422. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  36423. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  36424. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  36425. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  36426. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  36427. */
  36428. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  36429. /**
  36430. * Returns the string "AnimationGroup"
  36431. * @returns "AnimationGroup"
  36432. */
  36433. getClassName(): string;
  36434. /**
  36435. * Creates a detailled string about the object
  36436. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  36437. * @returns a string representing the object
  36438. */
  36439. toString(fullDetails?: boolean): string;
  36440. }
  36441. }
  36442. declare module "babylonjs/scene" {
  36443. import { Nullable } from "babylonjs/types";
  36444. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  36445. import { Observable } from "babylonjs/Misc/observable";
  36446. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  36447. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  36448. import { Geometry } from "babylonjs/Meshes/geometry";
  36449. import { TransformNode } from "babylonjs/Meshes/transformNode";
  36450. import { SubMesh } from "babylonjs/Meshes/subMesh";
  36451. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36452. import { Mesh } from "babylonjs/Meshes/mesh";
  36453. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  36454. import { Bone } from "babylonjs/Bones/bone";
  36455. import { Skeleton } from "babylonjs/Bones/skeleton";
  36456. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  36457. import { Camera } from "babylonjs/Cameras/camera";
  36458. import { AbstractScene } from "babylonjs/abstractScene";
  36459. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  36460. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  36461. import { Material } from "babylonjs/Materials/material";
  36462. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  36463. import { Effect } from "babylonjs/Materials/effect";
  36464. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  36465. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  36466. import { Light } from "babylonjs/Lights/light";
  36467. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  36468. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  36469. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  36470. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  36471. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  36472. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  36473. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  36474. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  36475. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  36476. import { Engine } from "babylonjs/Engines/engine";
  36477. import { Node } from "babylonjs/node";
  36478. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  36479. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  36480. import { WebRequest } from "babylonjs/Misc/webRequest";
  36481. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  36482. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  36483. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  36484. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  36485. import { Plane } from "babylonjs/Maths/math.plane";
  36486. import { LoadFileError, RequestFileError, ReadFileError } from "babylonjs/Misc/fileTools";
  36487. import { Ray } from "babylonjs/Culling/ray";
  36488. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  36489. import { Animation } from "babylonjs/Animations/animation";
  36490. import { Animatable } from "babylonjs/Animations/animatable";
  36491. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  36492. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  36493. import { Collider } from "babylonjs/Collisions/collider";
  36494. /**
  36495. * Define an interface for all classes that will hold resources
  36496. */
  36497. export interface IDisposable {
  36498. /**
  36499. * Releases all held resources
  36500. */
  36501. dispose(): void;
  36502. }
  36503. /** Interface defining initialization parameters for Scene class */
  36504. export interface SceneOptions {
  36505. /**
  36506. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  36507. * It will improve performance when the number of geometries becomes important.
  36508. */
  36509. useGeometryUniqueIdsMap?: boolean;
  36510. /**
  36511. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  36512. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  36513. */
  36514. useMaterialMeshMap?: boolean;
  36515. /**
  36516. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  36517. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  36518. */
  36519. useClonedMeshMap?: boolean;
  36520. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  36521. virtual?: boolean;
  36522. }
  36523. /**
  36524. * Represents a scene to be rendered by the engine.
  36525. * @see http://doc.babylonjs.com/features/scene
  36526. */
  36527. export class Scene extends AbstractScene implements IAnimatable {
  36528. /** The fog is deactivated */
  36529. static readonly FOGMODE_NONE: number;
  36530. /** The fog density is following an exponential function */
  36531. static readonly FOGMODE_EXP: number;
  36532. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  36533. static readonly FOGMODE_EXP2: number;
  36534. /** The fog density is following a linear function. */
  36535. static readonly FOGMODE_LINEAR: number;
  36536. /**
  36537. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  36538. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36539. */
  36540. static MinDeltaTime: number;
  36541. /**
  36542. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  36543. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36544. */
  36545. static MaxDeltaTime: number;
  36546. /**
  36547. * Factory used to create the default material.
  36548. * @param name The name of the material to create
  36549. * @param scene The scene to create the material for
  36550. * @returns The default material
  36551. */
  36552. static DefaultMaterialFactory(scene: Scene): Material;
  36553. /**
  36554. * Factory used to create the a collision coordinator.
  36555. * @returns The collision coordinator
  36556. */
  36557. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  36558. /** @hidden */
  36559. _inputManager: InputManager;
  36560. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  36561. cameraToUseForPointers: Nullable<Camera>;
  36562. /** @hidden */
  36563. readonly _isScene: boolean;
  36564. /** @hidden */
  36565. _blockEntityCollection: boolean;
  36566. /**
  36567. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  36568. */
  36569. autoClear: boolean;
  36570. /**
  36571. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  36572. */
  36573. autoClearDepthAndStencil: boolean;
  36574. /**
  36575. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  36576. */
  36577. clearColor: Color4;
  36578. /**
  36579. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  36580. */
  36581. ambientColor: Color3;
  36582. /**
  36583. * This is use to store the default BRDF lookup for PBR materials in your scene.
  36584. * It should only be one of the following (if not the default embedded one):
  36585. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  36586. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  36587. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  36588. * The material properties need to be setup according to the type of texture in use.
  36589. */
  36590. environmentBRDFTexture: BaseTexture;
  36591. /** @hidden */
  36592. protected _environmentTexture: Nullable<BaseTexture>;
  36593. /**
  36594. * Texture used in all pbr material as the reflection texture.
  36595. * As in the majority of the scene they are the same (exception for multi room and so on),
  36596. * this is easier to reference from here than from all the materials.
  36597. */
  36598. get environmentTexture(): Nullable<BaseTexture>;
  36599. /**
  36600. * Texture used in all pbr material as the reflection texture.
  36601. * As in the majority of the scene they are the same (exception for multi room and so on),
  36602. * this is easier to set here than in all the materials.
  36603. */
  36604. set environmentTexture(value: Nullable<BaseTexture>);
  36605. /** @hidden */
  36606. protected _environmentIntensity: number;
  36607. /**
  36608. * Intensity of the environment in all pbr material.
  36609. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  36610. * As in the majority of the scene they are the same (exception for multi room and so on),
  36611. * this is easier to reference from here than from all the materials.
  36612. */
  36613. get environmentIntensity(): number;
  36614. /**
  36615. * Intensity of the environment in all pbr material.
  36616. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  36617. * As in the majority of the scene they are the same (exception for multi room and so on),
  36618. * this is easier to set here than in all the materials.
  36619. */
  36620. set environmentIntensity(value: number);
  36621. /** @hidden */
  36622. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  36623. /**
  36624. * Default image processing configuration used either in the rendering
  36625. * Forward main pass or through the imageProcessingPostProcess if present.
  36626. * As in the majority of the scene they are the same (exception for multi camera),
  36627. * this is easier to reference from here than from all the materials and post process.
  36628. *
  36629. * No setter as we it is a shared configuration, you can set the values instead.
  36630. */
  36631. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  36632. private _forceWireframe;
  36633. /**
  36634. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  36635. */
  36636. set forceWireframe(value: boolean);
  36637. get forceWireframe(): boolean;
  36638. private _skipFrustumClipping;
  36639. /**
  36640. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  36641. */
  36642. set skipFrustumClipping(value: boolean);
  36643. get skipFrustumClipping(): boolean;
  36644. private _forcePointsCloud;
  36645. /**
  36646. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  36647. */
  36648. set forcePointsCloud(value: boolean);
  36649. get forcePointsCloud(): boolean;
  36650. /**
  36651. * Gets or sets the active clipplane 1
  36652. */
  36653. clipPlane: Nullable<Plane>;
  36654. /**
  36655. * Gets or sets the active clipplane 2
  36656. */
  36657. clipPlane2: Nullable<Plane>;
  36658. /**
  36659. * Gets or sets the active clipplane 3
  36660. */
  36661. clipPlane3: Nullable<Plane>;
  36662. /**
  36663. * Gets or sets the active clipplane 4
  36664. */
  36665. clipPlane4: Nullable<Plane>;
  36666. /**
  36667. * Gets or sets the active clipplane 5
  36668. */
  36669. clipPlane5: Nullable<Plane>;
  36670. /**
  36671. * Gets or sets the active clipplane 6
  36672. */
  36673. clipPlane6: Nullable<Plane>;
  36674. /**
  36675. * Gets or sets a boolean indicating if animations are enabled
  36676. */
  36677. animationsEnabled: boolean;
  36678. private _animationPropertiesOverride;
  36679. /**
  36680. * Gets or sets the animation properties override
  36681. */
  36682. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  36683. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  36684. /**
  36685. * Gets or sets a boolean indicating if a constant deltatime has to be used
  36686. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  36687. */
  36688. useConstantAnimationDeltaTime: boolean;
  36689. /**
  36690. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  36691. * Please note that it requires to run a ray cast through the scene on every frame
  36692. */
  36693. constantlyUpdateMeshUnderPointer: boolean;
  36694. /**
  36695. * Defines the HTML cursor to use when hovering over interactive elements
  36696. */
  36697. hoverCursor: string;
  36698. /**
  36699. * Defines the HTML default cursor to use (empty by default)
  36700. */
  36701. defaultCursor: string;
  36702. /**
  36703. * Defines whether cursors are handled by the scene.
  36704. */
  36705. doNotHandleCursors: boolean;
  36706. /**
  36707. * This is used to call preventDefault() on pointer down
  36708. * in order to block unwanted artifacts like system double clicks
  36709. */
  36710. preventDefaultOnPointerDown: boolean;
  36711. /**
  36712. * This is used to call preventDefault() on pointer up
  36713. * in order to block unwanted artifacts like system double clicks
  36714. */
  36715. preventDefaultOnPointerUp: boolean;
  36716. /**
  36717. * Gets or sets user defined metadata
  36718. */
  36719. metadata: any;
  36720. /**
  36721. * For internal use only. Please do not use.
  36722. */
  36723. reservedDataStore: any;
  36724. /**
  36725. * Gets the name of the plugin used to load this scene (null by default)
  36726. */
  36727. loadingPluginName: string;
  36728. /**
  36729. * Use this array to add regular expressions used to disable offline support for specific urls
  36730. */
  36731. disableOfflineSupportExceptionRules: RegExp[];
  36732. /**
  36733. * An event triggered when the scene is disposed.
  36734. */
  36735. onDisposeObservable: Observable<Scene>;
  36736. private _onDisposeObserver;
  36737. /** Sets a function to be executed when this scene is disposed. */
  36738. set onDispose(callback: () => void);
  36739. /**
  36740. * An event triggered before rendering the scene (right after animations and physics)
  36741. */
  36742. onBeforeRenderObservable: Observable<Scene>;
  36743. private _onBeforeRenderObserver;
  36744. /** Sets a function to be executed before rendering this scene */
  36745. set beforeRender(callback: Nullable<() => void>);
  36746. /**
  36747. * An event triggered after rendering the scene
  36748. */
  36749. onAfterRenderObservable: Observable<Scene>;
  36750. /**
  36751. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  36752. */
  36753. onAfterRenderCameraObservable: Observable<Camera>;
  36754. private _onAfterRenderObserver;
  36755. /** Sets a function to be executed after rendering this scene */
  36756. set afterRender(callback: Nullable<() => void>);
  36757. /**
  36758. * An event triggered before animating the scene
  36759. */
  36760. onBeforeAnimationsObservable: Observable<Scene>;
  36761. /**
  36762. * An event triggered after animations processing
  36763. */
  36764. onAfterAnimationsObservable: Observable<Scene>;
  36765. /**
  36766. * An event triggered before draw calls are ready to be sent
  36767. */
  36768. onBeforeDrawPhaseObservable: Observable<Scene>;
  36769. /**
  36770. * An event triggered after draw calls have been sent
  36771. */
  36772. onAfterDrawPhaseObservable: Observable<Scene>;
  36773. /**
  36774. * An event triggered when the scene is ready
  36775. */
  36776. onReadyObservable: Observable<Scene>;
  36777. /**
  36778. * An event triggered before rendering a camera
  36779. */
  36780. onBeforeCameraRenderObservable: Observable<Camera>;
  36781. private _onBeforeCameraRenderObserver;
  36782. /** Sets a function to be executed before rendering a camera*/
  36783. set beforeCameraRender(callback: () => void);
  36784. /**
  36785. * An event triggered after rendering a camera
  36786. */
  36787. onAfterCameraRenderObservable: Observable<Camera>;
  36788. private _onAfterCameraRenderObserver;
  36789. /** Sets a function to be executed after rendering a camera*/
  36790. set afterCameraRender(callback: () => void);
  36791. /**
  36792. * An event triggered when active meshes evaluation is about to start
  36793. */
  36794. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  36795. /**
  36796. * An event triggered when active meshes evaluation is done
  36797. */
  36798. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  36799. /**
  36800. * An event triggered when particles rendering is about to start
  36801. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  36802. */
  36803. onBeforeParticlesRenderingObservable: Observable<Scene>;
  36804. /**
  36805. * An event triggered when particles rendering is done
  36806. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  36807. */
  36808. onAfterParticlesRenderingObservable: Observable<Scene>;
  36809. /**
  36810. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  36811. */
  36812. onDataLoadedObservable: Observable<Scene>;
  36813. /**
  36814. * An event triggered when a camera is created
  36815. */
  36816. onNewCameraAddedObservable: Observable<Camera>;
  36817. /**
  36818. * An event triggered when a camera is removed
  36819. */
  36820. onCameraRemovedObservable: Observable<Camera>;
  36821. /**
  36822. * An event triggered when a light is created
  36823. */
  36824. onNewLightAddedObservable: Observable<Light>;
  36825. /**
  36826. * An event triggered when a light is removed
  36827. */
  36828. onLightRemovedObservable: Observable<Light>;
  36829. /**
  36830. * An event triggered when a geometry is created
  36831. */
  36832. onNewGeometryAddedObservable: Observable<Geometry>;
  36833. /**
  36834. * An event triggered when a geometry is removed
  36835. */
  36836. onGeometryRemovedObservable: Observable<Geometry>;
  36837. /**
  36838. * An event triggered when a transform node is created
  36839. */
  36840. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  36841. /**
  36842. * An event triggered when a transform node is removed
  36843. */
  36844. onTransformNodeRemovedObservable: Observable<TransformNode>;
  36845. /**
  36846. * An event triggered when a mesh is created
  36847. */
  36848. onNewMeshAddedObservable: Observable<AbstractMesh>;
  36849. /**
  36850. * An event triggered when a mesh is removed
  36851. */
  36852. onMeshRemovedObservable: Observable<AbstractMesh>;
  36853. /**
  36854. * An event triggered when a skeleton is created
  36855. */
  36856. onNewSkeletonAddedObservable: Observable<Skeleton>;
  36857. /**
  36858. * An event triggered when a skeleton is removed
  36859. */
  36860. onSkeletonRemovedObservable: Observable<Skeleton>;
  36861. /**
  36862. * An event triggered when a material is created
  36863. */
  36864. onNewMaterialAddedObservable: Observable<Material>;
  36865. /**
  36866. * An event triggered when a material is removed
  36867. */
  36868. onMaterialRemovedObservable: Observable<Material>;
  36869. /**
  36870. * An event triggered when a texture is created
  36871. */
  36872. onNewTextureAddedObservable: Observable<BaseTexture>;
  36873. /**
  36874. * An event triggered when a texture is removed
  36875. */
  36876. onTextureRemovedObservable: Observable<BaseTexture>;
  36877. /**
  36878. * An event triggered when render targets are about to be rendered
  36879. * Can happen multiple times per frame.
  36880. */
  36881. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  36882. /**
  36883. * An event triggered when render targets were rendered.
  36884. * Can happen multiple times per frame.
  36885. */
  36886. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  36887. /**
  36888. * An event triggered before calculating deterministic simulation step
  36889. */
  36890. onBeforeStepObservable: Observable<Scene>;
  36891. /**
  36892. * An event triggered after calculating deterministic simulation step
  36893. */
  36894. onAfterStepObservable: Observable<Scene>;
  36895. /**
  36896. * An event triggered when the activeCamera property is updated
  36897. */
  36898. onActiveCameraChanged: Observable<Scene>;
  36899. /**
  36900. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  36901. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  36902. * 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)
  36903. */
  36904. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  36905. /**
  36906. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  36907. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  36908. * 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)
  36909. */
  36910. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  36911. /**
  36912. * This Observable will when a mesh has been imported into the scene.
  36913. */
  36914. onMeshImportedObservable: Observable<AbstractMesh>;
  36915. /**
  36916. * This Observable will when an animation file has been imported into the scene.
  36917. */
  36918. onAnimationFileImportedObservable: Observable<Scene>;
  36919. /**
  36920. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  36921. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  36922. */
  36923. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  36924. /** @hidden */
  36925. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  36926. /**
  36927. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  36928. */
  36929. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  36930. /**
  36931. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  36932. */
  36933. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  36934. /**
  36935. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  36936. */
  36937. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  36938. /** Callback called when a pointer move is detected */
  36939. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  36940. /** Callback called when a pointer down is detected */
  36941. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  36942. /** Callback called when a pointer up is detected */
  36943. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  36944. /** Callback called when a pointer pick is detected */
  36945. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  36946. /**
  36947. * 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).
  36948. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  36949. */
  36950. onPrePointerObservable: Observable<PointerInfoPre>;
  36951. /**
  36952. * Observable event triggered each time an input event is received from the rendering canvas
  36953. */
  36954. onPointerObservable: Observable<PointerInfo>;
  36955. /**
  36956. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  36957. */
  36958. get unTranslatedPointer(): Vector2;
  36959. /**
  36960. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  36961. */
  36962. static get DragMovementThreshold(): number;
  36963. static set DragMovementThreshold(value: number);
  36964. /**
  36965. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  36966. */
  36967. static get LongPressDelay(): number;
  36968. static set LongPressDelay(value: number);
  36969. /**
  36970. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  36971. */
  36972. static get DoubleClickDelay(): number;
  36973. static set DoubleClickDelay(value: number);
  36974. /** If you need to check double click without raising a single click at first click, enable this flag */
  36975. static get ExclusiveDoubleClickMode(): boolean;
  36976. static set ExclusiveDoubleClickMode(value: boolean);
  36977. /** @hidden */
  36978. _mirroredCameraPosition: Nullable<Vector3>;
  36979. /**
  36980. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  36981. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  36982. */
  36983. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  36984. /**
  36985. * Observable event triggered each time an keyboard event is received from the hosting window
  36986. */
  36987. onKeyboardObservable: Observable<KeyboardInfo>;
  36988. private _useRightHandedSystem;
  36989. /**
  36990. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  36991. */
  36992. set useRightHandedSystem(value: boolean);
  36993. get useRightHandedSystem(): boolean;
  36994. private _timeAccumulator;
  36995. private _currentStepId;
  36996. private _currentInternalStep;
  36997. /**
  36998. * Sets the step Id used by deterministic lock step
  36999. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  37000. * @param newStepId defines the step Id
  37001. */
  37002. setStepId(newStepId: number): void;
  37003. /**
  37004. * Gets the step Id used by deterministic lock step
  37005. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  37006. * @returns the step Id
  37007. */
  37008. getStepId(): number;
  37009. /**
  37010. * Gets the internal step used by deterministic lock step
  37011. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  37012. * @returns the internal step
  37013. */
  37014. getInternalStep(): number;
  37015. private _fogEnabled;
  37016. /**
  37017. * Gets or sets a boolean indicating if fog is enabled on this scene
  37018. * @see http://doc.babylonjs.com/babylon101/environment#fog
  37019. * (Default is true)
  37020. */
  37021. set fogEnabled(value: boolean);
  37022. get fogEnabled(): boolean;
  37023. private _fogMode;
  37024. /**
  37025. * Gets or sets the fog mode to use
  37026. * @see http://doc.babylonjs.com/babylon101/environment#fog
  37027. * | mode | value |
  37028. * | --- | --- |
  37029. * | FOGMODE_NONE | 0 |
  37030. * | FOGMODE_EXP | 1 |
  37031. * | FOGMODE_EXP2 | 2 |
  37032. * | FOGMODE_LINEAR | 3 |
  37033. */
  37034. set fogMode(value: number);
  37035. get fogMode(): number;
  37036. /**
  37037. * Gets or sets the fog color to use
  37038. * @see http://doc.babylonjs.com/babylon101/environment#fog
  37039. * (Default is Color3(0.2, 0.2, 0.3))
  37040. */
  37041. fogColor: Color3;
  37042. /**
  37043. * Gets or sets the fog density to use
  37044. * @see http://doc.babylonjs.com/babylon101/environment#fog
  37045. * (Default is 0.1)
  37046. */
  37047. fogDensity: number;
  37048. /**
  37049. * Gets or sets the fog start distance to use
  37050. * @see http://doc.babylonjs.com/babylon101/environment#fog
  37051. * (Default is 0)
  37052. */
  37053. fogStart: number;
  37054. /**
  37055. * Gets or sets the fog end distance to use
  37056. * @see http://doc.babylonjs.com/babylon101/environment#fog
  37057. * (Default is 1000)
  37058. */
  37059. fogEnd: number;
  37060. private _shadowsEnabled;
  37061. /**
  37062. * Gets or sets a boolean indicating if shadows are enabled on this scene
  37063. */
  37064. set shadowsEnabled(value: boolean);
  37065. get shadowsEnabled(): boolean;
  37066. private _lightsEnabled;
  37067. /**
  37068. * Gets or sets a boolean indicating if lights are enabled on this scene
  37069. */
  37070. set lightsEnabled(value: boolean);
  37071. get lightsEnabled(): boolean;
  37072. /** All of the active cameras added to this scene. */
  37073. activeCameras: Camera[];
  37074. /** @hidden */
  37075. _activeCamera: Nullable<Camera>;
  37076. /** Gets or sets the current active camera */
  37077. get activeCamera(): Nullable<Camera>;
  37078. set activeCamera(value: Nullable<Camera>);
  37079. private _defaultMaterial;
  37080. /** The default material used on meshes when no material is affected */
  37081. get defaultMaterial(): Material;
  37082. /** The default material used on meshes when no material is affected */
  37083. set defaultMaterial(value: Material);
  37084. private _texturesEnabled;
  37085. /**
  37086. * Gets or sets a boolean indicating if textures are enabled on this scene
  37087. */
  37088. set texturesEnabled(value: boolean);
  37089. get texturesEnabled(): boolean;
  37090. /**
  37091. * Gets or sets a boolean indicating if particles are enabled on this scene
  37092. */
  37093. particlesEnabled: boolean;
  37094. /**
  37095. * Gets or sets a boolean indicating if sprites are enabled on this scene
  37096. */
  37097. spritesEnabled: boolean;
  37098. private _skeletonsEnabled;
  37099. /**
  37100. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  37101. */
  37102. set skeletonsEnabled(value: boolean);
  37103. get skeletonsEnabled(): boolean;
  37104. /**
  37105. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  37106. */
  37107. lensFlaresEnabled: boolean;
  37108. /**
  37109. * Gets or sets a boolean indicating if collisions are enabled on this scene
  37110. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  37111. */
  37112. collisionsEnabled: boolean;
  37113. private _collisionCoordinator;
  37114. /** @hidden */
  37115. get collisionCoordinator(): ICollisionCoordinator;
  37116. /**
  37117. * Defines the gravity applied to this scene (used only for collisions)
  37118. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  37119. */
  37120. gravity: Vector3;
  37121. /**
  37122. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  37123. */
  37124. postProcessesEnabled: boolean;
  37125. /**
  37126. * The list of postprocesses added to the scene
  37127. */
  37128. postProcesses: PostProcess[];
  37129. /**
  37130. * Gets the current postprocess manager
  37131. */
  37132. postProcessManager: PostProcessManager;
  37133. /**
  37134. * Gets or sets a boolean indicating if render targets are enabled on this scene
  37135. */
  37136. renderTargetsEnabled: boolean;
  37137. /**
  37138. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  37139. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  37140. */
  37141. dumpNextRenderTargets: boolean;
  37142. /**
  37143. * The list of user defined render targets added to the scene
  37144. */
  37145. customRenderTargets: RenderTargetTexture[];
  37146. /**
  37147. * Defines if texture loading must be delayed
  37148. * If true, textures will only be loaded when they need to be rendered
  37149. */
  37150. useDelayedTextureLoading: boolean;
  37151. /**
  37152. * Gets the list of meshes imported to the scene through SceneLoader
  37153. */
  37154. importedMeshesFiles: String[];
  37155. /**
  37156. * Gets or sets a boolean indicating if probes are enabled on this scene
  37157. */
  37158. probesEnabled: boolean;
  37159. /**
  37160. * Gets or sets the current offline provider to use to store scene data
  37161. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  37162. */
  37163. offlineProvider: IOfflineProvider;
  37164. /**
  37165. * Gets or sets the action manager associated with the scene
  37166. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  37167. */
  37168. actionManager: AbstractActionManager;
  37169. private _meshesForIntersections;
  37170. /**
  37171. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  37172. */
  37173. proceduralTexturesEnabled: boolean;
  37174. private _engine;
  37175. private _totalVertices;
  37176. /** @hidden */
  37177. _activeIndices: PerfCounter;
  37178. /** @hidden */
  37179. _activeParticles: PerfCounter;
  37180. /** @hidden */
  37181. _activeBones: PerfCounter;
  37182. private _animationRatio;
  37183. /** @hidden */
  37184. _animationTimeLast: number;
  37185. /** @hidden */
  37186. _animationTime: number;
  37187. /**
  37188. * Gets or sets a general scale for animation speed
  37189. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  37190. */
  37191. animationTimeScale: number;
  37192. /** @hidden */
  37193. _cachedMaterial: Nullable<Material>;
  37194. /** @hidden */
  37195. _cachedEffect: Nullable<Effect>;
  37196. /** @hidden */
  37197. _cachedVisibility: Nullable<number>;
  37198. private _renderId;
  37199. private _frameId;
  37200. private _executeWhenReadyTimeoutId;
  37201. private _intermediateRendering;
  37202. private _viewUpdateFlag;
  37203. private _projectionUpdateFlag;
  37204. /** @hidden */
  37205. _toBeDisposed: Nullable<IDisposable>[];
  37206. private _activeRequests;
  37207. /** @hidden */
  37208. _pendingData: any[];
  37209. private _isDisposed;
  37210. /**
  37211. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  37212. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  37213. */
  37214. dispatchAllSubMeshesOfActiveMeshes: boolean;
  37215. private _activeMeshes;
  37216. private _processedMaterials;
  37217. private _renderTargets;
  37218. /** @hidden */
  37219. _activeParticleSystems: SmartArray<IParticleSystem>;
  37220. private _activeSkeletons;
  37221. private _softwareSkinnedMeshes;
  37222. private _renderingManager;
  37223. /** @hidden */
  37224. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  37225. private _transformMatrix;
  37226. private _sceneUbo;
  37227. /** @hidden */
  37228. _viewMatrix: Matrix;
  37229. private _projectionMatrix;
  37230. /** @hidden */
  37231. _forcedViewPosition: Nullable<Vector3>;
  37232. /** @hidden */
  37233. _frustumPlanes: Plane[];
  37234. /**
  37235. * Gets the list of frustum planes (built from the active camera)
  37236. */
  37237. get frustumPlanes(): Plane[];
  37238. /**
  37239. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  37240. * This is useful if there are more lights that the maximum simulteanous authorized
  37241. */
  37242. requireLightSorting: boolean;
  37243. /** @hidden */
  37244. readonly useMaterialMeshMap: boolean;
  37245. /** @hidden */
  37246. readonly useClonedMeshMap: boolean;
  37247. private _externalData;
  37248. private _uid;
  37249. /**
  37250. * @hidden
  37251. * Backing store of defined scene components.
  37252. */
  37253. _components: ISceneComponent[];
  37254. /**
  37255. * @hidden
  37256. * Backing store of defined scene components.
  37257. */
  37258. _serializableComponents: ISceneSerializableComponent[];
  37259. /**
  37260. * List of components to register on the next registration step.
  37261. */
  37262. private _transientComponents;
  37263. /**
  37264. * Registers the transient components if needed.
  37265. */
  37266. private _registerTransientComponents;
  37267. /**
  37268. * @hidden
  37269. * Add a component to the scene.
  37270. * Note that the ccomponent could be registered on th next frame if this is called after
  37271. * the register component stage.
  37272. * @param component Defines the component to add to the scene
  37273. */
  37274. _addComponent(component: ISceneComponent): void;
  37275. /**
  37276. * @hidden
  37277. * Gets a component from the scene.
  37278. * @param name defines the name of the component to retrieve
  37279. * @returns the component or null if not present
  37280. */
  37281. _getComponent(name: string): Nullable<ISceneComponent>;
  37282. /**
  37283. * @hidden
  37284. * Defines the actions happening before camera updates.
  37285. */
  37286. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  37287. /**
  37288. * @hidden
  37289. * Defines the actions happening before clear the canvas.
  37290. */
  37291. _beforeClearStage: Stage<SimpleStageAction>;
  37292. /**
  37293. * @hidden
  37294. * Defines the actions when collecting render targets for the frame.
  37295. */
  37296. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  37297. /**
  37298. * @hidden
  37299. * Defines the actions happening for one camera in the frame.
  37300. */
  37301. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  37302. /**
  37303. * @hidden
  37304. * Defines the actions happening during the per mesh ready checks.
  37305. */
  37306. _isReadyForMeshStage: Stage<MeshStageAction>;
  37307. /**
  37308. * @hidden
  37309. * Defines the actions happening before evaluate active mesh checks.
  37310. */
  37311. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  37312. /**
  37313. * @hidden
  37314. * Defines the actions happening during the evaluate sub mesh checks.
  37315. */
  37316. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  37317. /**
  37318. * @hidden
  37319. * Defines the actions happening during the active mesh stage.
  37320. */
  37321. _activeMeshStage: Stage<ActiveMeshStageAction>;
  37322. /**
  37323. * @hidden
  37324. * Defines the actions happening during the per camera render target step.
  37325. */
  37326. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  37327. /**
  37328. * @hidden
  37329. * Defines the actions happening just before the active camera is drawing.
  37330. */
  37331. _beforeCameraDrawStage: Stage<CameraStageAction>;
  37332. /**
  37333. * @hidden
  37334. * Defines the actions happening just before a render target is drawing.
  37335. */
  37336. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  37337. /**
  37338. * @hidden
  37339. * Defines the actions happening just before a rendering group is drawing.
  37340. */
  37341. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  37342. /**
  37343. * @hidden
  37344. * Defines the actions happening just before a mesh is drawing.
  37345. */
  37346. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  37347. /**
  37348. * @hidden
  37349. * Defines the actions happening just after a mesh has been drawn.
  37350. */
  37351. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  37352. /**
  37353. * @hidden
  37354. * Defines the actions happening just after a rendering group has been drawn.
  37355. */
  37356. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  37357. /**
  37358. * @hidden
  37359. * Defines the actions happening just after the active camera has been drawn.
  37360. */
  37361. _afterCameraDrawStage: Stage<CameraStageAction>;
  37362. /**
  37363. * @hidden
  37364. * Defines the actions happening just after a render target has been drawn.
  37365. */
  37366. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  37367. /**
  37368. * @hidden
  37369. * Defines the actions happening just after rendering all cameras and computing intersections.
  37370. */
  37371. _afterRenderStage: Stage<SimpleStageAction>;
  37372. /**
  37373. * @hidden
  37374. * Defines the actions happening when a pointer move event happens.
  37375. */
  37376. _pointerMoveStage: Stage<PointerMoveStageAction>;
  37377. /**
  37378. * @hidden
  37379. * Defines the actions happening when a pointer down event happens.
  37380. */
  37381. _pointerDownStage: Stage<PointerUpDownStageAction>;
  37382. /**
  37383. * @hidden
  37384. * Defines the actions happening when a pointer up event happens.
  37385. */
  37386. _pointerUpStage: Stage<PointerUpDownStageAction>;
  37387. /**
  37388. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  37389. */
  37390. private geometriesByUniqueId;
  37391. /**
  37392. * Creates a new Scene
  37393. * @param engine defines the engine to use to render this scene
  37394. * @param options defines the scene options
  37395. */
  37396. constructor(engine: Engine, options?: SceneOptions);
  37397. /**
  37398. * Gets a string idenfifying the name of the class
  37399. * @returns "Scene" string
  37400. */
  37401. getClassName(): string;
  37402. private _defaultMeshCandidates;
  37403. /**
  37404. * @hidden
  37405. */
  37406. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  37407. private _defaultSubMeshCandidates;
  37408. /**
  37409. * @hidden
  37410. */
  37411. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  37412. /**
  37413. * Sets the default candidate providers for the scene.
  37414. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  37415. * and getCollidingSubMeshCandidates to their default function
  37416. */
  37417. setDefaultCandidateProviders(): void;
  37418. /**
  37419. * Gets the mesh that is currently under the pointer
  37420. */
  37421. get meshUnderPointer(): Nullable<AbstractMesh>;
  37422. /**
  37423. * Gets or sets the current on-screen X position of the pointer
  37424. */
  37425. get pointerX(): number;
  37426. set pointerX(value: number);
  37427. /**
  37428. * Gets or sets the current on-screen Y position of the pointer
  37429. */
  37430. get pointerY(): number;
  37431. set pointerY(value: number);
  37432. /**
  37433. * Gets the cached material (ie. the latest rendered one)
  37434. * @returns the cached material
  37435. */
  37436. getCachedMaterial(): Nullable<Material>;
  37437. /**
  37438. * Gets the cached effect (ie. the latest rendered one)
  37439. * @returns the cached effect
  37440. */
  37441. getCachedEffect(): Nullable<Effect>;
  37442. /**
  37443. * Gets the cached visibility state (ie. the latest rendered one)
  37444. * @returns the cached visibility state
  37445. */
  37446. getCachedVisibility(): Nullable<number>;
  37447. /**
  37448. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  37449. * @param material defines the current material
  37450. * @param effect defines the current effect
  37451. * @param visibility defines the current visibility state
  37452. * @returns true if one parameter is not cached
  37453. */
  37454. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  37455. /**
  37456. * Gets the engine associated with the scene
  37457. * @returns an Engine
  37458. */
  37459. getEngine(): Engine;
  37460. /**
  37461. * Gets the total number of vertices rendered per frame
  37462. * @returns the total number of vertices rendered per frame
  37463. */
  37464. getTotalVertices(): number;
  37465. /**
  37466. * Gets the performance counter for total vertices
  37467. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  37468. */
  37469. get totalVerticesPerfCounter(): PerfCounter;
  37470. /**
  37471. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  37472. * @returns the total number of active indices rendered per frame
  37473. */
  37474. getActiveIndices(): number;
  37475. /**
  37476. * Gets the performance counter for active indices
  37477. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  37478. */
  37479. get totalActiveIndicesPerfCounter(): PerfCounter;
  37480. /**
  37481. * Gets the total number of active particles rendered per frame
  37482. * @returns the total number of active particles rendered per frame
  37483. */
  37484. getActiveParticles(): number;
  37485. /**
  37486. * Gets the performance counter for active particles
  37487. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  37488. */
  37489. get activeParticlesPerfCounter(): PerfCounter;
  37490. /**
  37491. * Gets the total number of active bones rendered per frame
  37492. * @returns the total number of active bones rendered per frame
  37493. */
  37494. getActiveBones(): number;
  37495. /**
  37496. * Gets the performance counter for active bones
  37497. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  37498. */
  37499. get activeBonesPerfCounter(): PerfCounter;
  37500. /**
  37501. * Gets the array of active meshes
  37502. * @returns an array of AbstractMesh
  37503. */
  37504. getActiveMeshes(): SmartArray<AbstractMesh>;
  37505. /**
  37506. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  37507. * @returns a number
  37508. */
  37509. getAnimationRatio(): number;
  37510. /**
  37511. * Gets an unique Id for the current render phase
  37512. * @returns a number
  37513. */
  37514. getRenderId(): number;
  37515. /**
  37516. * Gets an unique Id for the current frame
  37517. * @returns a number
  37518. */
  37519. getFrameId(): number;
  37520. /** Call this function if you want to manually increment the render Id*/
  37521. incrementRenderId(): void;
  37522. private _createUbo;
  37523. /**
  37524. * Use this method to simulate a pointer move on a mesh
  37525. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  37526. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  37527. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  37528. * @returns the current scene
  37529. */
  37530. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  37531. /**
  37532. * Use this method to simulate a pointer down on a mesh
  37533. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  37534. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  37535. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  37536. * @returns the current scene
  37537. */
  37538. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  37539. /**
  37540. * Use this method to simulate a pointer up on a mesh
  37541. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  37542. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  37543. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  37544. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  37545. * @returns the current scene
  37546. */
  37547. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  37548. /**
  37549. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  37550. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  37551. * @returns true if the pointer was captured
  37552. */
  37553. isPointerCaptured(pointerId?: number): boolean;
  37554. /**
  37555. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  37556. * @param attachUp defines if you want to attach events to pointerup
  37557. * @param attachDown defines if you want to attach events to pointerdown
  37558. * @param attachMove defines if you want to attach events to pointermove
  37559. */
  37560. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  37561. /** Detaches all event handlers*/
  37562. detachControl(): void;
  37563. /**
  37564. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  37565. * Delay loaded resources are not taking in account
  37566. * @return true if all required resources are ready
  37567. */
  37568. isReady(): boolean;
  37569. /** Resets all cached information relative to material (including effect and visibility) */
  37570. resetCachedMaterial(): void;
  37571. /**
  37572. * Registers a function to be called before every frame render
  37573. * @param func defines the function to register
  37574. */
  37575. registerBeforeRender(func: () => void): void;
  37576. /**
  37577. * Unregisters a function called before every frame render
  37578. * @param func defines the function to unregister
  37579. */
  37580. unregisterBeforeRender(func: () => void): void;
  37581. /**
  37582. * Registers a function to be called after every frame render
  37583. * @param func defines the function to register
  37584. */
  37585. registerAfterRender(func: () => void): void;
  37586. /**
  37587. * Unregisters a function called after every frame render
  37588. * @param func defines the function to unregister
  37589. */
  37590. unregisterAfterRender(func: () => void): void;
  37591. private _executeOnceBeforeRender;
  37592. /**
  37593. * The provided function will run before render once and will be disposed afterwards.
  37594. * A timeout delay can be provided so that the function will be executed in N ms.
  37595. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  37596. * @param func The function to be executed.
  37597. * @param timeout optional delay in ms
  37598. */
  37599. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  37600. /** @hidden */
  37601. _addPendingData(data: any): void;
  37602. /** @hidden */
  37603. _removePendingData(data: any): void;
  37604. /**
  37605. * Returns the number of items waiting to be loaded
  37606. * @returns the number of items waiting to be loaded
  37607. */
  37608. getWaitingItemsCount(): number;
  37609. /**
  37610. * Returns a boolean indicating if the scene is still loading data
  37611. */
  37612. get isLoading(): boolean;
  37613. /**
  37614. * Registers a function to be executed when the scene is ready
  37615. * @param {Function} func - the function to be executed
  37616. */
  37617. executeWhenReady(func: () => void): void;
  37618. /**
  37619. * Returns a promise that resolves when the scene is ready
  37620. * @returns A promise that resolves when the scene is ready
  37621. */
  37622. whenReadyAsync(): Promise<void>;
  37623. /** @hidden */
  37624. _checkIsReady(): void;
  37625. /**
  37626. * Gets all animatable attached to the scene
  37627. */
  37628. get animatables(): Animatable[];
  37629. /**
  37630. * Resets the last animation time frame.
  37631. * Useful to override when animations start running when loading a scene for the first time.
  37632. */
  37633. resetLastAnimationTimeFrame(): void;
  37634. /**
  37635. * Gets the current view matrix
  37636. * @returns a Matrix
  37637. */
  37638. getViewMatrix(): Matrix;
  37639. /**
  37640. * Gets the current projection matrix
  37641. * @returns a Matrix
  37642. */
  37643. getProjectionMatrix(): Matrix;
  37644. /**
  37645. * Gets the current transform matrix
  37646. * @returns a Matrix made of View * Projection
  37647. */
  37648. getTransformMatrix(): Matrix;
  37649. /**
  37650. * Sets the current transform matrix
  37651. * @param viewL defines the View matrix to use
  37652. * @param projectionL defines the Projection matrix to use
  37653. * @param viewR defines the right View matrix to use (if provided)
  37654. * @param projectionR defines the right Projection matrix to use (if provided)
  37655. */
  37656. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  37657. /**
  37658. * Gets the uniform buffer used to store scene data
  37659. * @returns a UniformBuffer
  37660. */
  37661. getSceneUniformBuffer(): UniformBuffer;
  37662. /**
  37663. * Gets an unique (relatively to the current scene) Id
  37664. * @returns an unique number for the scene
  37665. */
  37666. getUniqueId(): number;
  37667. /**
  37668. * Add a mesh to the list of scene's meshes
  37669. * @param newMesh defines the mesh to add
  37670. * @param recursive if all child meshes should also be added to the scene
  37671. */
  37672. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  37673. /**
  37674. * Remove a mesh for the list of scene's meshes
  37675. * @param toRemove defines the mesh to remove
  37676. * @param recursive if all child meshes should also be removed from the scene
  37677. * @returns the index where the mesh was in the mesh list
  37678. */
  37679. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  37680. /**
  37681. * Add a transform node to the list of scene's transform nodes
  37682. * @param newTransformNode defines the transform node to add
  37683. */
  37684. addTransformNode(newTransformNode: TransformNode): void;
  37685. /**
  37686. * Remove a transform node for the list of scene's transform nodes
  37687. * @param toRemove defines the transform node to remove
  37688. * @returns the index where the transform node was in the transform node list
  37689. */
  37690. removeTransformNode(toRemove: TransformNode): number;
  37691. /**
  37692. * Remove a skeleton for the list of scene's skeletons
  37693. * @param toRemove defines the skeleton to remove
  37694. * @returns the index where the skeleton was in the skeleton list
  37695. */
  37696. removeSkeleton(toRemove: Skeleton): number;
  37697. /**
  37698. * Remove a morph target for the list of scene's morph targets
  37699. * @param toRemove defines the morph target to remove
  37700. * @returns the index where the morph target was in the morph target list
  37701. */
  37702. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  37703. /**
  37704. * Remove a light for the list of scene's lights
  37705. * @param toRemove defines the light to remove
  37706. * @returns the index where the light was in the light list
  37707. */
  37708. removeLight(toRemove: Light): number;
  37709. /**
  37710. * Remove a camera for the list of scene's cameras
  37711. * @param toRemove defines the camera to remove
  37712. * @returns the index where the camera was in the camera list
  37713. */
  37714. removeCamera(toRemove: Camera): number;
  37715. /**
  37716. * Remove a particle system for the list of scene's particle systems
  37717. * @param toRemove defines the particle system to remove
  37718. * @returns the index where the particle system was in the particle system list
  37719. */
  37720. removeParticleSystem(toRemove: IParticleSystem): number;
  37721. /**
  37722. * Remove a animation for the list of scene's animations
  37723. * @param toRemove defines the animation to remove
  37724. * @returns the index where the animation was in the animation list
  37725. */
  37726. removeAnimation(toRemove: Animation): number;
  37727. /**
  37728. * Will stop the animation of the given target
  37729. * @param target - the target
  37730. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  37731. * @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)
  37732. */
  37733. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  37734. /**
  37735. * Removes the given animation group from this scene.
  37736. * @param toRemove The animation group to remove
  37737. * @returns The index of the removed animation group
  37738. */
  37739. removeAnimationGroup(toRemove: AnimationGroup): number;
  37740. /**
  37741. * Removes the given multi-material from this scene.
  37742. * @param toRemove The multi-material to remove
  37743. * @returns The index of the removed multi-material
  37744. */
  37745. removeMultiMaterial(toRemove: MultiMaterial): number;
  37746. /**
  37747. * Removes the given material from this scene.
  37748. * @param toRemove The material to remove
  37749. * @returns The index of the removed material
  37750. */
  37751. removeMaterial(toRemove: Material): number;
  37752. /**
  37753. * Removes the given action manager from this scene.
  37754. * @param toRemove The action manager to remove
  37755. * @returns The index of the removed action manager
  37756. */
  37757. removeActionManager(toRemove: AbstractActionManager): number;
  37758. /**
  37759. * Removes the given texture from this scene.
  37760. * @param toRemove The texture to remove
  37761. * @returns The index of the removed texture
  37762. */
  37763. removeTexture(toRemove: BaseTexture): number;
  37764. /**
  37765. * Adds the given light to this scene
  37766. * @param newLight The light to add
  37767. */
  37768. addLight(newLight: Light): void;
  37769. /**
  37770. * Sorts the list list based on light priorities
  37771. */
  37772. sortLightsByPriority(): void;
  37773. /**
  37774. * Adds the given camera to this scene
  37775. * @param newCamera The camera to add
  37776. */
  37777. addCamera(newCamera: Camera): void;
  37778. /**
  37779. * Adds the given skeleton to this scene
  37780. * @param newSkeleton The skeleton to add
  37781. */
  37782. addSkeleton(newSkeleton: Skeleton): void;
  37783. /**
  37784. * Adds the given particle system to this scene
  37785. * @param newParticleSystem The particle system to add
  37786. */
  37787. addParticleSystem(newParticleSystem: IParticleSystem): void;
  37788. /**
  37789. * Adds the given animation to this scene
  37790. * @param newAnimation The animation to add
  37791. */
  37792. addAnimation(newAnimation: Animation): void;
  37793. /**
  37794. * Adds the given animation group to this scene.
  37795. * @param newAnimationGroup The animation group to add
  37796. */
  37797. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  37798. /**
  37799. * Adds the given multi-material to this scene
  37800. * @param newMultiMaterial The multi-material to add
  37801. */
  37802. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  37803. /**
  37804. * Adds the given material to this scene
  37805. * @param newMaterial The material to add
  37806. */
  37807. addMaterial(newMaterial: Material): void;
  37808. /**
  37809. * Adds the given morph target to this scene
  37810. * @param newMorphTargetManager The morph target to add
  37811. */
  37812. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  37813. /**
  37814. * Adds the given geometry to this scene
  37815. * @param newGeometry The geometry to add
  37816. */
  37817. addGeometry(newGeometry: Geometry): void;
  37818. /**
  37819. * Adds the given action manager to this scene
  37820. * @param newActionManager The action manager to add
  37821. */
  37822. addActionManager(newActionManager: AbstractActionManager): void;
  37823. /**
  37824. * Adds the given texture to this scene.
  37825. * @param newTexture The texture to add
  37826. */
  37827. addTexture(newTexture: BaseTexture): void;
  37828. /**
  37829. * Switch active camera
  37830. * @param newCamera defines the new active camera
  37831. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  37832. */
  37833. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  37834. /**
  37835. * sets the active camera of the scene using its ID
  37836. * @param id defines the camera's ID
  37837. * @return the new active camera or null if none found.
  37838. */
  37839. setActiveCameraByID(id: string): Nullable<Camera>;
  37840. /**
  37841. * sets the active camera of the scene using its name
  37842. * @param name defines the camera's name
  37843. * @returns the new active camera or null if none found.
  37844. */
  37845. setActiveCameraByName(name: string): Nullable<Camera>;
  37846. /**
  37847. * get an animation group using its name
  37848. * @param name defines the material's name
  37849. * @return the animation group or null if none found.
  37850. */
  37851. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  37852. /**
  37853. * Get a material using its unique id
  37854. * @param uniqueId defines the material's unique id
  37855. * @return the material or null if none found.
  37856. */
  37857. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  37858. /**
  37859. * get a material using its id
  37860. * @param id defines the material's ID
  37861. * @return the material or null if none found.
  37862. */
  37863. getMaterialByID(id: string): Nullable<Material>;
  37864. /**
  37865. * Gets a the last added material using a given id
  37866. * @param id defines the material's ID
  37867. * @return the last material with the given id or null if none found.
  37868. */
  37869. getLastMaterialByID(id: string): Nullable<Material>;
  37870. /**
  37871. * Gets a material using its name
  37872. * @param name defines the material's name
  37873. * @return the material or null if none found.
  37874. */
  37875. getMaterialByName(name: string): Nullable<Material>;
  37876. /**
  37877. * Get a texture using its unique id
  37878. * @param uniqueId defines the texture's unique id
  37879. * @return the texture or null if none found.
  37880. */
  37881. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  37882. /**
  37883. * Gets a camera using its id
  37884. * @param id defines the id to look for
  37885. * @returns the camera or null if not found
  37886. */
  37887. getCameraByID(id: string): Nullable<Camera>;
  37888. /**
  37889. * Gets a camera using its unique id
  37890. * @param uniqueId defines the unique id to look for
  37891. * @returns the camera or null if not found
  37892. */
  37893. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  37894. /**
  37895. * Gets a camera using its name
  37896. * @param name defines the camera's name
  37897. * @return the camera or null if none found.
  37898. */
  37899. getCameraByName(name: string): Nullable<Camera>;
  37900. /**
  37901. * Gets a bone using its id
  37902. * @param id defines the bone's id
  37903. * @return the bone or null if not found
  37904. */
  37905. getBoneByID(id: string): Nullable<Bone>;
  37906. /**
  37907. * Gets a bone using its id
  37908. * @param name defines the bone's name
  37909. * @return the bone or null if not found
  37910. */
  37911. getBoneByName(name: string): Nullable<Bone>;
  37912. /**
  37913. * Gets a light node using its name
  37914. * @param name defines the the light's name
  37915. * @return the light or null if none found.
  37916. */
  37917. getLightByName(name: string): Nullable<Light>;
  37918. /**
  37919. * Gets a light node using its id
  37920. * @param id defines the light's id
  37921. * @return the light or null if none found.
  37922. */
  37923. getLightByID(id: string): Nullable<Light>;
  37924. /**
  37925. * Gets a light node using its scene-generated unique ID
  37926. * @param uniqueId defines the light's unique id
  37927. * @return the light or null if none found.
  37928. */
  37929. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  37930. /**
  37931. * Gets a particle system by id
  37932. * @param id defines the particle system id
  37933. * @return the corresponding system or null if none found
  37934. */
  37935. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  37936. /**
  37937. * Gets a geometry using its ID
  37938. * @param id defines the geometry's id
  37939. * @return the geometry or null if none found.
  37940. */
  37941. getGeometryByID(id: string): Nullable<Geometry>;
  37942. private _getGeometryByUniqueID;
  37943. /**
  37944. * Add a new geometry to this scene
  37945. * @param geometry defines the geometry to be added to the scene.
  37946. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  37947. * @return a boolean defining if the geometry was added or not
  37948. */
  37949. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  37950. /**
  37951. * Removes an existing geometry
  37952. * @param geometry defines the geometry to be removed from the scene
  37953. * @return a boolean defining if the geometry was removed or not
  37954. */
  37955. removeGeometry(geometry: Geometry): boolean;
  37956. /**
  37957. * Gets the list of geometries attached to the scene
  37958. * @returns an array of Geometry
  37959. */
  37960. getGeometries(): Geometry[];
  37961. /**
  37962. * Gets the first added mesh found of a given ID
  37963. * @param id defines the id to search for
  37964. * @return the mesh found or null if not found at all
  37965. */
  37966. getMeshByID(id: string): Nullable<AbstractMesh>;
  37967. /**
  37968. * Gets a list of meshes using their id
  37969. * @param id defines the id to search for
  37970. * @returns a list of meshes
  37971. */
  37972. getMeshesByID(id: string): Array<AbstractMesh>;
  37973. /**
  37974. * Gets the first added transform node found of a given ID
  37975. * @param id defines the id to search for
  37976. * @return the found transform node or null if not found at all.
  37977. */
  37978. getTransformNodeByID(id: string): Nullable<TransformNode>;
  37979. /**
  37980. * Gets a transform node with its auto-generated unique id
  37981. * @param uniqueId efines the unique id to search for
  37982. * @return the found transform node or null if not found at all.
  37983. */
  37984. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  37985. /**
  37986. * Gets a list of transform nodes using their id
  37987. * @param id defines the id to search for
  37988. * @returns a list of transform nodes
  37989. */
  37990. getTransformNodesByID(id: string): Array<TransformNode>;
  37991. /**
  37992. * Gets a mesh with its auto-generated unique id
  37993. * @param uniqueId defines the unique id to search for
  37994. * @return the found mesh or null if not found at all.
  37995. */
  37996. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  37997. /**
  37998. * Gets a the last added mesh using a given id
  37999. * @param id defines the id to search for
  38000. * @return the found mesh or null if not found at all.
  38001. */
  38002. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  38003. /**
  38004. * Gets a the last added node (Mesh, Camera, Light) using a given id
  38005. * @param id defines the id to search for
  38006. * @return the found node or null if not found at all
  38007. */
  38008. getLastEntryByID(id: string): Nullable<Node>;
  38009. /**
  38010. * Gets a node (Mesh, Camera, Light) using a given id
  38011. * @param id defines the id to search for
  38012. * @return the found node or null if not found at all
  38013. */
  38014. getNodeByID(id: string): Nullable<Node>;
  38015. /**
  38016. * Gets a node (Mesh, Camera, Light) using a given name
  38017. * @param name defines the name to search for
  38018. * @return the found node or null if not found at all.
  38019. */
  38020. getNodeByName(name: string): Nullable<Node>;
  38021. /**
  38022. * Gets a mesh using a given name
  38023. * @param name defines the name to search for
  38024. * @return the found mesh or null if not found at all.
  38025. */
  38026. getMeshByName(name: string): Nullable<AbstractMesh>;
  38027. /**
  38028. * Gets a transform node using a given name
  38029. * @param name defines the name to search for
  38030. * @return the found transform node or null if not found at all.
  38031. */
  38032. getTransformNodeByName(name: string): Nullable<TransformNode>;
  38033. /**
  38034. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  38035. * @param id defines the id to search for
  38036. * @return the found skeleton or null if not found at all.
  38037. */
  38038. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  38039. /**
  38040. * Gets a skeleton using a given auto generated unique id
  38041. * @param uniqueId defines the unique id to search for
  38042. * @return the found skeleton or null if not found at all.
  38043. */
  38044. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  38045. /**
  38046. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  38047. * @param id defines the id to search for
  38048. * @return the found skeleton or null if not found at all.
  38049. */
  38050. getSkeletonById(id: string): Nullable<Skeleton>;
  38051. /**
  38052. * Gets a skeleton using a given name
  38053. * @param name defines the name to search for
  38054. * @return the found skeleton or null if not found at all.
  38055. */
  38056. getSkeletonByName(name: string): Nullable<Skeleton>;
  38057. /**
  38058. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  38059. * @param id defines the id to search for
  38060. * @return the found morph target manager or null if not found at all.
  38061. */
  38062. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  38063. /**
  38064. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  38065. * @param id defines the id to search for
  38066. * @return the found morph target or null if not found at all.
  38067. */
  38068. getMorphTargetById(id: string): Nullable<MorphTarget>;
  38069. /**
  38070. * Gets a boolean indicating if the given mesh is active
  38071. * @param mesh defines the mesh to look for
  38072. * @returns true if the mesh is in the active list
  38073. */
  38074. isActiveMesh(mesh: AbstractMesh): boolean;
  38075. /**
  38076. * Return a unique id as a string which can serve as an identifier for the scene
  38077. */
  38078. get uid(): string;
  38079. /**
  38080. * Add an externaly attached data from its key.
  38081. * This method call will fail and return false, if such key already exists.
  38082. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  38083. * @param key the unique key that identifies the data
  38084. * @param data the data object to associate to the key for this Engine instance
  38085. * @return true if no such key were already present and the data was added successfully, false otherwise
  38086. */
  38087. addExternalData<T>(key: string, data: T): boolean;
  38088. /**
  38089. * Get an externaly attached data from its key
  38090. * @param key the unique key that identifies the data
  38091. * @return the associated data, if present (can be null), or undefined if not present
  38092. */
  38093. getExternalData<T>(key: string): Nullable<T>;
  38094. /**
  38095. * Get an externaly attached data from its key, create it using a factory if it's not already present
  38096. * @param key the unique key that identifies the data
  38097. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  38098. * @return the associated data, can be null if the factory returned null.
  38099. */
  38100. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  38101. /**
  38102. * Remove an externaly attached data from the Engine instance
  38103. * @param key the unique key that identifies the data
  38104. * @return true if the data was successfully removed, false if it doesn't exist
  38105. */
  38106. removeExternalData(key: string): boolean;
  38107. private _evaluateSubMesh;
  38108. /**
  38109. * Clear the processed materials smart array preventing retention point in material dispose.
  38110. */
  38111. freeProcessedMaterials(): void;
  38112. private _preventFreeActiveMeshesAndRenderingGroups;
  38113. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  38114. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  38115. * when disposing several meshes in a row or a hierarchy of meshes.
  38116. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  38117. */
  38118. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  38119. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  38120. /**
  38121. * Clear the active meshes smart array preventing retention point in mesh dispose.
  38122. */
  38123. freeActiveMeshes(): void;
  38124. /**
  38125. * Clear the info related to rendering groups preventing retention points during dispose.
  38126. */
  38127. freeRenderingGroups(): void;
  38128. /** @hidden */
  38129. _isInIntermediateRendering(): boolean;
  38130. /**
  38131. * Lambda returning the list of potentially active meshes.
  38132. */
  38133. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  38134. /**
  38135. * Lambda returning the list of potentially active sub meshes.
  38136. */
  38137. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  38138. /**
  38139. * Lambda returning the list of potentially intersecting sub meshes.
  38140. */
  38141. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  38142. /**
  38143. * Lambda returning the list of potentially colliding sub meshes.
  38144. */
  38145. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  38146. private _activeMeshesFrozen;
  38147. private _skipEvaluateActiveMeshesCompletely;
  38148. /**
  38149. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  38150. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  38151. * @returns the current scene
  38152. */
  38153. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  38154. /**
  38155. * Use this function to restart evaluating active meshes on every frame
  38156. * @returns the current scene
  38157. */
  38158. unfreezeActiveMeshes(): Scene;
  38159. private _evaluateActiveMeshes;
  38160. private _activeMesh;
  38161. /**
  38162. * Update the transform matrix to update from the current active camera
  38163. * @param force defines a boolean used to force the update even if cache is up to date
  38164. */
  38165. updateTransformMatrix(force?: boolean): void;
  38166. private _bindFrameBuffer;
  38167. /** @hidden */
  38168. _allowPostProcessClearColor: boolean;
  38169. /** @hidden */
  38170. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  38171. private _processSubCameras;
  38172. private _checkIntersections;
  38173. /** @hidden */
  38174. _advancePhysicsEngineStep(step: number): void;
  38175. /**
  38176. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  38177. */
  38178. getDeterministicFrameTime: () => number;
  38179. /** @hidden */
  38180. _animate(): void;
  38181. /** Execute all animations (for a frame) */
  38182. animate(): void;
  38183. /**
  38184. * Render the scene
  38185. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  38186. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  38187. */
  38188. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  38189. /**
  38190. * Freeze all materials
  38191. * A frozen material will not be updatable but should be faster to render
  38192. */
  38193. freezeMaterials(): void;
  38194. /**
  38195. * Unfreeze all materials
  38196. * A frozen material will not be updatable but should be faster to render
  38197. */
  38198. unfreezeMaterials(): void;
  38199. /**
  38200. * Releases all held ressources
  38201. */
  38202. dispose(): void;
  38203. /**
  38204. * Gets if the scene is already disposed
  38205. */
  38206. get isDisposed(): boolean;
  38207. /**
  38208. * Call this function to reduce memory footprint of the scene.
  38209. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  38210. */
  38211. clearCachedVertexData(): void;
  38212. /**
  38213. * This function will remove the local cached buffer data from texture.
  38214. * It will save memory but will prevent the texture from being rebuilt
  38215. */
  38216. cleanCachedTextureBuffer(): void;
  38217. /**
  38218. * Get the world extend vectors with an optional filter
  38219. *
  38220. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  38221. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  38222. */
  38223. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  38224. min: Vector3;
  38225. max: Vector3;
  38226. };
  38227. /**
  38228. * Creates a ray that can be used to pick in the scene
  38229. * @param x defines the x coordinate of the origin (on-screen)
  38230. * @param y defines the y coordinate of the origin (on-screen)
  38231. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  38232. * @param camera defines the camera to use for the picking
  38233. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  38234. * @returns a Ray
  38235. */
  38236. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  38237. /**
  38238. * Creates a ray that can be used to pick in the scene
  38239. * @param x defines the x coordinate of the origin (on-screen)
  38240. * @param y defines the y coordinate of the origin (on-screen)
  38241. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  38242. * @param result defines the ray where to store the picking ray
  38243. * @param camera defines the camera to use for the picking
  38244. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  38245. * @returns the current scene
  38246. */
  38247. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  38248. /**
  38249. * Creates a ray that can be used to pick in the scene
  38250. * @param x defines the x coordinate of the origin (on-screen)
  38251. * @param y defines the y coordinate of the origin (on-screen)
  38252. * @param camera defines the camera to use for the picking
  38253. * @returns a Ray
  38254. */
  38255. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  38256. /**
  38257. * Creates a ray that can be used to pick in the scene
  38258. * @param x defines the x coordinate of the origin (on-screen)
  38259. * @param y defines the y coordinate of the origin (on-screen)
  38260. * @param result defines the ray where to store the picking ray
  38261. * @param camera defines the camera to use for the picking
  38262. * @returns the current scene
  38263. */
  38264. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  38265. /** Launch a ray to try to pick a mesh in the scene
  38266. * @param x position on screen
  38267. * @param y position on screen
  38268. * @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
  38269. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  38270. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  38271. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  38272. * @returns a PickingInfo
  38273. */
  38274. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  38275. /** Use the given ray to pick a mesh in the scene
  38276. * @param ray The ray to use to pick meshes
  38277. * @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
  38278. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  38279. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  38280. * @returns a PickingInfo
  38281. */
  38282. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  38283. /**
  38284. * Launch a ray to try to pick a mesh in the scene
  38285. * @param x X position on screen
  38286. * @param y Y position on screen
  38287. * @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
  38288. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  38289. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  38290. * @returns an array of PickingInfo
  38291. */
  38292. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  38293. /**
  38294. * Launch a ray to try to pick a mesh in the scene
  38295. * @param ray Ray to use
  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 trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  38298. * @returns an array of PickingInfo
  38299. */
  38300. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  38301. /**
  38302. * Force the value of meshUnderPointer
  38303. * @param mesh defines the mesh to use
  38304. */
  38305. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  38306. /**
  38307. * Gets the mesh under the pointer
  38308. * @returns a Mesh or null if no mesh is under the pointer
  38309. */
  38310. getPointerOverMesh(): Nullable<AbstractMesh>;
  38311. /** @hidden */
  38312. _rebuildGeometries(): void;
  38313. /** @hidden */
  38314. _rebuildTextures(): void;
  38315. private _getByTags;
  38316. /**
  38317. * Get a list of meshes by tags
  38318. * @param tagsQuery defines the tags query to use
  38319. * @param forEach defines a predicate used to filter results
  38320. * @returns an array of Mesh
  38321. */
  38322. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  38323. /**
  38324. * Get a list of cameras by tags
  38325. * @param tagsQuery defines the tags query to use
  38326. * @param forEach defines a predicate used to filter results
  38327. * @returns an array of Camera
  38328. */
  38329. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  38330. /**
  38331. * Get a list of lights by tags
  38332. * @param tagsQuery defines the tags query to use
  38333. * @param forEach defines a predicate used to filter results
  38334. * @returns an array of Light
  38335. */
  38336. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  38337. /**
  38338. * Get a list of materials by tags
  38339. * @param tagsQuery defines the tags query to use
  38340. * @param forEach defines a predicate used to filter results
  38341. * @returns an array of Material
  38342. */
  38343. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  38344. /**
  38345. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  38346. * This allowed control for front to back rendering or reversly depending of the special needs.
  38347. *
  38348. * @param renderingGroupId The rendering group id corresponding to its index
  38349. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  38350. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  38351. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  38352. */
  38353. 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;
  38354. /**
  38355. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  38356. *
  38357. * @param renderingGroupId The rendering group id corresponding to its index
  38358. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  38359. * @param depth Automatically clears depth between groups if true and autoClear is true.
  38360. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  38361. */
  38362. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  38363. /**
  38364. * Gets the current auto clear configuration for one rendering group of the rendering
  38365. * manager.
  38366. * @param index the rendering group index to get the information for
  38367. * @returns The auto clear setup for the requested rendering group
  38368. */
  38369. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  38370. private _blockMaterialDirtyMechanism;
  38371. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  38372. get blockMaterialDirtyMechanism(): boolean;
  38373. set blockMaterialDirtyMechanism(value: boolean);
  38374. /**
  38375. * Will flag all materials as dirty to trigger new shader compilation
  38376. * @param flag defines the flag used to specify which material part must be marked as dirty
  38377. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  38378. */
  38379. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  38380. /** @hidden */
  38381. _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;
  38382. /** @hidden */
  38383. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  38384. /** @hidden */
  38385. _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;
  38386. /** @hidden */
  38387. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  38388. /** @hidden */
  38389. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  38390. /** @hidden */
  38391. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  38392. }
  38393. }
  38394. declare module "babylonjs/assetContainer" {
  38395. import { AbstractScene } from "babylonjs/abstractScene";
  38396. import { Scene } from "babylonjs/scene";
  38397. import { Mesh } from "babylonjs/Meshes/mesh";
  38398. import { TransformNode } from "babylonjs/Meshes/transformNode";
  38399. import { Skeleton } from "babylonjs/Bones/skeleton";
  38400. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  38401. import { Animatable } from "babylonjs/Animations/animatable";
  38402. import { Nullable } from "babylonjs/types";
  38403. import { Node } from "babylonjs/node";
  38404. /**
  38405. * Set of assets to keep when moving a scene into an asset container.
  38406. */
  38407. export class KeepAssets extends AbstractScene {
  38408. }
  38409. /**
  38410. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  38411. */
  38412. export class InstantiatedEntries {
  38413. /**
  38414. * List of new root nodes (eg. nodes with no parent)
  38415. */
  38416. rootNodes: TransformNode[];
  38417. /**
  38418. * List of new skeletons
  38419. */
  38420. skeletons: Skeleton[];
  38421. /**
  38422. * List of new animation groups
  38423. */
  38424. animationGroups: AnimationGroup[];
  38425. }
  38426. /**
  38427. * Container with a set of assets that can be added or removed from a scene.
  38428. */
  38429. export class AssetContainer extends AbstractScene {
  38430. private _wasAddedToScene;
  38431. /**
  38432. * The scene the AssetContainer belongs to.
  38433. */
  38434. scene: Scene;
  38435. /**
  38436. * Instantiates an AssetContainer.
  38437. * @param scene The scene the AssetContainer belongs to.
  38438. */
  38439. constructor(scene: Scene);
  38440. /**
  38441. * Instantiate or clone all meshes and add the new ones to the scene.
  38442. * Skeletons and animation groups will all be cloned
  38443. * @param nameFunction defines an optional function used to get new names for clones
  38444. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  38445. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  38446. */
  38447. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  38448. /**
  38449. * Adds all the assets from the container to the scene.
  38450. */
  38451. addAllToScene(): void;
  38452. /**
  38453. * Removes all the assets in the container from the scene
  38454. */
  38455. removeAllFromScene(): void;
  38456. /**
  38457. * Disposes all the assets in the container
  38458. */
  38459. dispose(): void;
  38460. private _moveAssets;
  38461. /**
  38462. * Removes all the assets contained in the scene and adds them to the container.
  38463. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  38464. */
  38465. moveAllFromScene(keepAssets?: KeepAssets): void;
  38466. /**
  38467. * 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.
  38468. * @returns the root mesh
  38469. */
  38470. createRootMesh(): Mesh;
  38471. /**
  38472. * Merge animations from this asset container into a scene
  38473. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  38474. * @param animatables set of animatables to retarget to a node from the scene
  38475. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  38476. */
  38477. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): void;
  38478. }
  38479. }
  38480. declare module "babylonjs/abstractScene" {
  38481. import { Scene } from "babylonjs/scene";
  38482. import { Nullable } from "babylonjs/types";
  38483. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38484. import { TransformNode } from "babylonjs/Meshes/transformNode";
  38485. import { Geometry } from "babylonjs/Meshes/geometry";
  38486. import { Skeleton } from "babylonjs/Bones/skeleton";
  38487. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  38488. import { AssetContainer } from "babylonjs/assetContainer";
  38489. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  38490. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  38491. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  38492. import { Material } from "babylonjs/Materials/material";
  38493. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  38494. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  38495. import { Camera } from "babylonjs/Cameras/camera";
  38496. import { Light } from "babylonjs/Lights/light";
  38497. import { Node } from "babylonjs/node";
  38498. import { Animation } from "babylonjs/Animations/animation";
  38499. /**
  38500. * Defines how the parser contract is defined.
  38501. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  38502. */
  38503. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  38504. /**
  38505. * Defines how the individual parser contract is defined.
  38506. * These parser can parse an individual asset
  38507. */
  38508. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  38509. /**
  38510. * Base class of the scene acting as a container for the different elements composing a scene.
  38511. * This class is dynamically extended by the different components of the scene increasing
  38512. * flexibility and reducing coupling
  38513. */
  38514. export abstract class AbstractScene {
  38515. /**
  38516. * Stores the list of available parsers in the application.
  38517. */
  38518. private static _BabylonFileParsers;
  38519. /**
  38520. * Stores the list of available individual parsers in the application.
  38521. */
  38522. private static _IndividualBabylonFileParsers;
  38523. /**
  38524. * Adds a parser in the list of available ones
  38525. * @param name Defines the name of the parser
  38526. * @param parser Defines the parser to add
  38527. */
  38528. static AddParser(name: string, parser: BabylonFileParser): void;
  38529. /**
  38530. * Gets a general parser from the list of avaialble ones
  38531. * @param name Defines the name of the parser
  38532. * @returns the requested parser or null
  38533. */
  38534. static GetParser(name: string): Nullable<BabylonFileParser>;
  38535. /**
  38536. * Adds n individual parser in the list of available ones
  38537. * @param name Defines the name of the parser
  38538. * @param parser Defines the parser to add
  38539. */
  38540. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  38541. /**
  38542. * Gets an individual parser from the list of avaialble ones
  38543. * @param name Defines the name of the parser
  38544. * @returns the requested parser or null
  38545. */
  38546. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  38547. /**
  38548. * Parser json data and populate both a scene and its associated container object
  38549. * @param jsonData Defines the data to parse
  38550. * @param scene Defines the scene to parse the data for
  38551. * @param container Defines the container attached to the parsing sequence
  38552. * @param rootUrl Defines the root url of the data
  38553. */
  38554. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  38555. /**
  38556. * Gets the list of root nodes (ie. nodes with no parent)
  38557. */
  38558. rootNodes: Node[];
  38559. /** All of the cameras added to this scene
  38560. * @see http://doc.babylonjs.com/babylon101/cameras
  38561. */
  38562. cameras: Camera[];
  38563. /**
  38564. * All of the lights added to this scene
  38565. * @see http://doc.babylonjs.com/babylon101/lights
  38566. */
  38567. lights: Light[];
  38568. /**
  38569. * All of the (abstract) meshes added to this scene
  38570. */
  38571. meshes: AbstractMesh[];
  38572. /**
  38573. * The list of skeletons added to the scene
  38574. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  38575. */
  38576. skeletons: Skeleton[];
  38577. /**
  38578. * All of the particle systems added to this scene
  38579. * @see http://doc.babylonjs.com/babylon101/particles
  38580. */
  38581. particleSystems: IParticleSystem[];
  38582. /**
  38583. * Gets a list of Animations associated with the scene
  38584. */
  38585. animations: Animation[];
  38586. /**
  38587. * All of the animation groups added to this scene
  38588. * @see http://doc.babylonjs.com/how_to/group
  38589. */
  38590. animationGroups: AnimationGroup[];
  38591. /**
  38592. * All of the multi-materials added to this scene
  38593. * @see http://doc.babylonjs.com/how_to/multi_materials
  38594. */
  38595. multiMaterials: MultiMaterial[];
  38596. /**
  38597. * All of the materials added to this scene
  38598. * In the context of a Scene, it is not supposed to be modified manually.
  38599. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  38600. * Note also that the order of the Material within the array is not significant and might change.
  38601. * @see http://doc.babylonjs.com/babylon101/materials
  38602. */
  38603. materials: Material[];
  38604. /**
  38605. * The list of morph target managers added to the scene
  38606. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  38607. */
  38608. morphTargetManagers: MorphTargetManager[];
  38609. /**
  38610. * The list of geometries used in the scene.
  38611. */
  38612. geometries: Geometry[];
  38613. /**
  38614. * All of the tranform nodes added to this scene
  38615. * In the context of a Scene, it is not supposed to be modified manually.
  38616. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  38617. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  38618. * @see http://doc.babylonjs.com/how_to/transformnode
  38619. */
  38620. transformNodes: TransformNode[];
  38621. /**
  38622. * ActionManagers available on the scene.
  38623. */
  38624. actionManagers: AbstractActionManager[];
  38625. /**
  38626. * Textures to keep.
  38627. */
  38628. textures: BaseTexture[];
  38629. /**
  38630. * Environment texture for the scene
  38631. */
  38632. environmentTexture: Nullable<BaseTexture>;
  38633. /**
  38634. * @returns all meshes, lights, cameras, transformNodes and bones
  38635. */
  38636. getNodes(): Array<Node>;
  38637. }
  38638. }
  38639. declare module "babylonjs/Audio/sound" {
  38640. import { Observable } from "babylonjs/Misc/observable";
  38641. import { Vector3 } from "babylonjs/Maths/math.vector";
  38642. import { Nullable } from "babylonjs/types";
  38643. import { Scene } from "babylonjs/scene";
  38644. import { TransformNode } from "babylonjs/Meshes/transformNode";
  38645. /**
  38646. * Interface used to define options for Sound class
  38647. */
  38648. export interface ISoundOptions {
  38649. /**
  38650. * Does the sound autoplay once loaded.
  38651. */
  38652. autoplay?: boolean;
  38653. /**
  38654. * Does the sound loop after it finishes playing once.
  38655. */
  38656. loop?: boolean;
  38657. /**
  38658. * Sound's volume
  38659. */
  38660. volume?: number;
  38661. /**
  38662. * Is it a spatial sound?
  38663. */
  38664. spatialSound?: boolean;
  38665. /**
  38666. * Maximum distance to hear that sound
  38667. */
  38668. maxDistance?: number;
  38669. /**
  38670. * Uses user defined attenuation function
  38671. */
  38672. useCustomAttenuation?: boolean;
  38673. /**
  38674. * Define the roll off factor of spatial sounds.
  38675. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38676. */
  38677. rolloffFactor?: number;
  38678. /**
  38679. * Define the reference distance the sound should be heard perfectly.
  38680. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38681. */
  38682. refDistance?: number;
  38683. /**
  38684. * Define the distance attenuation model the sound will follow.
  38685. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38686. */
  38687. distanceModel?: string;
  38688. /**
  38689. * Defines the playback speed (1 by default)
  38690. */
  38691. playbackRate?: number;
  38692. /**
  38693. * Defines if the sound is from a streaming source
  38694. */
  38695. streaming?: boolean;
  38696. /**
  38697. * Defines an optional length (in seconds) inside the sound file
  38698. */
  38699. length?: number;
  38700. /**
  38701. * Defines an optional offset (in seconds) inside the sound file
  38702. */
  38703. offset?: number;
  38704. /**
  38705. * If true, URLs will not be required to state the audio file codec to use.
  38706. */
  38707. skipCodecCheck?: boolean;
  38708. }
  38709. /**
  38710. * Defines a sound that can be played in the application.
  38711. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  38712. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38713. */
  38714. export class Sound {
  38715. /**
  38716. * The name of the sound in the scene.
  38717. */
  38718. name: string;
  38719. /**
  38720. * Does the sound autoplay once loaded.
  38721. */
  38722. autoplay: boolean;
  38723. /**
  38724. * Does the sound loop after it finishes playing once.
  38725. */
  38726. loop: boolean;
  38727. /**
  38728. * Does the sound use a custom attenuation curve to simulate the falloff
  38729. * happening when the source gets further away from the camera.
  38730. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  38731. */
  38732. useCustomAttenuation: boolean;
  38733. /**
  38734. * The sound track id this sound belongs to.
  38735. */
  38736. soundTrackId: number;
  38737. /**
  38738. * Is this sound currently played.
  38739. */
  38740. isPlaying: boolean;
  38741. /**
  38742. * Is this sound currently paused.
  38743. */
  38744. isPaused: boolean;
  38745. /**
  38746. * Does this sound enables spatial sound.
  38747. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38748. */
  38749. spatialSound: boolean;
  38750. /**
  38751. * Define the reference distance the sound should be heard perfectly.
  38752. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38753. */
  38754. refDistance: number;
  38755. /**
  38756. * Define the roll off factor of spatial sounds.
  38757. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38758. */
  38759. rolloffFactor: number;
  38760. /**
  38761. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  38762. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38763. */
  38764. maxDistance: number;
  38765. /**
  38766. * Define the distance attenuation model the sound will follow.
  38767. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38768. */
  38769. distanceModel: string;
  38770. /**
  38771. * @hidden
  38772. * Back Compat
  38773. **/
  38774. onended: () => any;
  38775. /**
  38776. * Observable event when the current playing sound finishes.
  38777. */
  38778. onEndedObservable: Observable<Sound>;
  38779. private _panningModel;
  38780. private _playbackRate;
  38781. private _streaming;
  38782. private _startTime;
  38783. private _startOffset;
  38784. private _position;
  38785. /** @hidden */
  38786. _positionInEmitterSpace: boolean;
  38787. private _localDirection;
  38788. private _volume;
  38789. private _isReadyToPlay;
  38790. private _isDirectional;
  38791. private _readyToPlayCallback;
  38792. private _audioBuffer;
  38793. private _soundSource;
  38794. private _streamingSource;
  38795. private _soundPanner;
  38796. private _soundGain;
  38797. private _inputAudioNode;
  38798. private _outputAudioNode;
  38799. private _coneInnerAngle;
  38800. private _coneOuterAngle;
  38801. private _coneOuterGain;
  38802. private _scene;
  38803. private _connectedTransformNode;
  38804. private _customAttenuationFunction;
  38805. private _registerFunc;
  38806. private _isOutputConnected;
  38807. private _htmlAudioElement;
  38808. private _urlType;
  38809. private _length?;
  38810. private _offset?;
  38811. /** @hidden */
  38812. static _SceneComponentInitialization: (scene: Scene) => void;
  38813. /**
  38814. * Create a sound and attach it to a scene
  38815. * @param name Name of your sound
  38816. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  38817. * @param scene defines the scene the sound belongs to
  38818. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  38819. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  38820. */
  38821. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  38822. /**
  38823. * Release the sound and its associated resources
  38824. */
  38825. dispose(): void;
  38826. /**
  38827. * Gets if the sounds is ready to be played or not.
  38828. * @returns true if ready, otherwise false
  38829. */
  38830. isReady(): boolean;
  38831. private _soundLoaded;
  38832. /**
  38833. * Sets the data of the sound from an audiobuffer
  38834. * @param audioBuffer The audioBuffer containing the data
  38835. */
  38836. setAudioBuffer(audioBuffer: AudioBuffer): void;
  38837. /**
  38838. * Updates the current sounds options such as maxdistance, loop...
  38839. * @param options A JSON object containing values named as the object properties
  38840. */
  38841. updateOptions(options: ISoundOptions): void;
  38842. private _createSpatialParameters;
  38843. private _updateSpatialParameters;
  38844. /**
  38845. * Switch the panning model to HRTF:
  38846. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  38847. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38848. */
  38849. switchPanningModelToHRTF(): void;
  38850. /**
  38851. * Switch the panning model to Equal Power:
  38852. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  38853. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38854. */
  38855. switchPanningModelToEqualPower(): void;
  38856. private _switchPanningModel;
  38857. /**
  38858. * Connect this sound to a sound track audio node like gain...
  38859. * @param soundTrackAudioNode the sound track audio node to connect to
  38860. */
  38861. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  38862. /**
  38863. * Transform this sound into a directional source
  38864. * @param coneInnerAngle Size of the inner cone in degree
  38865. * @param coneOuterAngle Size of the outer cone in degree
  38866. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  38867. */
  38868. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  38869. /**
  38870. * Gets or sets the inner angle for the directional cone.
  38871. */
  38872. get directionalConeInnerAngle(): number;
  38873. /**
  38874. * Gets or sets the inner angle for the directional cone.
  38875. */
  38876. set directionalConeInnerAngle(value: number);
  38877. /**
  38878. * Gets or sets the outer angle for the directional cone.
  38879. */
  38880. get directionalConeOuterAngle(): number;
  38881. /**
  38882. * Gets or sets the outer angle for the directional cone.
  38883. */
  38884. set directionalConeOuterAngle(value: number);
  38885. /**
  38886. * Sets the position of the emitter if spatial sound is enabled
  38887. * @param newPosition Defines the new posisiton
  38888. */
  38889. setPosition(newPosition: Vector3): void;
  38890. /**
  38891. * Sets the local direction of the emitter if spatial sound is enabled
  38892. * @param newLocalDirection Defines the new local direction
  38893. */
  38894. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  38895. private _updateDirection;
  38896. /** @hidden */
  38897. updateDistanceFromListener(): void;
  38898. /**
  38899. * Sets a new custom attenuation function for the sound.
  38900. * @param callback Defines the function used for the attenuation
  38901. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  38902. */
  38903. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  38904. /**
  38905. * Play the sound
  38906. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  38907. * @param offset (optional) Start the sound at a specific time in seconds
  38908. * @param length (optional) Sound duration (in seconds)
  38909. */
  38910. play(time?: number, offset?: number, length?: number): void;
  38911. private _onended;
  38912. /**
  38913. * Stop the sound
  38914. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  38915. */
  38916. stop(time?: number): void;
  38917. /**
  38918. * Put the sound in pause
  38919. */
  38920. pause(): void;
  38921. /**
  38922. * Sets a dedicated volume for this sounds
  38923. * @param newVolume Define the new volume of the sound
  38924. * @param time Define time for gradual change to new volume
  38925. */
  38926. setVolume(newVolume: number, time?: number): void;
  38927. /**
  38928. * Set the sound play back rate
  38929. * @param newPlaybackRate Define the playback rate the sound should be played at
  38930. */
  38931. setPlaybackRate(newPlaybackRate: number): void;
  38932. /**
  38933. * Gets the volume of the sound.
  38934. * @returns the volume of the sound
  38935. */
  38936. getVolume(): number;
  38937. /**
  38938. * Attach the sound to a dedicated mesh
  38939. * @param transformNode The transform node to connect the sound with
  38940. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  38941. */
  38942. attachToMesh(transformNode: TransformNode): void;
  38943. /**
  38944. * Detach the sound from the previously attached mesh
  38945. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  38946. */
  38947. detachFromMesh(): void;
  38948. private _onRegisterAfterWorldMatrixUpdate;
  38949. /**
  38950. * Clone the current sound in the scene.
  38951. * @returns the new sound clone
  38952. */
  38953. clone(): Nullable<Sound>;
  38954. /**
  38955. * Gets the current underlying audio buffer containing the data
  38956. * @returns the audio buffer
  38957. */
  38958. getAudioBuffer(): Nullable<AudioBuffer>;
  38959. /**
  38960. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  38961. * @returns the source node
  38962. */
  38963. getSoundSource(): Nullable<AudioBufferSourceNode>;
  38964. /**
  38965. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  38966. * @returns the gain node
  38967. */
  38968. getSoundGain(): Nullable<GainNode>;
  38969. /**
  38970. * Serializes the Sound in a JSON representation
  38971. * @returns the JSON representation of the sound
  38972. */
  38973. serialize(): any;
  38974. /**
  38975. * Parse a JSON representation of a sound to innstantiate in a given scene
  38976. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  38977. * @param scene Define the scene the new parsed sound should be created in
  38978. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  38979. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  38980. * @returns the newly parsed sound
  38981. */
  38982. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  38983. }
  38984. }
  38985. declare module "babylonjs/Actions/directAudioActions" {
  38986. import { Action } from "babylonjs/Actions/action";
  38987. import { Condition } from "babylonjs/Actions/condition";
  38988. import { Sound } from "babylonjs/Audio/sound";
  38989. /**
  38990. * This defines an action helpful to play a defined sound on a triggered action.
  38991. */
  38992. export class PlaySoundAction extends Action {
  38993. private _sound;
  38994. /**
  38995. * Instantiate the action
  38996. * @param triggerOptions defines the trigger options
  38997. * @param sound defines the sound to play
  38998. * @param condition defines the trigger related conditions
  38999. */
  39000. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  39001. /** @hidden */
  39002. _prepare(): void;
  39003. /**
  39004. * Execute the action and play the sound.
  39005. */
  39006. execute(): void;
  39007. /**
  39008. * Serializes the actions and its related information.
  39009. * @param parent defines the object to serialize in
  39010. * @returns the serialized object
  39011. */
  39012. serialize(parent: any): any;
  39013. }
  39014. /**
  39015. * This defines an action helpful to stop a defined sound on a triggered action.
  39016. */
  39017. export class StopSoundAction extends Action {
  39018. private _sound;
  39019. /**
  39020. * Instantiate the action
  39021. * @param triggerOptions defines the trigger options
  39022. * @param sound defines the sound to stop
  39023. * @param condition defines the trigger related conditions
  39024. */
  39025. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  39026. /** @hidden */
  39027. _prepare(): void;
  39028. /**
  39029. * Execute the action and stop the sound.
  39030. */
  39031. execute(): void;
  39032. /**
  39033. * Serializes the actions and its related information.
  39034. * @param parent defines the object to serialize in
  39035. * @returns the serialized object
  39036. */
  39037. serialize(parent: any): any;
  39038. }
  39039. }
  39040. declare module "babylonjs/Actions/interpolateValueAction" {
  39041. import { Action } from "babylonjs/Actions/action";
  39042. import { Condition } from "babylonjs/Actions/condition";
  39043. import { Observable } from "babylonjs/Misc/observable";
  39044. /**
  39045. * This defines an action responsible to change the value of a property
  39046. * by interpolating between its current value and the newly set one once triggered.
  39047. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  39048. */
  39049. export class InterpolateValueAction extends Action {
  39050. /**
  39051. * Defines the path of the property where the value should be interpolated
  39052. */
  39053. propertyPath: string;
  39054. /**
  39055. * Defines the target value at the end of the interpolation.
  39056. */
  39057. value: any;
  39058. /**
  39059. * Defines the time it will take for the property to interpolate to the value.
  39060. */
  39061. duration: number;
  39062. /**
  39063. * Defines if the other scene animations should be stopped when the action has been triggered
  39064. */
  39065. stopOtherAnimations?: boolean;
  39066. /**
  39067. * Defines a callback raised once the interpolation animation has been done.
  39068. */
  39069. onInterpolationDone?: () => void;
  39070. /**
  39071. * Observable triggered once the interpolation animation has been done.
  39072. */
  39073. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  39074. private _target;
  39075. private _effectiveTarget;
  39076. private _property;
  39077. /**
  39078. * Instantiate the action
  39079. * @param triggerOptions defines the trigger options
  39080. * @param target defines the object containing the value to interpolate
  39081. * @param propertyPath defines the path to the property in the target object
  39082. * @param value defines the target value at the end of the interpolation
  39083. * @param duration deines the time it will take for the property to interpolate to the value.
  39084. * @param condition defines the trigger related conditions
  39085. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  39086. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  39087. */
  39088. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  39089. /** @hidden */
  39090. _prepare(): void;
  39091. /**
  39092. * Execute the action starts the value interpolation.
  39093. */
  39094. execute(): void;
  39095. /**
  39096. * Serializes the actions and its related information.
  39097. * @param parent defines the object to serialize in
  39098. * @returns the serialized object
  39099. */
  39100. serialize(parent: any): any;
  39101. }
  39102. }
  39103. declare module "babylonjs/Actions/index" {
  39104. export * from "babylonjs/Actions/abstractActionManager";
  39105. export * from "babylonjs/Actions/action";
  39106. export * from "babylonjs/Actions/actionEvent";
  39107. export * from "babylonjs/Actions/actionManager";
  39108. export * from "babylonjs/Actions/condition";
  39109. export * from "babylonjs/Actions/directActions";
  39110. export * from "babylonjs/Actions/directAudioActions";
  39111. export * from "babylonjs/Actions/interpolateValueAction";
  39112. }
  39113. declare module "babylonjs/Animations/index" {
  39114. export * from "babylonjs/Animations/animatable";
  39115. export * from "babylonjs/Animations/animation";
  39116. export * from "babylonjs/Animations/animationGroup";
  39117. export * from "babylonjs/Animations/animationPropertiesOverride";
  39118. export * from "babylonjs/Animations/easing";
  39119. export * from "babylonjs/Animations/runtimeAnimation";
  39120. export * from "babylonjs/Animations/animationEvent";
  39121. export * from "babylonjs/Animations/animationGroup";
  39122. export * from "babylonjs/Animations/animationKey";
  39123. export * from "babylonjs/Animations/animationRange";
  39124. export * from "babylonjs/Animations/animatable.interface";
  39125. }
  39126. declare module "babylonjs/Audio/soundTrack" {
  39127. import { Sound } from "babylonjs/Audio/sound";
  39128. import { Analyser } from "babylonjs/Audio/analyser";
  39129. import { Scene } from "babylonjs/scene";
  39130. /**
  39131. * Options allowed during the creation of a sound track.
  39132. */
  39133. export interface ISoundTrackOptions {
  39134. /**
  39135. * The volume the sound track should take during creation
  39136. */
  39137. volume?: number;
  39138. /**
  39139. * Define if the sound track is the main sound track of the scene
  39140. */
  39141. mainTrack?: boolean;
  39142. }
  39143. /**
  39144. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  39145. * It will be also used in a future release to apply effects on a specific track.
  39146. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  39147. */
  39148. export class SoundTrack {
  39149. /**
  39150. * The unique identifier of the sound track in the scene.
  39151. */
  39152. id: number;
  39153. /**
  39154. * The list of sounds included in the sound track.
  39155. */
  39156. soundCollection: Array<Sound>;
  39157. private _outputAudioNode;
  39158. private _scene;
  39159. private _connectedAnalyser;
  39160. private _options;
  39161. private _isInitialized;
  39162. /**
  39163. * Creates a new sound track.
  39164. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  39165. * @param scene Define the scene the sound track belongs to
  39166. * @param options
  39167. */
  39168. constructor(scene: Scene, options?: ISoundTrackOptions);
  39169. private _initializeSoundTrackAudioGraph;
  39170. /**
  39171. * Release the sound track and its associated resources
  39172. */
  39173. dispose(): void;
  39174. /**
  39175. * Adds a sound to this sound track
  39176. * @param sound define the cound to add
  39177. * @ignoreNaming
  39178. */
  39179. AddSound(sound: Sound): void;
  39180. /**
  39181. * Removes a sound to this sound track
  39182. * @param sound define the cound to remove
  39183. * @ignoreNaming
  39184. */
  39185. RemoveSound(sound: Sound): void;
  39186. /**
  39187. * Set a global volume for the full sound track.
  39188. * @param newVolume Define the new volume of the sound track
  39189. */
  39190. setVolume(newVolume: number): void;
  39191. /**
  39192. * Switch the panning model to HRTF:
  39193. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  39194. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  39195. */
  39196. switchPanningModelToHRTF(): void;
  39197. /**
  39198. * Switch the panning model to Equal Power:
  39199. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  39200. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  39201. */
  39202. switchPanningModelToEqualPower(): void;
  39203. /**
  39204. * Connect the sound track to an audio analyser allowing some amazing
  39205. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  39206. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  39207. * @param analyser The analyser to connect to the engine
  39208. */
  39209. connectToAnalyser(analyser: Analyser): void;
  39210. }
  39211. }
  39212. declare module "babylonjs/Audio/audioSceneComponent" {
  39213. import { Sound } from "babylonjs/Audio/sound";
  39214. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  39215. import { Nullable } from "babylonjs/types";
  39216. import { Vector3 } from "babylonjs/Maths/math.vector";
  39217. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  39218. import { Scene } from "babylonjs/scene";
  39219. import { AbstractScene } from "babylonjs/abstractScene";
  39220. import "babylonjs/Audio/audioEngine";
  39221. module "babylonjs/abstractScene" {
  39222. interface AbstractScene {
  39223. /**
  39224. * The list of sounds used in the scene.
  39225. */
  39226. sounds: Nullable<Array<Sound>>;
  39227. }
  39228. }
  39229. module "babylonjs/scene" {
  39230. interface Scene {
  39231. /**
  39232. * @hidden
  39233. * Backing field
  39234. */
  39235. _mainSoundTrack: SoundTrack;
  39236. /**
  39237. * The main sound track played by the scene.
  39238. * It cotains your primary collection of sounds.
  39239. */
  39240. mainSoundTrack: SoundTrack;
  39241. /**
  39242. * The list of sound tracks added to the scene
  39243. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  39244. */
  39245. soundTracks: Nullable<Array<SoundTrack>>;
  39246. /**
  39247. * Gets a sound using a given name
  39248. * @param name defines the name to search for
  39249. * @return the found sound or null if not found at all.
  39250. */
  39251. getSoundByName(name: string): Nullable<Sound>;
  39252. /**
  39253. * Gets or sets if audio support is enabled
  39254. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  39255. */
  39256. audioEnabled: boolean;
  39257. /**
  39258. * Gets or sets if audio will be output to headphones
  39259. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  39260. */
  39261. headphone: boolean;
  39262. /**
  39263. * Gets or sets custom audio listener position provider
  39264. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  39265. */
  39266. audioListenerPositionProvider: Nullable<() => Vector3>;
  39267. /**
  39268. * Gets or sets a refresh rate when using 3D audio positioning
  39269. */
  39270. audioPositioningRefreshRate: number;
  39271. }
  39272. }
  39273. /**
  39274. * Defines the sound scene component responsible to manage any sounds
  39275. * in a given scene.
  39276. */
  39277. export class AudioSceneComponent implements ISceneSerializableComponent {
  39278. /**
  39279. * The component name helpfull to identify the component in the list of scene components.
  39280. */
  39281. readonly name: string;
  39282. /**
  39283. * The scene the component belongs to.
  39284. */
  39285. scene: Scene;
  39286. private _audioEnabled;
  39287. /**
  39288. * Gets whether audio is enabled or not.
  39289. * Please use related enable/disable method to switch state.
  39290. */
  39291. get audioEnabled(): boolean;
  39292. private _headphone;
  39293. /**
  39294. * Gets whether audio is outputing to headphone or not.
  39295. * Please use the according Switch methods to change output.
  39296. */
  39297. get headphone(): boolean;
  39298. /**
  39299. * Gets or sets a refresh rate when using 3D audio positioning
  39300. */
  39301. audioPositioningRefreshRate: number;
  39302. private _audioListenerPositionProvider;
  39303. /**
  39304. * Gets the current audio listener position provider
  39305. */
  39306. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  39307. /**
  39308. * Sets a custom listener position for all sounds in the scene
  39309. * By default, this is the position of the first active camera
  39310. */
  39311. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  39312. /**
  39313. * Creates a new instance of the component for the given scene
  39314. * @param scene Defines the scene to register the component in
  39315. */
  39316. constructor(scene: Scene);
  39317. /**
  39318. * Registers the component in a given scene
  39319. */
  39320. register(): void;
  39321. /**
  39322. * Rebuilds the elements related to this component in case of
  39323. * context lost for instance.
  39324. */
  39325. rebuild(): void;
  39326. /**
  39327. * Serializes the component data to the specified json object
  39328. * @param serializationObject The object to serialize to
  39329. */
  39330. serialize(serializationObject: any): void;
  39331. /**
  39332. * Adds all the elements from the container to the scene
  39333. * @param container the container holding the elements
  39334. */
  39335. addFromContainer(container: AbstractScene): void;
  39336. /**
  39337. * Removes all the elements in the container from the scene
  39338. * @param container contains the elements to remove
  39339. * @param dispose if the removed element should be disposed (default: false)
  39340. */
  39341. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  39342. /**
  39343. * Disposes the component and the associated ressources.
  39344. */
  39345. dispose(): void;
  39346. /**
  39347. * Disables audio in the associated scene.
  39348. */
  39349. disableAudio(): void;
  39350. /**
  39351. * Enables audio in the associated scene.
  39352. */
  39353. enableAudio(): void;
  39354. /**
  39355. * Switch audio to headphone output.
  39356. */
  39357. switchAudioModeForHeadphones(): void;
  39358. /**
  39359. * Switch audio to normal speakers.
  39360. */
  39361. switchAudioModeForNormalSpeakers(): void;
  39362. private _cachedCameraDirection;
  39363. private _cachedCameraPosition;
  39364. private _lastCheck;
  39365. private _afterRender;
  39366. }
  39367. }
  39368. declare module "babylonjs/Audio/weightedsound" {
  39369. import { Sound } from "babylonjs/Audio/sound";
  39370. /**
  39371. * Wraps one or more Sound objects and selects one with random weight for playback.
  39372. */
  39373. export class WeightedSound {
  39374. /** When true a Sound will be selected and played when the current playing Sound completes. */
  39375. loop: boolean;
  39376. private _coneInnerAngle;
  39377. private _coneOuterAngle;
  39378. private _volume;
  39379. /** A Sound is currently playing. */
  39380. isPlaying: boolean;
  39381. /** A Sound is currently paused. */
  39382. isPaused: boolean;
  39383. private _sounds;
  39384. private _weights;
  39385. private _currentIndex?;
  39386. /**
  39387. * Creates a new WeightedSound from the list of sounds given.
  39388. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  39389. * @param sounds Array of Sounds that will be selected from.
  39390. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  39391. */
  39392. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  39393. /**
  39394. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  39395. */
  39396. get directionalConeInnerAngle(): number;
  39397. /**
  39398. * The size of cone in degress for a directional sound in which there will be no attenuation.
  39399. */
  39400. set directionalConeInnerAngle(value: number);
  39401. /**
  39402. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  39403. * Listener angles between innerAngle and outerAngle will falloff linearly.
  39404. */
  39405. get directionalConeOuterAngle(): number;
  39406. /**
  39407. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  39408. * Listener angles between innerAngle and outerAngle will falloff linearly.
  39409. */
  39410. set directionalConeOuterAngle(value: number);
  39411. /**
  39412. * Playback volume.
  39413. */
  39414. get volume(): number;
  39415. /**
  39416. * Playback volume.
  39417. */
  39418. set volume(value: number);
  39419. private _onended;
  39420. /**
  39421. * Suspend playback
  39422. */
  39423. pause(): void;
  39424. /**
  39425. * Stop playback
  39426. */
  39427. stop(): void;
  39428. /**
  39429. * Start playback.
  39430. * @param startOffset Position the clip head at a specific time in seconds.
  39431. */
  39432. play(startOffset?: number): void;
  39433. }
  39434. }
  39435. declare module "babylonjs/Audio/index" {
  39436. export * from "babylonjs/Audio/analyser";
  39437. export * from "babylonjs/Audio/audioEngine";
  39438. export * from "babylonjs/Audio/audioSceneComponent";
  39439. export * from "babylonjs/Audio/sound";
  39440. export * from "babylonjs/Audio/soundTrack";
  39441. export * from "babylonjs/Audio/weightedsound";
  39442. }
  39443. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  39444. import { Behavior } from "babylonjs/Behaviors/behavior";
  39445. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39446. import { BackEase } from "babylonjs/Animations/easing";
  39447. /**
  39448. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  39449. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  39450. */
  39451. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  39452. /**
  39453. * Gets the name of the behavior.
  39454. */
  39455. get name(): string;
  39456. /**
  39457. * The easing function used by animations
  39458. */
  39459. static EasingFunction: BackEase;
  39460. /**
  39461. * The easing mode used by animations
  39462. */
  39463. static EasingMode: number;
  39464. /**
  39465. * The duration of the animation, in milliseconds
  39466. */
  39467. transitionDuration: number;
  39468. /**
  39469. * Length of the distance animated by the transition when lower radius is reached
  39470. */
  39471. lowerRadiusTransitionRange: number;
  39472. /**
  39473. * Length of the distance animated by the transition when upper radius is reached
  39474. */
  39475. upperRadiusTransitionRange: number;
  39476. private _autoTransitionRange;
  39477. /**
  39478. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  39479. */
  39480. get autoTransitionRange(): boolean;
  39481. /**
  39482. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  39483. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  39484. */
  39485. set autoTransitionRange(value: boolean);
  39486. private _attachedCamera;
  39487. private _onAfterCheckInputsObserver;
  39488. private _onMeshTargetChangedObserver;
  39489. /**
  39490. * Initializes the behavior.
  39491. */
  39492. init(): void;
  39493. /**
  39494. * Attaches the behavior to its arc rotate camera.
  39495. * @param camera Defines the camera to attach the behavior to
  39496. */
  39497. attach(camera: ArcRotateCamera): void;
  39498. /**
  39499. * Detaches the behavior from its current arc rotate camera.
  39500. */
  39501. detach(): void;
  39502. private _radiusIsAnimating;
  39503. private _radiusBounceTransition;
  39504. private _animatables;
  39505. private _cachedWheelPrecision;
  39506. /**
  39507. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  39508. * @param radiusLimit The limit to check against.
  39509. * @return Bool to indicate if at limit.
  39510. */
  39511. private _isRadiusAtLimit;
  39512. /**
  39513. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  39514. * @param radiusDelta The delta by which to animate to. Can be negative.
  39515. */
  39516. private _applyBoundRadiusAnimation;
  39517. /**
  39518. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  39519. */
  39520. protected _clearAnimationLocks(): void;
  39521. /**
  39522. * Stops and removes all animations that have been applied to the camera
  39523. */
  39524. stopAllAnimations(): void;
  39525. }
  39526. }
  39527. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  39528. import { Behavior } from "babylonjs/Behaviors/behavior";
  39529. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39530. import { ExponentialEase } from "babylonjs/Animations/easing";
  39531. import { Nullable } from "babylonjs/types";
  39532. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39533. import { Vector3 } from "babylonjs/Maths/math.vector";
  39534. /**
  39535. * 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.
  39536. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  39537. */
  39538. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  39539. /**
  39540. * Gets the name of the behavior.
  39541. */
  39542. get name(): string;
  39543. private _mode;
  39544. private _radiusScale;
  39545. private _positionScale;
  39546. private _defaultElevation;
  39547. private _elevationReturnTime;
  39548. private _elevationReturnWaitTime;
  39549. private _zoomStopsAnimation;
  39550. private _framingTime;
  39551. /**
  39552. * The easing function used by animations
  39553. */
  39554. static EasingFunction: ExponentialEase;
  39555. /**
  39556. * The easing mode used by animations
  39557. */
  39558. static EasingMode: number;
  39559. /**
  39560. * Sets the current mode used by the behavior
  39561. */
  39562. set mode(mode: number);
  39563. /**
  39564. * Gets current mode used by the behavior.
  39565. */
  39566. get mode(): number;
  39567. /**
  39568. * Sets the scale applied to the radius (1 by default)
  39569. */
  39570. set radiusScale(radius: number);
  39571. /**
  39572. * Gets the scale applied to the radius
  39573. */
  39574. get radiusScale(): number;
  39575. /**
  39576. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  39577. */
  39578. set positionScale(scale: number);
  39579. /**
  39580. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  39581. */
  39582. get positionScale(): number;
  39583. /**
  39584. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  39585. * behaviour is triggered, in radians.
  39586. */
  39587. set defaultElevation(elevation: number);
  39588. /**
  39589. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  39590. * behaviour is triggered, in radians.
  39591. */
  39592. get defaultElevation(): number;
  39593. /**
  39594. * Sets the time (in milliseconds) taken to return to the default beta position.
  39595. * Negative value indicates camera should not return to default.
  39596. */
  39597. set elevationReturnTime(speed: number);
  39598. /**
  39599. * Gets the time (in milliseconds) taken to return to the default beta position.
  39600. * Negative value indicates camera should not return to default.
  39601. */
  39602. get elevationReturnTime(): number;
  39603. /**
  39604. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  39605. */
  39606. set elevationReturnWaitTime(time: number);
  39607. /**
  39608. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  39609. */
  39610. get elevationReturnWaitTime(): number;
  39611. /**
  39612. * Sets the flag that indicates if user zooming should stop animation.
  39613. */
  39614. set zoomStopsAnimation(flag: boolean);
  39615. /**
  39616. * Gets the flag that indicates if user zooming should stop animation.
  39617. */
  39618. get zoomStopsAnimation(): boolean;
  39619. /**
  39620. * Sets the transition time when framing the mesh, in milliseconds
  39621. */
  39622. set framingTime(time: number);
  39623. /**
  39624. * Gets the transition time when framing the mesh, in milliseconds
  39625. */
  39626. get framingTime(): number;
  39627. /**
  39628. * Define if the behavior should automatically change the configured
  39629. * camera limits and sensibilities.
  39630. */
  39631. autoCorrectCameraLimitsAndSensibility: boolean;
  39632. private _onPrePointerObservableObserver;
  39633. private _onAfterCheckInputsObserver;
  39634. private _onMeshTargetChangedObserver;
  39635. private _attachedCamera;
  39636. private _isPointerDown;
  39637. private _lastInteractionTime;
  39638. /**
  39639. * Initializes the behavior.
  39640. */
  39641. init(): void;
  39642. /**
  39643. * Attaches the behavior to its arc rotate camera.
  39644. * @param camera Defines the camera to attach the behavior to
  39645. */
  39646. attach(camera: ArcRotateCamera): void;
  39647. /**
  39648. * Detaches the behavior from its current arc rotate camera.
  39649. */
  39650. detach(): void;
  39651. private _animatables;
  39652. private _betaIsAnimating;
  39653. private _betaTransition;
  39654. private _radiusTransition;
  39655. private _vectorTransition;
  39656. /**
  39657. * Targets the given mesh and updates zoom level accordingly.
  39658. * @param mesh The mesh to target.
  39659. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39660. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39661. */
  39662. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39663. /**
  39664. * Targets the given mesh with its children and updates zoom level accordingly.
  39665. * @param mesh The mesh to target.
  39666. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39667. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39668. */
  39669. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39670. /**
  39671. * Targets the given meshes with their children and updates zoom level accordingly.
  39672. * @param meshes The mesh to target.
  39673. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39674. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39675. */
  39676. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39677. /**
  39678. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  39679. * @param minimumWorld Determines the smaller position of the bounding box extend
  39680. * @param maximumWorld Determines the bigger position of the bounding box extend
  39681. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39682. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39683. */
  39684. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39685. /**
  39686. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  39687. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  39688. * frustum width.
  39689. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  39690. * to fully enclose the mesh in the viewing frustum.
  39691. */
  39692. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  39693. /**
  39694. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  39695. * is automatically returned to its default position (expected to be above ground plane).
  39696. */
  39697. private _maintainCameraAboveGround;
  39698. /**
  39699. * Returns the frustum slope based on the canvas ratio and camera FOV
  39700. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  39701. */
  39702. private _getFrustumSlope;
  39703. /**
  39704. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  39705. */
  39706. private _clearAnimationLocks;
  39707. /**
  39708. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  39709. */
  39710. private _applyUserInteraction;
  39711. /**
  39712. * Stops and removes all animations that have been applied to the camera
  39713. */
  39714. stopAllAnimations(): void;
  39715. /**
  39716. * Gets a value indicating if the user is moving the camera
  39717. */
  39718. get isUserIsMoving(): boolean;
  39719. /**
  39720. * The camera can move all the way towards the mesh.
  39721. */
  39722. static IgnoreBoundsSizeMode: number;
  39723. /**
  39724. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  39725. */
  39726. static FitFrustumSidesMode: number;
  39727. }
  39728. }
  39729. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  39730. import { Nullable } from "babylonjs/types";
  39731. import { Camera } from "babylonjs/Cameras/camera";
  39732. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39733. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  39734. /**
  39735. * Base class for Camera Pointer Inputs.
  39736. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  39737. * for example usage.
  39738. */
  39739. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  39740. /**
  39741. * Defines the camera the input is attached to.
  39742. */
  39743. abstract camera: Camera;
  39744. /**
  39745. * Whether keyboard modifier keys are pressed at time of last mouse event.
  39746. */
  39747. protected _altKey: boolean;
  39748. protected _ctrlKey: boolean;
  39749. protected _metaKey: boolean;
  39750. protected _shiftKey: boolean;
  39751. /**
  39752. * Which mouse buttons were pressed at time of last mouse event.
  39753. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  39754. */
  39755. protected _buttonsPressed: number;
  39756. /**
  39757. * Defines the buttons associated with the input to handle camera move.
  39758. */
  39759. buttons: number[];
  39760. /**
  39761. * Attach the input controls to a specific dom element to get the input from.
  39762. * @param element Defines the element the controls should be listened from
  39763. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39764. */
  39765. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39766. /**
  39767. * Detach the current controls from the specified dom element.
  39768. * @param element Defines the element to stop listening the inputs from
  39769. */
  39770. detachControl(element: Nullable<HTMLElement>): void;
  39771. /**
  39772. * Gets the class name of the current input.
  39773. * @returns the class name
  39774. */
  39775. getClassName(): string;
  39776. /**
  39777. * Get the friendly name associated with the input class.
  39778. * @returns the input friendly name
  39779. */
  39780. getSimpleName(): string;
  39781. /**
  39782. * Called on pointer POINTERDOUBLETAP event.
  39783. * Override this method to provide functionality on POINTERDOUBLETAP event.
  39784. */
  39785. protected onDoubleTap(type: string): void;
  39786. /**
  39787. * Called on pointer POINTERMOVE event if only a single touch is active.
  39788. * Override this method to provide functionality.
  39789. */
  39790. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  39791. /**
  39792. * Called on pointer POINTERMOVE event if multiple touches are active.
  39793. * Override this method to provide functionality.
  39794. */
  39795. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  39796. /**
  39797. * Called on JS contextmenu event.
  39798. * Override this method to provide functionality.
  39799. */
  39800. protected onContextMenu(evt: PointerEvent): void;
  39801. /**
  39802. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  39803. * press.
  39804. * Override this method to provide functionality.
  39805. */
  39806. protected onButtonDown(evt: PointerEvent): void;
  39807. /**
  39808. * Called each time a new POINTERUP event occurs. Ie, for each button
  39809. * release.
  39810. * Override this method to provide functionality.
  39811. */
  39812. protected onButtonUp(evt: PointerEvent): void;
  39813. /**
  39814. * Called when window becomes inactive.
  39815. * Override this method to provide functionality.
  39816. */
  39817. protected onLostFocus(): void;
  39818. private _pointerInput;
  39819. private _observer;
  39820. private _onLostFocus;
  39821. private pointA;
  39822. private pointB;
  39823. }
  39824. }
  39825. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  39826. import { Nullable } from "babylonjs/types";
  39827. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39828. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  39829. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  39830. /**
  39831. * Manage the pointers inputs to control an arc rotate camera.
  39832. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39833. */
  39834. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  39835. /**
  39836. * Defines the camera the input is attached to.
  39837. */
  39838. camera: ArcRotateCamera;
  39839. /**
  39840. * Gets the class name of the current input.
  39841. * @returns the class name
  39842. */
  39843. getClassName(): string;
  39844. /**
  39845. * Defines the buttons associated with the input to handle camera move.
  39846. */
  39847. buttons: number[];
  39848. /**
  39849. * Defines the pointer angular sensibility along the X axis or how fast is
  39850. * the camera rotating.
  39851. */
  39852. angularSensibilityX: number;
  39853. /**
  39854. * Defines the pointer angular sensibility along the Y axis or how fast is
  39855. * the camera rotating.
  39856. */
  39857. angularSensibilityY: number;
  39858. /**
  39859. * Defines the pointer pinch precision or how fast is the camera zooming.
  39860. */
  39861. pinchPrecision: number;
  39862. /**
  39863. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  39864. * from 0.
  39865. * It defines the percentage of current camera.radius to use as delta when
  39866. * pinch zoom is used.
  39867. */
  39868. pinchDeltaPercentage: number;
  39869. /**
  39870. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  39871. * that any object in the plane at the camera's target point will scale
  39872. * perfectly with finger motion.
  39873. * Overrides pinchDeltaPercentage and pinchPrecision.
  39874. */
  39875. useNaturalPinchZoom: boolean;
  39876. /**
  39877. * Defines the pointer panning sensibility or how fast is the camera moving.
  39878. */
  39879. panningSensibility: number;
  39880. /**
  39881. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  39882. */
  39883. multiTouchPanning: boolean;
  39884. /**
  39885. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  39886. * zoom (pinch) through multitouch.
  39887. */
  39888. multiTouchPanAndZoom: boolean;
  39889. /**
  39890. * Revers pinch action direction.
  39891. */
  39892. pinchInwards: boolean;
  39893. private _isPanClick;
  39894. private _twoFingerActivityCount;
  39895. private _isPinching;
  39896. /**
  39897. * Called on pointer POINTERMOVE event if only a single touch is active.
  39898. */
  39899. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  39900. /**
  39901. * Called on pointer POINTERDOUBLETAP event.
  39902. */
  39903. protected onDoubleTap(type: string): void;
  39904. /**
  39905. * Called on pointer POINTERMOVE event if multiple touches are active.
  39906. */
  39907. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  39908. /**
  39909. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  39910. * press.
  39911. */
  39912. protected onButtonDown(evt: PointerEvent): void;
  39913. /**
  39914. * Called each time a new POINTERUP event occurs. Ie, for each button
  39915. * release.
  39916. */
  39917. protected onButtonUp(evt: PointerEvent): void;
  39918. /**
  39919. * Called when window becomes inactive.
  39920. */
  39921. protected onLostFocus(): void;
  39922. }
  39923. }
  39924. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  39925. import { Nullable } from "babylonjs/types";
  39926. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39927. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39928. /**
  39929. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  39930. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39931. */
  39932. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  39933. /**
  39934. * Defines the camera the input is attached to.
  39935. */
  39936. camera: ArcRotateCamera;
  39937. /**
  39938. * Defines the list of key codes associated with the up action (increase alpha)
  39939. */
  39940. keysUp: number[];
  39941. /**
  39942. * Defines the list of key codes associated with the down action (decrease alpha)
  39943. */
  39944. keysDown: number[];
  39945. /**
  39946. * Defines the list of key codes associated with the left action (increase beta)
  39947. */
  39948. keysLeft: number[];
  39949. /**
  39950. * Defines the list of key codes associated with the right action (decrease beta)
  39951. */
  39952. keysRight: number[];
  39953. /**
  39954. * Defines the list of key codes associated with the reset action.
  39955. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  39956. */
  39957. keysReset: number[];
  39958. /**
  39959. * Defines the panning sensibility of the inputs.
  39960. * (How fast is the camera panning)
  39961. */
  39962. panningSensibility: number;
  39963. /**
  39964. * Defines the zooming sensibility of the inputs.
  39965. * (How fast is the camera zooming)
  39966. */
  39967. zoomingSensibility: number;
  39968. /**
  39969. * Defines whether maintaining the alt key down switch the movement mode from
  39970. * orientation to zoom.
  39971. */
  39972. useAltToZoom: boolean;
  39973. /**
  39974. * Rotation speed of the camera
  39975. */
  39976. angularSpeed: number;
  39977. private _keys;
  39978. private _ctrlPressed;
  39979. private _altPressed;
  39980. private _onCanvasBlurObserver;
  39981. private _onKeyboardObserver;
  39982. private _engine;
  39983. private _scene;
  39984. /**
  39985. * Attach the input controls to a specific dom element to get the input from.
  39986. * @param element Defines the element the controls should be listened from
  39987. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39988. */
  39989. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39990. /**
  39991. * Detach the current controls from the specified dom element.
  39992. * @param element Defines the element to stop listening the inputs from
  39993. */
  39994. detachControl(element: Nullable<HTMLElement>): void;
  39995. /**
  39996. * Update the current camera state depending on the inputs that have been used this frame.
  39997. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39998. */
  39999. checkInputs(): void;
  40000. /**
  40001. * Gets the class name of the current intput.
  40002. * @returns the class name
  40003. */
  40004. getClassName(): string;
  40005. /**
  40006. * Get the friendly name associated with the input class.
  40007. * @returns the input friendly name
  40008. */
  40009. getSimpleName(): string;
  40010. }
  40011. }
  40012. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  40013. import { Nullable } from "babylonjs/types";
  40014. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40015. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40016. /**
  40017. * Manage the mouse wheel inputs to control an arc rotate camera.
  40018. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40019. */
  40020. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  40021. /**
  40022. * Defines the camera the input is attached to.
  40023. */
  40024. camera: ArcRotateCamera;
  40025. /**
  40026. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  40027. */
  40028. wheelPrecision: number;
  40029. /**
  40030. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  40031. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  40032. */
  40033. wheelDeltaPercentage: number;
  40034. private _wheel;
  40035. private _observer;
  40036. private computeDeltaFromMouseWheelLegacyEvent;
  40037. /**
  40038. * Attach the input controls to a specific dom element to get the input from.
  40039. * @param element Defines the element the controls should be listened from
  40040. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40041. */
  40042. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40043. /**
  40044. * Detach the current controls from the specified dom element.
  40045. * @param element Defines the element to stop listening the inputs from
  40046. */
  40047. detachControl(element: Nullable<HTMLElement>): void;
  40048. /**
  40049. * Gets the class name of the current intput.
  40050. * @returns the class name
  40051. */
  40052. getClassName(): string;
  40053. /**
  40054. * Get the friendly name associated with the input class.
  40055. * @returns the input friendly name
  40056. */
  40057. getSimpleName(): string;
  40058. }
  40059. }
  40060. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  40061. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40062. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  40063. /**
  40064. * Default Inputs manager for the ArcRotateCamera.
  40065. * It groups all the default supported inputs for ease of use.
  40066. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40067. */
  40068. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  40069. /**
  40070. * Instantiates a new ArcRotateCameraInputsManager.
  40071. * @param camera Defines the camera the inputs belong to
  40072. */
  40073. constructor(camera: ArcRotateCamera);
  40074. /**
  40075. * Add mouse wheel input support to the input manager.
  40076. * @returns the current input manager
  40077. */
  40078. addMouseWheel(): ArcRotateCameraInputsManager;
  40079. /**
  40080. * Add pointers input support to the input manager.
  40081. * @returns the current input manager
  40082. */
  40083. addPointers(): ArcRotateCameraInputsManager;
  40084. /**
  40085. * Add keyboard input support to the input manager.
  40086. * @returns the current input manager
  40087. */
  40088. addKeyboard(): ArcRotateCameraInputsManager;
  40089. }
  40090. }
  40091. declare module "babylonjs/Cameras/arcRotateCamera" {
  40092. import { Observable } from "babylonjs/Misc/observable";
  40093. import { Nullable } from "babylonjs/types";
  40094. import { Scene } from "babylonjs/scene";
  40095. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  40096. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40097. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  40098. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  40099. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  40100. import { Camera } from "babylonjs/Cameras/camera";
  40101. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  40102. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  40103. import { Collider } from "babylonjs/Collisions/collider";
  40104. /**
  40105. * This represents an orbital type of camera.
  40106. *
  40107. * 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.
  40108. * 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.
  40109. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  40110. */
  40111. export class ArcRotateCamera extends TargetCamera {
  40112. /**
  40113. * Defines the rotation angle of the camera along the longitudinal axis.
  40114. */
  40115. alpha: number;
  40116. /**
  40117. * Defines the rotation angle of the camera along the latitudinal axis.
  40118. */
  40119. beta: number;
  40120. /**
  40121. * Defines the radius of the camera from it s target point.
  40122. */
  40123. radius: number;
  40124. protected _target: Vector3;
  40125. protected _targetHost: Nullable<AbstractMesh>;
  40126. /**
  40127. * Defines the target point of the camera.
  40128. * The camera looks towards it form the radius distance.
  40129. */
  40130. get target(): Vector3;
  40131. set target(value: Vector3);
  40132. /**
  40133. * Define the current local position of the camera in the scene
  40134. */
  40135. get position(): Vector3;
  40136. set position(newPosition: Vector3);
  40137. protected _upVector: Vector3;
  40138. protected _upToYMatrix: Matrix;
  40139. protected _YToUpMatrix: Matrix;
  40140. /**
  40141. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  40142. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  40143. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  40144. */
  40145. set upVector(vec: Vector3);
  40146. get upVector(): Vector3;
  40147. /**
  40148. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  40149. */
  40150. setMatUp(): void;
  40151. /**
  40152. * Current inertia value on the longitudinal axis.
  40153. * The bigger this number the longer it will take for the camera to stop.
  40154. */
  40155. inertialAlphaOffset: number;
  40156. /**
  40157. * Current inertia value on the latitudinal axis.
  40158. * The bigger this number the longer it will take for the camera to stop.
  40159. */
  40160. inertialBetaOffset: number;
  40161. /**
  40162. * Current inertia value on the radius axis.
  40163. * The bigger this number the longer it will take for the camera to stop.
  40164. */
  40165. inertialRadiusOffset: number;
  40166. /**
  40167. * Minimum allowed angle on the longitudinal axis.
  40168. * This can help limiting how the Camera is able to move in the scene.
  40169. */
  40170. lowerAlphaLimit: Nullable<number>;
  40171. /**
  40172. * Maximum allowed angle on the longitudinal axis.
  40173. * This can help limiting how the Camera is able to move in the scene.
  40174. */
  40175. upperAlphaLimit: Nullable<number>;
  40176. /**
  40177. * Minimum allowed angle on the latitudinal axis.
  40178. * This can help limiting how the Camera is able to move in the scene.
  40179. */
  40180. lowerBetaLimit: number;
  40181. /**
  40182. * Maximum allowed angle on the latitudinal axis.
  40183. * This can help limiting how the Camera is able to move in the scene.
  40184. */
  40185. upperBetaLimit: number;
  40186. /**
  40187. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  40188. * This can help limiting how the Camera is able to move in the scene.
  40189. */
  40190. lowerRadiusLimit: Nullable<number>;
  40191. /**
  40192. * Maximum allowed distance of the camera to the target (The camera can not get further).
  40193. * This can help limiting how the Camera is able to move in the scene.
  40194. */
  40195. upperRadiusLimit: Nullable<number>;
  40196. /**
  40197. * Defines the current inertia value used during panning of the camera along the X axis.
  40198. */
  40199. inertialPanningX: number;
  40200. /**
  40201. * Defines the current inertia value used during panning of the camera along the Y axis.
  40202. */
  40203. inertialPanningY: number;
  40204. /**
  40205. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  40206. * Basically if your fingers moves away from more than this distance you will be considered
  40207. * in pinch mode.
  40208. */
  40209. pinchToPanMaxDistance: number;
  40210. /**
  40211. * Defines the maximum distance the camera can pan.
  40212. * This could help keeping the cammera always in your scene.
  40213. */
  40214. panningDistanceLimit: Nullable<number>;
  40215. /**
  40216. * Defines the target of the camera before paning.
  40217. */
  40218. panningOriginTarget: Vector3;
  40219. /**
  40220. * Defines the value of the inertia used during panning.
  40221. * 0 would mean stop inertia and one would mean no decelleration at all.
  40222. */
  40223. panningInertia: number;
  40224. /**
  40225. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  40226. */
  40227. get angularSensibilityX(): number;
  40228. set angularSensibilityX(value: number);
  40229. /**
  40230. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  40231. */
  40232. get angularSensibilityY(): number;
  40233. set angularSensibilityY(value: number);
  40234. /**
  40235. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  40236. */
  40237. get pinchPrecision(): number;
  40238. set pinchPrecision(value: number);
  40239. /**
  40240. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  40241. * It will be used instead of pinchDeltaPrecision if different from 0.
  40242. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  40243. */
  40244. get pinchDeltaPercentage(): number;
  40245. set pinchDeltaPercentage(value: number);
  40246. /**
  40247. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  40248. * and pinch delta percentage.
  40249. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  40250. * that any object in the plane at the camera's target point will scale
  40251. * perfectly with finger motion.
  40252. */
  40253. get useNaturalPinchZoom(): boolean;
  40254. set useNaturalPinchZoom(value: boolean);
  40255. /**
  40256. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  40257. */
  40258. get panningSensibility(): number;
  40259. set panningSensibility(value: number);
  40260. /**
  40261. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  40262. */
  40263. get keysUp(): number[];
  40264. set keysUp(value: number[]);
  40265. /**
  40266. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  40267. */
  40268. get keysDown(): number[];
  40269. set keysDown(value: number[]);
  40270. /**
  40271. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  40272. */
  40273. get keysLeft(): number[];
  40274. set keysLeft(value: number[]);
  40275. /**
  40276. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  40277. */
  40278. get keysRight(): number[];
  40279. set keysRight(value: number[]);
  40280. /**
  40281. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  40282. */
  40283. get wheelPrecision(): number;
  40284. set wheelPrecision(value: number);
  40285. /**
  40286. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  40287. * It will be used instead of pinchDeltaPrecision if different from 0.
  40288. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  40289. */
  40290. get wheelDeltaPercentage(): number;
  40291. set wheelDeltaPercentage(value: number);
  40292. /**
  40293. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  40294. */
  40295. zoomOnFactor: number;
  40296. /**
  40297. * Defines a screen offset for the camera position.
  40298. */
  40299. targetScreenOffset: Vector2;
  40300. /**
  40301. * Allows the camera to be completely reversed.
  40302. * If false the camera can not arrive upside down.
  40303. */
  40304. allowUpsideDown: boolean;
  40305. /**
  40306. * Define if double tap/click is used to restore the previously saved state of the camera.
  40307. */
  40308. useInputToRestoreState: boolean;
  40309. /** @hidden */
  40310. _viewMatrix: Matrix;
  40311. /** @hidden */
  40312. _useCtrlForPanning: boolean;
  40313. /** @hidden */
  40314. _panningMouseButton: number;
  40315. /**
  40316. * Defines the input associated to the camera.
  40317. */
  40318. inputs: ArcRotateCameraInputsManager;
  40319. /** @hidden */
  40320. _reset: () => void;
  40321. /**
  40322. * Defines the allowed panning axis.
  40323. */
  40324. panningAxis: Vector3;
  40325. protected _localDirection: Vector3;
  40326. protected _transformedDirection: Vector3;
  40327. private _bouncingBehavior;
  40328. /**
  40329. * Gets the bouncing behavior of the camera if it has been enabled.
  40330. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  40331. */
  40332. get bouncingBehavior(): Nullable<BouncingBehavior>;
  40333. /**
  40334. * Defines if the bouncing behavior of the camera is enabled on the camera.
  40335. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  40336. */
  40337. get useBouncingBehavior(): boolean;
  40338. set useBouncingBehavior(value: boolean);
  40339. private _framingBehavior;
  40340. /**
  40341. * Gets the framing behavior of the camera if it has been enabled.
  40342. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  40343. */
  40344. get framingBehavior(): Nullable<FramingBehavior>;
  40345. /**
  40346. * Defines if the framing behavior of the camera is enabled on the camera.
  40347. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  40348. */
  40349. get useFramingBehavior(): boolean;
  40350. set useFramingBehavior(value: boolean);
  40351. private _autoRotationBehavior;
  40352. /**
  40353. * Gets the auto rotation behavior of the camera if it has been enabled.
  40354. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  40355. */
  40356. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  40357. /**
  40358. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  40359. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  40360. */
  40361. get useAutoRotationBehavior(): boolean;
  40362. set useAutoRotationBehavior(value: boolean);
  40363. /**
  40364. * Observable triggered when the mesh target has been changed on the camera.
  40365. */
  40366. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  40367. /**
  40368. * Event raised when the camera is colliding with a mesh.
  40369. */
  40370. onCollide: (collidedMesh: AbstractMesh) => void;
  40371. /**
  40372. * Defines whether the camera should check collision with the objects oh the scene.
  40373. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  40374. */
  40375. checkCollisions: boolean;
  40376. /**
  40377. * Defines the collision radius of the camera.
  40378. * This simulates a sphere around the camera.
  40379. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  40380. */
  40381. collisionRadius: Vector3;
  40382. protected _collider: Collider;
  40383. protected _previousPosition: Vector3;
  40384. protected _collisionVelocity: Vector3;
  40385. protected _newPosition: Vector3;
  40386. protected _previousAlpha: number;
  40387. protected _previousBeta: number;
  40388. protected _previousRadius: number;
  40389. protected _collisionTriggered: boolean;
  40390. protected _targetBoundingCenter: Nullable<Vector3>;
  40391. private _computationVector;
  40392. /**
  40393. * Instantiates a new ArcRotateCamera in a given scene
  40394. * @param name Defines the name of the camera
  40395. * @param alpha Defines the camera rotation along the logitudinal axis
  40396. * @param beta Defines the camera rotation along the latitudinal axis
  40397. * @param radius Defines the camera distance from its target
  40398. * @param target Defines the camera target
  40399. * @param scene Defines the scene the camera belongs to
  40400. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  40401. */
  40402. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  40403. /** @hidden */
  40404. _initCache(): void;
  40405. /** @hidden */
  40406. _updateCache(ignoreParentClass?: boolean): void;
  40407. protected _getTargetPosition(): Vector3;
  40408. private _storedAlpha;
  40409. private _storedBeta;
  40410. private _storedRadius;
  40411. private _storedTarget;
  40412. private _storedTargetScreenOffset;
  40413. /**
  40414. * Stores the current state of the camera (alpha, beta, radius and target)
  40415. * @returns the camera itself
  40416. */
  40417. storeState(): Camera;
  40418. /**
  40419. * @hidden
  40420. * Restored camera state. You must call storeState() first
  40421. */
  40422. _restoreStateValues(): boolean;
  40423. /** @hidden */
  40424. _isSynchronizedViewMatrix(): boolean;
  40425. /**
  40426. * Attached controls to the current camera.
  40427. * @param element Defines the element the controls should be listened from
  40428. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40429. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  40430. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  40431. */
  40432. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  40433. /**
  40434. * Detach the current controls from the camera.
  40435. * The camera will stop reacting to inputs.
  40436. * @param element Defines the element to stop listening the inputs from
  40437. */
  40438. detachControl(element: HTMLElement): void;
  40439. /** @hidden */
  40440. _checkInputs(): void;
  40441. protected _checkLimits(): void;
  40442. /**
  40443. * Rebuilds angles (alpha, beta) and radius from the give position and target
  40444. */
  40445. rebuildAnglesAndRadius(): void;
  40446. /**
  40447. * Use a position to define the current camera related information like alpha, beta and radius
  40448. * @param position Defines the position to set the camera at
  40449. */
  40450. setPosition(position: Vector3): void;
  40451. /**
  40452. * Defines the target the camera should look at.
  40453. * This will automatically adapt alpha beta and radius to fit within the new target.
  40454. * @param target Defines the new target as a Vector or a mesh
  40455. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  40456. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  40457. */
  40458. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  40459. /** @hidden */
  40460. _getViewMatrix(): Matrix;
  40461. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  40462. /**
  40463. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  40464. * @param meshes Defines the mesh to zoom on
  40465. * @param doNotUpdateMaxZ Defines whether or not maxZ should be updated whilst zooming on the mesh (this can happen if the mesh is big and the maxradius pretty small for instance)
  40466. */
  40467. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  40468. /**
  40469. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  40470. * The target will be changed but the radius
  40471. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  40472. * @param doNotUpdateMaxZ Defines whether or not maxZ should be updated whilst zooming on the mesh (this can happen if the mesh is big and the maxradius pretty small for instance)
  40473. */
  40474. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  40475. min: Vector3;
  40476. max: Vector3;
  40477. distance: number;
  40478. }, doNotUpdateMaxZ?: boolean): void;
  40479. /**
  40480. * @override
  40481. * Override Camera.createRigCamera
  40482. */
  40483. createRigCamera(name: string, cameraIndex: number): Camera;
  40484. /**
  40485. * @hidden
  40486. * @override
  40487. * Override Camera._updateRigCameras
  40488. */
  40489. _updateRigCameras(): void;
  40490. /**
  40491. * Destroy the camera and release the current resources hold by it.
  40492. */
  40493. dispose(): void;
  40494. /**
  40495. * Gets the current object class name.
  40496. * @return the class name
  40497. */
  40498. getClassName(): string;
  40499. }
  40500. }
  40501. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  40502. import { Behavior } from "babylonjs/Behaviors/behavior";
  40503. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40504. /**
  40505. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  40506. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  40507. */
  40508. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  40509. /**
  40510. * Gets the name of the behavior.
  40511. */
  40512. get name(): string;
  40513. private _zoomStopsAnimation;
  40514. private _idleRotationSpeed;
  40515. private _idleRotationWaitTime;
  40516. private _idleRotationSpinupTime;
  40517. /**
  40518. * Sets the flag that indicates if user zooming should stop animation.
  40519. */
  40520. set zoomStopsAnimation(flag: boolean);
  40521. /**
  40522. * Gets the flag that indicates if user zooming should stop animation.
  40523. */
  40524. get zoomStopsAnimation(): boolean;
  40525. /**
  40526. * Sets the default speed at which the camera rotates around the model.
  40527. */
  40528. set idleRotationSpeed(speed: number);
  40529. /**
  40530. * Gets the default speed at which the camera rotates around the model.
  40531. */
  40532. get idleRotationSpeed(): number;
  40533. /**
  40534. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  40535. */
  40536. set idleRotationWaitTime(time: number);
  40537. /**
  40538. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  40539. */
  40540. get idleRotationWaitTime(): number;
  40541. /**
  40542. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  40543. */
  40544. set idleRotationSpinupTime(time: number);
  40545. /**
  40546. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  40547. */
  40548. get idleRotationSpinupTime(): number;
  40549. /**
  40550. * Gets a value indicating if the camera is currently rotating because of this behavior
  40551. */
  40552. get rotationInProgress(): boolean;
  40553. private _onPrePointerObservableObserver;
  40554. private _onAfterCheckInputsObserver;
  40555. private _attachedCamera;
  40556. private _isPointerDown;
  40557. private _lastFrameTime;
  40558. private _lastInteractionTime;
  40559. private _cameraRotationSpeed;
  40560. /**
  40561. * Initializes the behavior.
  40562. */
  40563. init(): void;
  40564. /**
  40565. * Attaches the behavior to its arc rotate camera.
  40566. * @param camera Defines the camera to attach the behavior to
  40567. */
  40568. attach(camera: ArcRotateCamera): void;
  40569. /**
  40570. * Detaches the behavior from its current arc rotate camera.
  40571. */
  40572. detach(): void;
  40573. /**
  40574. * Returns true if user is scrolling.
  40575. * @return true if user is scrolling.
  40576. */
  40577. private _userIsZooming;
  40578. private _lastFrameRadius;
  40579. private _shouldAnimationStopForInteraction;
  40580. /**
  40581. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  40582. */
  40583. private _applyUserInteraction;
  40584. private _userIsMoving;
  40585. }
  40586. }
  40587. declare module "babylonjs/Behaviors/Cameras/index" {
  40588. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  40589. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  40590. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  40591. }
  40592. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  40593. import { Mesh } from "babylonjs/Meshes/mesh";
  40594. import { TransformNode } from "babylonjs/Meshes/transformNode";
  40595. import { Behavior } from "babylonjs/Behaviors/behavior";
  40596. /**
  40597. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  40598. */
  40599. export class AttachToBoxBehavior implements Behavior<Mesh> {
  40600. private ui;
  40601. /**
  40602. * The name of the behavior
  40603. */
  40604. name: string;
  40605. /**
  40606. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  40607. */
  40608. distanceAwayFromFace: number;
  40609. /**
  40610. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  40611. */
  40612. distanceAwayFromBottomOfFace: number;
  40613. private _faceVectors;
  40614. private _target;
  40615. private _scene;
  40616. private _onRenderObserver;
  40617. private _tmpMatrix;
  40618. private _tmpVector;
  40619. /**
  40620. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  40621. * @param ui The transform node that should be attched to the mesh
  40622. */
  40623. constructor(ui: TransformNode);
  40624. /**
  40625. * Initializes the behavior
  40626. */
  40627. init(): void;
  40628. private _closestFace;
  40629. private _zeroVector;
  40630. private _lookAtTmpMatrix;
  40631. private _lookAtToRef;
  40632. /**
  40633. * Attaches the AttachToBoxBehavior to the passed in mesh
  40634. * @param target The mesh that the specified node will be attached to
  40635. */
  40636. attach(target: Mesh): void;
  40637. /**
  40638. * Detaches the behavior from the mesh
  40639. */
  40640. detach(): void;
  40641. }
  40642. }
  40643. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  40644. import { Behavior } from "babylonjs/Behaviors/behavior";
  40645. import { Mesh } from "babylonjs/Meshes/mesh";
  40646. /**
  40647. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  40648. */
  40649. export class FadeInOutBehavior implements Behavior<Mesh> {
  40650. /**
  40651. * Time in milliseconds to delay before fading in (Default: 0)
  40652. */
  40653. delay: number;
  40654. /**
  40655. * Time in milliseconds for the mesh to fade in (Default: 300)
  40656. */
  40657. fadeInTime: number;
  40658. private _millisecondsPerFrame;
  40659. private _hovered;
  40660. private _hoverValue;
  40661. private _ownerNode;
  40662. /**
  40663. * Instatiates the FadeInOutBehavior
  40664. */
  40665. constructor();
  40666. /**
  40667. * The name of the behavior
  40668. */
  40669. get name(): string;
  40670. /**
  40671. * Initializes the behavior
  40672. */
  40673. init(): void;
  40674. /**
  40675. * Attaches the fade behavior on the passed in mesh
  40676. * @param ownerNode The mesh that will be faded in/out once attached
  40677. */
  40678. attach(ownerNode: Mesh): void;
  40679. /**
  40680. * Detaches the behavior from the mesh
  40681. */
  40682. detach(): void;
  40683. /**
  40684. * Triggers the mesh to begin fading in or out
  40685. * @param value if the object should fade in or out (true to fade in)
  40686. */
  40687. fadeIn(value: boolean): void;
  40688. private _update;
  40689. private _setAllVisibility;
  40690. }
  40691. }
  40692. declare module "babylonjs/Misc/pivotTools" {
  40693. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40694. /**
  40695. * Class containing a set of static utilities functions for managing Pivots
  40696. * @hidden
  40697. */
  40698. export class PivotTools {
  40699. private static _PivotCached;
  40700. private static _OldPivotPoint;
  40701. private static _PivotTranslation;
  40702. private static _PivotTmpVector;
  40703. /** @hidden */
  40704. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  40705. /** @hidden */
  40706. static _RestorePivotPoint(mesh: AbstractMesh): void;
  40707. }
  40708. }
  40709. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  40710. import { Scene } from "babylonjs/scene";
  40711. import { Vector4 } from "babylonjs/Maths/math.vector";
  40712. import { Mesh } from "babylonjs/Meshes/mesh";
  40713. import { Nullable } from "babylonjs/types";
  40714. import { Plane } from "babylonjs/Maths/math.plane";
  40715. /**
  40716. * Class containing static functions to help procedurally build meshes
  40717. */
  40718. export class PlaneBuilder {
  40719. /**
  40720. * Creates a plane mesh
  40721. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  40722. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  40723. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  40724. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40725. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  40726. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40727. * @param name defines the name of the mesh
  40728. * @param options defines the options used to create the mesh
  40729. * @param scene defines the hosting scene
  40730. * @returns the plane mesh
  40731. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  40732. */
  40733. static CreatePlane(name: string, options: {
  40734. size?: number;
  40735. width?: number;
  40736. height?: number;
  40737. sideOrientation?: number;
  40738. frontUVs?: Vector4;
  40739. backUVs?: Vector4;
  40740. updatable?: boolean;
  40741. sourcePlane?: Plane;
  40742. }, scene?: Nullable<Scene>): Mesh;
  40743. }
  40744. }
  40745. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  40746. import { Behavior } from "babylonjs/Behaviors/behavior";
  40747. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40748. import { Observable } from "babylonjs/Misc/observable";
  40749. import { Vector3 } from "babylonjs/Maths/math.vector";
  40750. import { Ray } from "babylonjs/Culling/ray";
  40751. import "babylonjs/Meshes/Builders/planeBuilder";
  40752. /**
  40753. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  40754. */
  40755. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  40756. private static _AnyMouseID;
  40757. /**
  40758. * Abstract mesh the behavior is set on
  40759. */
  40760. attachedNode: AbstractMesh;
  40761. private _dragPlane;
  40762. private _scene;
  40763. private _pointerObserver;
  40764. private _beforeRenderObserver;
  40765. private static _planeScene;
  40766. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  40767. /**
  40768. * 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)
  40769. */
  40770. maxDragAngle: number;
  40771. /**
  40772. * @hidden
  40773. */
  40774. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  40775. /**
  40776. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  40777. */
  40778. currentDraggingPointerID: number;
  40779. /**
  40780. * The last position where the pointer hit the drag plane in world space
  40781. */
  40782. lastDragPosition: Vector3;
  40783. /**
  40784. * If the behavior is currently in a dragging state
  40785. */
  40786. dragging: boolean;
  40787. /**
  40788. * 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)
  40789. */
  40790. dragDeltaRatio: number;
  40791. /**
  40792. * If the drag plane orientation should be updated during the dragging (Default: true)
  40793. */
  40794. updateDragPlane: boolean;
  40795. private _debugMode;
  40796. private _moving;
  40797. /**
  40798. * Fires each time the attached mesh is dragged with the pointer
  40799. * * delta between last drag position and current drag position in world space
  40800. * * dragDistance along the drag axis
  40801. * * dragPlaneNormal normal of the current drag plane used during the drag
  40802. * * dragPlanePoint in world space where the drag intersects the drag plane
  40803. */
  40804. onDragObservable: Observable<{
  40805. delta: Vector3;
  40806. dragPlanePoint: Vector3;
  40807. dragPlaneNormal: Vector3;
  40808. dragDistance: number;
  40809. pointerId: number;
  40810. }>;
  40811. /**
  40812. * Fires each time a drag begins (eg. mouse down on mesh)
  40813. */
  40814. onDragStartObservable: Observable<{
  40815. dragPlanePoint: Vector3;
  40816. pointerId: number;
  40817. }>;
  40818. /**
  40819. * Fires each time a drag ends (eg. mouse release after drag)
  40820. */
  40821. onDragEndObservable: Observable<{
  40822. dragPlanePoint: Vector3;
  40823. pointerId: number;
  40824. }>;
  40825. /**
  40826. * If the attached mesh should be moved when dragged
  40827. */
  40828. moveAttached: boolean;
  40829. /**
  40830. * If the drag behavior will react to drag events (Default: true)
  40831. */
  40832. enabled: boolean;
  40833. /**
  40834. * If pointer events should start and release the drag (Default: true)
  40835. */
  40836. startAndReleaseDragOnPointerEvents: boolean;
  40837. /**
  40838. * If camera controls should be detached during the drag
  40839. */
  40840. detachCameraControls: boolean;
  40841. /**
  40842. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  40843. */
  40844. useObjectOrientationForDragging: boolean;
  40845. private _options;
  40846. /**
  40847. * Gets the options used by the behavior
  40848. */
  40849. get options(): {
  40850. dragAxis?: Vector3;
  40851. dragPlaneNormal?: Vector3;
  40852. };
  40853. /**
  40854. * Sets the options used by the behavior
  40855. */
  40856. set options(options: {
  40857. dragAxis?: Vector3;
  40858. dragPlaneNormal?: Vector3;
  40859. });
  40860. /**
  40861. * Creates a pointer drag behavior that can be attached to a mesh
  40862. * @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)
  40863. */
  40864. constructor(options?: {
  40865. dragAxis?: Vector3;
  40866. dragPlaneNormal?: Vector3;
  40867. });
  40868. /**
  40869. * Predicate to determine if it is valid to move the object to a new position when it is moved
  40870. */
  40871. validateDrag: (targetPosition: Vector3) => boolean;
  40872. /**
  40873. * The name of the behavior
  40874. */
  40875. get name(): string;
  40876. /**
  40877. * Initializes the behavior
  40878. */
  40879. init(): void;
  40880. private _tmpVector;
  40881. private _alternatePickedPoint;
  40882. private _worldDragAxis;
  40883. private _targetPosition;
  40884. private _attachedElement;
  40885. /**
  40886. * Attaches the drag behavior the passed in mesh
  40887. * @param ownerNode The mesh that will be dragged around once attached
  40888. * @param predicate Predicate to use for pick filtering
  40889. */
  40890. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  40891. /**
  40892. * Force relase the drag action by code.
  40893. */
  40894. releaseDrag(): void;
  40895. private _startDragRay;
  40896. private _lastPointerRay;
  40897. /**
  40898. * Simulates the start of a pointer drag event on the behavior
  40899. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  40900. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  40901. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  40902. */
  40903. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  40904. private _startDrag;
  40905. private _dragDelta;
  40906. private _moveDrag;
  40907. private _pickWithRayOnDragPlane;
  40908. private _pointA;
  40909. private _pointB;
  40910. private _pointC;
  40911. private _lineA;
  40912. private _lineB;
  40913. private _localAxis;
  40914. private _lookAt;
  40915. private _updateDragPlanePosition;
  40916. /**
  40917. * Detaches the behavior from the mesh
  40918. */
  40919. detach(): void;
  40920. }
  40921. }
  40922. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  40923. import { Mesh } from "babylonjs/Meshes/mesh";
  40924. import { Behavior } from "babylonjs/Behaviors/behavior";
  40925. /**
  40926. * A behavior that when attached to a mesh will allow the mesh to be scaled
  40927. */
  40928. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  40929. private _dragBehaviorA;
  40930. private _dragBehaviorB;
  40931. private _startDistance;
  40932. private _initialScale;
  40933. private _targetScale;
  40934. private _ownerNode;
  40935. private _sceneRenderObserver;
  40936. /**
  40937. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  40938. */
  40939. constructor();
  40940. /**
  40941. * The name of the behavior
  40942. */
  40943. get name(): string;
  40944. /**
  40945. * Initializes the behavior
  40946. */
  40947. init(): void;
  40948. private _getCurrentDistance;
  40949. /**
  40950. * Attaches the scale behavior the passed in mesh
  40951. * @param ownerNode The mesh that will be scaled around once attached
  40952. */
  40953. attach(ownerNode: Mesh): void;
  40954. /**
  40955. * Detaches the behavior from the mesh
  40956. */
  40957. detach(): void;
  40958. }
  40959. }
  40960. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  40961. import { Behavior } from "babylonjs/Behaviors/behavior";
  40962. import { Mesh } from "babylonjs/Meshes/mesh";
  40963. import { Observable } from "babylonjs/Misc/observable";
  40964. /**
  40965. * 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
  40966. */
  40967. export class SixDofDragBehavior implements Behavior<Mesh> {
  40968. private static _virtualScene;
  40969. private _ownerNode;
  40970. private _sceneRenderObserver;
  40971. private _scene;
  40972. private _targetPosition;
  40973. private _virtualOriginMesh;
  40974. private _virtualDragMesh;
  40975. private _pointerObserver;
  40976. private _moving;
  40977. private _startingOrientation;
  40978. private _attachedElement;
  40979. /**
  40980. * 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)
  40981. */
  40982. private zDragFactor;
  40983. /**
  40984. * If the object should rotate to face the drag origin
  40985. */
  40986. rotateDraggedObject: boolean;
  40987. /**
  40988. * If the behavior is currently in a dragging state
  40989. */
  40990. dragging: boolean;
  40991. /**
  40992. * 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)
  40993. */
  40994. dragDeltaRatio: number;
  40995. /**
  40996. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  40997. */
  40998. currentDraggingPointerID: number;
  40999. /**
  41000. * If camera controls should be detached during the drag
  41001. */
  41002. detachCameraControls: boolean;
  41003. /**
  41004. * Fires each time a drag starts
  41005. */
  41006. onDragStartObservable: Observable<{}>;
  41007. /**
  41008. * Fires each time a drag ends (eg. mouse release after drag)
  41009. */
  41010. onDragEndObservable: Observable<{}>;
  41011. /**
  41012. * 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
  41013. */
  41014. constructor();
  41015. /**
  41016. * The name of the behavior
  41017. */
  41018. get name(): string;
  41019. /**
  41020. * Initializes the behavior
  41021. */
  41022. init(): void;
  41023. /**
  41024. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  41025. */
  41026. private get _pointerCamera();
  41027. /**
  41028. * Attaches the scale behavior the passed in mesh
  41029. * @param ownerNode The mesh that will be scaled around once attached
  41030. */
  41031. attach(ownerNode: Mesh): void;
  41032. /**
  41033. * Detaches the behavior from the mesh
  41034. */
  41035. detach(): void;
  41036. }
  41037. }
  41038. declare module "babylonjs/Behaviors/Meshes/index" {
  41039. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  41040. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  41041. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  41042. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  41043. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  41044. }
  41045. declare module "babylonjs/Behaviors/index" {
  41046. export * from "babylonjs/Behaviors/behavior";
  41047. export * from "babylonjs/Behaviors/Cameras/index";
  41048. export * from "babylonjs/Behaviors/Meshes/index";
  41049. }
  41050. declare module "babylonjs/Bones/boneIKController" {
  41051. import { Bone } from "babylonjs/Bones/bone";
  41052. import { Vector3 } from "babylonjs/Maths/math.vector";
  41053. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41054. import { Nullable } from "babylonjs/types";
  41055. /**
  41056. * Class used to apply inverse kinematics to bones
  41057. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  41058. */
  41059. export class BoneIKController {
  41060. private static _tmpVecs;
  41061. private static _tmpQuat;
  41062. private static _tmpMats;
  41063. /**
  41064. * Gets or sets the target mesh
  41065. */
  41066. targetMesh: AbstractMesh;
  41067. /** Gets or sets the mesh used as pole */
  41068. poleTargetMesh: AbstractMesh;
  41069. /**
  41070. * Gets or sets the bone used as pole
  41071. */
  41072. poleTargetBone: Nullable<Bone>;
  41073. /**
  41074. * Gets or sets the target position
  41075. */
  41076. targetPosition: Vector3;
  41077. /**
  41078. * Gets or sets the pole target position
  41079. */
  41080. poleTargetPosition: Vector3;
  41081. /**
  41082. * Gets or sets the pole target local offset
  41083. */
  41084. poleTargetLocalOffset: Vector3;
  41085. /**
  41086. * Gets or sets the pole angle
  41087. */
  41088. poleAngle: number;
  41089. /**
  41090. * Gets or sets the mesh associated with the controller
  41091. */
  41092. mesh: AbstractMesh;
  41093. /**
  41094. * 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)
  41095. */
  41096. slerpAmount: number;
  41097. private _bone1Quat;
  41098. private _bone1Mat;
  41099. private _bone2Ang;
  41100. private _bone1;
  41101. private _bone2;
  41102. private _bone1Length;
  41103. private _bone2Length;
  41104. private _maxAngle;
  41105. private _maxReach;
  41106. private _rightHandedSystem;
  41107. private _bendAxis;
  41108. private _slerping;
  41109. private _adjustRoll;
  41110. /**
  41111. * Gets or sets maximum allowed angle
  41112. */
  41113. get maxAngle(): number;
  41114. set maxAngle(value: number);
  41115. /**
  41116. * Creates a new BoneIKController
  41117. * @param mesh defines the mesh to control
  41118. * @param bone defines the bone to control
  41119. * @param options defines options to set up the controller
  41120. */
  41121. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  41122. targetMesh?: AbstractMesh;
  41123. poleTargetMesh?: AbstractMesh;
  41124. poleTargetBone?: Bone;
  41125. poleTargetLocalOffset?: Vector3;
  41126. poleAngle?: number;
  41127. bendAxis?: Vector3;
  41128. maxAngle?: number;
  41129. slerpAmount?: number;
  41130. });
  41131. private _setMaxAngle;
  41132. /**
  41133. * Force the controller to update the bones
  41134. */
  41135. update(): void;
  41136. }
  41137. }
  41138. declare module "babylonjs/Bones/boneLookController" {
  41139. import { Vector3 } from "babylonjs/Maths/math.vector";
  41140. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41141. import { Bone } from "babylonjs/Bones/bone";
  41142. import { Space } from "babylonjs/Maths/math.axis";
  41143. /**
  41144. * Class used to make a bone look toward a point in space
  41145. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  41146. */
  41147. export class BoneLookController {
  41148. private static _tmpVecs;
  41149. private static _tmpQuat;
  41150. private static _tmpMats;
  41151. /**
  41152. * The target Vector3 that the bone will look at
  41153. */
  41154. target: Vector3;
  41155. /**
  41156. * The mesh that the bone is attached to
  41157. */
  41158. mesh: AbstractMesh;
  41159. /**
  41160. * The bone that will be looking to the target
  41161. */
  41162. bone: Bone;
  41163. /**
  41164. * The up axis of the coordinate system that is used when the bone is rotated
  41165. */
  41166. upAxis: Vector3;
  41167. /**
  41168. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  41169. */
  41170. upAxisSpace: Space;
  41171. /**
  41172. * Used to make an adjustment to the yaw of the bone
  41173. */
  41174. adjustYaw: number;
  41175. /**
  41176. * Used to make an adjustment to the pitch of the bone
  41177. */
  41178. adjustPitch: number;
  41179. /**
  41180. * Used to make an adjustment to the roll of the bone
  41181. */
  41182. adjustRoll: number;
  41183. /**
  41184. * 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)
  41185. */
  41186. slerpAmount: number;
  41187. private _minYaw;
  41188. private _maxYaw;
  41189. private _minPitch;
  41190. private _maxPitch;
  41191. private _minYawSin;
  41192. private _minYawCos;
  41193. private _maxYawSin;
  41194. private _maxYawCos;
  41195. private _midYawConstraint;
  41196. private _minPitchTan;
  41197. private _maxPitchTan;
  41198. private _boneQuat;
  41199. private _slerping;
  41200. private _transformYawPitch;
  41201. private _transformYawPitchInv;
  41202. private _firstFrameSkipped;
  41203. private _yawRange;
  41204. private _fowardAxis;
  41205. /**
  41206. * Gets or sets the minimum yaw angle that the bone can look to
  41207. */
  41208. get minYaw(): number;
  41209. set minYaw(value: number);
  41210. /**
  41211. * Gets or sets the maximum yaw angle that the bone can look to
  41212. */
  41213. get maxYaw(): number;
  41214. set maxYaw(value: number);
  41215. /**
  41216. * Gets or sets the minimum pitch angle that the bone can look to
  41217. */
  41218. get minPitch(): number;
  41219. set minPitch(value: number);
  41220. /**
  41221. * Gets or sets the maximum pitch angle that the bone can look to
  41222. */
  41223. get maxPitch(): number;
  41224. set maxPitch(value: number);
  41225. /**
  41226. * Create a BoneLookController
  41227. * @param mesh the mesh that the bone belongs to
  41228. * @param bone the bone that will be looking to the target
  41229. * @param target the target Vector3 to look at
  41230. * @param options optional settings:
  41231. * * maxYaw: the maximum angle the bone will yaw to
  41232. * * minYaw: the minimum angle the bone will yaw to
  41233. * * maxPitch: the maximum angle the bone will pitch to
  41234. * * minPitch: the minimum angle the bone will yaw to
  41235. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  41236. * * upAxis: the up axis of the coordinate system
  41237. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  41238. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  41239. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  41240. * * adjustYaw: used to make an adjustment to the yaw of the bone
  41241. * * adjustPitch: used to make an adjustment to the pitch of the bone
  41242. * * adjustRoll: used to make an adjustment to the roll of the bone
  41243. **/
  41244. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  41245. maxYaw?: number;
  41246. minYaw?: number;
  41247. maxPitch?: number;
  41248. minPitch?: number;
  41249. slerpAmount?: number;
  41250. upAxis?: Vector3;
  41251. upAxisSpace?: Space;
  41252. yawAxis?: Vector3;
  41253. pitchAxis?: Vector3;
  41254. adjustYaw?: number;
  41255. adjustPitch?: number;
  41256. adjustRoll?: number;
  41257. });
  41258. /**
  41259. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  41260. */
  41261. update(): void;
  41262. private _getAngleDiff;
  41263. private _getAngleBetween;
  41264. private _isAngleBetween;
  41265. }
  41266. }
  41267. declare module "babylonjs/Bones/index" {
  41268. export * from "babylonjs/Bones/bone";
  41269. export * from "babylonjs/Bones/boneIKController";
  41270. export * from "babylonjs/Bones/boneLookController";
  41271. export * from "babylonjs/Bones/skeleton";
  41272. }
  41273. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  41274. import { Nullable } from "babylonjs/types";
  41275. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  41276. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41277. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  41278. /**
  41279. * Manage the gamepad inputs to control an arc rotate camera.
  41280. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41281. */
  41282. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  41283. /**
  41284. * Defines the camera the input is attached to.
  41285. */
  41286. camera: ArcRotateCamera;
  41287. /**
  41288. * Defines the gamepad the input is gathering event from.
  41289. */
  41290. gamepad: Nullable<Gamepad>;
  41291. /**
  41292. * Defines the gamepad rotation sensiblity.
  41293. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  41294. */
  41295. gamepadRotationSensibility: number;
  41296. /**
  41297. * Defines the gamepad move sensiblity.
  41298. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  41299. */
  41300. gamepadMoveSensibility: number;
  41301. private _yAxisScale;
  41302. /**
  41303. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  41304. */
  41305. get invertYAxis(): boolean;
  41306. set invertYAxis(value: boolean);
  41307. private _onGamepadConnectedObserver;
  41308. private _onGamepadDisconnectedObserver;
  41309. /**
  41310. * Attach the input controls to a specific dom element to get the input from.
  41311. * @param element Defines the element the controls should be listened from
  41312. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41313. */
  41314. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41315. /**
  41316. * Detach the current controls from the specified dom element.
  41317. * @param element Defines the element to stop listening the inputs from
  41318. */
  41319. detachControl(element: Nullable<HTMLElement>): void;
  41320. /**
  41321. * Update the current camera state depending on the inputs that have been used this frame.
  41322. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41323. */
  41324. checkInputs(): void;
  41325. /**
  41326. * Gets the class name of the current intput.
  41327. * @returns the class name
  41328. */
  41329. getClassName(): string;
  41330. /**
  41331. * Get the friendly name associated with the input class.
  41332. * @returns the input friendly name
  41333. */
  41334. getSimpleName(): string;
  41335. }
  41336. }
  41337. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  41338. import { Nullable } from "babylonjs/types";
  41339. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  41340. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41341. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  41342. interface ArcRotateCameraInputsManager {
  41343. /**
  41344. * Add orientation input support to the input manager.
  41345. * @returns the current input manager
  41346. */
  41347. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  41348. }
  41349. }
  41350. /**
  41351. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  41352. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41353. */
  41354. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  41355. /**
  41356. * Defines the camera the input is attached to.
  41357. */
  41358. camera: ArcRotateCamera;
  41359. /**
  41360. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  41361. */
  41362. alphaCorrection: number;
  41363. /**
  41364. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  41365. */
  41366. gammaCorrection: number;
  41367. private _alpha;
  41368. private _gamma;
  41369. private _dirty;
  41370. private _deviceOrientationHandler;
  41371. /**
  41372. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  41373. */
  41374. constructor();
  41375. /**
  41376. * Attach the input controls to a specific dom element to get the input from.
  41377. * @param element Defines the element the controls should be listened from
  41378. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41379. */
  41380. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41381. /** @hidden */
  41382. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  41383. /**
  41384. * Update the current camera state depending on the inputs that have been used this frame.
  41385. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41386. */
  41387. checkInputs(): void;
  41388. /**
  41389. * Detach the current controls from the specified dom element.
  41390. * @param element Defines the element to stop listening the inputs from
  41391. */
  41392. detachControl(element: Nullable<HTMLElement>): void;
  41393. /**
  41394. * Gets the class name of the current intput.
  41395. * @returns the class name
  41396. */
  41397. getClassName(): string;
  41398. /**
  41399. * Get the friendly name associated with the input class.
  41400. * @returns the input friendly name
  41401. */
  41402. getSimpleName(): string;
  41403. }
  41404. }
  41405. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  41406. import { Nullable } from "babylonjs/types";
  41407. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41408. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  41409. /**
  41410. * Listen to mouse events to control the camera.
  41411. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41412. */
  41413. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  41414. /**
  41415. * Defines the camera the input is attached to.
  41416. */
  41417. camera: FlyCamera;
  41418. /**
  41419. * Defines if touch is enabled. (Default is true.)
  41420. */
  41421. touchEnabled: boolean;
  41422. /**
  41423. * Defines the buttons associated with the input to handle camera rotation.
  41424. */
  41425. buttons: number[];
  41426. /**
  41427. * Assign buttons for Yaw control.
  41428. */
  41429. buttonsYaw: number[];
  41430. /**
  41431. * Assign buttons for Pitch control.
  41432. */
  41433. buttonsPitch: number[];
  41434. /**
  41435. * Assign buttons for Roll control.
  41436. */
  41437. buttonsRoll: number[];
  41438. /**
  41439. * Detect if any button is being pressed while mouse is moved.
  41440. * -1 = Mouse locked.
  41441. * 0 = Left button.
  41442. * 1 = Middle Button.
  41443. * 2 = Right Button.
  41444. */
  41445. activeButton: number;
  41446. /**
  41447. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  41448. * Higher values reduce its sensitivity.
  41449. */
  41450. angularSensibility: number;
  41451. private _mousemoveCallback;
  41452. private _observer;
  41453. private _rollObserver;
  41454. private previousPosition;
  41455. private noPreventDefault;
  41456. private element;
  41457. /**
  41458. * Listen to mouse events to control the camera.
  41459. * @param touchEnabled Define if touch is enabled. (Default is true.)
  41460. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41461. */
  41462. constructor(touchEnabled?: boolean);
  41463. /**
  41464. * Attach the mouse control to the HTML DOM element.
  41465. * @param element Defines the element that listens to the input events.
  41466. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  41467. */
  41468. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41469. /**
  41470. * Detach the current controls from the specified dom element.
  41471. * @param element Defines the element to stop listening the inputs from
  41472. */
  41473. detachControl(element: Nullable<HTMLElement>): void;
  41474. /**
  41475. * Gets the class name of the current input.
  41476. * @returns the class name.
  41477. */
  41478. getClassName(): string;
  41479. /**
  41480. * Get the friendly name associated with the input class.
  41481. * @returns the input's friendly name.
  41482. */
  41483. getSimpleName(): string;
  41484. private _pointerInput;
  41485. private _onMouseMove;
  41486. /**
  41487. * Rotate camera by mouse offset.
  41488. */
  41489. private rotateCamera;
  41490. }
  41491. }
  41492. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  41493. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  41494. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  41495. /**
  41496. * Default Inputs manager for the FlyCamera.
  41497. * It groups all the default supported inputs for ease of use.
  41498. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41499. */
  41500. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  41501. /**
  41502. * Instantiates a new FlyCameraInputsManager.
  41503. * @param camera Defines the camera the inputs belong to.
  41504. */
  41505. constructor(camera: FlyCamera);
  41506. /**
  41507. * Add keyboard input support to the input manager.
  41508. * @returns the new FlyCameraKeyboardMoveInput().
  41509. */
  41510. addKeyboard(): FlyCameraInputsManager;
  41511. /**
  41512. * Add mouse input support to the input manager.
  41513. * @param touchEnabled Enable touch screen support.
  41514. * @returns the new FlyCameraMouseInput().
  41515. */
  41516. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  41517. }
  41518. }
  41519. declare module "babylonjs/Cameras/flyCamera" {
  41520. import { Scene } from "babylonjs/scene";
  41521. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  41522. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41523. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  41524. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  41525. /**
  41526. * This is a flying camera, designed for 3D movement and rotation in all directions,
  41527. * such as in a 3D Space Shooter or a Flight Simulator.
  41528. */
  41529. export class FlyCamera extends TargetCamera {
  41530. /**
  41531. * Define the collision ellipsoid of the camera.
  41532. * This is helpful for simulating a camera body, like a player's body.
  41533. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  41534. */
  41535. ellipsoid: Vector3;
  41536. /**
  41537. * Define an offset for the position of the ellipsoid around the camera.
  41538. * This can be helpful if the camera is attached away from the player's body center,
  41539. * such as at its head.
  41540. */
  41541. ellipsoidOffset: Vector3;
  41542. /**
  41543. * Enable or disable collisions of the camera with the rest of the scene objects.
  41544. */
  41545. checkCollisions: boolean;
  41546. /**
  41547. * Enable or disable gravity on the camera.
  41548. */
  41549. applyGravity: boolean;
  41550. /**
  41551. * Define the current direction the camera is moving to.
  41552. */
  41553. cameraDirection: Vector3;
  41554. /**
  41555. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  41556. * This overrides and empties cameraRotation.
  41557. */
  41558. rotationQuaternion: Quaternion;
  41559. /**
  41560. * Track Roll to maintain the wanted Rolling when looking around.
  41561. */
  41562. _trackRoll: number;
  41563. /**
  41564. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  41565. */
  41566. rollCorrect: number;
  41567. /**
  41568. * Mimic a banked turn, Rolling the camera when Yawing.
  41569. * It's recommended to use rollCorrect = 10 for faster banking correction.
  41570. */
  41571. bankedTurn: boolean;
  41572. /**
  41573. * Limit in radians for how much Roll banking will add. (Default: 90°)
  41574. */
  41575. bankedTurnLimit: number;
  41576. /**
  41577. * Value of 0 disables the banked Roll.
  41578. * Value of 1 is equal to the Yaw angle in radians.
  41579. */
  41580. bankedTurnMultiplier: number;
  41581. /**
  41582. * The inputs manager loads all the input sources, such as keyboard and mouse.
  41583. */
  41584. inputs: FlyCameraInputsManager;
  41585. /**
  41586. * Gets the input sensibility for mouse input.
  41587. * Higher values reduce sensitivity.
  41588. */
  41589. get angularSensibility(): number;
  41590. /**
  41591. * Sets the input sensibility for a mouse input.
  41592. * Higher values reduce sensitivity.
  41593. */
  41594. set angularSensibility(value: number);
  41595. /**
  41596. * Get the keys for camera movement forward.
  41597. */
  41598. get keysForward(): number[];
  41599. /**
  41600. * Set the keys for camera movement forward.
  41601. */
  41602. set keysForward(value: number[]);
  41603. /**
  41604. * Get the keys for camera movement backward.
  41605. */
  41606. get keysBackward(): number[];
  41607. set keysBackward(value: number[]);
  41608. /**
  41609. * Get the keys for camera movement up.
  41610. */
  41611. get keysUp(): number[];
  41612. /**
  41613. * Set the keys for camera movement up.
  41614. */
  41615. set keysUp(value: number[]);
  41616. /**
  41617. * Get the keys for camera movement down.
  41618. */
  41619. get keysDown(): number[];
  41620. /**
  41621. * Set the keys for camera movement down.
  41622. */
  41623. set keysDown(value: number[]);
  41624. /**
  41625. * Get the keys for camera movement left.
  41626. */
  41627. get keysLeft(): number[];
  41628. /**
  41629. * Set the keys for camera movement left.
  41630. */
  41631. set keysLeft(value: number[]);
  41632. /**
  41633. * Set the keys for camera movement right.
  41634. */
  41635. get keysRight(): number[];
  41636. /**
  41637. * Set the keys for camera movement right.
  41638. */
  41639. set keysRight(value: number[]);
  41640. /**
  41641. * Event raised when the camera collides with a mesh in the scene.
  41642. */
  41643. onCollide: (collidedMesh: AbstractMesh) => void;
  41644. private _collider;
  41645. private _needMoveForGravity;
  41646. private _oldPosition;
  41647. private _diffPosition;
  41648. private _newPosition;
  41649. /** @hidden */
  41650. _localDirection: Vector3;
  41651. /** @hidden */
  41652. _transformedDirection: Vector3;
  41653. /**
  41654. * Instantiates a FlyCamera.
  41655. * This is a flying camera, designed for 3D movement and rotation in all directions,
  41656. * such as in a 3D Space Shooter or a Flight Simulator.
  41657. * @param name Define the name of the camera in the scene.
  41658. * @param position Define the starting position of the camera in the scene.
  41659. * @param scene Define the scene the camera belongs to.
  41660. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  41661. */
  41662. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  41663. /**
  41664. * Attach a control to the HTML DOM element.
  41665. * @param element Defines the element that listens to the input events.
  41666. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  41667. */
  41668. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41669. /**
  41670. * Detach a control from the HTML DOM element.
  41671. * The camera will stop reacting to that input.
  41672. * @param element Defines the element that listens to the input events.
  41673. */
  41674. detachControl(element: HTMLElement): void;
  41675. private _collisionMask;
  41676. /**
  41677. * Get the mask that the camera ignores in collision events.
  41678. */
  41679. get collisionMask(): number;
  41680. /**
  41681. * Set the mask that the camera ignores in collision events.
  41682. */
  41683. set collisionMask(mask: number);
  41684. /** @hidden */
  41685. _collideWithWorld(displacement: Vector3): void;
  41686. /** @hidden */
  41687. private _onCollisionPositionChange;
  41688. /** @hidden */
  41689. _checkInputs(): void;
  41690. /** @hidden */
  41691. _decideIfNeedsToMove(): boolean;
  41692. /** @hidden */
  41693. _updatePosition(): void;
  41694. /**
  41695. * Restore the Roll to its target value at the rate specified.
  41696. * @param rate - Higher means slower restoring.
  41697. * @hidden
  41698. */
  41699. restoreRoll(rate: number): void;
  41700. /**
  41701. * Destroy the camera and release the current resources held by it.
  41702. */
  41703. dispose(): void;
  41704. /**
  41705. * Get the current object class name.
  41706. * @returns the class name.
  41707. */
  41708. getClassName(): string;
  41709. }
  41710. }
  41711. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  41712. import { Nullable } from "babylonjs/types";
  41713. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41714. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  41715. /**
  41716. * Listen to keyboard events to control the camera.
  41717. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41718. */
  41719. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  41720. /**
  41721. * Defines the camera the input is attached to.
  41722. */
  41723. camera: FlyCamera;
  41724. /**
  41725. * The list of keyboard keys used to control the forward move of the camera.
  41726. */
  41727. keysForward: number[];
  41728. /**
  41729. * The list of keyboard keys used to control the backward move of the camera.
  41730. */
  41731. keysBackward: number[];
  41732. /**
  41733. * The list of keyboard keys used to control the forward move of the camera.
  41734. */
  41735. keysUp: number[];
  41736. /**
  41737. * The list of keyboard keys used to control the backward move of the camera.
  41738. */
  41739. keysDown: number[];
  41740. /**
  41741. * The list of keyboard keys used to control the right strafe move of the camera.
  41742. */
  41743. keysRight: number[];
  41744. /**
  41745. * The list of keyboard keys used to control the left strafe move of the camera.
  41746. */
  41747. keysLeft: number[];
  41748. private _keys;
  41749. private _onCanvasBlurObserver;
  41750. private _onKeyboardObserver;
  41751. private _engine;
  41752. private _scene;
  41753. /**
  41754. * Attach the input controls to a specific dom element to get the input from.
  41755. * @param element Defines the element the controls should be listened from
  41756. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41757. */
  41758. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41759. /**
  41760. * Detach the current controls from the specified dom element.
  41761. * @param element Defines the element to stop listening the inputs from
  41762. */
  41763. detachControl(element: Nullable<HTMLElement>): void;
  41764. /**
  41765. * Gets the class name of the current intput.
  41766. * @returns the class name
  41767. */
  41768. getClassName(): string;
  41769. /** @hidden */
  41770. _onLostFocus(e: FocusEvent): void;
  41771. /**
  41772. * Get the friendly name associated with the input class.
  41773. * @returns the input friendly name
  41774. */
  41775. getSimpleName(): string;
  41776. /**
  41777. * Update the current camera state depending on the inputs that have been used this frame.
  41778. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41779. */
  41780. checkInputs(): void;
  41781. }
  41782. }
  41783. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  41784. import { Nullable } from "babylonjs/types";
  41785. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  41786. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41787. /**
  41788. * Manage the mouse wheel inputs to control a follow camera.
  41789. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41790. */
  41791. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  41792. /**
  41793. * Defines the camera the input is attached to.
  41794. */
  41795. camera: FollowCamera;
  41796. /**
  41797. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  41798. */
  41799. axisControlRadius: boolean;
  41800. /**
  41801. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  41802. */
  41803. axisControlHeight: boolean;
  41804. /**
  41805. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  41806. */
  41807. axisControlRotation: boolean;
  41808. /**
  41809. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  41810. * relation to mouseWheel events.
  41811. */
  41812. wheelPrecision: number;
  41813. /**
  41814. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  41815. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  41816. */
  41817. wheelDeltaPercentage: number;
  41818. private _wheel;
  41819. private _observer;
  41820. /**
  41821. * Attach the input controls to a specific dom element to get the input from.
  41822. * @param element Defines the element the controls should be listened from
  41823. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41824. */
  41825. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41826. /**
  41827. * Detach the current controls from the specified dom element.
  41828. * @param element Defines the element to stop listening the inputs from
  41829. */
  41830. detachControl(element: Nullable<HTMLElement>): void;
  41831. /**
  41832. * Gets the class name of the current intput.
  41833. * @returns the class name
  41834. */
  41835. getClassName(): string;
  41836. /**
  41837. * Get the friendly name associated with the input class.
  41838. * @returns the input friendly name
  41839. */
  41840. getSimpleName(): string;
  41841. }
  41842. }
  41843. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  41844. import { Nullable } from "babylonjs/types";
  41845. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  41846. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  41847. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  41848. /**
  41849. * Manage the pointers inputs to control an follow camera.
  41850. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41851. */
  41852. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  41853. /**
  41854. * Defines the camera the input is attached to.
  41855. */
  41856. camera: FollowCamera;
  41857. /**
  41858. * Gets the class name of the current input.
  41859. * @returns the class name
  41860. */
  41861. getClassName(): string;
  41862. /**
  41863. * Defines the pointer angular sensibility along the X axis or how fast is
  41864. * the camera rotating.
  41865. * A negative number will reverse the axis direction.
  41866. */
  41867. angularSensibilityX: number;
  41868. /**
  41869. * Defines the pointer angular sensibility along the Y axis or how fast is
  41870. * the camera rotating.
  41871. * A negative number will reverse the axis direction.
  41872. */
  41873. angularSensibilityY: number;
  41874. /**
  41875. * Defines the pointer pinch precision or how fast is the camera zooming.
  41876. * A negative number will reverse the axis direction.
  41877. */
  41878. pinchPrecision: number;
  41879. /**
  41880. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  41881. * from 0.
  41882. * It defines the percentage of current camera.radius to use as delta when
  41883. * pinch zoom is used.
  41884. */
  41885. pinchDeltaPercentage: number;
  41886. /**
  41887. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  41888. */
  41889. axisXControlRadius: boolean;
  41890. /**
  41891. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  41892. */
  41893. axisXControlHeight: boolean;
  41894. /**
  41895. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  41896. */
  41897. axisXControlRotation: boolean;
  41898. /**
  41899. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  41900. */
  41901. axisYControlRadius: boolean;
  41902. /**
  41903. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  41904. */
  41905. axisYControlHeight: boolean;
  41906. /**
  41907. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  41908. */
  41909. axisYControlRotation: boolean;
  41910. /**
  41911. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  41912. */
  41913. axisPinchControlRadius: boolean;
  41914. /**
  41915. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  41916. */
  41917. axisPinchControlHeight: boolean;
  41918. /**
  41919. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  41920. */
  41921. axisPinchControlRotation: boolean;
  41922. /**
  41923. * Log error messages if basic misconfiguration has occurred.
  41924. */
  41925. warningEnable: boolean;
  41926. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  41927. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  41928. private _warningCounter;
  41929. private _warning;
  41930. }
  41931. }
  41932. declare module "babylonjs/Cameras/followCameraInputsManager" {
  41933. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  41934. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  41935. /**
  41936. * Default Inputs manager for the FollowCamera.
  41937. * It groups all the default supported inputs for ease of use.
  41938. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41939. */
  41940. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  41941. /**
  41942. * Instantiates a new FollowCameraInputsManager.
  41943. * @param camera Defines the camera the inputs belong to
  41944. */
  41945. constructor(camera: FollowCamera);
  41946. /**
  41947. * Add keyboard input support to the input manager.
  41948. * @returns the current input manager
  41949. */
  41950. addKeyboard(): FollowCameraInputsManager;
  41951. /**
  41952. * Add mouse wheel input support to the input manager.
  41953. * @returns the current input manager
  41954. */
  41955. addMouseWheel(): FollowCameraInputsManager;
  41956. /**
  41957. * Add pointers input support to the input manager.
  41958. * @returns the current input manager
  41959. */
  41960. addPointers(): FollowCameraInputsManager;
  41961. /**
  41962. * Add orientation input support to the input manager.
  41963. * @returns the current input manager
  41964. */
  41965. addVRDeviceOrientation(): FollowCameraInputsManager;
  41966. }
  41967. }
  41968. declare module "babylonjs/Cameras/followCamera" {
  41969. import { Nullable } from "babylonjs/types";
  41970. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  41971. import { Scene } from "babylonjs/scene";
  41972. import { Vector3 } from "babylonjs/Maths/math.vector";
  41973. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41974. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  41975. /**
  41976. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  41977. * an arc rotate version arcFollowCamera are available.
  41978. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  41979. */
  41980. export class FollowCamera extends TargetCamera {
  41981. /**
  41982. * Distance the follow camera should follow an object at
  41983. */
  41984. radius: number;
  41985. /**
  41986. * Minimum allowed distance of the camera to the axis of rotation
  41987. * (The camera can not get closer).
  41988. * This can help limiting how the Camera is able to move in the scene.
  41989. */
  41990. lowerRadiusLimit: Nullable<number>;
  41991. /**
  41992. * Maximum allowed distance of the camera to the axis of rotation
  41993. * (The camera can not get further).
  41994. * This can help limiting how the Camera is able to move in the scene.
  41995. */
  41996. upperRadiusLimit: Nullable<number>;
  41997. /**
  41998. * Define a rotation offset between the camera and the object it follows
  41999. */
  42000. rotationOffset: number;
  42001. /**
  42002. * Minimum allowed angle to camera position relative to target object.
  42003. * This can help limiting how the Camera is able to move in the scene.
  42004. */
  42005. lowerRotationOffsetLimit: Nullable<number>;
  42006. /**
  42007. * Maximum allowed angle to camera position relative to target object.
  42008. * This can help limiting how the Camera is able to move in the scene.
  42009. */
  42010. upperRotationOffsetLimit: Nullable<number>;
  42011. /**
  42012. * Define a height offset between the camera and the object it follows.
  42013. * It can help following an object from the top (like a car chaing a plane)
  42014. */
  42015. heightOffset: number;
  42016. /**
  42017. * Minimum allowed height of camera position relative to target object.
  42018. * This can help limiting how the Camera is able to move in the scene.
  42019. */
  42020. lowerHeightOffsetLimit: Nullable<number>;
  42021. /**
  42022. * Maximum allowed height of camera position relative to target object.
  42023. * This can help limiting how the Camera is able to move in the scene.
  42024. */
  42025. upperHeightOffsetLimit: Nullable<number>;
  42026. /**
  42027. * Define how fast the camera can accelerate to follow it s target.
  42028. */
  42029. cameraAcceleration: number;
  42030. /**
  42031. * Define the speed limit of the camera following an object.
  42032. */
  42033. maxCameraSpeed: number;
  42034. /**
  42035. * Define the target of the camera.
  42036. */
  42037. lockedTarget: Nullable<AbstractMesh>;
  42038. /**
  42039. * Defines the input associated with the camera.
  42040. */
  42041. inputs: FollowCameraInputsManager;
  42042. /**
  42043. * Instantiates the follow camera.
  42044. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  42045. * @param name Define the name of the camera in the scene
  42046. * @param position Define the position of the camera
  42047. * @param scene Define the scene the camera belong to
  42048. * @param lockedTarget Define the target of the camera
  42049. */
  42050. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  42051. private _follow;
  42052. /**
  42053. * Attached controls to the current camera.
  42054. * @param element Defines the element the controls should be listened from
  42055. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42056. */
  42057. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42058. /**
  42059. * Detach the current controls from the camera.
  42060. * The camera will stop reacting to inputs.
  42061. * @param element Defines the element to stop listening the inputs from
  42062. */
  42063. detachControl(element: HTMLElement): void;
  42064. /** @hidden */
  42065. _checkInputs(): void;
  42066. private _checkLimits;
  42067. /**
  42068. * Gets the camera class name.
  42069. * @returns the class name
  42070. */
  42071. getClassName(): string;
  42072. }
  42073. /**
  42074. * Arc Rotate version of the follow camera.
  42075. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  42076. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  42077. */
  42078. export class ArcFollowCamera extends TargetCamera {
  42079. /** The longitudinal angle of the camera */
  42080. alpha: number;
  42081. /** The latitudinal angle of the camera */
  42082. beta: number;
  42083. /** The radius of the camera from its target */
  42084. radius: number;
  42085. /** Define the camera target (the messh it should follow) */
  42086. target: Nullable<AbstractMesh>;
  42087. private _cartesianCoordinates;
  42088. /**
  42089. * Instantiates a new ArcFollowCamera
  42090. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  42091. * @param name Define the name of the camera
  42092. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  42093. * @param beta Define the rotation angle of the camera around the elevation axis
  42094. * @param radius Define the radius of the camera from its target point
  42095. * @param target Define the target of the camera
  42096. * @param scene Define the scene the camera belongs to
  42097. */
  42098. constructor(name: string,
  42099. /** The longitudinal angle of the camera */
  42100. alpha: number,
  42101. /** The latitudinal angle of the camera */
  42102. beta: number,
  42103. /** The radius of the camera from its target */
  42104. radius: number,
  42105. /** Define the camera target (the messh it should follow) */
  42106. target: Nullable<AbstractMesh>, scene: Scene);
  42107. private _follow;
  42108. /** @hidden */
  42109. _checkInputs(): void;
  42110. /**
  42111. * Returns the class name of the object.
  42112. * It is mostly used internally for serialization purposes.
  42113. */
  42114. getClassName(): string;
  42115. }
  42116. }
  42117. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  42118. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  42119. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  42120. import { Nullable } from "babylonjs/types";
  42121. /**
  42122. * Manage the keyboard inputs to control the movement of a follow camera.
  42123. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42124. */
  42125. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  42126. /**
  42127. * Defines the camera the input is attached to.
  42128. */
  42129. camera: FollowCamera;
  42130. /**
  42131. * Defines the list of key codes associated with the up action (increase heightOffset)
  42132. */
  42133. keysHeightOffsetIncr: number[];
  42134. /**
  42135. * Defines the list of key codes associated with the down action (decrease heightOffset)
  42136. */
  42137. keysHeightOffsetDecr: number[];
  42138. /**
  42139. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  42140. */
  42141. keysHeightOffsetModifierAlt: boolean;
  42142. /**
  42143. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  42144. */
  42145. keysHeightOffsetModifierCtrl: boolean;
  42146. /**
  42147. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  42148. */
  42149. keysHeightOffsetModifierShift: boolean;
  42150. /**
  42151. * Defines the list of key codes associated with the left action (increase rotationOffset)
  42152. */
  42153. keysRotationOffsetIncr: number[];
  42154. /**
  42155. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  42156. */
  42157. keysRotationOffsetDecr: number[];
  42158. /**
  42159. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  42160. */
  42161. keysRotationOffsetModifierAlt: boolean;
  42162. /**
  42163. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  42164. */
  42165. keysRotationOffsetModifierCtrl: boolean;
  42166. /**
  42167. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  42168. */
  42169. keysRotationOffsetModifierShift: boolean;
  42170. /**
  42171. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  42172. */
  42173. keysRadiusIncr: number[];
  42174. /**
  42175. * Defines the list of key codes associated with the zoom-out action (increase radius)
  42176. */
  42177. keysRadiusDecr: number[];
  42178. /**
  42179. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  42180. */
  42181. keysRadiusModifierAlt: boolean;
  42182. /**
  42183. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  42184. */
  42185. keysRadiusModifierCtrl: boolean;
  42186. /**
  42187. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  42188. */
  42189. keysRadiusModifierShift: boolean;
  42190. /**
  42191. * Defines the rate of change of heightOffset.
  42192. */
  42193. heightSensibility: number;
  42194. /**
  42195. * Defines the rate of change of rotationOffset.
  42196. */
  42197. rotationSensibility: number;
  42198. /**
  42199. * Defines the rate of change of radius.
  42200. */
  42201. radiusSensibility: number;
  42202. private _keys;
  42203. private _ctrlPressed;
  42204. private _altPressed;
  42205. private _shiftPressed;
  42206. private _onCanvasBlurObserver;
  42207. private _onKeyboardObserver;
  42208. private _engine;
  42209. private _scene;
  42210. /**
  42211. * Attach the input controls to a specific dom element to get the input from.
  42212. * @param element Defines the element the controls should be listened from
  42213. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42214. */
  42215. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42216. /**
  42217. * Detach the current controls from the specified dom element.
  42218. * @param element Defines the element to stop listening the inputs from
  42219. */
  42220. detachControl(element: Nullable<HTMLElement>): void;
  42221. /**
  42222. * Update the current camera state depending on the inputs that have been used this frame.
  42223. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42224. */
  42225. checkInputs(): void;
  42226. /**
  42227. * Gets the class name of the current input.
  42228. * @returns the class name
  42229. */
  42230. getClassName(): string;
  42231. /**
  42232. * Get the friendly name associated with the input class.
  42233. * @returns the input friendly name
  42234. */
  42235. getSimpleName(): string;
  42236. /**
  42237. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  42238. * allow modification of the heightOffset value.
  42239. */
  42240. private _modifierHeightOffset;
  42241. /**
  42242. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  42243. * allow modification of the rotationOffset value.
  42244. */
  42245. private _modifierRotationOffset;
  42246. /**
  42247. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  42248. * allow modification of the radius value.
  42249. */
  42250. private _modifierRadius;
  42251. }
  42252. }
  42253. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  42254. import { Nullable } from "babylonjs/types";
  42255. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  42256. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42257. import { Observable } from "babylonjs/Misc/observable";
  42258. module "babylonjs/Cameras/freeCameraInputsManager" {
  42259. interface FreeCameraInputsManager {
  42260. /**
  42261. * @hidden
  42262. */
  42263. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  42264. /**
  42265. * Add orientation input support to the input manager.
  42266. * @returns the current input manager
  42267. */
  42268. addDeviceOrientation(): FreeCameraInputsManager;
  42269. }
  42270. }
  42271. /**
  42272. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  42273. * Screen rotation is taken into account.
  42274. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42275. */
  42276. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  42277. private _camera;
  42278. private _screenOrientationAngle;
  42279. private _constantTranform;
  42280. private _screenQuaternion;
  42281. private _alpha;
  42282. private _beta;
  42283. private _gamma;
  42284. /**
  42285. * Can be used to detect if a device orientation sensor is available on a device
  42286. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  42287. * @returns a promise that will resolve on orientation change
  42288. */
  42289. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  42290. /**
  42291. * @hidden
  42292. */
  42293. _onDeviceOrientationChangedObservable: Observable<void>;
  42294. /**
  42295. * Instantiates a new input
  42296. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42297. */
  42298. constructor();
  42299. /**
  42300. * Define the camera controlled by the input.
  42301. */
  42302. get camera(): FreeCamera;
  42303. set camera(camera: FreeCamera);
  42304. /**
  42305. * Attach the input controls to a specific dom element to get the input from.
  42306. * @param element Defines the element the controls should be listened from
  42307. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42308. */
  42309. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42310. private _orientationChanged;
  42311. private _deviceOrientation;
  42312. /**
  42313. * Detach the current controls from the specified dom element.
  42314. * @param element Defines the element to stop listening the inputs from
  42315. */
  42316. detachControl(element: Nullable<HTMLElement>): void;
  42317. /**
  42318. * Update the current camera state depending on the inputs that have been used this frame.
  42319. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42320. */
  42321. checkInputs(): void;
  42322. /**
  42323. * Gets the class name of the current intput.
  42324. * @returns the class name
  42325. */
  42326. getClassName(): string;
  42327. /**
  42328. * Get the friendly name associated with the input class.
  42329. * @returns the input friendly name
  42330. */
  42331. getSimpleName(): string;
  42332. }
  42333. }
  42334. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  42335. import { Nullable } from "babylonjs/types";
  42336. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  42337. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42338. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  42339. /**
  42340. * Manage the gamepad inputs to control a free camera.
  42341. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42342. */
  42343. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  42344. /**
  42345. * Define the camera the input is attached to.
  42346. */
  42347. camera: FreeCamera;
  42348. /**
  42349. * Define the Gamepad controlling the input
  42350. */
  42351. gamepad: Nullable<Gamepad>;
  42352. /**
  42353. * Defines the gamepad rotation sensiblity.
  42354. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  42355. */
  42356. gamepadAngularSensibility: number;
  42357. /**
  42358. * Defines the gamepad move sensiblity.
  42359. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  42360. */
  42361. gamepadMoveSensibility: number;
  42362. private _yAxisScale;
  42363. /**
  42364. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  42365. */
  42366. get invertYAxis(): boolean;
  42367. set invertYAxis(value: boolean);
  42368. private _onGamepadConnectedObserver;
  42369. private _onGamepadDisconnectedObserver;
  42370. private _cameraTransform;
  42371. private _deltaTransform;
  42372. private _vector3;
  42373. private _vector2;
  42374. /**
  42375. * Attach the input controls to a specific dom element to get the input from.
  42376. * @param element Defines the element the controls should be listened from
  42377. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42378. */
  42379. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42380. /**
  42381. * Detach the current controls from the specified dom element.
  42382. * @param element Defines the element to stop listening the inputs from
  42383. */
  42384. detachControl(element: Nullable<HTMLElement>): void;
  42385. /**
  42386. * Update the current camera state depending on the inputs that have been used this frame.
  42387. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42388. */
  42389. checkInputs(): void;
  42390. /**
  42391. * Gets the class name of the current intput.
  42392. * @returns the class name
  42393. */
  42394. getClassName(): string;
  42395. /**
  42396. * Get the friendly name associated with the input class.
  42397. * @returns the input friendly name
  42398. */
  42399. getSimpleName(): string;
  42400. }
  42401. }
  42402. declare module "babylonjs/Misc/virtualJoystick" {
  42403. import { Nullable } from "babylonjs/types";
  42404. import { Vector3 } from "babylonjs/Maths/math.vector";
  42405. /**
  42406. * Defines the potential axis of a Joystick
  42407. */
  42408. export enum JoystickAxis {
  42409. /** X axis */
  42410. X = 0,
  42411. /** Y axis */
  42412. Y = 1,
  42413. /** Z axis */
  42414. Z = 2
  42415. }
  42416. /**
  42417. * Class used to define virtual joystick (used in touch mode)
  42418. */
  42419. export class VirtualJoystick {
  42420. /**
  42421. * Gets or sets a boolean indicating that left and right values must be inverted
  42422. */
  42423. reverseLeftRight: boolean;
  42424. /**
  42425. * Gets or sets a boolean indicating that up and down values must be inverted
  42426. */
  42427. reverseUpDown: boolean;
  42428. /**
  42429. * Gets the offset value for the position (ie. the change of the position value)
  42430. */
  42431. deltaPosition: Vector3;
  42432. /**
  42433. * Gets a boolean indicating if the virtual joystick was pressed
  42434. */
  42435. pressed: boolean;
  42436. /**
  42437. * Canvas the virtual joystick will render onto, default z-index of this is 5
  42438. */
  42439. static Canvas: Nullable<HTMLCanvasElement>;
  42440. private static _globalJoystickIndex;
  42441. private static vjCanvasContext;
  42442. private static vjCanvasWidth;
  42443. private static vjCanvasHeight;
  42444. private static halfWidth;
  42445. private _action;
  42446. private _axisTargetedByLeftAndRight;
  42447. private _axisTargetedByUpAndDown;
  42448. private _joystickSensibility;
  42449. private _inversedSensibility;
  42450. private _joystickPointerID;
  42451. private _joystickColor;
  42452. private _joystickPointerPos;
  42453. private _joystickPreviousPointerPos;
  42454. private _joystickPointerStartPos;
  42455. private _deltaJoystickVector;
  42456. private _leftJoystick;
  42457. private _touches;
  42458. private _onPointerDownHandlerRef;
  42459. private _onPointerMoveHandlerRef;
  42460. private _onPointerUpHandlerRef;
  42461. private _onResize;
  42462. /**
  42463. * Creates a new virtual joystick
  42464. * @param leftJoystick defines that the joystick is for left hand (false by default)
  42465. */
  42466. constructor(leftJoystick?: boolean);
  42467. /**
  42468. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  42469. * @param newJoystickSensibility defines the new sensibility
  42470. */
  42471. setJoystickSensibility(newJoystickSensibility: number): void;
  42472. private _onPointerDown;
  42473. private _onPointerMove;
  42474. private _onPointerUp;
  42475. /**
  42476. * Change the color of the virtual joystick
  42477. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  42478. */
  42479. setJoystickColor(newColor: string): void;
  42480. /**
  42481. * Defines a callback to call when the joystick is touched
  42482. * @param action defines the callback
  42483. */
  42484. setActionOnTouch(action: () => any): void;
  42485. /**
  42486. * Defines which axis you'd like to control for left & right
  42487. * @param axis defines the axis to use
  42488. */
  42489. setAxisForLeftRight(axis: JoystickAxis): void;
  42490. /**
  42491. * Defines which axis you'd like to control for up & down
  42492. * @param axis defines the axis to use
  42493. */
  42494. setAxisForUpDown(axis: JoystickAxis): void;
  42495. private _drawVirtualJoystick;
  42496. /**
  42497. * Release internal HTML canvas
  42498. */
  42499. releaseCanvas(): void;
  42500. }
  42501. }
  42502. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  42503. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  42504. import { Nullable } from "babylonjs/types";
  42505. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  42506. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42507. module "babylonjs/Cameras/freeCameraInputsManager" {
  42508. interface FreeCameraInputsManager {
  42509. /**
  42510. * Add virtual joystick input support to the input manager.
  42511. * @returns the current input manager
  42512. */
  42513. addVirtualJoystick(): FreeCameraInputsManager;
  42514. }
  42515. }
  42516. /**
  42517. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  42518. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42519. */
  42520. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  42521. /**
  42522. * Defines the camera the input is attached to.
  42523. */
  42524. camera: FreeCamera;
  42525. private _leftjoystick;
  42526. private _rightjoystick;
  42527. /**
  42528. * Gets the left stick of the virtual joystick.
  42529. * @returns The virtual Joystick
  42530. */
  42531. getLeftJoystick(): VirtualJoystick;
  42532. /**
  42533. * Gets the right stick of the virtual joystick.
  42534. * @returns The virtual Joystick
  42535. */
  42536. getRightJoystick(): VirtualJoystick;
  42537. /**
  42538. * Update the current camera state depending on the inputs that have been used this frame.
  42539. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42540. */
  42541. checkInputs(): void;
  42542. /**
  42543. * Attach the input controls to a specific dom element to get the input from.
  42544. * @param element Defines the element the controls should be listened from
  42545. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42546. */
  42547. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42548. /**
  42549. * Detach the current controls from the specified dom element.
  42550. * @param element Defines the element to stop listening the inputs from
  42551. */
  42552. detachControl(element: Nullable<HTMLElement>): void;
  42553. /**
  42554. * Gets the class name of the current intput.
  42555. * @returns the class name
  42556. */
  42557. getClassName(): string;
  42558. /**
  42559. * Get the friendly name associated with the input class.
  42560. * @returns the input friendly name
  42561. */
  42562. getSimpleName(): string;
  42563. }
  42564. }
  42565. declare module "babylonjs/Cameras/Inputs/index" {
  42566. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  42567. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  42568. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  42569. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  42570. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  42571. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  42572. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  42573. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  42574. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  42575. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  42576. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  42577. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  42578. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  42579. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  42580. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  42581. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  42582. }
  42583. declare module "babylonjs/Cameras/touchCamera" {
  42584. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42585. import { Scene } from "babylonjs/scene";
  42586. import { Vector3 } from "babylonjs/Maths/math.vector";
  42587. /**
  42588. * This represents a FPS type of camera controlled by touch.
  42589. * This is like a universal camera minus the Gamepad controls.
  42590. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42591. */
  42592. export class TouchCamera extends FreeCamera {
  42593. /**
  42594. * Defines the touch sensibility for rotation.
  42595. * The higher the faster.
  42596. */
  42597. get touchAngularSensibility(): number;
  42598. set touchAngularSensibility(value: number);
  42599. /**
  42600. * Defines the touch sensibility for move.
  42601. * The higher the faster.
  42602. */
  42603. get touchMoveSensibility(): number;
  42604. set touchMoveSensibility(value: number);
  42605. /**
  42606. * Instantiates a new touch camera.
  42607. * This represents a FPS type of camera controlled by touch.
  42608. * This is like a universal camera minus the Gamepad controls.
  42609. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42610. * @param name Define the name of the camera in the scene
  42611. * @param position Define the start position of the camera in the scene
  42612. * @param scene Define the scene the camera belongs to
  42613. */
  42614. constructor(name: string, position: Vector3, scene: Scene);
  42615. /**
  42616. * Gets the current object class name.
  42617. * @return the class name
  42618. */
  42619. getClassName(): string;
  42620. /** @hidden */
  42621. _setupInputs(): void;
  42622. }
  42623. }
  42624. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  42625. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42626. import { Scene } from "babylonjs/scene";
  42627. import { Vector3 } from "babylonjs/Maths/math.vector";
  42628. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  42629. import { Axis } from "babylonjs/Maths/math.axis";
  42630. /**
  42631. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  42632. * being tilted forward or back and left or right.
  42633. */
  42634. export class DeviceOrientationCamera extends FreeCamera {
  42635. private _initialQuaternion;
  42636. private _quaternionCache;
  42637. private _tmpDragQuaternion;
  42638. private _disablePointerInputWhenUsingDeviceOrientation;
  42639. /**
  42640. * Creates a new device orientation camera
  42641. * @param name The name of the camera
  42642. * @param position The start position camera
  42643. * @param scene The scene the camera belongs to
  42644. */
  42645. constructor(name: string, position: Vector3, scene: Scene);
  42646. /**
  42647. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  42648. */
  42649. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  42650. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  42651. private _dragFactor;
  42652. /**
  42653. * Enabled turning on the y axis when the orientation sensor is active
  42654. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  42655. */
  42656. enableHorizontalDragging(dragFactor?: number): void;
  42657. /**
  42658. * Gets the current instance class name ("DeviceOrientationCamera").
  42659. * This helps avoiding instanceof at run time.
  42660. * @returns the class name
  42661. */
  42662. getClassName(): string;
  42663. /**
  42664. * @hidden
  42665. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  42666. */
  42667. _checkInputs(): void;
  42668. /**
  42669. * Reset the camera to its default orientation on the specified axis only.
  42670. * @param axis The axis to reset
  42671. */
  42672. resetToCurrentRotation(axis?: Axis): void;
  42673. }
  42674. }
  42675. declare module "babylonjs/Gamepads/xboxGamepad" {
  42676. import { Observable } from "babylonjs/Misc/observable";
  42677. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  42678. /**
  42679. * Defines supported buttons for XBox360 compatible gamepads
  42680. */
  42681. export enum Xbox360Button {
  42682. /** A */
  42683. A = 0,
  42684. /** B */
  42685. B = 1,
  42686. /** X */
  42687. X = 2,
  42688. /** Y */
  42689. Y = 3,
  42690. /** Left button */
  42691. LB = 4,
  42692. /** Right button */
  42693. RB = 5,
  42694. /** Back */
  42695. Back = 8,
  42696. /** Start */
  42697. Start = 9,
  42698. /** Left stick */
  42699. LeftStick = 10,
  42700. /** Right stick */
  42701. RightStick = 11
  42702. }
  42703. /** Defines values for XBox360 DPad */
  42704. export enum Xbox360Dpad {
  42705. /** Up */
  42706. Up = 12,
  42707. /** Down */
  42708. Down = 13,
  42709. /** Left */
  42710. Left = 14,
  42711. /** Right */
  42712. Right = 15
  42713. }
  42714. /**
  42715. * Defines a XBox360 gamepad
  42716. */
  42717. export class Xbox360Pad extends Gamepad {
  42718. private _leftTrigger;
  42719. private _rightTrigger;
  42720. private _onlefttriggerchanged;
  42721. private _onrighttriggerchanged;
  42722. private _onbuttondown;
  42723. private _onbuttonup;
  42724. private _ondpaddown;
  42725. private _ondpadup;
  42726. /** Observable raised when a button is pressed */
  42727. onButtonDownObservable: Observable<Xbox360Button>;
  42728. /** Observable raised when a button is released */
  42729. onButtonUpObservable: Observable<Xbox360Button>;
  42730. /** Observable raised when a pad is pressed */
  42731. onPadDownObservable: Observable<Xbox360Dpad>;
  42732. /** Observable raised when a pad is released */
  42733. onPadUpObservable: Observable<Xbox360Dpad>;
  42734. private _buttonA;
  42735. private _buttonB;
  42736. private _buttonX;
  42737. private _buttonY;
  42738. private _buttonBack;
  42739. private _buttonStart;
  42740. private _buttonLB;
  42741. private _buttonRB;
  42742. private _buttonLeftStick;
  42743. private _buttonRightStick;
  42744. private _dPadUp;
  42745. private _dPadDown;
  42746. private _dPadLeft;
  42747. private _dPadRight;
  42748. private _isXboxOnePad;
  42749. /**
  42750. * Creates a new XBox360 gamepad object
  42751. * @param id defines the id of this gamepad
  42752. * @param index defines its index
  42753. * @param gamepad defines the internal HTML gamepad object
  42754. * @param xboxOne defines if it is a XBox One gamepad
  42755. */
  42756. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  42757. /**
  42758. * Defines the callback to call when left trigger is pressed
  42759. * @param callback defines the callback to use
  42760. */
  42761. onlefttriggerchanged(callback: (value: number) => void): void;
  42762. /**
  42763. * Defines the callback to call when right trigger is pressed
  42764. * @param callback defines the callback to use
  42765. */
  42766. onrighttriggerchanged(callback: (value: number) => void): void;
  42767. /**
  42768. * Gets the left trigger value
  42769. */
  42770. get leftTrigger(): number;
  42771. /**
  42772. * Sets the left trigger value
  42773. */
  42774. set leftTrigger(newValue: number);
  42775. /**
  42776. * Gets the right trigger value
  42777. */
  42778. get rightTrigger(): number;
  42779. /**
  42780. * Sets the right trigger value
  42781. */
  42782. set rightTrigger(newValue: number);
  42783. /**
  42784. * Defines the callback to call when a button is pressed
  42785. * @param callback defines the callback to use
  42786. */
  42787. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  42788. /**
  42789. * Defines the callback to call when a button is released
  42790. * @param callback defines the callback to use
  42791. */
  42792. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  42793. /**
  42794. * Defines the callback to call when a pad is pressed
  42795. * @param callback defines the callback to use
  42796. */
  42797. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  42798. /**
  42799. * Defines the callback to call when a pad is released
  42800. * @param callback defines the callback to use
  42801. */
  42802. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  42803. private _setButtonValue;
  42804. private _setDPadValue;
  42805. /**
  42806. * Gets the value of the `A` button
  42807. */
  42808. get buttonA(): number;
  42809. /**
  42810. * Sets the value of the `A` button
  42811. */
  42812. set buttonA(value: number);
  42813. /**
  42814. * Gets the value of the `B` button
  42815. */
  42816. get buttonB(): number;
  42817. /**
  42818. * Sets the value of the `B` button
  42819. */
  42820. set buttonB(value: number);
  42821. /**
  42822. * Gets the value of the `X` button
  42823. */
  42824. get buttonX(): number;
  42825. /**
  42826. * Sets the value of the `X` button
  42827. */
  42828. set buttonX(value: number);
  42829. /**
  42830. * Gets the value of the `Y` button
  42831. */
  42832. get buttonY(): number;
  42833. /**
  42834. * Sets the value of the `Y` button
  42835. */
  42836. set buttonY(value: number);
  42837. /**
  42838. * Gets the value of the `Start` button
  42839. */
  42840. get buttonStart(): number;
  42841. /**
  42842. * Sets the value of the `Start` button
  42843. */
  42844. set buttonStart(value: number);
  42845. /**
  42846. * Gets the value of the `Back` button
  42847. */
  42848. get buttonBack(): number;
  42849. /**
  42850. * Sets the value of the `Back` button
  42851. */
  42852. set buttonBack(value: number);
  42853. /**
  42854. * Gets the value of the `Left` button
  42855. */
  42856. get buttonLB(): number;
  42857. /**
  42858. * Sets the value of the `Left` button
  42859. */
  42860. set buttonLB(value: number);
  42861. /**
  42862. * Gets the value of the `Right` button
  42863. */
  42864. get buttonRB(): number;
  42865. /**
  42866. * Sets the value of the `Right` button
  42867. */
  42868. set buttonRB(value: number);
  42869. /**
  42870. * Gets the value of the Left joystick
  42871. */
  42872. get buttonLeftStick(): number;
  42873. /**
  42874. * Sets the value of the Left joystick
  42875. */
  42876. set buttonLeftStick(value: number);
  42877. /**
  42878. * Gets the value of the Right joystick
  42879. */
  42880. get buttonRightStick(): number;
  42881. /**
  42882. * Sets the value of the Right joystick
  42883. */
  42884. set buttonRightStick(value: number);
  42885. /**
  42886. * Gets the value of D-pad up
  42887. */
  42888. get dPadUp(): number;
  42889. /**
  42890. * Sets the value of D-pad up
  42891. */
  42892. set dPadUp(value: number);
  42893. /**
  42894. * Gets the value of D-pad down
  42895. */
  42896. get dPadDown(): number;
  42897. /**
  42898. * Sets the value of D-pad down
  42899. */
  42900. set dPadDown(value: number);
  42901. /**
  42902. * Gets the value of D-pad left
  42903. */
  42904. get dPadLeft(): number;
  42905. /**
  42906. * Sets the value of D-pad left
  42907. */
  42908. set dPadLeft(value: number);
  42909. /**
  42910. * Gets the value of D-pad right
  42911. */
  42912. get dPadRight(): number;
  42913. /**
  42914. * Sets the value of D-pad right
  42915. */
  42916. set dPadRight(value: number);
  42917. /**
  42918. * Force the gamepad to synchronize with device values
  42919. */
  42920. update(): void;
  42921. /**
  42922. * Disposes the gamepad
  42923. */
  42924. dispose(): void;
  42925. }
  42926. }
  42927. declare module "babylonjs/Gamepads/dualShockGamepad" {
  42928. import { Observable } from "babylonjs/Misc/observable";
  42929. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  42930. /**
  42931. * Defines supported buttons for DualShock compatible gamepads
  42932. */
  42933. export enum DualShockButton {
  42934. /** Cross */
  42935. Cross = 0,
  42936. /** Circle */
  42937. Circle = 1,
  42938. /** Square */
  42939. Square = 2,
  42940. /** Triangle */
  42941. Triangle = 3,
  42942. /** L1 */
  42943. L1 = 4,
  42944. /** R1 */
  42945. R1 = 5,
  42946. /** Share */
  42947. Share = 8,
  42948. /** Options */
  42949. Options = 9,
  42950. /** Left stick */
  42951. LeftStick = 10,
  42952. /** Right stick */
  42953. RightStick = 11
  42954. }
  42955. /** Defines values for DualShock DPad */
  42956. export enum DualShockDpad {
  42957. /** Up */
  42958. Up = 12,
  42959. /** Down */
  42960. Down = 13,
  42961. /** Left */
  42962. Left = 14,
  42963. /** Right */
  42964. Right = 15
  42965. }
  42966. /**
  42967. * Defines a DualShock gamepad
  42968. */
  42969. export class DualShockPad extends Gamepad {
  42970. private _leftTrigger;
  42971. private _rightTrigger;
  42972. private _onlefttriggerchanged;
  42973. private _onrighttriggerchanged;
  42974. private _onbuttondown;
  42975. private _onbuttonup;
  42976. private _ondpaddown;
  42977. private _ondpadup;
  42978. /** Observable raised when a button is pressed */
  42979. onButtonDownObservable: Observable<DualShockButton>;
  42980. /** Observable raised when a button is released */
  42981. onButtonUpObservable: Observable<DualShockButton>;
  42982. /** Observable raised when a pad is pressed */
  42983. onPadDownObservable: Observable<DualShockDpad>;
  42984. /** Observable raised when a pad is released */
  42985. onPadUpObservable: Observable<DualShockDpad>;
  42986. private _buttonCross;
  42987. private _buttonCircle;
  42988. private _buttonSquare;
  42989. private _buttonTriangle;
  42990. private _buttonShare;
  42991. private _buttonOptions;
  42992. private _buttonL1;
  42993. private _buttonR1;
  42994. private _buttonLeftStick;
  42995. private _buttonRightStick;
  42996. private _dPadUp;
  42997. private _dPadDown;
  42998. private _dPadLeft;
  42999. private _dPadRight;
  43000. /**
  43001. * Creates a new DualShock gamepad object
  43002. * @param id defines the id of this gamepad
  43003. * @param index defines its index
  43004. * @param gamepad defines the internal HTML gamepad object
  43005. */
  43006. constructor(id: string, index: number, gamepad: any);
  43007. /**
  43008. * Defines the callback to call when left trigger is pressed
  43009. * @param callback defines the callback to use
  43010. */
  43011. onlefttriggerchanged(callback: (value: number) => void): void;
  43012. /**
  43013. * Defines the callback to call when right trigger is pressed
  43014. * @param callback defines the callback to use
  43015. */
  43016. onrighttriggerchanged(callback: (value: number) => void): void;
  43017. /**
  43018. * Gets the left trigger value
  43019. */
  43020. get leftTrigger(): number;
  43021. /**
  43022. * Sets the left trigger value
  43023. */
  43024. set leftTrigger(newValue: number);
  43025. /**
  43026. * Gets the right trigger value
  43027. */
  43028. get rightTrigger(): number;
  43029. /**
  43030. * Sets the right trigger value
  43031. */
  43032. set rightTrigger(newValue: number);
  43033. /**
  43034. * Defines the callback to call when a button is pressed
  43035. * @param callback defines the callback to use
  43036. */
  43037. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  43038. /**
  43039. * Defines the callback to call when a button is released
  43040. * @param callback defines the callback to use
  43041. */
  43042. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  43043. /**
  43044. * Defines the callback to call when a pad is pressed
  43045. * @param callback defines the callback to use
  43046. */
  43047. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  43048. /**
  43049. * Defines the callback to call when a pad is released
  43050. * @param callback defines the callback to use
  43051. */
  43052. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  43053. private _setButtonValue;
  43054. private _setDPadValue;
  43055. /**
  43056. * Gets the value of the `Cross` button
  43057. */
  43058. get buttonCross(): number;
  43059. /**
  43060. * Sets the value of the `Cross` button
  43061. */
  43062. set buttonCross(value: number);
  43063. /**
  43064. * Gets the value of the `Circle` button
  43065. */
  43066. get buttonCircle(): number;
  43067. /**
  43068. * Sets the value of the `Circle` button
  43069. */
  43070. set buttonCircle(value: number);
  43071. /**
  43072. * Gets the value of the `Square` button
  43073. */
  43074. get buttonSquare(): number;
  43075. /**
  43076. * Sets the value of the `Square` button
  43077. */
  43078. set buttonSquare(value: number);
  43079. /**
  43080. * Gets the value of the `Triangle` button
  43081. */
  43082. get buttonTriangle(): number;
  43083. /**
  43084. * Sets the value of the `Triangle` button
  43085. */
  43086. set buttonTriangle(value: number);
  43087. /**
  43088. * Gets the value of the `Options` button
  43089. */
  43090. get buttonOptions(): number;
  43091. /**
  43092. * Sets the value of the `Options` button
  43093. */
  43094. set buttonOptions(value: number);
  43095. /**
  43096. * Gets the value of the `Share` button
  43097. */
  43098. get buttonShare(): number;
  43099. /**
  43100. * Sets the value of the `Share` button
  43101. */
  43102. set buttonShare(value: number);
  43103. /**
  43104. * Gets the value of the `L1` button
  43105. */
  43106. get buttonL1(): number;
  43107. /**
  43108. * Sets the value of the `L1` button
  43109. */
  43110. set buttonL1(value: number);
  43111. /**
  43112. * Gets the value of the `R1` button
  43113. */
  43114. get buttonR1(): number;
  43115. /**
  43116. * Sets the value of the `R1` button
  43117. */
  43118. set buttonR1(value: number);
  43119. /**
  43120. * Gets the value of the Left joystick
  43121. */
  43122. get buttonLeftStick(): number;
  43123. /**
  43124. * Sets the value of the Left joystick
  43125. */
  43126. set buttonLeftStick(value: number);
  43127. /**
  43128. * Gets the value of the Right joystick
  43129. */
  43130. get buttonRightStick(): number;
  43131. /**
  43132. * Sets the value of the Right joystick
  43133. */
  43134. set buttonRightStick(value: number);
  43135. /**
  43136. * Gets the value of D-pad up
  43137. */
  43138. get dPadUp(): number;
  43139. /**
  43140. * Sets the value of D-pad up
  43141. */
  43142. set dPadUp(value: number);
  43143. /**
  43144. * Gets the value of D-pad down
  43145. */
  43146. get dPadDown(): number;
  43147. /**
  43148. * Sets the value of D-pad down
  43149. */
  43150. set dPadDown(value: number);
  43151. /**
  43152. * Gets the value of D-pad left
  43153. */
  43154. get dPadLeft(): number;
  43155. /**
  43156. * Sets the value of D-pad left
  43157. */
  43158. set dPadLeft(value: number);
  43159. /**
  43160. * Gets the value of D-pad right
  43161. */
  43162. get dPadRight(): number;
  43163. /**
  43164. * Sets the value of D-pad right
  43165. */
  43166. set dPadRight(value: number);
  43167. /**
  43168. * Force the gamepad to synchronize with device values
  43169. */
  43170. update(): void;
  43171. /**
  43172. * Disposes the gamepad
  43173. */
  43174. dispose(): void;
  43175. }
  43176. }
  43177. declare module "babylonjs/Gamepads/gamepadManager" {
  43178. import { Observable } from "babylonjs/Misc/observable";
  43179. import { Nullable } from "babylonjs/types";
  43180. import { Scene } from "babylonjs/scene";
  43181. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  43182. /**
  43183. * Manager for handling gamepads
  43184. */
  43185. export class GamepadManager {
  43186. private _scene?;
  43187. private _babylonGamepads;
  43188. private _oneGamepadConnected;
  43189. /** @hidden */
  43190. _isMonitoring: boolean;
  43191. private _gamepadEventSupported;
  43192. private _gamepadSupport?;
  43193. /**
  43194. * observable to be triggered when the gamepad controller has been connected
  43195. */
  43196. onGamepadConnectedObservable: Observable<Gamepad>;
  43197. /**
  43198. * observable to be triggered when the gamepad controller has been disconnected
  43199. */
  43200. onGamepadDisconnectedObservable: Observable<Gamepad>;
  43201. private _onGamepadConnectedEvent;
  43202. private _onGamepadDisconnectedEvent;
  43203. /**
  43204. * Initializes the gamepad manager
  43205. * @param _scene BabylonJS scene
  43206. */
  43207. constructor(_scene?: Scene | undefined);
  43208. /**
  43209. * The gamepads in the game pad manager
  43210. */
  43211. get gamepads(): Gamepad[];
  43212. /**
  43213. * Get the gamepad controllers based on type
  43214. * @param type The type of gamepad controller
  43215. * @returns Nullable gamepad
  43216. */
  43217. getGamepadByType(type?: number): Nullable<Gamepad>;
  43218. /**
  43219. * Disposes the gamepad manager
  43220. */
  43221. dispose(): void;
  43222. private _addNewGamepad;
  43223. private _startMonitoringGamepads;
  43224. private _stopMonitoringGamepads;
  43225. /** @hidden */
  43226. _checkGamepadsStatus(): void;
  43227. private _updateGamepadObjects;
  43228. }
  43229. }
  43230. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  43231. import { Nullable } from "babylonjs/types";
  43232. import { Scene } from "babylonjs/scene";
  43233. import { ISceneComponent } from "babylonjs/sceneComponent";
  43234. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  43235. module "babylonjs/scene" {
  43236. interface Scene {
  43237. /** @hidden */
  43238. _gamepadManager: Nullable<GamepadManager>;
  43239. /**
  43240. * Gets the gamepad manager associated with the scene
  43241. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  43242. */
  43243. gamepadManager: GamepadManager;
  43244. }
  43245. }
  43246. module "babylonjs/Cameras/freeCameraInputsManager" {
  43247. /**
  43248. * Interface representing a free camera inputs manager
  43249. */
  43250. interface FreeCameraInputsManager {
  43251. /**
  43252. * Adds gamepad input support to the FreeCameraInputsManager.
  43253. * @returns the FreeCameraInputsManager
  43254. */
  43255. addGamepad(): FreeCameraInputsManager;
  43256. }
  43257. }
  43258. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  43259. /**
  43260. * Interface representing an arc rotate camera inputs manager
  43261. */
  43262. interface ArcRotateCameraInputsManager {
  43263. /**
  43264. * Adds gamepad input support to the ArcRotateCamera InputManager.
  43265. * @returns the camera inputs manager
  43266. */
  43267. addGamepad(): ArcRotateCameraInputsManager;
  43268. }
  43269. }
  43270. /**
  43271. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  43272. */
  43273. export class GamepadSystemSceneComponent implements ISceneComponent {
  43274. /**
  43275. * The component name helpfull to identify the component in the list of scene components.
  43276. */
  43277. readonly name: string;
  43278. /**
  43279. * The scene the component belongs to.
  43280. */
  43281. scene: Scene;
  43282. /**
  43283. * Creates a new instance of the component for the given scene
  43284. * @param scene Defines the scene to register the component in
  43285. */
  43286. constructor(scene: Scene);
  43287. /**
  43288. * Registers the component in a given scene
  43289. */
  43290. register(): void;
  43291. /**
  43292. * Rebuilds the elements related to this component in case of
  43293. * context lost for instance.
  43294. */
  43295. rebuild(): void;
  43296. /**
  43297. * Disposes the component and the associated ressources
  43298. */
  43299. dispose(): void;
  43300. private _beforeCameraUpdate;
  43301. }
  43302. }
  43303. declare module "babylonjs/Cameras/universalCamera" {
  43304. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  43305. import { Scene } from "babylonjs/scene";
  43306. import { Vector3 } from "babylonjs/Maths/math.vector";
  43307. import "babylonjs/Gamepads/gamepadSceneComponent";
  43308. /**
  43309. * 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,
  43310. * which still works and will still be found in many Playgrounds.
  43311. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  43312. */
  43313. export class UniversalCamera extends TouchCamera {
  43314. /**
  43315. * Defines the gamepad rotation sensiblity.
  43316. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  43317. */
  43318. get gamepadAngularSensibility(): number;
  43319. set gamepadAngularSensibility(value: number);
  43320. /**
  43321. * Defines the gamepad move sensiblity.
  43322. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  43323. */
  43324. get gamepadMoveSensibility(): number;
  43325. set gamepadMoveSensibility(value: number);
  43326. /**
  43327. * 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,
  43328. * which still works and will still be found in many Playgrounds.
  43329. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  43330. * @param name Define the name of the camera in the scene
  43331. * @param position Define the start position of the camera in the scene
  43332. * @param scene Define the scene the camera belongs to
  43333. */
  43334. constructor(name: string, position: Vector3, scene: Scene);
  43335. /**
  43336. * Gets the current object class name.
  43337. * @return the class name
  43338. */
  43339. getClassName(): string;
  43340. }
  43341. }
  43342. declare module "babylonjs/Cameras/gamepadCamera" {
  43343. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  43344. import { Scene } from "babylonjs/scene";
  43345. import { Vector3 } from "babylonjs/Maths/math.vector";
  43346. /**
  43347. * This represents a FPS type of camera. This is only here for back compat purpose.
  43348. * Please use the UniversalCamera instead as both are identical.
  43349. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  43350. */
  43351. export class GamepadCamera extends UniversalCamera {
  43352. /**
  43353. * Instantiates a new Gamepad Camera
  43354. * This represents a FPS type of camera. This is only here for back compat purpose.
  43355. * Please use the UniversalCamera instead as both are identical.
  43356. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  43357. * @param name Define the name of the camera in the scene
  43358. * @param position Define the start position of the camera in the scene
  43359. * @param scene Define the scene the camera belongs to
  43360. */
  43361. constructor(name: string, position: Vector3, scene: Scene);
  43362. /**
  43363. * Gets the current object class name.
  43364. * @return the class name
  43365. */
  43366. getClassName(): string;
  43367. }
  43368. }
  43369. declare module "babylonjs/Shaders/pass.fragment" {
  43370. /** @hidden */
  43371. export var passPixelShader: {
  43372. name: string;
  43373. shader: string;
  43374. };
  43375. }
  43376. declare module "babylonjs/Shaders/passCube.fragment" {
  43377. /** @hidden */
  43378. export var passCubePixelShader: {
  43379. name: string;
  43380. shader: string;
  43381. };
  43382. }
  43383. declare module "babylonjs/PostProcesses/passPostProcess" {
  43384. import { Nullable } from "babylonjs/types";
  43385. import { Camera } from "babylonjs/Cameras/camera";
  43386. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  43387. import { Engine } from "babylonjs/Engines/engine";
  43388. import "babylonjs/Shaders/pass.fragment";
  43389. import "babylonjs/Shaders/passCube.fragment";
  43390. /**
  43391. * PassPostProcess which produces an output the same as it's input
  43392. */
  43393. export class PassPostProcess extends PostProcess {
  43394. /**
  43395. * Creates the PassPostProcess
  43396. * @param name The name of the effect.
  43397. * @param options The required width/height ratio to downsize to before computing the render pass.
  43398. * @param camera The camera to apply the render pass to.
  43399. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  43400. * @param engine The engine which the post process will be applied. (default: current engine)
  43401. * @param reusable If the post process can be reused on the same frame. (default: false)
  43402. * @param textureType The type of texture to be used when performing the post processing.
  43403. * @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)
  43404. */
  43405. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  43406. }
  43407. /**
  43408. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  43409. */
  43410. export class PassCubePostProcess extends PostProcess {
  43411. private _face;
  43412. /**
  43413. * Gets or sets the cube face to display.
  43414. * * 0 is +X
  43415. * * 1 is -X
  43416. * * 2 is +Y
  43417. * * 3 is -Y
  43418. * * 4 is +Z
  43419. * * 5 is -Z
  43420. */
  43421. get face(): number;
  43422. set face(value: number);
  43423. /**
  43424. * Creates the PassCubePostProcess
  43425. * @param name The name of the effect.
  43426. * @param options The required width/height ratio to downsize to before computing the render pass.
  43427. * @param camera The camera to apply the render pass to.
  43428. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  43429. * @param engine The engine which the post process will be applied. (default: current engine)
  43430. * @param reusable If the post process can be reused on the same frame. (default: false)
  43431. * @param textureType The type of texture to be used when performing the post processing.
  43432. * @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)
  43433. */
  43434. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  43435. }
  43436. }
  43437. declare module "babylonjs/Shaders/anaglyph.fragment" {
  43438. /** @hidden */
  43439. export var anaglyphPixelShader: {
  43440. name: string;
  43441. shader: string;
  43442. };
  43443. }
  43444. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  43445. import { Engine } from "babylonjs/Engines/engine";
  43446. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  43447. import { Camera } from "babylonjs/Cameras/camera";
  43448. import "babylonjs/Shaders/anaglyph.fragment";
  43449. /**
  43450. * Postprocess used to generate anaglyphic rendering
  43451. */
  43452. export class AnaglyphPostProcess extends PostProcess {
  43453. private _passedProcess;
  43454. /**
  43455. * Creates a new AnaglyphPostProcess
  43456. * @param name defines postprocess name
  43457. * @param options defines creation options or target ratio scale
  43458. * @param rigCameras defines cameras using this postprocess
  43459. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  43460. * @param engine defines hosting engine
  43461. * @param reusable defines if the postprocess will be reused multiple times per frame
  43462. */
  43463. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  43464. }
  43465. }
  43466. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  43467. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  43468. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43469. import { Scene } from "babylonjs/scene";
  43470. import { Vector3 } from "babylonjs/Maths/math.vector";
  43471. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43472. /**
  43473. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  43474. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  43475. */
  43476. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  43477. /**
  43478. * Creates a new AnaglyphArcRotateCamera
  43479. * @param name defines camera name
  43480. * @param alpha defines alpha angle (in radians)
  43481. * @param beta defines beta angle (in radians)
  43482. * @param radius defines radius
  43483. * @param target defines camera target
  43484. * @param interaxialDistance defines distance between each color axis
  43485. * @param scene defines the hosting scene
  43486. */
  43487. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  43488. /**
  43489. * Gets camera class name
  43490. * @returns AnaglyphArcRotateCamera
  43491. */
  43492. getClassName(): string;
  43493. }
  43494. }
  43495. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  43496. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  43497. import { Scene } from "babylonjs/scene";
  43498. import { Vector3 } from "babylonjs/Maths/math.vector";
  43499. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43500. /**
  43501. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  43502. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  43503. */
  43504. export class AnaglyphFreeCamera extends FreeCamera {
  43505. /**
  43506. * Creates a new AnaglyphFreeCamera
  43507. * @param name defines camera name
  43508. * @param position defines initial position
  43509. * @param interaxialDistance defines distance between each color axis
  43510. * @param scene defines the hosting scene
  43511. */
  43512. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  43513. /**
  43514. * Gets camera class name
  43515. * @returns AnaglyphFreeCamera
  43516. */
  43517. getClassName(): string;
  43518. }
  43519. }
  43520. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  43521. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  43522. import { Scene } from "babylonjs/scene";
  43523. import { Vector3 } from "babylonjs/Maths/math.vector";
  43524. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43525. /**
  43526. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  43527. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  43528. */
  43529. export class AnaglyphGamepadCamera extends GamepadCamera {
  43530. /**
  43531. * Creates a new AnaglyphGamepadCamera
  43532. * @param name defines camera name
  43533. * @param position defines initial position
  43534. * @param interaxialDistance defines distance between each color axis
  43535. * @param scene defines the hosting scene
  43536. */
  43537. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  43538. /**
  43539. * Gets camera class name
  43540. * @returns AnaglyphGamepadCamera
  43541. */
  43542. getClassName(): string;
  43543. }
  43544. }
  43545. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  43546. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  43547. import { Scene } from "babylonjs/scene";
  43548. import { Vector3 } from "babylonjs/Maths/math.vector";
  43549. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43550. /**
  43551. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  43552. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  43553. */
  43554. export class AnaglyphUniversalCamera extends UniversalCamera {
  43555. /**
  43556. * Creates a new AnaglyphUniversalCamera
  43557. * @param name defines camera name
  43558. * @param position defines initial position
  43559. * @param interaxialDistance defines distance between each color axis
  43560. * @param scene defines the hosting scene
  43561. */
  43562. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  43563. /**
  43564. * Gets camera class name
  43565. * @returns AnaglyphUniversalCamera
  43566. */
  43567. getClassName(): string;
  43568. }
  43569. }
  43570. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  43571. /** @hidden */
  43572. export var stereoscopicInterlacePixelShader: {
  43573. name: string;
  43574. shader: string;
  43575. };
  43576. }
  43577. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  43578. import { Camera } from "babylonjs/Cameras/camera";
  43579. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  43580. import { Engine } from "babylonjs/Engines/engine";
  43581. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  43582. /**
  43583. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  43584. */
  43585. export class StereoscopicInterlacePostProcessI extends PostProcess {
  43586. private _stepSize;
  43587. private _passedProcess;
  43588. /**
  43589. * Initializes a StereoscopicInterlacePostProcessI
  43590. * @param name The name of the effect.
  43591. * @param rigCameras The rig cameras to be appled to the post process
  43592. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  43593. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  43594. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  43595. * @param engine The engine which the post process will be applied. (default: current engine)
  43596. * @param reusable If the post process can be reused on the same frame. (default: false)
  43597. */
  43598. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  43599. }
  43600. /**
  43601. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  43602. */
  43603. export class StereoscopicInterlacePostProcess extends PostProcess {
  43604. private _stepSize;
  43605. private _passedProcess;
  43606. /**
  43607. * Initializes a StereoscopicInterlacePostProcess
  43608. * @param name The name of the effect.
  43609. * @param rigCameras The rig cameras to be appled to the post process
  43610. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  43611. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  43612. * @param engine The engine which the post process will be applied. (default: current engine)
  43613. * @param reusable If the post process can be reused on the same frame. (default: false)
  43614. */
  43615. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  43616. }
  43617. }
  43618. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  43619. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  43620. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43621. import { Scene } from "babylonjs/scene";
  43622. import { Vector3 } from "babylonjs/Maths/math.vector";
  43623. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43624. /**
  43625. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  43626. * @see http://doc.babylonjs.com/features/cameras
  43627. */
  43628. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  43629. /**
  43630. * Creates a new StereoscopicArcRotateCamera
  43631. * @param name defines camera name
  43632. * @param alpha defines alpha angle (in radians)
  43633. * @param beta defines beta angle (in radians)
  43634. * @param radius defines radius
  43635. * @param target defines camera target
  43636. * @param interaxialDistance defines distance between each color axis
  43637. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  43638. * @param scene defines the hosting scene
  43639. */
  43640. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  43641. /**
  43642. * Gets camera class name
  43643. * @returns StereoscopicArcRotateCamera
  43644. */
  43645. getClassName(): string;
  43646. }
  43647. }
  43648. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  43649. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  43650. import { Scene } from "babylonjs/scene";
  43651. import { Vector3 } from "babylonjs/Maths/math.vector";
  43652. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43653. /**
  43654. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  43655. * @see http://doc.babylonjs.com/features/cameras
  43656. */
  43657. export class StereoscopicFreeCamera extends FreeCamera {
  43658. /**
  43659. * Creates a new StereoscopicFreeCamera
  43660. * @param name defines camera name
  43661. * @param position defines initial position
  43662. * @param interaxialDistance defines distance between each color axis
  43663. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  43664. * @param scene defines the hosting scene
  43665. */
  43666. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  43667. /**
  43668. * Gets camera class name
  43669. * @returns StereoscopicFreeCamera
  43670. */
  43671. getClassName(): string;
  43672. }
  43673. }
  43674. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  43675. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  43676. import { Scene } from "babylonjs/scene";
  43677. import { Vector3 } from "babylonjs/Maths/math.vector";
  43678. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43679. /**
  43680. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  43681. * @see http://doc.babylonjs.com/features/cameras
  43682. */
  43683. export class StereoscopicGamepadCamera extends GamepadCamera {
  43684. /**
  43685. * Creates a new StereoscopicGamepadCamera
  43686. * @param name defines camera name
  43687. * @param position defines initial position
  43688. * @param interaxialDistance defines distance between each color axis
  43689. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  43690. * @param scene defines the hosting scene
  43691. */
  43692. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  43693. /**
  43694. * Gets camera class name
  43695. * @returns StereoscopicGamepadCamera
  43696. */
  43697. getClassName(): string;
  43698. }
  43699. }
  43700. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  43701. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  43702. import { Scene } from "babylonjs/scene";
  43703. import { Vector3 } from "babylonjs/Maths/math.vector";
  43704. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43705. /**
  43706. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  43707. * @see http://doc.babylonjs.com/features/cameras
  43708. */
  43709. export class StereoscopicUniversalCamera extends UniversalCamera {
  43710. /**
  43711. * Creates a new StereoscopicUniversalCamera
  43712. * @param name defines camera name
  43713. * @param position defines initial position
  43714. * @param interaxialDistance defines distance between each color axis
  43715. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  43716. * @param scene defines the hosting scene
  43717. */
  43718. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  43719. /**
  43720. * Gets camera class name
  43721. * @returns StereoscopicUniversalCamera
  43722. */
  43723. getClassName(): string;
  43724. }
  43725. }
  43726. declare module "babylonjs/Cameras/Stereoscopic/index" {
  43727. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  43728. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  43729. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  43730. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  43731. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  43732. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  43733. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  43734. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  43735. }
  43736. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  43737. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  43738. import { Scene } from "babylonjs/scene";
  43739. import { Vector3 } from "babylonjs/Maths/math.vector";
  43740. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  43741. /**
  43742. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  43743. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  43744. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  43745. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  43746. */
  43747. export class VirtualJoysticksCamera extends FreeCamera {
  43748. /**
  43749. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  43750. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  43751. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  43752. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  43753. * @param name Define the name of the camera in the scene
  43754. * @param position Define the start position of the camera in the scene
  43755. * @param scene Define the scene the camera belongs to
  43756. */
  43757. constructor(name: string, position: Vector3, scene: Scene);
  43758. /**
  43759. * Gets the current object class name.
  43760. * @return the class name
  43761. */
  43762. getClassName(): string;
  43763. }
  43764. }
  43765. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  43766. import { Matrix } from "babylonjs/Maths/math.vector";
  43767. /**
  43768. * This represents all the required metrics to create a VR camera.
  43769. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  43770. */
  43771. export class VRCameraMetrics {
  43772. /**
  43773. * Define the horizontal resolution off the screen.
  43774. */
  43775. hResolution: number;
  43776. /**
  43777. * Define the vertical resolution off the screen.
  43778. */
  43779. vResolution: number;
  43780. /**
  43781. * Define the horizontal screen size.
  43782. */
  43783. hScreenSize: number;
  43784. /**
  43785. * Define the vertical screen size.
  43786. */
  43787. vScreenSize: number;
  43788. /**
  43789. * Define the vertical screen center position.
  43790. */
  43791. vScreenCenter: number;
  43792. /**
  43793. * Define the distance of the eyes to the screen.
  43794. */
  43795. eyeToScreenDistance: number;
  43796. /**
  43797. * Define the distance between both lenses
  43798. */
  43799. lensSeparationDistance: number;
  43800. /**
  43801. * Define the distance between both viewer's eyes.
  43802. */
  43803. interpupillaryDistance: number;
  43804. /**
  43805. * Define the distortion factor of the VR postprocess.
  43806. * Please, touch with care.
  43807. */
  43808. distortionK: number[];
  43809. /**
  43810. * Define the chromatic aberration correction factors for the VR post process.
  43811. */
  43812. chromaAbCorrection: number[];
  43813. /**
  43814. * Define the scale factor of the post process.
  43815. * The smaller the better but the slower.
  43816. */
  43817. postProcessScaleFactor: number;
  43818. /**
  43819. * Define an offset for the lens center.
  43820. */
  43821. lensCenterOffset: number;
  43822. /**
  43823. * Define if the current vr camera should compensate the distortion of the lense or not.
  43824. */
  43825. compensateDistortion: boolean;
  43826. /**
  43827. * Defines if multiview should be enabled when rendering (Default: false)
  43828. */
  43829. multiviewEnabled: boolean;
  43830. /**
  43831. * Gets the rendering aspect ratio based on the provided resolutions.
  43832. */
  43833. get aspectRatio(): number;
  43834. /**
  43835. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  43836. */
  43837. get aspectRatioFov(): number;
  43838. /**
  43839. * @hidden
  43840. */
  43841. get leftHMatrix(): Matrix;
  43842. /**
  43843. * @hidden
  43844. */
  43845. get rightHMatrix(): Matrix;
  43846. /**
  43847. * @hidden
  43848. */
  43849. get leftPreViewMatrix(): Matrix;
  43850. /**
  43851. * @hidden
  43852. */
  43853. get rightPreViewMatrix(): Matrix;
  43854. /**
  43855. * Get the default VRMetrics based on the most generic setup.
  43856. * @returns the default vr metrics
  43857. */
  43858. static GetDefault(): VRCameraMetrics;
  43859. }
  43860. }
  43861. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  43862. /** @hidden */
  43863. export var vrDistortionCorrectionPixelShader: {
  43864. name: string;
  43865. shader: string;
  43866. };
  43867. }
  43868. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  43869. import { Camera } from "babylonjs/Cameras/camera";
  43870. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  43871. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  43872. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  43873. /**
  43874. * VRDistortionCorrectionPostProcess used for mobile VR
  43875. */
  43876. export class VRDistortionCorrectionPostProcess extends PostProcess {
  43877. private _isRightEye;
  43878. private _distortionFactors;
  43879. private _postProcessScaleFactor;
  43880. private _lensCenterOffset;
  43881. private _scaleIn;
  43882. private _scaleFactor;
  43883. private _lensCenter;
  43884. /**
  43885. * Initializes the VRDistortionCorrectionPostProcess
  43886. * @param name The name of the effect.
  43887. * @param camera The camera to apply the render pass to.
  43888. * @param isRightEye If this is for the right eye distortion
  43889. * @param vrMetrics All the required metrics for the VR camera
  43890. */
  43891. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  43892. }
  43893. }
  43894. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  43895. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  43896. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43897. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  43898. import { Scene } from "babylonjs/scene";
  43899. import { Vector3 } from "babylonjs/Maths/math.vector";
  43900. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  43901. import "babylonjs/Cameras/RigModes/vrRigMode";
  43902. /**
  43903. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  43904. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  43905. */
  43906. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  43907. /**
  43908. * Creates a new VRDeviceOrientationArcRotateCamera
  43909. * @param name defines camera name
  43910. * @param alpha defines the camera rotation along the logitudinal axis
  43911. * @param beta defines the camera rotation along the latitudinal axis
  43912. * @param radius defines the camera distance from its target
  43913. * @param target defines the camera target
  43914. * @param scene defines the scene the camera belongs to
  43915. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  43916. * @param vrCameraMetrics defines the vr metrics associated to the camera
  43917. */
  43918. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  43919. /**
  43920. * Gets camera class name
  43921. * @returns VRDeviceOrientationArcRotateCamera
  43922. */
  43923. getClassName(): string;
  43924. }
  43925. }
  43926. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  43927. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  43928. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  43929. import { Scene } from "babylonjs/scene";
  43930. import { Vector3 } from "babylonjs/Maths/math.vector";
  43931. import "babylonjs/Cameras/RigModes/vrRigMode";
  43932. /**
  43933. * Camera used to simulate VR rendering (based on FreeCamera)
  43934. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  43935. */
  43936. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  43937. /**
  43938. * Creates a new VRDeviceOrientationFreeCamera
  43939. * @param name defines camera name
  43940. * @param position defines the start position of the camera
  43941. * @param scene defines the scene the camera belongs to
  43942. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  43943. * @param vrCameraMetrics defines the vr metrics associated to the camera
  43944. */
  43945. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  43946. /**
  43947. * Gets camera class name
  43948. * @returns VRDeviceOrientationFreeCamera
  43949. */
  43950. getClassName(): string;
  43951. }
  43952. }
  43953. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  43954. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  43955. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  43956. import { Scene } from "babylonjs/scene";
  43957. import { Vector3 } from "babylonjs/Maths/math.vector";
  43958. import "babylonjs/Gamepads/gamepadSceneComponent";
  43959. /**
  43960. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  43961. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  43962. */
  43963. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  43964. /**
  43965. * Creates a new VRDeviceOrientationGamepadCamera
  43966. * @param name defines camera name
  43967. * @param position defines the start position of the camera
  43968. * @param scene defines the scene the camera belongs to
  43969. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  43970. * @param vrCameraMetrics defines the vr metrics associated to the camera
  43971. */
  43972. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  43973. /**
  43974. * Gets camera class name
  43975. * @returns VRDeviceOrientationGamepadCamera
  43976. */
  43977. getClassName(): string;
  43978. }
  43979. }
  43980. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  43981. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  43982. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  43983. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  43984. /** @hidden */
  43985. export var imageProcessingPixelShader: {
  43986. name: string;
  43987. shader: string;
  43988. };
  43989. }
  43990. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  43991. import { Nullable } from "babylonjs/types";
  43992. import { Color4 } from "babylonjs/Maths/math.color";
  43993. import { Camera } from "babylonjs/Cameras/camera";
  43994. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  43995. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  43996. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  43997. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  43998. import { Engine } from "babylonjs/Engines/engine";
  43999. import "babylonjs/Shaders/imageProcessing.fragment";
  44000. import "babylonjs/Shaders/postprocess.vertex";
  44001. /**
  44002. * ImageProcessingPostProcess
  44003. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  44004. */
  44005. export class ImageProcessingPostProcess extends PostProcess {
  44006. /**
  44007. * Default configuration related to image processing available in the PBR Material.
  44008. */
  44009. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  44010. /**
  44011. * Gets the image processing configuration used either in this material.
  44012. */
  44013. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  44014. /**
  44015. * Sets the Default image processing configuration used either in the this material.
  44016. *
  44017. * If sets to null, the scene one is in use.
  44018. */
  44019. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  44020. /**
  44021. * Keep track of the image processing observer to allow dispose and replace.
  44022. */
  44023. private _imageProcessingObserver;
  44024. /**
  44025. * Attaches a new image processing configuration to the PBR Material.
  44026. * @param configuration
  44027. */
  44028. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  44029. /**
  44030. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  44031. */
  44032. get colorCurves(): Nullable<ColorCurves>;
  44033. /**
  44034. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  44035. */
  44036. set colorCurves(value: Nullable<ColorCurves>);
  44037. /**
  44038. * Gets wether the color curves effect is enabled.
  44039. */
  44040. get colorCurvesEnabled(): boolean;
  44041. /**
  44042. * Sets wether the color curves effect is enabled.
  44043. */
  44044. set colorCurvesEnabled(value: boolean);
  44045. /**
  44046. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  44047. */
  44048. get colorGradingTexture(): Nullable<BaseTexture>;
  44049. /**
  44050. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  44051. */
  44052. set colorGradingTexture(value: Nullable<BaseTexture>);
  44053. /**
  44054. * Gets wether the color grading effect is enabled.
  44055. */
  44056. get colorGradingEnabled(): boolean;
  44057. /**
  44058. * Gets wether the color grading effect is enabled.
  44059. */
  44060. set colorGradingEnabled(value: boolean);
  44061. /**
  44062. * Gets exposure used in the effect.
  44063. */
  44064. get exposure(): number;
  44065. /**
  44066. * Sets exposure used in the effect.
  44067. */
  44068. set exposure(value: number);
  44069. /**
  44070. * Gets wether tonemapping is enabled or not.
  44071. */
  44072. get toneMappingEnabled(): boolean;
  44073. /**
  44074. * Sets wether tonemapping is enabled or not
  44075. */
  44076. set toneMappingEnabled(value: boolean);
  44077. /**
  44078. * Gets the type of tone mapping effect.
  44079. */
  44080. get toneMappingType(): number;
  44081. /**
  44082. * Sets the type of tone mapping effect.
  44083. */
  44084. set toneMappingType(value: number);
  44085. /**
  44086. * Gets contrast used in the effect.
  44087. */
  44088. get contrast(): number;
  44089. /**
  44090. * Sets contrast used in the effect.
  44091. */
  44092. set contrast(value: number);
  44093. /**
  44094. * Gets Vignette stretch size.
  44095. */
  44096. get vignetteStretch(): number;
  44097. /**
  44098. * Sets Vignette stretch size.
  44099. */
  44100. set vignetteStretch(value: number);
  44101. /**
  44102. * Gets Vignette centre X Offset.
  44103. */
  44104. get vignetteCentreX(): number;
  44105. /**
  44106. * Sets Vignette centre X Offset.
  44107. */
  44108. set vignetteCentreX(value: number);
  44109. /**
  44110. * Gets Vignette centre Y Offset.
  44111. */
  44112. get vignetteCentreY(): number;
  44113. /**
  44114. * Sets Vignette centre Y Offset.
  44115. */
  44116. set vignetteCentreY(value: number);
  44117. /**
  44118. * Gets Vignette weight or intensity of the vignette effect.
  44119. */
  44120. get vignetteWeight(): number;
  44121. /**
  44122. * Sets Vignette weight or intensity of the vignette effect.
  44123. */
  44124. set vignetteWeight(value: number);
  44125. /**
  44126. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  44127. * if vignetteEnabled is set to true.
  44128. */
  44129. get vignetteColor(): Color4;
  44130. /**
  44131. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  44132. * if vignetteEnabled is set to true.
  44133. */
  44134. set vignetteColor(value: Color4);
  44135. /**
  44136. * Gets Camera field of view used by the Vignette effect.
  44137. */
  44138. get vignetteCameraFov(): number;
  44139. /**
  44140. * Sets Camera field of view used by the Vignette effect.
  44141. */
  44142. set vignetteCameraFov(value: number);
  44143. /**
  44144. * Gets the vignette blend mode allowing different kind of effect.
  44145. */
  44146. get vignetteBlendMode(): number;
  44147. /**
  44148. * Sets the vignette blend mode allowing different kind of effect.
  44149. */
  44150. set vignetteBlendMode(value: number);
  44151. /**
  44152. * Gets wether the vignette effect is enabled.
  44153. */
  44154. get vignetteEnabled(): boolean;
  44155. /**
  44156. * Sets wether the vignette effect is enabled.
  44157. */
  44158. set vignetteEnabled(value: boolean);
  44159. private _fromLinearSpace;
  44160. /**
  44161. * Gets wether the input of the processing is in Gamma or Linear Space.
  44162. */
  44163. get fromLinearSpace(): boolean;
  44164. /**
  44165. * Sets wether the input of the processing is in Gamma or Linear Space.
  44166. */
  44167. set fromLinearSpace(value: boolean);
  44168. /**
  44169. * Defines cache preventing GC.
  44170. */
  44171. private _defines;
  44172. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  44173. /**
  44174. * "ImageProcessingPostProcess"
  44175. * @returns "ImageProcessingPostProcess"
  44176. */
  44177. getClassName(): string;
  44178. protected _updateParameters(): void;
  44179. dispose(camera?: Camera): void;
  44180. }
  44181. }
  44182. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  44183. import { Scene } from "babylonjs/scene";
  44184. import { Color3 } from "babylonjs/Maths/math.color";
  44185. import { Mesh } from "babylonjs/Meshes/mesh";
  44186. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  44187. import { Nullable } from "babylonjs/types";
  44188. /**
  44189. * Class containing static functions to help procedurally build meshes
  44190. */
  44191. export class GroundBuilder {
  44192. /**
  44193. * Creates a ground mesh
  44194. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  44195. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  44196. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44197. * @param name defines the name of the mesh
  44198. * @param options defines the options used to create the mesh
  44199. * @param scene defines the hosting scene
  44200. * @returns the ground mesh
  44201. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  44202. */
  44203. static CreateGround(name: string, options: {
  44204. width?: number;
  44205. height?: number;
  44206. subdivisions?: number;
  44207. subdivisionsX?: number;
  44208. subdivisionsY?: number;
  44209. updatable?: boolean;
  44210. }, scene: any): Mesh;
  44211. /**
  44212. * Creates a tiled ground mesh
  44213. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  44214. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  44215. * * 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
  44216. * * 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
  44217. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  44218. * @param name defines the name of the mesh
  44219. * @param options defines the options used to create the mesh
  44220. * @param scene defines the hosting scene
  44221. * @returns the tiled ground mesh
  44222. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  44223. */
  44224. static CreateTiledGround(name: string, options: {
  44225. xmin: number;
  44226. zmin: number;
  44227. xmax: number;
  44228. zmax: number;
  44229. subdivisions?: {
  44230. w: number;
  44231. h: number;
  44232. };
  44233. precision?: {
  44234. w: number;
  44235. h: number;
  44236. };
  44237. updatable?: boolean;
  44238. }, scene?: Nullable<Scene>): Mesh;
  44239. /**
  44240. * Creates a ground mesh from a height map
  44241. * * The parameter `url` sets the URL of the height map image resource.
  44242. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  44243. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  44244. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  44245. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  44246. * * 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.
  44247. * * 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).
  44248. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  44249. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  44250. * @param name defines the name of the mesh
  44251. * @param url defines the url to the height map
  44252. * @param options defines the options used to create the mesh
  44253. * @param scene defines the hosting scene
  44254. * @returns the ground mesh
  44255. * @see https://doc.babylonjs.com/babylon101/height_map
  44256. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  44257. */
  44258. static CreateGroundFromHeightMap(name: string, url: string, options: {
  44259. width?: number;
  44260. height?: number;
  44261. subdivisions?: number;
  44262. minHeight?: number;
  44263. maxHeight?: number;
  44264. colorFilter?: Color3;
  44265. alphaFilter?: number;
  44266. updatable?: boolean;
  44267. onReady?: (mesh: GroundMesh) => void;
  44268. }, scene?: Nullable<Scene>): GroundMesh;
  44269. }
  44270. }
  44271. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  44272. import { Vector4 } from "babylonjs/Maths/math.vector";
  44273. import { Mesh } from "babylonjs/Meshes/mesh";
  44274. /**
  44275. * Class containing static functions to help procedurally build meshes
  44276. */
  44277. export class TorusBuilder {
  44278. /**
  44279. * Creates a torus mesh
  44280. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  44281. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  44282. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  44283. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44284. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  44285. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  44286. * @param name defines the name of the mesh
  44287. * @param options defines the options used to create the mesh
  44288. * @param scene defines the hosting scene
  44289. * @returns the torus mesh
  44290. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  44291. */
  44292. static CreateTorus(name: string, options: {
  44293. diameter?: number;
  44294. thickness?: number;
  44295. tessellation?: number;
  44296. updatable?: boolean;
  44297. sideOrientation?: number;
  44298. frontUVs?: Vector4;
  44299. backUVs?: Vector4;
  44300. }, scene: any): Mesh;
  44301. }
  44302. }
  44303. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  44304. import { Vector4 } from "babylonjs/Maths/math.vector";
  44305. import { Color4 } from "babylonjs/Maths/math.color";
  44306. import { Mesh } from "babylonjs/Meshes/mesh";
  44307. /**
  44308. * Class containing static functions to help procedurally build meshes
  44309. */
  44310. export class CylinderBuilder {
  44311. /**
  44312. * Creates a cylinder or a cone mesh
  44313. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  44314. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  44315. * * 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.
  44316. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  44317. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  44318. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  44319. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  44320. * * 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).
  44321. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  44322. * * 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).
  44323. * * 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
  44324. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  44325. * * 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
  44326. * * 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.
  44327. * * If `enclose` is false, a ring surface is one element.
  44328. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  44329. * * 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
  44330. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44331. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  44332. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  44333. * @param name defines the name of the mesh
  44334. * @param options defines the options used to create the mesh
  44335. * @param scene defines the hosting scene
  44336. * @returns the cylinder mesh
  44337. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  44338. */
  44339. static CreateCylinder(name: string, options: {
  44340. height?: number;
  44341. diameterTop?: number;
  44342. diameterBottom?: number;
  44343. diameter?: number;
  44344. tessellation?: number;
  44345. subdivisions?: number;
  44346. arc?: number;
  44347. faceColors?: Color4[];
  44348. faceUV?: Vector4[];
  44349. updatable?: boolean;
  44350. hasRings?: boolean;
  44351. enclose?: boolean;
  44352. cap?: number;
  44353. sideOrientation?: number;
  44354. frontUVs?: Vector4;
  44355. backUVs?: Vector4;
  44356. }, scene: any): Mesh;
  44357. }
  44358. }
  44359. declare module "babylonjs/XR/webXRTypes" {
  44360. import { Nullable } from "babylonjs/types";
  44361. import { IDisposable } from "babylonjs/scene";
  44362. /**
  44363. * States of the webXR experience
  44364. */
  44365. export enum WebXRState {
  44366. /**
  44367. * Transitioning to being in XR mode
  44368. */
  44369. ENTERING_XR = 0,
  44370. /**
  44371. * Transitioning to non XR mode
  44372. */
  44373. EXITING_XR = 1,
  44374. /**
  44375. * In XR mode and presenting
  44376. */
  44377. IN_XR = 2,
  44378. /**
  44379. * Not entered XR mode
  44380. */
  44381. NOT_IN_XR = 3
  44382. }
  44383. /**
  44384. * Abstraction of the XR render target
  44385. */
  44386. export interface WebXRRenderTarget extends IDisposable {
  44387. /**
  44388. * xrpresent context of the canvas which can be used to display/mirror xr content
  44389. */
  44390. canvasContext: WebGLRenderingContext;
  44391. /**
  44392. * xr layer for the canvas
  44393. */
  44394. xrLayer: Nullable<XRWebGLLayer>;
  44395. /**
  44396. * Initializes the xr layer for the session
  44397. * @param xrSession xr session
  44398. * @returns a promise that will resolve once the XR Layer has been created
  44399. */
  44400. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  44401. }
  44402. }
  44403. declare module "babylonjs/XR/webXRManagedOutputCanvas" {
  44404. import { Nullable } from "babylonjs/types";
  44405. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  44406. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  44407. /**
  44408. * COnfiguration object for WebXR output canvas
  44409. */
  44410. export class WebXRManagedOutputCanvasOptions {
  44411. /**
  44412. * An optional canvas in case you wish to create it yourself and provide it here.
  44413. * If not provided, a new canvas will be created
  44414. */
  44415. canvasElement?: HTMLCanvasElement;
  44416. /**
  44417. * Options for this XR Layer output
  44418. */
  44419. canvasOptions?: XRWebGLLayerOptions;
  44420. /**
  44421. * CSS styling for a newly created canvas (if not provided)
  44422. */
  44423. newCanvasCssStyle?: string;
  44424. /**
  44425. * Get the default values of the configuration object
  44426. * @returns default values of this configuration object
  44427. */
  44428. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  44429. }
  44430. /**
  44431. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  44432. */
  44433. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  44434. private _options;
  44435. private _canvas;
  44436. private _engine;
  44437. /**
  44438. * Rendering context of the canvas which can be used to display/mirror xr content
  44439. */
  44440. canvasContext: WebGLRenderingContext;
  44441. /**
  44442. * xr layer for the canvas
  44443. */
  44444. xrLayer: Nullable<XRWebGLLayer>;
  44445. /**
  44446. * Initializes the canvas to be added/removed upon entering/exiting xr
  44447. * @param _xrSessionManager The XR Session manager
  44448. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  44449. */
  44450. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  44451. /**
  44452. * Disposes of the object
  44453. */
  44454. dispose(): void;
  44455. /**
  44456. * Initializes the xr layer for the session
  44457. * @param xrSession xr session
  44458. * @returns a promise that will resolve once the XR Layer has been created
  44459. */
  44460. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  44461. private _addCanvas;
  44462. private _removeCanvas;
  44463. private _setManagedOutputCanvas;
  44464. }
  44465. }
  44466. declare module "babylonjs/XR/webXRSessionManager" {
  44467. import { Observable } from "babylonjs/Misc/observable";
  44468. import { Nullable } from "babylonjs/types";
  44469. import { IDisposable, Scene } from "babylonjs/scene";
  44470. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  44471. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  44472. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  44473. /**
  44474. * Manages an XRSession to work with Babylon's engine
  44475. * @see https://doc.babylonjs.com/how_to/webxr
  44476. */
  44477. export class WebXRSessionManager implements IDisposable {
  44478. /** The scene which the session should be created for */
  44479. scene: Scene;
  44480. private _referenceSpace;
  44481. private _rttProvider;
  44482. private _sessionEnded;
  44483. private _xrNavigator;
  44484. private baseLayer;
  44485. /**
  44486. * The base reference space from which the session started. good if you want to reset your
  44487. * reference space
  44488. */
  44489. baseReferenceSpace: XRReferenceSpace;
  44490. /**
  44491. * Current XR frame
  44492. */
  44493. currentFrame: Nullable<XRFrame>;
  44494. /** WebXR timestamp updated every frame */
  44495. currentTimestamp: number;
  44496. /**
  44497. * Used just in case of a failure to initialize an immersive session.
  44498. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  44499. */
  44500. defaultHeightCompensation: number;
  44501. /**
  44502. * Fires every time a new xrFrame arrives which can be used to update the camera
  44503. */
  44504. onXRFrameObservable: Observable<XRFrame>;
  44505. /**
  44506. * Fires when the reference space changed
  44507. */
  44508. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  44509. /**
  44510. * Fires when the xr session is ended either by the device or manually done
  44511. */
  44512. onXRSessionEnded: Observable<any>;
  44513. /**
  44514. * Fires when the xr session is ended either by the device or manually done
  44515. */
  44516. onXRSessionInit: Observable<XRSession>;
  44517. /**
  44518. * Underlying xr session
  44519. */
  44520. session: XRSession;
  44521. /**
  44522. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  44523. * or get the offset the player is currently at.
  44524. */
  44525. viewerReferenceSpace: XRReferenceSpace;
  44526. /**
  44527. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  44528. * @param scene The scene which the session should be created for
  44529. */
  44530. constructor(
  44531. /** The scene which the session should be created for */
  44532. scene: Scene);
  44533. /**
  44534. * The current reference space used in this session. This reference space can constantly change!
  44535. * It is mainly used to offset the camera's position.
  44536. */
  44537. get referenceSpace(): XRReferenceSpace;
  44538. /**
  44539. * Set a new reference space and triggers the observable
  44540. */
  44541. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  44542. /**
  44543. * Disposes of the session manager
  44544. */
  44545. dispose(): void;
  44546. /**
  44547. * Stops the xrSession and restores the render loop
  44548. * @returns Promise which resolves after it exits XR
  44549. */
  44550. exitXRAsync(): Promise<void>;
  44551. /**
  44552. * Gets the correct render target texture to be rendered this frame for this eye
  44553. * @param eye the eye for which to get the render target
  44554. * @returns the render target for the specified eye
  44555. */
  44556. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  44557. /**
  44558. * Creates a WebXRRenderTarget object for the XR session
  44559. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  44560. * @param options optional options to provide when creating a new render target
  44561. * @returns a WebXR render target to which the session can render
  44562. */
  44563. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  44564. /**
  44565. * Initializes the manager
  44566. * After initialization enterXR can be called to start an XR session
  44567. * @returns Promise which resolves after it is initialized
  44568. */
  44569. initializeAsync(): Promise<void>;
  44570. /**
  44571. * Initializes an xr session
  44572. * @param xrSessionMode mode to initialize
  44573. * @param xrSessionInit defines optional and required values to pass to the session builder
  44574. * @returns a promise which will resolve once the session has been initialized
  44575. */
  44576. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  44577. /**
  44578. * Checks if a session would be supported for the creation options specified
  44579. * @param sessionMode session mode to check if supported eg. immersive-vr
  44580. * @returns A Promise that resolves to true if supported and false if not
  44581. */
  44582. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  44583. /**
  44584. * Resets the reference space to the one started the session
  44585. */
  44586. resetReferenceSpace(): void;
  44587. /**
  44588. * Starts rendering to the xr layer
  44589. */
  44590. runXRRenderLoop(): void;
  44591. /**
  44592. * Sets the reference space on the xr session
  44593. * @param referenceSpaceType space to set
  44594. * @returns a promise that will resolve once the reference space has been set
  44595. */
  44596. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  44597. /**
  44598. * Updates the render state of the session
  44599. * @param state state to set
  44600. * @returns a promise that resolves once the render state has been updated
  44601. */
  44602. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  44603. /**
  44604. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  44605. * @param sessionMode defines the session to test
  44606. * @returns a promise with boolean as final value
  44607. */
  44608. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  44609. private _createRenderTargetTexture;
  44610. }
  44611. }
  44612. declare module "babylonjs/XR/webXRCamera" {
  44613. import { Scene } from "babylonjs/scene";
  44614. import { Camera } from "babylonjs/Cameras/camera";
  44615. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  44616. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  44617. /**
  44618. * WebXR Camera which holds the views for the xrSession
  44619. * @see https://doc.babylonjs.com/how_to/webxr_camera
  44620. */
  44621. export class WebXRCamera extends FreeCamera {
  44622. private _xrSessionManager;
  44623. private _firstFrame;
  44624. private _referenceQuaternion;
  44625. private _referencedPosition;
  44626. private _xrInvPositionCache;
  44627. private _xrInvQuaternionCache;
  44628. /**
  44629. * Should position compensation execute on first frame.
  44630. * This is used when copying the position from a native (non XR) camera
  44631. */
  44632. compensateOnFirstFrame: boolean;
  44633. /**
  44634. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  44635. * @param name the name of the camera
  44636. * @param scene the scene to add the camera to
  44637. * @param _xrSessionManager a constructed xr session manager
  44638. */
  44639. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  44640. /**
  44641. * Return the user's height, unrelated to the current ground.
  44642. * This will be the y position of this camera, when ground level is 0.
  44643. */
  44644. get realWorldHeight(): number;
  44645. /** @hidden */
  44646. _updateForDualEyeDebugging(): void;
  44647. /**
  44648. * Sets this camera's transformation based on a non-vr camera
  44649. * @param otherCamera the non-vr camera to copy the transformation from
  44650. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  44651. */
  44652. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  44653. /**
  44654. * Gets the current instance class name ("WebXRCamera").
  44655. * @returns the class name
  44656. */
  44657. getClassName(): string;
  44658. private _updateFromXRSession;
  44659. private _updateNumberOfRigCameras;
  44660. private _updateReferenceSpace;
  44661. private _updateReferenceSpaceOffset;
  44662. }
  44663. }
  44664. declare module "babylonjs/XR/webXRFeaturesManager" {
  44665. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  44666. import { IDisposable } from "babylonjs/scene";
  44667. /**
  44668. * Defining the interface required for a (webxr) feature
  44669. */
  44670. export interface IWebXRFeature extends IDisposable {
  44671. /**
  44672. * Is this feature attached
  44673. */
  44674. attached: boolean;
  44675. /**
  44676. * Should auto-attach be disabled?
  44677. */
  44678. disableAutoAttach: boolean;
  44679. /**
  44680. * Attach the feature to the session
  44681. * Will usually be called by the features manager
  44682. *
  44683. * @param force should attachment be forced (even when already attached)
  44684. * @returns true if successful.
  44685. */
  44686. attach(force?: boolean): boolean;
  44687. /**
  44688. * Detach the feature from the session
  44689. * Will usually be called by the features manager
  44690. *
  44691. * @returns true if successful.
  44692. */
  44693. detach(): boolean;
  44694. }
  44695. /**
  44696. * A list of the currently available features without referencing them
  44697. */
  44698. export class WebXRFeatureName {
  44699. /**
  44700. * The name of the anchor system feature
  44701. */
  44702. static ANCHOR_SYSTEM: string;
  44703. /**
  44704. * The name of the background remover feature
  44705. */
  44706. static BACKGROUND_REMOVER: string;
  44707. /**
  44708. * The name of the hit test feature
  44709. */
  44710. static HIT_TEST: string;
  44711. /**
  44712. * physics impostors for xr controllers feature
  44713. */
  44714. static PHYSICS_CONTROLLERS: string;
  44715. /**
  44716. * The name of the plane detection feature
  44717. */
  44718. static PLANE_DETECTION: string;
  44719. /**
  44720. * The name of the pointer selection feature
  44721. */
  44722. static POINTER_SELECTION: string;
  44723. /**
  44724. * The name of the teleportation feature
  44725. */
  44726. static TELEPORTATION: string;
  44727. }
  44728. /**
  44729. * Defining the constructor of a feature. Used to register the modules.
  44730. */
  44731. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  44732. /**
  44733. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  44734. * It is mainly used in AR sessions.
  44735. *
  44736. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  44737. */
  44738. export class WebXRFeaturesManager implements IDisposable {
  44739. private _xrSessionManager;
  44740. private static readonly _AvailableFeatures;
  44741. private _features;
  44742. /**
  44743. * constructs a new features manages.
  44744. *
  44745. * @param _xrSessionManager an instance of WebXRSessionManager
  44746. */
  44747. constructor(_xrSessionManager: WebXRSessionManager);
  44748. /**
  44749. * Used to register a module. After calling this function a developer can use this feature in the scene.
  44750. * Mainly used internally.
  44751. *
  44752. * @param featureName the name of the feature to register
  44753. * @param constructorFunction the function used to construct the module
  44754. * @param version the (babylon) version of the module
  44755. * @param stable is that a stable version of this module
  44756. */
  44757. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  44758. /**
  44759. * Returns a constructor of a specific feature.
  44760. *
  44761. * @param featureName the name of the feature to construct
  44762. * @param version the version of the feature to load
  44763. * @param xrSessionManager the xrSessionManager. Used to construct the module
  44764. * @param options optional options provided to the module.
  44765. * @returns a function that, when called, will return a new instance of this feature
  44766. */
  44767. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  44768. /**
  44769. * Can be used to return the list of features currently registered
  44770. *
  44771. * @returns an Array of available features
  44772. */
  44773. static GetAvailableFeatures(): string[];
  44774. /**
  44775. * Gets the versions available for a specific feature
  44776. * @param featureName the name of the feature
  44777. * @returns an array with the available versions
  44778. */
  44779. static GetAvailableVersions(featureName: string): string[];
  44780. /**
  44781. * Return the latest unstable version of this feature
  44782. * @param featureName the name of the feature to search
  44783. * @returns the version number. if not found will return -1
  44784. */
  44785. static GetLatestVersionOfFeature(featureName: string): number;
  44786. /**
  44787. * Return the latest stable version of this feature
  44788. * @param featureName the name of the feature to search
  44789. * @returns the version number. if not found will return -1
  44790. */
  44791. static GetStableVersionOfFeature(featureName: string): number;
  44792. /**
  44793. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  44794. * Can be used during a session to start a feature
  44795. * @param featureName the name of feature to attach
  44796. */
  44797. attachFeature(featureName: string): void;
  44798. /**
  44799. * Can be used inside a session or when the session ends to detach a specific feature
  44800. * @param featureName the name of the feature to detach
  44801. */
  44802. detachFeature(featureName: string): void;
  44803. /**
  44804. * Used to disable an already-enabled feature
  44805. * The feature will be disposed and will be recreated once enabled.
  44806. * @param featureName the feature to disable
  44807. * @returns true if disable was successful
  44808. */
  44809. disableFeature(featureName: string | {
  44810. Name: string;
  44811. }): boolean;
  44812. /**
  44813. * dispose this features manager
  44814. */
  44815. dispose(): void;
  44816. /**
  44817. * 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.
  44818. * 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.
  44819. *
  44820. * @param featureName the name of the feature to load or the class of the feature
  44821. * @param version optional version to load. if not provided the latest version will be enabled
  44822. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  44823. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  44824. * @returns a new constructed feature or throws an error if feature not found.
  44825. */
  44826. enableFeature(featureName: string | {
  44827. Name: string;
  44828. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  44829. /**
  44830. * get the implementation of an enabled feature.
  44831. * @param featureName the name of the feature to load
  44832. * @returns the feature class, if found
  44833. */
  44834. getEnabledFeature(featureName: string): IWebXRFeature;
  44835. /**
  44836. * Get the list of enabled features
  44837. * @returns an array of enabled features
  44838. */
  44839. getEnabledFeatures(): string[];
  44840. }
  44841. }
  44842. declare module "babylonjs/XR/webXRExperienceHelper" {
  44843. import { Observable } from "babylonjs/Misc/observable";
  44844. import { IDisposable, Scene } from "babylonjs/scene";
  44845. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  44846. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  44847. import { WebXRState, WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  44848. import { WebXRFeaturesManager } from "babylonjs/XR/webXRFeaturesManager";
  44849. /**
  44850. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  44851. * @see https://doc.babylonjs.com/how_to/webxr
  44852. */
  44853. export class WebXRExperienceHelper implements IDisposable {
  44854. private scene;
  44855. private _nonVRCamera;
  44856. private _originalSceneAutoClear;
  44857. private _supported;
  44858. /**
  44859. * Camera used to render xr content
  44860. */
  44861. camera: WebXRCamera;
  44862. /** A features manager for this xr session */
  44863. featuresManager: WebXRFeaturesManager;
  44864. /**
  44865. * Observers registered here will be triggered after the camera's initial transformation is set
  44866. * This can be used to set a different ground level or an extra rotation.
  44867. *
  44868. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  44869. * to the position set after this observable is done executing.
  44870. */
  44871. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  44872. /**
  44873. * Fires when the state of the experience helper has changed
  44874. */
  44875. onStateChangedObservable: Observable<WebXRState>;
  44876. /** Session manager used to keep track of xr session */
  44877. sessionManager: WebXRSessionManager;
  44878. /**
  44879. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  44880. */
  44881. state: WebXRState;
  44882. /**
  44883. * Creates a WebXRExperienceHelper
  44884. * @param scene The scene the helper should be created in
  44885. */
  44886. private constructor();
  44887. /**
  44888. * Creates the experience helper
  44889. * @param scene the scene to attach the experience helper to
  44890. * @returns a promise for the experience helper
  44891. */
  44892. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  44893. /**
  44894. * Disposes of the experience helper
  44895. */
  44896. dispose(): void;
  44897. /**
  44898. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  44899. * @param sessionMode options for the XR session
  44900. * @param referenceSpaceType frame of reference of the XR session
  44901. * @param renderTarget the output canvas that will be used to enter XR mode
  44902. * @returns promise that resolves after xr mode has entered
  44903. */
  44904. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget): Promise<WebXRSessionManager>;
  44905. /**
  44906. * Exits XR mode and returns the scene to its original state
  44907. * @returns promise that resolves after xr mode has exited
  44908. */
  44909. exitXRAsync(): Promise<void>;
  44910. private _nonXRToXRCamera;
  44911. private _setState;
  44912. }
  44913. }
  44914. declare module "babylonjs/XR/motionController/webXRControllerComponent" {
  44915. import { IMinimalMotionControllerObject, MotionControllerComponentType } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  44916. import { Observable } from "babylonjs/Misc/observable";
  44917. import { IDisposable } from "babylonjs/scene";
  44918. /**
  44919. * X-Y values for axes in WebXR
  44920. */
  44921. export interface IWebXRMotionControllerAxesValue {
  44922. /**
  44923. * The value of the x axis
  44924. */
  44925. x: number;
  44926. /**
  44927. * The value of the y-axis
  44928. */
  44929. y: number;
  44930. }
  44931. /**
  44932. * changed / previous values for the values of this component
  44933. */
  44934. export interface IWebXRMotionControllerComponentChangesValues<T> {
  44935. /**
  44936. * current (this frame) value
  44937. */
  44938. current: T;
  44939. /**
  44940. * previous (last change) value
  44941. */
  44942. previous: T;
  44943. }
  44944. /**
  44945. * Represents changes in the component between current frame and last values recorded
  44946. */
  44947. export interface IWebXRMotionControllerComponentChanges {
  44948. /**
  44949. * will be populated with previous and current values if axes changed
  44950. */
  44951. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  44952. /**
  44953. * will be populated with previous and current values if pressed changed
  44954. */
  44955. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  44956. /**
  44957. * will be populated with previous and current values if touched changed
  44958. */
  44959. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  44960. /**
  44961. * will be populated with previous and current values if value changed
  44962. */
  44963. value?: IWebXRMotionControllerComponentChangesValues<number>;
  44964. }
  44965. /**
  44966. * This class represents a single component (for example button or thumbstick) of a motion controller
  44967. */
  44968. export class WebXRControllerComponent implements IDisposable {
  44969. /**
  44970. * the id of this component
  44971. */
  44972. id: string;
  44973. /**
  44974. * the type of the component
  44975. */
  44976. type: MotionControllerComponentType;
  44977. private _buttonIndex;
  44978. private _axesIndices;
  44979. private _axes;
  44980. private _changes;
  44981. private _currentValue;
  44982. private _hasChanges;
  44983. private _pressed;
  44984. private _touched;
  44985. /**
  44986. * button component type
  44987. */
  44988. static BUTTON_TYPE: MotionControllerComponentType;
  44989. /**
  44990. * squeeze component type
  44991. */
  44992. static SQUEEZE_TYPE: MotionControllerComponentType;
  44993. /**
  44994. * Thumbstick component type
  44995. */
  44996. static THUMBSTICK_TYPE: MotionControllerComponentType;
  44997. /**
  44998. * Touchpad component type
  44999. */
  45000. static TOUCHPAD_TYPE: MotionControllerComponentType;
  45001. /**
  45002. * trigger component type
  45003. */
  45004. static TRIGGER_TYPE: MotionControllerComponentType;
  45005. /**
  45006. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  45007. * the axes data changes
  45008. */
  45009. onAxisValueChangedObservable: Observable<{
  45010. x: number;
  45011. y: number;
  45012. }>;
  45013. /**
  45014. * Observers registered here will be triggered when the state of a button changes
  45015. * State change is either pressed / touched / value
  45016. */
  45017. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  45018. /**
  45019. * Creates a new component for a motion controller.
  45020. * It is created by the motion controller itself
  45021. *
  45022. * @param id the id of this component
  45023. * @param type the type of the component
  45024. * @param _buttonIndex index in the buttons array of the gamepad
  45025. * @param _axesIndices indices of the values in the axes array of the gamepad
  45026. */
  45027. constructor(
  45028. /**
  45029. * the id of this component
  45030. */
  45031. id: string,
  45032. /**
  45033. * the type of the component
  45034. */
  45035. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  45036. /**
  45037. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  45038. */
  45039. get axes(): IWebXRMotionControllerAxesValue;
  45040. /**
  45041. * Get the changes. Elements will be populated only if they changed with their previous and current value
  45042. */
  45043. get changes(): IWebXRMotionControllerComponentChanges;
  45044. /**
  45045. * Return whether or not the component changed the last frame
  45046. */
  45047. get hasChanges(): boolean;
  45048. /**
  45049. * is the button currently pressed
  45050. */
  45051. get pressed(): boolean;
  45052. /**
  45053. * is the button currently touched
  45054. */
  45055. get touched(): boolean;
  45056. /**
  45057. * Get the current value of this component
  45058. */
  45059. get value(): number;
  45060. /**
  45061. * Dispose this component
  45062. */
  45063. dispose(): void;
  45064. /**
  45065. * Are there axes correlating to this component
  45066. * @return true is axes data is available
  45067. */
  45068. isAxes(): boolean;
  45069. /**
  45070. * Is this component a button (hence - pressable)
  45071. * @returns true if can be pressed
  45072. */
  45073. isButton(): boolean;
  45074. /**
  45075. * update this component using the gamepad object it is in. Called on every frame
  45076. * @param nativeController the native gamepad controller object
  45077. */
  45078. update(nativeController: IMinimalMotionControllerObject): void;
  45079. }
  45080. }
  45081. declare module "babylonjs/Loading/sceneLoader" {
  45082. import { Observable } from "babylonjs/Misc/observable";
  45083. import { Nullable } from "babylonjs/types";
  45084. import { Scene } from "babylonjs/scene";
  45085. import { Engine } from "babylonjs/Engines/engine";
  45086. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45087. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  45088. import { AssetContainer } from "babylonjs/assetContainer";
  45089. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  45090. import { Skeleton } from "babylonjs/Bones/skeleton";
  45091. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  45092. import { WebRequest } from "babylonjs/Misc/webRequest";
  45093. /**
  45094. * Class used to represent data loading progression
  45095. */
  45096. export class SceneLoaderProgressEvent {
  45097. /** defines if data length to load can be evaluated */
  45098. readonly lengthComputable: boolean;
  45099. /** defines the loaded data length */
  45100. readonly loaded: number;
  45101. /** defines the data length to load */
  45102. readonly total: number;
  45103. /**
  45104. * Create a new progress event
  45105. * @param lengthComputable defines if data length to load can be evaluated
  45106. * @param loaded defines the loaded data length
  45107. * @param total defines the data length to load
  45108. */
  45109. constructor(
  45110. /** defines if data length to load can be evaluated */
  45111. lengthComputable: boolean,
  45112. /** defines the loaded data length */
  45113. loaded: number,
  45114. /** defines the data length to load */
  45115. total: number);
  45116. /**
  45117. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  45118. * @param event defines the source event
  45119. * @returns a new SceneLoaderProgressEvent
  45120. */
  45121. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  45122. }
  45123. /**
  45124. * Interface used by SceneLoader plugins to define supported file extensions
  45125. */
  45126. export interface ISceneLoaderPluginExtensions {
  45127. /**
  45128. * Defines the list of supported extensions
  45129. */
  45130. [extension: string]: {
  45131. isBinary: boolean;
  45132. };
  45133. }
  45134. /**
  45135. * Interface used by SceneLoader plugin factory
  45136. */
  45137. export interface ISceneLoaderPluginFactory {
  45138. /**
  45139. * Defines the name of the factory
  45140. */
  45141. name: string;
  45142. /**
  45143. * Function called to create a new plugin
  45144. * @return the new plugin
  45145. */
  45146. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  45147. /**
  45148. * The callback that returns true if the data can be directly loaded.
  45149. * @param data string containing the file data
  45150. * @returns if the data can be loaded directly
  45151. */
  45152. canDirectLoad?(data: string): boolean;
  45153. }
  45154. /**
  45155. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  45156. */
  45157. export interface ISceneLoaderPluginBase {
  45158. /**
  45159. * The friendly name of this plugin.
  45160. */
  45161. name: string;
  45162. /**
  45163. * The file extensions supported by this plugin.
  45164. */
  45165. extensions: string | ISceneLoaderPluginExtensions;
  45166. /**
  45167. * The callback called when loading from a url.
  45168. * @param scene scene loading this url
  45169. * @param url url to load
  45170. * @param onSuccess callback called when the file successfully loads
  45171. * @param onProgress callback called while file is loading (if the server supports this mode)
  45172. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  45173. * @param onError callback called when the file fails to load
  45174. * @returns a file request object
  45175. */
  45176. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  45177. /**
  45178. * The callback called when loading from a file object.
  45179. * @param scene scene loading this file
  45180. * @param file defines the file to load
  45181. * @param onSuccess defines the callback to call when data is loaded
  45182. * @param onProgress defines the callback to call during loading process
  45183. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  45184. * @param onError defines the callback to call when an error occurs
  45185. * @returns a file request object
  45186. */
  45187. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  45188. /**
  45189. * The callback that returns true if the data can be directly loaded.
  45190. * @param data string containing the file data
  45191. * @returns if the data can be loaded directly
  45192. */
  45193. canDirectLoad?(data: string): boolean;
  45194. /**
  45195. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  45196. * @param scene scene loading this data
  45197. * @param data string containing the data
  45198. * @returns data to pass to the plugin
  45199. */
  45200. directLoad?(scene: Scene, data: string): any;
  45201. /**
  45202. * The callback that allows custom handling of the root url based on the response url.
  45203. * @param rootUrl the original root url
  45204. * @param responseURL the response url if available
  45205. * @returns the new root url
  45206. */
  45207. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  45208. }
  45209. /**
  45210. * Interface used to define a SceneLoader plugin
  45211. */
  45212. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  45213. /**
  45214. * Import meshes into a scene.
  45215. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  45216. * @param scene The scene to import into
  45217. * @param data The data to import
  45218. * @param rootUrl The root url for scene and resources
  45219. * @param meshes The meshes array to import into
  45220. * @param particleSystems The particle systems array to import into
  45221. * @param skeletons The skeletons array to import into
  45222. * @param onError The callback when import fails
  45223. * @returns True if successful or false otherwise
  45224. */
  45225. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  45226. /**
  45227. * Load into a scene.
  45228. * @param scene The scene to load into
  45229. * @param data The data to import
  45230. * @param rootUrl The root url for scene and resources
  45231. * @param onError The callback when import fails
  45232. * @returns True if successful or false otherwise
  45233. */
  45234. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  45235. /**
  45236. * Load into an asset container.
  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 The loaded asset container
  45242. */
  45243. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  45244. }
  45245. /**
  45246. * Interface used to define an async SceneLoader plugin
  45247. */
  45248. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  45249. /**
  45250. * Import meshes into a scene.
  45251. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  45252. * @param scene The scene to import into
  45253. * @param data The data to import
  45254. * @param rootUrl The root url for scene and resources
  45255. * @param onProgress The callback when the load progresses
  45256. * @param fileName Defines the name of the file to load
  45257. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  45258. */
  45259. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  45260. meshes: AbstractMesh[];
  45261. particleSystems: IParticleSystem[];
  45262. skeletons: Skeleton[];
  45263. animationGroups: AnimationGroup[];
  45264. }>;
  45265. /**
  45266. * Load into a scene.
  45267. * @param scene The scene to load into
  45268. * @param data The data to import
  45269. * @param rootUrl The root url for scene and resources
  45270. * @param onProgress The callback when the load progresses
  45271. * @param fileName Defines the name of the file to load
  45272. * @returns Nothing
  45273. */
  45274. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  45275. /**
  45276. * Load into an asset container.
  45277. * @param scene The scene to load into
  45278. * @param data The data to import
  45279. * @param rootUrl The root url for scene and resources
  45280. * @param onProgress The callback when the load progresses
  45281. * @param fileName Defines the name of the file to load
  45282. * @returns The loaded asset container
  45283. */
  45284. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  45285. }
  45286. /**
  45287. * Mode that determines how to handle old animation groups before loading new ones.
  45288. */
  45289. export enum SceneLoaderAnimationGroupLoadingMode {
  45290. /**
  45291. * Reset all old animations to initial state then dispose them.
  45292. */
  45293. Clean = 0,
  45294. /**
  45295. * Stop all old animations.
  45296. */
  45297. Stop = 1,
  45298. /**
  45299. * Restart old animations from first frame.
  45300. */
  45301. Sync = 2,
  45302. /**
  45303. * Old animations remains untouched.
  45304. */
  45305. NoSync = 3
  45306. }
  45307. /**
  45308. * Class used to load scene from various file formats using registered plugins
  45309. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  45310. */
  45311. export class SceneLoader {
  45312. /**
  45313. * No logging while loading
  45314. */
  45315. static readonly NO_LOGGING: number;
  45316. /**
  45317. * Minimal logging while loading
  45318. */
  45319. static readonly MINIMAL_LOGGING: number;
  45320. /**
  45321. * Summary logging while loading
  45322. */
  45323. static readonly SUMMARY_LOGGING: number;
  45324. /**
  45325. * Detailled logging while loading
  45326. */
  45327. static readonly DETAILED_LOGGING: number;
  45328. /**
  45329. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  45330. */
  45331. static get ForceFullSceneLoadingForIncremental(): boolean;
  45332. static set ForceFullSceneLoadingForIncremental(value: boolean);
  45333. /**
  45334. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  45335. */
  45336. static get ShowLoadingScreen(): boolean;
  45337. static set ShowLoadingScreen(value: boolean);
  45338. /**
  45339. * Defines the current logging level (while loading the scene)
  45340. * @ignorenaming
  45341. */
  45342. static get loggingLevel(): number;
  45343. static set loggingLevel(value: number);
  45344. /**
  45345. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  45346. */
  45347. static get CleanBoneMatrixWeights(): boolean;
  45348. static set CleanBoneMatrixWeights(value: boolean);
  45349. /**
  45350. * Event raised when a plugin is used to load a scene
  45351. */
  45352. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  45353. private static _registeredPlugins;
  45354. private static _getDefaultPlugin;
  45355. private static _getPluginForExtension;
  45356. private static _getPluginForDirectLoad;
  45357. private static _getPluginForFilename;
  45358. private static _getDirectLoad;
  45359. private static _loadData;
  45360. private static _getFileInfo;
  45361. /**
  45362. * Gets a plugin that can load the given extension
  45363. * @param extension defines the extension to load
  45364. * @returns a plugin or null if none works
  45365. */
  45366. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  45367. /**
  45368. * Gets a boolean indicating that the given extension can be loaded
  45369. * @param extension defines the extension to load
  45370. * @returns true if the extension is supported
  45371. */
  45372. static IsPluginForExtensionAvailable(extension: string): boolean;
  45373. /**
  45374. * Adds a new plugin to the list of registered plugins
  45375. * @param plugin defines the plugin to add
  45376. */
  45377. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  45378. /**
  45379. * Import meshes into a scene
  45380. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  45381. * @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)
  45382. * @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)
  45383. * @param scene the instance of BABYLON.Scene to append to
  45384. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  45385. * @param onProgress a callback with a progress event for each file being loaded
  45386. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45387. * @param pluginExtension the extension used to determine the plugin
  45388. * @returns The loaded plugin
  45389. */
  45390. 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>;
  45391. /**
  45392. * Import meshes into a scene
  45393. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  45394. * @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)
  45395. * @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)
  45396. * @param scene the instance of BABYLON.Scene to append to
  45397. * @param onProgress a callback with a progress event for each file being loaded
  45398. * @param pluginExtension the extension used to determine the plugin
  45399. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  45400. */
  45401. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  45402. meshes: AbstractMesh[];
  45403. particleSystems: IParticleSystem[];
  45404. skeletons: Skeleton[];
  45405. animationGroups: AnimationGroup[];
  45406. }>;
  45407. /**
  45408. * Load a scene
  45409. * @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)
  45410. * @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)
  45411. * @param engine is the instance of BABYLON.Engine to use to create the scene
  45412. * @param onSuccess a callback with the scene when import succeeds
  45413. * @param onProgress a callback with a progress event for each file being loaded
  45414. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45415. * @param pluginExtension the extension used to determine the plugin
  45416. * @returns The loaded plugin
  45417. */
  45418. 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>;
  45419. /**
  45420. * Load a scene
  45421. * @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)
  45422. * @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)
  45423. * @param engine is the instance of BABYLON.Engine to use to create the scene
  45424. * @param onProgress a callback with a progress event for each file being loaded
  45425. * @param pluginExtension the extension used to determine the plugin
  45426. * @returns The loaded scene
  45427. */
  45428. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  45429. /**
  45430. * Append a scene
  45431. * @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)
  45432. * @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)
  45433. * @param scene is the instance of BABYLON.Scene to append to
  45434. * @param onSuccess a callback with the scene when import succeeds
  45435. * @param onProgress a callback with a progress event for each file being loaded
  45436. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45437. * @param pluginExtension the extension used to determine the plugin
  45438. * @returns The loaded plugin
  45439. */
  45440. 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>;
  45441. /**
  45442. * Append a scene
  45443. * @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)
  45444. * @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)
  45445. * @param scene is the instance of BABYLON.Scene to append to
  45446. * @param onProgress a callback with a progress event for each file being loaded
  45447. * @param pluginExtension the extension used to determine the plugin
  45448. * @returns The given scene
  45449. */
  45450. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  45451. /**
  45452. * Load a scene into an asset container
  45453. * @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)
  45454. * @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)
  45455. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  45456. * @param onSuccess a callback with the scene when import succeeds
  45457. * @param onProgress a callback with a progress event for each file being loaded
  45458. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45459. * @param pluginExtension the extension used to determine the plugin
  45460. * @returns The loaded plugin
  45461. */
  45462. 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>;
  45463. /**
  45464. * Load a scene into an asset container
  45465. * @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)
  45466. * @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)
  45467. * @param scene is the instance of Scene to append to
  45468. * @param onProgress a callback with a progress event for each file being loaded
  45469. * @param pluginExtension the extension used to determine the plugin
  45470. * @returns The loaded asset container
  45471. */
  45472. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  45473. /**
  45474. * Import animations from a file into a scene
  45475. * @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)
  45476. * @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)
  45477. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  45478. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  45479. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  45480. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  45481. * @param onSuccess a callback with the scene when import succeeds
  45482. * @param onProgress a callback with a progress event for each file being loaded
  45483. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45484. */
  45485. 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;
  45486. /**
  45487. * Import animations from a file into a scene
  45488. * @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)
  45489. * @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)
  45490. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  45491. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  45492. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  45493. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  45494. * @param onSuccess a callback with the scene when import succeeds
  45495. * @param onProgress a callback with a progress event for each file being loaded
  45496. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45497. * @returns the updated scene with imported animations
  45498. */
  45499. 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>;
  45500. }
  45501. }
  45502. declare module "babylonjs/XR/motionController/webXRAbstractMotionController" {
  45503. import { IDisposable, Scene } from "babylonjs/scene";
  45504. import { WebXRControllerComponent } from "babylonjs/XR/motionController/webXRControllerComponent";
  45505. import { Observable } from "babylonjs/Misc/observable";
  45506. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45507. import { Nullable } from "babylonjs/types";
  45508. /**
  45509. * Handness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  45510. */
  45511. export type MotionControllerHandness = "none" | "left" | "right";
  45512. /**
  45513. * The type of components available in motion controllers.
  45514. * This is not the name of the component.
  45515. */
  45516. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  45517. /**
  45518. * The state of a controller component
  45519. */
  45520. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  45521. /**
  45522. * The schema of motion controller layout.
  45523. * No object will be initialized using this interface
  45524. * This is used just to define the profile.
  45525. */
  45526. export interface IMotionControllerLayout {
  45527. /**
  45528. * Path to load the assets. Usually relative to the base path
  45529. */
  45530. assetPath: string;
  45531. /**
  45532. * Available components (unsorted)
  45533. */
  45534. components: {
  45535. /**
  45536. * A map of component Ids
  45537. */
  45538. [componentId: string]: {
  45539. /**
  45540. * The type of input the component outputs
  45541. */
  45542. type: MotionControllerComponentType;
  45543. /**
  45544. * The indices of this component in the gamepad object
  45545. */
  45546. gamepadIndices: {
  45547. /**
  45548. * Index of button
  45549. */
  45550. button?: number;
  45551. /**
  45552. * If available, index of x-axis
  45553. */
  45554. xAxis?: number;
  45555. /**
  45556. * If available, index of y-axis
  45557. */
  45558. yAxis?: number;
  45559. };
  45560. /**
  45561. * The mesh's root node name
  45562. */
  45563. rootNodeName: string;
  45564. /**
  45565. * Animation definitions for this model
  45566. */
  45567. visualResponses: {
  45568. [stateKey: string]: {
  45569. /**
  45570. * What property will be animated
  45571. */
  45572. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  45573. /**
  45574. * What states influence this visual response
  45575. */
  45576. states: MotionControllerComponentStateType[];
  45577. /**
  45578. * Type of animation - movement or visibility
  45579. */
  45580. valueNodeProperty: "transform" | "visibility";
  45581. /**
  45582. * Base node name to move. Its position will be calculated according to the min and max nodes
  45583. */
  45584. valueNodeName?: string;
  45585. /**
  45586. * Minimum movement node
  45587. */
  45588. minNodeName?: string;
  45589. /**
  45590. * Max movement node
  45591. */
  45592. maxNodeName?: string;
  45593. };
  45594. };
  45595. /**
  45596. * If touch enabled, what is the name of node to display user feedback
  45597. */
  45598. touchPointNodeName?: string;
  45599. };
  45600. };
  45601. /**
  45602. * Is it xr standard mapping or not
  45603. */
  45604. gamepadMapping: "" | "xr-standard";
  45605. /**
  45606. * Base root node of this entire model
  45607. */
  45608. rootNodeName: string;
  45609. /**
  45610. * Defines the main button component id
  45611. */
  45612. selectComponentId: string;
  45613. }
  45614. /**
  45615. * A definition for the layout map in the input profile
  45616. */
  45617. export interface IMotionControllerLayoutMap {
  45618. /**
  45619. * Layouts with handness type as a key
  45620. */
  45621. [handness: string]: IMotionControllerLayout;
  45622. }
  45623. /**
  45624. * The XR Input profile schema
  45625. * Profiles can be found here:
  45626. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  45627. */
  45628. export interface IMotionControllerProfile {
  45629. /**
  45630. * fallback profiles for this profileId
  45631. */
  45632. fallbackProfileIds: string[];
  45633. /**
  45634. * The layout map, with handness as key
  45635. */
  45636. layouts: IMotionControllerLayoutMap;
  45637. /**
  45638. * The id of this profile
  45639. * correlates to the profile(s) in the xrInput.profiles array
  45640. */
  45641. profileId: string;
  45642. }
  45643. /**
  45644. * A helper-interface for the 3 meshes needed for controller button animation
  45645. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  45646. */
  45647. export interface IMotionControllerButtonMeshMap {
  45648. /**
  45649. * the mesh that defines the pressed value mesh position.
  45650. * This is used to find the max-position of this button
  45651. */
  45652. pressedMesh: AbstractMesh;
  45653. /**
  45654. * the mesh that defines the unpressed value mesh position.
  45655. * This is used to find the min (or initial) position of this button
  45656. */
  45657. unpressedMesh: AbstractMesh;
  45658. /**
  45659. * The mesh that will be changed when value changes
  45660. */
  45661. valueMesh: AbstractMesh;
  45662. }
  45663. /**
  45664. * A helper-interface for the 3 meshes needed for controller axis animation.
  45665. * This will be expanded when touchpad animations are fully supported
  45666. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  45667. */
  45668. export interface IMotionControllerMeshMap {
  45669. /**
  45670. * the mesh that defines the maximum value mesh position.
  45671. */
  45672. maxMesh?: AbstractMesh;
  45673. /**
  45674. * the mesh that defines the minimum value mesh position.
  45675. */
  45676. minMesh?: AbstractMesh;
  45677. /**
  45678. * The mesh that will be changed when axis value changes
  45679. */
  45680. valueMesh: AbstractMesh;
  45681. }
  45682. /**
  45683. * The elements needed for change-detection of the gamepad objects in motion controllers
  45684. */
  45685. export interface IMinimalMotionControllerObject {
  45686. /**
  45687. * Available axes of this controller
  45688. */
  45689. axes: number[];
  45690. /**
  45691. * An array of available buttons
  45692. */
  45693. buttons: Array<{
  45694. /**
  45695. * Value of the button/trigger
  45696. */
  45697. value: number;
  45698. /**
  45699. * If the button/trigger is currently touched
  45700. */
  45701. touched: boolean;
  45702. /**
  45703. * If the button/trigger is currently pressed
  45704. */
  45705. pressed: boolean;
  45706. }>;
  45707. }
  45708. /**
  45709. * An Abstract Motion controller
  45710. * This class receives an xrInput and a profile layout and uses those to initialize the components
  45711. * Each component has an observable to check for changes in value and state
  45712. */
  45713. export abstract class WebXRAbstractMotionController implements IDisposable {
  45714. protected scene: Scene;
  45715. protected layout: IMotionControllerLayout;
  45716. /**
  45717. * The gamepad object correlating to this controller
  45718. */
  45719. gamepadObject: IMinimalMotionControllerObject;
  45720. /**
  45721. * handness (left/right/none) of this controller
  45722. */
  45723. handness: MotionControllerHandness;
  45724. private _initComponent;
  45725. private _modelReady;
  45726. /**
  45727. * A map of components (WebXRControllerComponent) in this motion controller
  45728. * Components have a ComponentType and can also have both button and axis definitions
  45729. */
  45730. readonly components: {
  45731. [id: string]: WebXRControllerComponent;
  45732. };
  45733. /**
  45734. * Disable the model's animation. Can be set at any time.
  45735. */
  45736. disableAnimation: boolean;
  45737. /**
  45738. * Observers registered here will be triggered when the model of this controller is done loading
  45739. */
  45740. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  45741. /**
  45742. * The profile id of this motion controller
  45743. */
  45744. abstract profileId: string;
  45745. /**
  45746. * The root mesh of the model. It is null if the model was not yet initialized
  45747. */
  45748. rootMesh: Nullable<AbstractMesh>;
  45749. /**
  45750. * constructs a new abstract motion controller
  45751. * @param scene the scene to which the model of the controller will be added
  45752. * @param layout The profile layout to load
  45753. * @param gamepadObject The gamepad object correlating to this controller
  45754. * @param handness handness (left/right/none) of this controller
  45755. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  45756. */
  45757. constructor(scene: Scene, layout: IMotionControllerLayout,
  45758. /**
  45759. * The gamepad object correlating to this controller
  45760. */
  45761. gamepadObject: IMinimalMotionControllerObject,
  45762. /**
  45763. * handness (left/right/none) of this controller
  45764. */
  45765. handness: MotionControllerHandness, _doNotLoadControllerMesh?: boolean);
  45766. /**
  45767. * Dispose this controller, the model mesh and all its components
  45768. */
  45769. dispose(): void;
  45770. /**
  45771. * Returns all components of specific type
  45772. * @param type the type to search for
  45773. * @return an array of components with this type
  45774. */
  45775. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  45776. /**
  45777. * get a component based an its component id as defined in layout.components
  45778. * @param id the id of the component
  45779. * @returns the component correlates to the id or undefined if not found
  45780. */
  45781. getComponent(id: string): WebXRControllerComponent;
  45782. /**
  45783. * Get the list of components available in this motion controller
  45784. * @returns an array of strings correlating to available components
  45785. */
  45786. getComponentIds(): string[];
  45787. /**
  45788. * Get the first component of specific type
  45789. * @param type type of component to find
  45790. * @return a controller component or null if not found
  45791. */
  45792. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  45793. /**
  45794. * Get the main (Select) component of this controller as defined in the layout
  45795. * @returns the main component of this controller
  45796. */
  45797. getMainComponent(): WebXRControllerComponent;
  45798. /**
  45799. * Loads the model correlating to this controller
  45800. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  45801. * @returns A promise fulfilled with the result of the model loading
  45802. */
  45803. loadModel(): Promise<boolean>;
  45804. /**
  45805. * Update this model using the current XRFrame
  45806. * @param xrFrame the current xr frame to use and update the model
  45807. */
  45808. updateFromXRFrame(xrFrame: XRFrame): void;
  45809. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  45810. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  45811. /**
  45812. * Moves the axis on the controller mesh based on its current state
  45813. * @param axis the index of the axis
  45814. * @param axisValue the value of the axis which determines the meshes new position
  45815. * @hidden
  45816. */
  45817. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  45818. /**
  45819. * Update the model itself with the current frame data
  45820. * @param xrFrame the frame to use for updating the model mesh
  45821. */
  45822. protected updateModel(xrFrame: XRFrame): void;
  45823. /**
  45824. * Get the filename and path for this controller's model
  45825. * @returns a map of filename and path
  45826. */
  45827. protected abstract _getFilenameAndPath(): {
  45828. filename: string;
  45829. path: string;
  45830. };
  45831. /**
  45832. * This function is called before the mesh is loaded. It checks for loading constraints.
  45833. * For example, this function can check if the GLB loader is available
  45834. * If this function returns false, the generic controller will be loaded instead
  45835. * @returns Is the client ready to load the mesh
  45836. */
  45837. protected abstract _getModelLoadingConstraints(): boolean;
  45838. /**
  45839. * This function will be called after the model was successfully loaded and can be used
  45840. * for mesh transformations before it is available for the user
  45841. * @param meshes the loaded meshes
  45842. */
  45843. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  45844. /**
  45845. * Set the root mesh for this controller. Important for the WebXR controller class
  45846. * @param meshes the loaded meshes
  45847. */
  45848. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  45849. /**
  45850. * A function executed each frame that updates the mesh (if needed)
  45851. * @param xrFrame the current xrFrame
  45852. */
  45853. protected abstract _updateModel(xrFrame: XRFrame): void;
  45854. private _getGenericFilenameAndPath;
  45855. private _getGenericParentMesh;
  45856. }
  45857. }
  45858. declare module "babylonjs/XR/motionController/webXRGenericMotionController" {
  45859. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  45860. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45861. import { Scene } from "babylonjs/scene";
  45862. /**
  45863. * A generic trigger-only motion controller for WebXR
  45864. */
  45865. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  45866. /**
  45867. * Static version of the profile id of this controller
  45868. */
  45869. static ProfileId: string;
  45870. profileId: string;
  45871. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  45872. protected _getFilenameAndPath(): {
  45873. filename: string;
  45874. path: string;
  45875. };
  45876. protected _getModelLoadingConstraints(): boolean;
  45877. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  45878. protected _setRootMesh(meshes: AbstractMesh[]): void;
  45879. protected _updateModel(): void;
  45880. }
  45881. }
  45882. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  45883. import { Vector4 } from "babylonjs/Maths/math.vector";
  45884. import { Mesh } from "babylonjs/Meshes/mesh";
  45885. import { Scene } from "babylonjs/scene";
  45886. import { Nullable } from "babylonjs/types";
  45887. /**
  45888. * Class containing static functions to help procedurally build meshes
  45889. */
  45890. export class SphereBuilder {
  45891. /**
  45892. * Creates a sphere mesh
  45893. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  45894. * * 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`)
  45895. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  45896. * * 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
  45897. * * 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)
  45898. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45899. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  45900. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45901. * @param name defines the name of the mesh
  45902. * @param options defines the options used to create the mesh
  45903. * @param scene defines the hosting scene
  45904. * @returns the sphere mesh
  45905. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  45906. */
  45907. static CreateSphere(name: string, options: {
  45908. segments?: number;
  45909. diameter?: number;
  45910. diameterX?: number;
  45911. diameterY?: number;
  45912. diameterZ?: number;
  45913. arc?: number;
  45914. slice?: number;
  45915. sideOrientation?: number;
  45916. frontUVs?: Vector4;
  45917. backUVs?: Vector4;
  45918. updatable?: boolean;
  45919. }, scene?: Nullable<Scene>): Mesh;
  45920. }
  45921. }
  45922. declare module "babylonjs/XR/motionController/webXRProfiledMotionController" {
  45923. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45924. import { WebXRAbstractMotionController, IMotionControllerProfile } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  45925. import { Scene } from "babylonjs/scene";
  45926. /**
  45927. * A profiled motion controller has its profile loaded from an online repository.
  45928. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  45929. */
  45930. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  45931. private _repositoryUrl;
  45932. private _buttonMeshMapping;
  45933. private _touchDots;
  45934. /**
  45935. * The profile ID of this controller. Will be populated when the controller initializes.
  45936. */
  45937. profileId: string;
  45938. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  45939. dispose(): void;
  45940. protected _getFilenameAndPath(): {
  45941. filename: string;
  45942. path: string;
  45943. };
  45944. protected _getModelLoadingConstraints(): boolean;
  45945. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  45946. protected _setRootMesh(meshes: AbstractMesh[]): void;
  45947. protected _updateModel(_xrFrame: XRFrame): void;
  45948. }
  45949. }
  45950. declare module "babylonjs/XR/motionController/webXRMotionControllerManager" {
  45951. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  45952. import { Scene } from "babylonjs/scene";
  45953. /**
  45954. * A construction function type to create a new controller based on an xrInput object
  45955. */
  45956. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  45957. /**
  45958. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  45959. *
  45960. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  45961. * it should be replaced with auto-loaded controllers.
  45962. *
  45963. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  45964. */
  45965. export class WebXRMotionControllerManager {
  45966. private static _AvailableControllers;
  45967. private static _Fallbacks;
  45968. private static _ProfileLoadingPromises;
  45969. private static _ProfilesList;
  45970. /**
  45971. * The base URL of the online controller repository. Can be changed at any time.
  45972. */
  45973. static BaseRepositoryUrl: string;
  45974. /**
  45975. * Which repository gets priority - local or online
  45976. */
  45977. static PrioritizeOnlineRepository: boolean;
  45978. /**
  45979. * Use the online repository, or use only locally-defined controllers
  45980. */
  45981. static UseOnlineRepository: boolean;
  45982. /**
  45983. * Clear the cache used for profile loading and reload when requested again
  45984. */
  45985. static ClearProfilesCache(): void;
  45986. /**
  45987. * Register the default fallbacks.
  45988. * This function is called automatically when this file is imported.
  45989. */
  45990. static DefaultFallbacks(): void;
  45991. /**
  45992. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  45993. * @param profileId the profile to which a fallback needs to be found
  45994. * @return an array with corresponding fallback profiles
  45995. */
  45996. static FindFallbackWithProfileId(profileId: string): string[];
  45997. /**
  45998. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  45999. * The order of search:
  46000. *
  46001. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  46002. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  46003. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  46004. * 4) return the generic trigger controller if none were found
  46005. *
  46006. * @param xrInput the xrInput to which a new controller is initialized
  46007. * @param scene the scene to which the model will be added
  46008. * @param forceProfile force a certain profile for this controller
  46009. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  46010. */
  46011. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  46012. /**
  46013. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  46014. *
  46015. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  46016. *
  46017. * @param type the profile type to register
  46018. * @param constructFunction the function to be called when loading this profile
  46019. */
  46020. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  46021. /**
  46022. * Register a fallback to a specific profile.
  46023. * @param profileId the profileId that will receive the fallbacks
  46024. * @param fallbacks A list of fallback profiles
  46025. */
  46026. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  46027. /**
  46028. * Will update the list of profiles available in the repository
  46029. * @return a promise that resolves to a map of profiles available online
  46030. */
  46031. static UpdateProfilesList(): Promise<{
  46032. [profile: string]: string;
  46033. }>;
  46034. private static _LoadProfileFromRepository;
  46035. private static _LoadProfilesFromAvailableControllers;
  46036. }
  46037. }
  46038. declare module "babylonjs/XR/webXRInputSource" {
  46039. import { Observable } from "babylonjs/Misc/observable";
  46040. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46041. import { Ray } from "babylonjs/Culling/ray";
  46042. import { Scene } from "babylonjs/scene";
  46043. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  46044. /**
  46045. * Configuration options for the WebXR controller creation
  46046. */
  46047. export interface IWebXRControllerOptions {
  46048. /**
  46049. * Should the controller mesh be animated when a user interacts with it
  46050. * The pressed buttons / thumbstick and touchpad animations will be disabled
  46051. */
  46052. disableMotionControllerAnimation?: boolean;
  46053. /**
  46054. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  46055. */
  46056. doNotLoadControllerMesh?: boolean;
  46057. /**
  46058. * Force a specific controller type for this controller.
  46059. * This can be used when creating your own profile or when testing different controllers
  46060. */
  46061. forceControllerProfile?: string;
  46062. }
  46063. /**
  46064. * Represents an XR controller
  46065. */
  46066. export class WebXRInputSource {
  46067. private _scene;
  46068. /** The underlying input source for the controller */
  46069. inputSource: XRInputSource;
  46070. private _options;
  46071. private _tmpQuaternion;
  46072. private _tmpVector;
  46073. private _uniqueId;
  46074. /**
  46075. * 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
  46076. */
  46077. grip?: AbstractMesh;
  46078. /**
  46079. * If available, this is the gamepad object related to this controller.
  46080. * Using this object it is possible to get click events and trackpad changes of the
  46081. * webxr controller that is currently being used.
  46082. */
  46083. motionController?: WebXRAbstractMotionController;
  46084. /**
  46085. * Event that fires when the controller is removed/disposed.
  46086. * The object provided as event data is this controller, after associated assets were disposed.
  46087. * uniqueId is still available.
  46088. */
  46089. onDisposeObservable: Observable<WebXRInputSource>;
  46090. /**
  46091. * Will be triggered when the mesh associated with the motion controller is done loading.
  46092. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  46093. * A shortened version of controller -> motion controller -> on mesh loaded.
  46094. */
  46095. onMeshLoadedObservable: Observable<AbstractMesh>;
  46096. /**
  46097. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  46098. */
  46099. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  46100. /**
  46101. * Pointer which can be used to select objects or attach a visible laser to
  46102. */
  46103. pointer: AbstractMesh;
  46104. /**
  46105. * Creates the controller
  46106. * @see https://doc.babylonjs.com/how_to/webxr
  46107. * @param _scene the scene which the controller should be associated to
  46108. * @param inputSource the underlying input source for the controller
  46109. * @param _options options for this controller creation
  46110. */
  46111. constructor(_scene: Scene,
  46112. /** The underlying input source for the controller */
  46113. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  46114. /**
  46115. * Get this controllers unique id
  46116. */
  46117. get uniqueId(): string;
  46118. /**
  46119. * Disposes of the object
  46120. */
  46121. dispose(): void;
  46122. /**
  46123. * Gets a world space ray coming from the pointer or grip
  46124. * @param result the resulting ray
  46125. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  46126. */
  46127. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  46128. /**
  46129. * Updates the controller pose based on the given XRFrame
  46130. * @param xrFrame xr frame to update the pose with
  46131. * @param referenceSpace reference space to use
  46132. */
  46133. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  46134. }
  46135. }
  46136. declare module "babylonjs/XR/webXRInput" {
  46137. import { Observable } from "babylonjs/Misc/observable";
  46138. import { IDisposable } from "babylonjs/scene";
  46139. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  46140. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  46141. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  46142. /**
  46143. * The schema for initialization options of the XR Input class
  46144. */
  46145. export interface IWebXRInputOptions {
  46146. /**
  46147. * If set to true no model will be automatically loaded
  46148. */
  46149. doNotLoadControllerMeshes?: boolean;
  46150. /**
  46151. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  46152. * If not found, the xr input profile data will be used.
  46153. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  46154. */
  46155. forceInputProfile?: string;
  46156. /**
  46157. * Do not send a request to the controller repository to load the profile.
  46158. *
  46159. * Instead, use the controllers available in babylon itself.
  46160. */
  46161. disableOnlineControllerRepository?: boolean;
  46162. /**
  46163. * A custom URL for the controllers repository
  46164. */
  46165. customControllersRepositoryURL?: string;
  46166. /**
  46167. * Should the controller model's components not move according to the user input
  46168. */
  46169. disableControllerAnimation?: boolean;
  46170. }
  46171. /**
  46172. * XR input used to track XR inputs such as controllers/rays
  46173. */
  46174. export class WebXRInput implements IDisposable {
  46175. /**
  46176. * the xr session manager for this session
  46177. */
  46178. xrSessionManager: WebXRSessionManager;
  46179. /**
  46180. * the WebXR camera for this session. Mainly used for teleportation
  46181. */
  46182. xrCamera: WebXRCamera;
  46183. private readonly options;
  46184. /**
  46185. * XR controllers being tracked
  46186. */
  46187. controllers: Array<WebXRInputSource>;
  46188. private _frameObserver;
  46189. private _sessionEndedObserver;
  46190. private _sessionInitObserver;
  46191. /**
  46192. * Event when a controller has been connected/added
  46193. */
  46194. onControllerAddedObservable: Observable<WebXRInputSource>;
  46195. /**
  46196. * Event when a controller has been removed/disconnected
  46197. */
  46198. onControllerRemovedObservable: Observable<WebXRInputSource>;
  46199. /**
  46200. * Initializes the WebXRInput
  46201. * @param xrSessionManager the xr session manager for this session
  46202. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  46203. * @param options = initialization options for this xr input
  46204. */
  46205. constructor(
  46206. /**
  46207. * the xr session manager for this session
  46208. */
  46209. xrSessionManager: WebXRSessionManager,
  46210. /**
  46211. * the WebXR camera for this session. Mainly used for teleportation
  46212. */
  46213. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  46214. private _onInputSourcesChange;
  46215. private _addAndRemoveControllers;
  46216. /**
  46217. * Disposes of the object
  46218. */
  46219. dispose(): void;
  46220. }
  46221. }
  46222. declare module "babylonjs/XR/features/WebXRAbstractFeature" {
  46223. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  46224. import { Observable, EventState } from "babylonjs/Misc/observable";
  46225. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  46226. /**
  46227. * This is the base class for all WebXR features.
  46228. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  46229. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  46230. */
  46231. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  46232. protected _xrSessionManager: WebXRSessionManager;
  46233. private _attached;
  46234. private _removeOnDetach;
  46235. /**
  46236. * Should auto-attach be disabled?
  46237. */
  46238. disableAutoAttach: boolean;
  46239. /**
  46240. * Construct a new (abstract) WebXR feature
  46241. * @param _xrSessionManager the xr session manager for this feature
  46242. */
  46243. constructor(_xrSessionManager: WebXRSessionManager);
  46244. /**
  46245. * Is this feature attached
  46246. */
  46247. get attached(): boolean;
  46248. /**
  46249. * attach this feature
  46250. *
  46251. * @param force should attachment be forced (even when already attached)
  46252. * @returns true if successful, false is failed or already attached
  46253. */
  46254. attach(force?: boolean): boolean;
  46255. /**
  46256. * detach this feature.
  46257. *
  46258. * @returns true if successful, false if failed or already detached
  46259. */
  46260. detach(): boolean;
  46261. /**
  46262. * Dispose this feature and all of the resources attached
  46263. */
  46264. dispose(): void;
  46265. /**
  46266. * This is used to register callbacks that will automatically be removed when detach is called.
  46267. * @param observable the observable to which the observer will be attached
  46268. * @param callback the callback to register
  46269. */
  46270. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  46271. /**
  46272. * Code in this function will be executed on each xrFrame received from the browser.
  46273. * This function will not execute after the feature is detached.
  46274. * @param _xrFrame the current frame
  46275. */
  46276. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  46277. }
  46278. }
  46279. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  46280. import { IDisposable, Scene } from "babylonjs/scene";
  46281. import { Nullable } from "babylonjs/types";
  46282. import { Observable } from "babylonjs/Misc/observable";
  46283. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46284. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  46285. import { Camera } from "babylonjs/Cameras/camera";
  46286. /**
  46287. * Renders a layer on top of an existing scene
  46288. */
  46289. export class UtilityLayerRenderer implements IDisposable {
  46290. /** the original scene that will be rendered on top of */
  46291. originalScene: Scene;
  46292. private _pointerCaptures;
  46293. private _lastPointerEvents;
  46294. private static _DefaultUtilityLayer;
  46295. private static _DefaultKeepDepthUtilityLayer;
  46296. private _sharedGizmoLight;
  46297. private _renderCamera;
  46298. /**
  46299. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  46300. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  46301. * @returns the camera that is used when rendering the utility layer
  46302. */
  46303. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  46304. /**
  46305. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  46306. * @param cam the camera that should be used when rendering the utility layer
  46307. */
  46308. setRenderCamera(cam: Nullable<Camera>): void;
  46309. /**
  46310. * @hidden
  46311. * Light which used by gizmos to get light shading
  46312. */
  46313. _getSharedGizmoLight(): HemisphericLight;
  46314. /**
  46315. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  46316. */
  46317. pickUtilitySceneFirst: boolean;
  46318. /**
  46319. * 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)
  46320. */
  46321. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  46322. /**
  46323. * 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)
  46324. */
  46325. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  46326. /**
  46327. * The scene that is rendered on top of the original scene
  46328. */
  46329. utilityLayerScene: Scene;
  46330. /**
  46331. * If the utility layer should automatically be rendered on top of existing scene
  46332. */
  46333. shouldRender: boolean;
  46334. /**
  46335. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  46336. */
  46337. onlyCheckPointerDownEvents: boolean;
  46338. /**
  46339. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  46340. */
  46341. processAllEvents: boolean;
  46342. /**
  46343. * Observable raised when the pointer move from the utility layer scene to the main scene
  46344. */
  46345. onPointerOutObservable: Observable<number>;
  46346. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  46347. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  46348. private _afterRenderObserver;
  46349. private _sceneDisposeObserver;
  46350. private _originalPointerObserver;
  46351. /**
  46352. * Instantiates a UtilityLayerRenderer
  46353. * @param originalScene the original scene that will be rendered on top of
  46354. * @param handleEvents boolean indicating if the utility layer should handle events
  46355. */
  46356. constructor(
  46357. /** the original scene that will be rendered on top of */
  46358. originalScene: Scene, handleEvents?: boolean);
  46359. private _notifyObservers;
  46360. /**
  46361. * Renders the utility layers scene on top of the original scene
  46362. */
  46363. render(): void;
  46364. /**
  46365. * Disposes of the renderer
  46366. */
  46367. dispose(): void;
  46368. private _updateCamera;
  46369. }
  46370. }
  46371. declare module "babylonjs/XR/features/WebXRControllerPointerSelection" {
  46372. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  46373. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46374. import { WebXRInput } from "babylonjs/XR/webXRInput";
  46375. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  46376. import { Scene } from "babylonjs/scene";
  46377. import { Nullable } from "babylonjs/types";
  46378. import { Color3 } from "babylonjs/Maths/math.color";
  46379. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  46380. /**
  46381. * Options interface for the pointer selection module
  46382. */
  46383. export interface IWebXRControllerPointerSelectionOptions {
  46384. /**
  46385. * if provided, this scene will be used to render meshes.
  46386. */
  46387. customUtilityLayerScene?: Scene;
  46388. /**
  46389. * 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)
  46390. * If not disabled, the last picked point will be used to execute a pointer up event
  46391. * If disabled, pointer up event will be triggered right after the pointer down event.
  46392. * Used in screen and gaze target ray mode only
  46393. */
  46394. disablePointerUpOnTouchOut: boolean;
  46395. /**
  46396. * For gaze mode (time to select instead of press)
  46397. */
  46398. forceGazeMode: boolean;
  46399. /**
  46400. * 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
  46401. * to start a new countdown to the pointer down event.
  46402. * Defaults to 1.
  46403. */
  46404. gazeModePointerMovedFactor?: number;
  46405. /**
  46406. * Different button type to use instead of the main component
  46407. */
  46408. overrideButtonId?: string;
  46409. /**
  46410. * use this rendering group id for the meshes (optional)
  46411. */
  46412. renderingGroupId?: number;
  46413. /**
  46414. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  46415. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  46416. * 3000 means 3 seconds between pointing at something and selecting it
  46417. */
  46418. timeToSelect?: number;
  46419. /**
  46420. * Should meshes created here be added to a utility layer or the main scene
  46421. */
  46422. useUtilityLayer?: boolean;
  46423. /**
  46424. * the xr input to use with this pointer selection
  46425. */
  46426. xrInput: WebXRInput;
  46427. }
  46428. /**
  46429. * A module that will enable pointer selection for motion controllers of XR Input Sources
  46430. */
  46431. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  46432. private readonly _options;
  46433. private static _idCounter;
  46434. private _attachController;
  46435. private _controllers;
  46436. private _scene;
  46437. private _tmpVectorForPickCompare;
  46438. /**
  46439. * The module's name
  46440. */
  46441. static readonly Name: string;
  46442. /**
  46443. * The (Babylon) version of this module.
  46444. * This is an integer representing the implementation version.
  46445. * This number does not correspond to the WebXR specs version
  46446. */
  46447. static readonly Version: number;
  46448. /**
  46449. * Disable lighting on the laser pointer (so it will always be visible)
  46450. */
  46451. disablePointerLighting: boolean;
  46452. /**
  46453. * Disable lighting on the selection mesh (so it will always be visible)
  46454. */
  46455. disableSelectionMeshLighting: boolean;
  46456. /**
  46457. * Should the laser pointer be displayed
  46458. */
  46459. displayLaserPointer: boolean;
  46460. /**
  46461. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  46462. */
  46463. displaySelectionMesh: boolean;
  46464. /**
  46465. * This color will be set to the laser pointer when selection is triggered
  46466. */
  46467. laserPointerPickedColor: Color3;
  46468. /**
  46469. * Default color of the laser pointer
  46470. */
  46471. lasterPointerDefaultColor: Color3;
  46472. /**
  46473. * default color of the selection ring
  46474. */
  46475. selectionMeshDefaultColor: Color3;
  46476. /**
  46477. * This color will be applied to the selection ring when selection is triggered
  46478. */
  46479. selectionMeshPickedColor: Color3;
  46480. /**
  46481. * Optional filter to be used for ray selection. This predicate shares behavior with
  46482. * scene.pointerMovePredicate which takes priority if it is also assigned.
  46483. */
  46484. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  46485. /**
  46486. * constructs a new background remover module
  46487. * @param _xrSessionManager the session manager for this module
  46488. * @param _options read-only options to be used in this module
  46489. */
  46490. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  46491. /**
  46492. * attach this feature
  46493. * Will usually be called by the features manager
  46494. *
  46495. * @returns true if successful.
  46496. */
  46497. attach(): boolean;
  46498. /**
  46499. * detach this feature.
  46500. * Will usually be called by the features manager
  46501. *
  46502. * @returns true if successful.
  46503. */
  46504. detach(): boolean;
  46505. /**
  46506. * Will get the mesh under a specific pointer.
  46507. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  46508. * @param controllerId the controllerId to check
  46509. * @returns The mesh under pointer or null if no mesh is under the pointer
  46510. */
  46511. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  46512. /**
  46513. * Get the xr controller that correlates to the pointer id in the pointer event
  46514. *
  46515. * @param id the pointer id to search for
  46516. * @returns the controller that correlates to this id or null if not found
  46517. */
  46518. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  46519. protected _onXRFrame(_xrFrame: XRFrame): void;
  46520. private _attachGazeMode;
  46521. private _attachScreenRayMode;
  46522. private _attachTrackedPointerRayMode;
  46523. private _convertNormalToDirectionOfRay;
  46524. private _detachController;
  46525. private _generateNewMeshPair;
  46526. private _pickingMoved;
  46527. private _updatePointerDistance;
  46528. }
  46529. }
  46530. declare module "babylonjs/XR/webXREnterExitUI" {
  46531. import { Nullable } from "babylonjs/types";
  46532. import { Observable } from "babylonjs/Misc/observable";
  46533. import { IDisposable, Scene } from "babylonjs/scene";
  46534. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  46535. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  46536. /**
  46537. * Button which can be used to enter a different mode of XR
  46538. */
  46539. export class WebXREnterExitUIButton {
  46540. /** button element */
  46541. element: HTMLElement;
  46542. /** XR initialization options for the button */
  46543. sessionMode: XRSessionMode;
  46544. /** Reference space type */
  46545. referenceSpaceType: XRReferenceSpaceType;
  46546. /**
  46547. * Creates a WebXREnterExitUIButton
  46548. * @param element button element
  46549. * @param sessionMode XR initialization session mode
  46550. * @param referenceSpaceType the type of reference space to be used
  46551. */
  46552. constructor(
  46553. /** button element */
  46554. element: HTMLElement,
  46555. /** XR initialization options for the button */
  46556. sessionMode: XRSessionMode,
  46557. /** Reference space type */
  46558. referenceSpaceType: XRReferenceSpaceType);
  46559. /**
  46560. * Extendable function which can be used to update the button's visuals when the state changes
  46561. * @param activeButton the current active button in the UI
  46562. */
  46563. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  46564. }
  46565. /**
  46566. * Options to create the webXR UI
  46567. */
  46568. export class WebXREnterExitUIOptions {
  46569. /**
  46570. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  46571. */
  46572. customButtons?: Array<WebXREnterExitUIButton>;
  46573. /**
  46574. * A reference space type to use when creating the default button.
  46575. * Default is local-floor
  46576. */
  46577. referenceSpaceType?: XRReferenceSpaceType;
  46578. /**
  46579. * Context to enter xr with
  46580. */
  46581. renderTarget?: Nullable<WebXRRenderTarget>;
  46582. /**
  46583. * A session mode to use when creating the default button.
  46584. * Default is immersive-vr
  46585. */
  46586. sessionMode?: XRSessionMode;
  46587. }
  46588. /**
  46589. * UI to allow the user to enter/exit XR mode
  46590. */
  46591. export class WebXREnterExitUI implements IDisposable {
  46592. private scene;
  46593. /** version of the options passed to this UI */
  46594. options: WebXREnterExitUIOptions;
  46595. private _activeButton;
  46596. private _buttons;
  46597. private _overlay;
  46598. /**
  46599. * Fired every time the active button is changed.
  46600. *
  46601. * When xr is entered via a button that launches xr that button will be the callback parameter
  46602. *
  46603. * When exiting xr the callback parameter will be null)
  46604. */
  46605. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  46606. /**
  46607. *
  46608. * @param scene babylon scene object to use
  46609. * @param options (read-only) version of the options passed to this UI
  46610. */
  46611. private constructor();
  46612. /**
  46613. * Creates UI to allow the user to enter/exit XR mode
  46614. * @param scene the scene to add the ui to
  46615. * @param helper the xr experience helper to enter/exit xr with
  46616. * @param options options to configure the UI
  46617. * @returns the created ui
  46618. */
  46619. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  46620. /**
  46621. * Disposes of the XR UI component
  46622. */
  46623. dispose(): void;
  46624. private _updateButtons;
  46625. }
  46626. }
  46627. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  46628. import { Vector3 } from "babylonjs/Maths/math.vector";
  46629. import { Color4 } from "babylonjs/Maths/math.color";
  46630. import { Nullable } from "babylonjs/types";
  46631. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  46632. import { Scene } from "babylonjs/scene";
  46633. /**
  46634. * Class containing static functions to help procedurally build meshes
  46635. */
  46636. export class LinesBuilder {
  46637. /**
  46638. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  46639. * * 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
  46640. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  46641. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  46642. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  46643. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  46644. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  46645. * * 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
  46646. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  46647. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46648. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  46649. * @param name defines the name of the new line system
  46650. * @param options defines the options used to create the line system
  46651. * @param scene defines the hosting scene
  46652. * @returns a new line system mesh
  46653. */
  46654. static CreateLineSystem(name: string, options: {
  46655. lines: Vector3[][];
  46656. updatable?: boolean;
  46657. instance?: Nullable<LinesMesh>;
  46658. colors?: Nullable<Color4[][]>;
  46659. useVertexAlpha?: boolean;
  46660. }, scene: Nullable<Scene>): LinesMesh;
  46661. /**
  46662. * Creates a line mesh
  46663. * 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
  46664. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  46665. * * The parameter `points` is an array successive Vector3
  46666. * * 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
  46667. * * The optional parameter `colors` is an array of successive Color4, one per line point
  46668. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  46669. * * When updating an instance, remember that only point positions can change, not the number of points
  46670. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46671. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  46672. * @param name defines the name of the new line system
  46673. * @param options defines the options used to create the line system
  46674. * @param scene defines the hosting scene
  46675. * @returns a new line mesh
  46676. */
  46677. static CreateLines(name: string, options: {
  46678. points: Vector3[];
  46679. updatable?: boolean;
  46680. instance?: Nullable<LinesMesh>;
  46681. colors?: Color4[];
  46682. useVertexAlpha?: boolean;
  46683. }, scene?: Nullable<Scene>): LinesMesh;
  46684. /**
  46685. * Creates a dashed line mesh
  46686. * * 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
  46687. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  46688. * * The parameter `points` is an array successive Vector3
  46689. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  46690. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  46691. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  46692. * * 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
  46693. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  46694. * * When updating an instance, remember that only point positions can change, not the number of points
  46695. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46696. * @param name defines the name of the mesh
  46697. * @param options defines the options used to create the mesh
  46698. * @param scene defines the hosting scene
  46699. * @returns the dashed line mesh
  46700. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  46701. */
  46702. static CreateDashedLines(name: string, options: {
  46703. points: Vector3[];
  46704. dashSize?: number;
  46705. gapSize?: number;
  46706. dashNb?: number;
  46707. updatable?: boolean;
  46708. instance?: LinesMesh;
  46709. useVertexAlpha?: boolean;
  46710. }, scene?: Nullable<Scene>): LinesMesh;
  46711. }
  46712. }
  46713. declare module "babylonjs/XR/features/WebXRControllerTeleportation" {
  46714. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  46715. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  46716. import { WebXRInput } from "babylonjs/XR/webXRInput";
  46717. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46718. import { Vector3 } from "babylonjs/Maths/math.vector";
  46719. import { Material } from "babylonjs/Materials/material";
  46720. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  46721. import { Scene } from "babylonjs/scene";
  46722. /**
  46723. * The options container for the teleportation module
  46724. */
  46725. export interface IWebXRTeleportationOptions {
  46726. /**
  46727. * if provided, this scene will be used to render meshes.
  46728. */
  46729. customUtilityLayerScene?: Scene;
  46730. /**
  46731. * Values to configure the default target mesh
  46732. */
  46733. defaultTargetMeshOptions?: {
  46734. /**
  46735. * Fill color of the teleportation area
  46736. */
  46737. teleportationFillColor?: string;
  46738. /**
  46739. * Border color for the teleportation area
  46740. */
  46741. teleportationBorderColor?: string;
  46742. /**
  46743. * Disable the mesh's animation sequence
  46744. */
  46745. disableAnimation?: boolean;
  46746. /**
  46747. * Disable lighting on the material or the ring and arrow
  46748. */
  46749. disableLighting?: boolean;
  46750. /**
  46751. * Override the default material of the torus and arrow
  46752. */
  46753. torusArrowMaterial?: Material;
  46754. };
  46755. /**
  46756. * A list of meshes to use as floor meshes.
  46757. * Meshes can be added and removed after initializing the feature using the
  46758. * addFloorMesh and removeFloorMesh functions
  46759. * If empty, rotation will still work
  46760. */
  46761. floorMeshes?: AbstractMesh[];
  46762. /**
  46763. * use this rendering group id for the meshes (optional)
  46764. */
  46765. renderingGroupId?: number;
  46766. /**
  46767. * Should teleportation move only to snap points
  46768. */
  46769. snapPointsOnly?: boolean;
  46770. /**
  46771. * An array of points to which the teleportation will snap to.
  46772. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  46773. */
  46774. snapPositions?: Vector3[];
  46775. /**
  46776. * How close should the teleportation ray be in order to snap to position.
  46777. * Default to 0.8 units (meters)
  46778. */
  46779. snapToPositionRadius?: number;
  46780. /**
  46781. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  46782. * If you want to support rotation, make sure your mesh has a direction indicator.
  46783. *
  46784. * When left untouched, the default mesh will be initialized.
  46785. */
  46786. teleportationTargetMesh?: AbstractMesh;
  46787. /**
  46788. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  46789. */
  46790. timeToTeleport?: number;
  46791. /**
  46792. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  46793. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  46794. */
  46795. useMainComponentOnly?: boolean;
  46796. /**
  46797. * Should meshes created here be added to a utility layer or the main scene
  46798. */
  46799. useUtilityLayer?: boolean;
  46800. /**
  46801. * Babylon XR Input class for controller
  46802. */
  46803. xrInput: WebXRInput;
  46804. }
  46805. /**
  46806. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  46807. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  46808. * the input of the attached controllers.
  46809. */
  46810. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  46811. private _options;
  46812. private _controllers;
  46813. private _currentTeleportationControllerId;
  46814. private _floorMeshes;
  46815. private _quadraticBezierCurve;
  46816. private _selectionFeature;
  46817. private _snapToPositions;
  46818. private _snappedToPoint;
  46819. private _teleportationRingMaterial?;
  46820. private _tmpRay;
  46821. private _tmpVector;
  46822. /**
  46823. * The module's name
  46824. */
  46825. static readonly Name: string;
  46826. /**
  46827. * The (Babylon) version of this module.
  46828. * This is an integer representing the implementation version.
  46829. * This number does not correspond to the webxr specs version
  46830. */
  46831. static readonly Version: number;
  46832. /**
  46833. * Is movement backwards enabled
  46834. */
  46835. backwardsMovementEnabled: boolean;
  46836. /**
  46837. * Distance to travel when moving backwards
  46838. */
  46839. backwardsTeleportationDistance: number;
  46840. /**
  46841. * The distance from the user to the inspection point in the direction of the controller
  46842. * A higher number will allow the user to move further
  46843. * defaults to 5 (meters, in xr units)
  46844. */
  46845. parabolicCheckRadius: number;
  46846. /**
  46847. * Should the module support parabolic ray on top of direct ray
  46848. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  46849. * Very helpful when moving between floors / different heights
  46850. */
  46851. parabolicRayEnabled: boolean;
  46852. /**
  46853. * How much rotation should be applied when rotating right and left
  46854. */
  46855. rotationAngle: number;
  46856. /**
  46857. * Is rotation enabled when moving forward?
  46858. * Disabling this feature will prevent the user from deciding the direction when teleporting
  46859. */
  46860. rotationEnabled: boolean;
  46861. /**
  46862. * constructs a new anchor system
  46863. * @param _xrSessionManager an instance of WebXRSessionManager
  46864. * @param _options configuration object for this feature
  46865. */
  46866. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  46867. /**
  46868. * Get the snapPointsOnly flag
  46869. */
  46870. get snapPointsOnly(): boolean;
  46871. /**
  46872. * Sets the snapPointsOnly flag
  46873. * @param snapToPoints should teleportation be exclusively to snap points
  46874. */
  46875. set snapPointsOnly(snapToPoints: boolean);
  46876. /**
  46877. * Add a new mesh to the floor meshes array
  46878. * @param mesh the mesh to use as floor mesh
  46879. */
  46880. addFloorMesh(mesh: AbstractMesh): void;
  46881. /**
  46882. * Add a new snap-to point to fix teleportation to this position
  46883. * @param newSnapPoint The new Snap-To point
  46884. */
  46885. addSnapPoint(newSnapPoint: Vector3): void;
  46886. attach(): boolean;
  46887. detach(): boolean;
  46888. dispose(): void;
  46889. /**
  46890. * Remove a mesh from the floor meshes array
  46891. * @param mesh the mesh to remove
  46892. */
  46893. removeFloorMesh(mesh: AbstractMesh): void;
  46894. /**
  46895. * Remove a mesh from the floor meshes array using its name
  46896. * @param name the mesh name to remove
  46897. */
  46898. removeFloorMeshByName(name: string): void;
  46899. /**
  46900. * 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
  46901. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  46902. * @returns was the point found and removed or not
  46903. */
  46904. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  46905. /**
  46906. * This function sets a selection feature that will be disabled when
  46907. * the forward ray is shown and will be reattached when hidden.
  46908. * This is used to remove the selection rays when moving.
  46909. * @param selectionFeature the feature to disable when forward movement is enabled
  46910. */
  46911. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  46912. protected _onXRFrame(_xrFrame: XRFrame): void;
  46913. private _attachController;
  46914. private _createDefaultTargetMesh;
  46915. private _detachController;
  46916. private _findClosestSnapPointWithRadius;
  46917. private _setTargetMeshPosition;
  46918. private _setTargetMeshVisibility;
  46919. private _showParabolicPath;
  46920. private _teleportForward;
  46921. }
  46922. }
  46923. declare module "babylonjs/XR/webXRDefaultExperience" {
  46924. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  46925. import { Scene } from "babylonjs/scene";
  46926. import { WebXRInput, IWebXRInputOptions } from "babylonjs/XR/webXRInput";
  46927. import { WebXRControllerPointerSelection } from "babylonjs/XR/features/WebXRControllerPointerSelection";
  46928. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  46929. import { WebXREnterExitUI, WebXREnterExitUIOptions } from "babylonjs/XR/webXREnterExitUI";
  46930. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46931. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  46932. import { WebXRMotionControllerTeleportation } from "babylonjs/XR/features/WebXRControllerTeleportation";
  46933. /**
  46934. * Options for the default xr helper
  46935. */
  46936. export class WebXRDefaultExperienceOptions {
  46937. /**
  46938. * Enable or disable default UI to enter XR
  46939. */
  46940. disableDefaultUI?: boolean;
  46941. /**
  46942. * Should teleportation not initialize. defaults to false.
  46943. */
  46944. disableTeleportation?: boolean;
  46945. /**
  46946. * Floor meshes that will be used for teleport
  46947. */
  46948. floorMeshes?: Array<AbstractMesh>;
  46949. /**
  46950. * If set to true, the first frame will not be used to reset position
  46951. * The first frame is mainly used when copying transformation from the old camera
  46952. * Mainly used in AR
  46953. */
  46954. ignoreNativeCameraTransformation?: boolean;
  46955. /**
  46956. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  46957. */
  46958. inputOptions?: IWebXRInputOptions;
  46959. /**
  46960. * optional configuration for the output canvas
  46961. */
  46962. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  46963. /**
  46964. * optional UI options. This can be used among other to change session mode and reference space type
  46965. */
  46966. uiOptions?: WebXREnterExitUIOptions;
  46967. /**
  46968. * When loading teleportation and pointer select, use stable versions instead of latest.
  46969. */
  46970. useStablePlugins?: boolean;
  46971. }
  46972. /**
  46973. * Default experience which provides a similar setup to the previous webVRExperience
  46974. */
  46975. export class WebXRDefaultExperience {
  46976. /**
  46977. * Base experience
  46978. */
  46979. baseExperience: WebXRExperienceHelper;
  46980. /**
  46981. * Enables ui for entering/exiting xr
  46982. */
  46983. enterExitUI: WebXREnterExitUI;
  46984. /**
  46985. * Input experience extension
  46986. */
  46987. input: WebXRInput;
  46988. /**
  46989. * Enables laser pointer and selection
  46990. */
  46991. pointerSelection: WebXRControllerPointerSelection;
  46992. /**
  46993. * Default target xr should render to
  46994. */
  46995. renderTarget: WebXRRenderTarget;
  46996. /**
  46997. * Enables teleportation
  46998. */
  46999. teleportation: WebXRMotionControllerTeleportation;
  47000. private constructor();
  47001. /**
  47002. * Creates the default xr experience
  47003. * @param scene scene
  47004. * @param options options for basic configuration
  47005. * @returns resulting WebXRDefaultExperience
  47006. */
  47007. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  47008. /**
  47009. * DIsposes of the experience helper
  47010. */
  47011. dispose(): void;
  47012. }
  47013. }
  47014. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  47015. import { Observable } from "babylonjs/Misc/observable";
  47016. import { Nullable } from "babylonjs/types";
  47017. import { Camera } from "babylonjs/Cameras/camera";
  47018. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  47019. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  47020. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  47021. import { Scene } from "babylonjs/scene";
  47022. import { Vector3 } from "babylonjs/Maths/math.vector";
  47023. import { Color3 } from "babylonjs/Maths/math.color";
  47024. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  47025. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47026. import { Mesh } from "babylonjs/Meshes/mesh";
  47027. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  47028. import { EasingFunction } from "babylonjs/Animations/easing";
  47029. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  47030. import "babylonjs/Meshes/Builders/groundBuilder";
  47031. import "babylonjs/Meshes/Builders/torusBuilder";
  47032. import "babylonjs/Meshes/Builders/cylinderBuilder";
  47033. import "babylonjs/Gamepads/gamepadSceneComponent";
  47034. import "babylonjs/Animations/animatable";
  47035. import { WebXRDefaultExperience } from "babylonjs/XR/webXRDefaultExperience";
  47036. /**
  47037. * Options to modify the vr teleportation behavior.
  47038. */
  47039. export interface VRTeleportationOptions {
  47040. /**
  47041. * The name of the mesh which should be used as the teleportation floor. (default: null)
  47042. */
  47043. floorMeshName?: string;
  47044. /**
  47045. * A list of meshes to be used as the teleportation floor. (default: empty)
  47046. */
  47047. floorMeshes?: Mesh[];
  47048. /**
  47049. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  47050. */
  47051. teleportationMode?: number;
  47052. /**
  47053. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  47054. */
  47055. teleportationTime?: number;
  47056. /**
  47057. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  47058. */
  47059. teleportationSpeed?: number;
  47060. /**
  47061. * The easing function used in the animation or null for Linear. (default CircleEase)
  47062. */
  47063. easingFunction?: EasingFunction;
  47064. }
  47065. /**
  47066. * Options to modify the vr experience helper's behavior.
  47067. */
  47068. export interface VRExperienceHelperOptions extends WebVROptions {
  47069. /**
  47070. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  47071. */
  47072. createDeviceOrientationCamera?: boolean;
  47073. /**
  47074. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  47075. */
  47076. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  47077. /**
  47078. * Uses the main button on the controller to toggle the laser casted. (default: true)
  47079. */
  47080. laserToggle?: boolean;
  47081. /**
  47082. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  47083. */
  47084. floorMeshes?: Mesh[];
  47085. /**
  47086. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  47087. */
  47088. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  47089. /**
  47090. * Defines if WebXR should be used instead of WebVR (if available)
  47091. */
  47092. useXR?: boolean;
  47093. }
  47094. /**
  47095. * Event containing information after VR has been entered
  47096. */
  47097. export class OnAfterEnteringVRObservableEvent {
  47098. /**
  47099. * If entering vr was successful
  47100. */
  47101. success: boolean;
  47102. }
  47103. /**
  47104. * Helps to quickly add VR support to an existing scene.
  47105. * See http://doc.babylonjs.com/how_to/webvr_helper
  47106. */
  47107. export class VRExperienceHelper {
  47108. /** Options to modify the vr experience helper's behavior. */
  47109. webVROptions: VRExperienceHelperOptions;
  47110. private _scene;
  47111. private _position;
  47112. private _btnVR;
  47113. private _btnVRDisplayed;
  47114. private _webVRsupported;
  47115. private _webVRready;
  47116. private _webVRrequesting;
  47117. private _webVRpresenting;
  47118. private _hasEnteredVR;
  47119. private _fullscreenVRpresenting;
  47120. private _inputElement;
  47121. private _webVRCamera;
  47122. private _vrDeviceOrientationCamera;
  47123. private _deviceOrientationCamera;
  47124. private _existingCamera;
  47125. private _onKeyDown;
  47126. private _onVrDisplayPresentChange;
  47127. private _onVRDisplayChanged;
  47128. private _onVRRequestPresentStart;
  47129. private _onVRRequestPresentComplete;
  47130. /**
  47131. * 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)
  47132. */
  47133. enableGazeEvenWhenNoPointerLock: boolean;
  47134. /**
  47135. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  47136. */
  47137. exitVROnDoubleTap: boolean;
  47138. /**
  47139. * Observable raised right before entering VR.
  47140. */
  47141. onEnteringVRObservable: Observable<VRExperienceHelper>;
  47142. /**
  47143. * Observable raised when entering VR has completed.
  47144. */
  47145. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  47146. /**
  47147. * Observable raised when exiting VR.
  47148. */
  47149. onExitingVRObservable: Observable<VRExperienceHelper>;
  47150. /**
  47151. * Observable raised when controller mesh is loaded.
  47152. */
  47153. onControllerMeshLoadedObservable: Observable<WebVRController>;
  47154. /** Return this.onEnteringVRObservable
  47155. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  47156. */
  47157. get onEnteringVR(): Observable<VRExperienceHelper>;
  47158. /** Return this.onExitingVRObservable
  47159. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  47160. */
  47161. get onExitingVR(): Observable<VRExperienceHelper>;
  47162. /** Return this.onControllerMeshLoadedObservable
  47163. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  47164. */
  47165. get onControllerMeshLoaded(): Observable<WebVRController>;
  47166. private _rayLength;
  47167. private _useCustomVRButton;
  47168. private _teleportationRequested;
  47169. private _teleportActive;
  47170. private _floorMeshName;
  47171. private _floorMeshesCollection;
  47172. private _teleportationMode;
  47173. private _teleportationTime;
  47174. private _teleportationSpeed;
  47175. private _teleportationEasing;
  47176. private _rotationAllowed;
  47177. private _teleportBackwardsVector;
  47178. private _teleportationTarget;
  47179. private _isDefaultTeleportationTarget;
  47180. private _postProcessMove;
  47181. private _teleportationFillColor;
  47182. private _teleportationBorderColor;
  47183. private _rotationAngle;
  47184. private _haloCenter;
  47185. private _cameraGazer;
  47186. private _padSensibilityUp;
  47187. private _padSensibilityDown;
  47188. private _leftController;
  47189. private _rightController;
  47190. private _gazeColor;
  47191. private _laserColor;
  47192. private _pickedLaserColor;
  47193. private _pickedGazeColor;
  47194. /**
  47195. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  47196. */
  47197. onNewMeshSelected: Observable<AbstractMesh>;
  47198. /**
  47199. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  47200. * This observable will provide the mesh and the controller used to select the mesh
  47201. */
  47202. onMeshSelectedWithController: Observable<{
  47203. mesh: AbstractMesh;
  47204. controller: WebVRController;
  47205. }>;
  47206. /**
  47207. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  47208. */
  47209. onNewMeshPicked: Observable<PickingInfo>;
  47210. private _circleEase;
  47211. /**
  47212. * Observable raised before camera teleportation
  47213. */
  47214. onBeforeCameraTeleport: Observable<Vector3>;
  47215. /**
  47216. * Observable raised after camera teleportation
  47217. */
  47218. onAfterCameraTeleport: Observable<Vector3>;
  47219. /**
  47220. * Observable raised when current selected mesh gets unselected
  47221. */
  47222. onSelectedMeshUnselected: Observable<AbstractMesh>;
  47223. private _raySelectionPredicate;
  47224. /**
  47225. * To be optionaly changed by user to define custom ray selection
  47226. */
  47227. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  47228. /**
  47229. * To be optionaly changed by user to define custom selection logic (after ray selection)
  47230. */
  47231. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  47232. /**
  47233. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  47234. */
  47235. teleportationEnabled: boolean;
  47236. private _defaultHeight;
  47237. private _teleportationInitialized;
  47238. private _interactionsEnabled;
  47239. private _interactionsRequested;
  47240. private _displayGaze;
  47241. private _displayLaserPointer;
  47242. /**
  47243. * The mesh used to display where the user is going to teleport.
  47244. */
  47245. get teleportationTarget(): Mesh;
  47246. /**
  47247. * Sets the mesh to be used to display where the user is going to teleport.
  47248. */
  47249. set teleportationTarget(value: Mesh);
  47250. /**
  47251. * 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
  47252. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  47253. * See http://doc.babylonjs.com/resources/baking_transformations
  47254. */
  47255. get gazeTrackerMesh(): Mesh;
  47256. set gazeTrackerMesh(value: Mesh);
  47257. /**
  47258. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  47259. */
  47260. updateGazeTrackerScale: boolean;
  47261. /**
  47262. * If the gaze trackers color should be updated when selecting meshes
  47263. */
  47264. updateGazeTrackerColor: boolean;
  47265. /**
  47266. * If the controller laser color should be updated when selecting meshes
  47267. */
  47268. updateControllerLaserColor: boolean;
  47269. /**
  47270. * The gaze tracking mesh corresponding to the left controller
  47271. */
  47272. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  47273. /**
  47274. * The gaze tracking mesh corresponding to the right controller
  47275. */
  47276. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  47277. /**
  47278. * If the ray of the gaze should be displayed.
  47279. */
  47280. get displayGaze(): boolean;
  47281. /**
  47282. * Sets if the ray of the gaze should be displayed.
  47283. */
  47284. set displayGaze(value: boolean);
  47285. /**
  47286. * If the ray of the LaserPointer should be displayed.
  47287. */
  47288. get displayLaserPointer(): boolean;
  47289. /**
  47290. * Sets if the ray of the LaserPointer should be displayed.
  47291. */
  47292. set displayLaserPointer(value: boolean);
  47293. /**
  47294. * The deviceOrientationCamera used as the camera when not in VR.
  47295. */
  47296. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  47297. /**
  47298. * Based on the current WebVR support, returns the current VR camera used.
  47299. */
  47300. get currentVRCamera(): Nullable<Camera>;
  47301. /**
  47302. * The webVRCamera which is used when in VR.
  47303. */
  47304. get webVRCamera(): WebVRFreeCamera;
  47305. /**
  47306. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  47307. */
  47308. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  47309. /**
  47310. * The html button that is used to trigger entering into VR.
  47311. */
  47312. get vrButton(): Nullable<HTMLButtonElement>;
  47313. private get _teleportationRequestInitiated();
  47314. /**
  47315. * Defines whether or not Pointer lock should be requested when switching to
  47316. * full screen.
  47317. */
  47318. requestPointerLockOnFullScreen: boolean;
  47319. /**
  47320. * If asking to force XR, this will be populated with the default xr experience
  47321. */
  47322. xr: WebXRDefaultExperience;
  47323. /**
  47324. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  47325. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  47326. */
  47327. xrTestDone: boolean;
  47328. /**
  47329. * Instantiates a VRExperienceHelper.
  47330. * Helps to quickly add VR support to an existing scene.
  47331. * @param scene The scene the VRExperienceHelper belongs to.
  47332. * @param webVROptions Options to modify the vr experience helper's behavior.
  47333. */
  47334. constructor(scene: Scene,
  47335. /** Options to modify the vr experience helper's behavior. */
  47336. webVROptions?: VRExperienceHelperOptions);
  47337. private completeVRInit;
  47338. private _onDefaultMeshLoaded;
  47339. private _onResize;
  47340. private _onFullscreenChange;
  47341. /**
  47342. * Gets a value indicating if we are currently in VR mode.
  47343. */
  47344. get isInVRMode(): boolean;
  47345. private onVrDisplayPresentChange;
  47346. private onVRDisplayChanged;
  47347. private moveButtonToBottomRight;
  47348. private displayVRButton;
  47349. private updateButtonVisibility;
  47350. private _cachedAngularSensibility;
  47351. /**
  47352. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  47353. * Otherwise, will use the fullscreen API.
  47354. */
  47355. enterVR(): void;
  47356. /**
  47357. * Attempt to exit VR, or fullscreen.
  47358. */
  47359. exitVR(): void;
  47360. /**
  47361. * The position of the vr experience helper.
  47362. */
  47363. get position(): Vector3;
  47364. /**
  47365. * Sets the position of the vr experience helper.
  47366. */
  47367. set position(value: Vector3);
  47368. /**
  47369. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  47370. */
  47371. enableInteractions(): void;
  47372. private get _noControllerIsActive();
  47373. private beforeRender;
  47374. private _isTeleportationFloor;
  47375. /**
  47376. * Adds a floor mesh to be used for teleportation.
  47377. * @param floorMesh the mesh to be used for teleportation.
  47378. */
  47379. addFloorMesh(floorMesh: Mesh): void;
  47380. /**
  47381. * Removes a floor mesh from being used for teleportation.
  47382. * @param floorMesh the mesh to be removed.
  47383. */
  47384. removeFloorMesh(floorMesh: Mesh): void;
  47385. /**
  47386. * Enables interactions and teleportation using the VR controllers and gaze.
  47387. * @param vrTeleportationOptions options to modify teleportation behavior.
  47388. */
  47389. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  47390. private _onNewGamepadConnected;
  47391. private _tryEnableInteractionOnController;
  47392. private _onNewGamepadDisconnected;
  47393. private _enableInteractionOnController;
  47394. private _checkTeleportWithRay;
  47395. private _checkRotate;
  47396. private _checkTeleportBackwards;
  47397. private _enableTeleportationOnController;
  47398. private _createTeleportationCircles;
  47399. private _displayTeleportationTarget;
  47400. private _hideTeleportationTarget;
  47401. private _rotateCamera;
  47402. private _moveTeleportationSelectorTo;
  47403. private _workingVector;
  47404. private _workingQuaternion;
  47405. private _workingMatrix;
  47406. /**
  47407. * Time Constant Teleportation Mode
  47408. */
  47409. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  47410. /**
  47411. * Speed Constant Teleportation Mode
  47412. */
  47413. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  47414. /**
  47415. * Teleports the users feet to the desired location
  47416. * @param location The location where the user's feet should be placed
  47417. */
  47418. teleportCamera(location: Vector3): void;
  47419. private _convertNormalToDirectionOfRay;
  47420. private _castRayAndSelectObject;
  47421. private _notifySelectedMeshUnselected;
  47422. /**
  47423. * Permanently set new colors for the laser pointer
  47424. * @param color the new laser color
  47425. * @param pickedColor the new laser color when picked mesh detected
  47426. */
  47427. setLaserColor(color: Color3, pickedColor?: Color3): void;
  47428. /**
  47429. * Set lighting enabled / disabled on the laser pointer of both controllers
  47430. * @param enabled should the lighting be enabled on the laser pointer
  47431. */
  47432. setLaserLightingState(enabled?: boolean): void;
  47433. /**
  47434. * Permanently set new colors for the gaze pointer
  47435. * @param color the new gaze color
  47436. * @param pickedColor the new gaze color when picked mesh detected
  47437. */
  47438. setGazeColor(color: Color3, pickedColor?: Color3): void;
  47439. /**
  47440. * Sets the color of the laser ray from the vr controllers.
  47441. * @param color new color for the ray.
  47442. */
  47443. changeLaserColor(color: Color3): void;
  47444. /**
  47445. * Sets the color of the ray from the vr headsets gaze.
  47446. * @param color new color for the ray.
  47447. */
  47448. changeGazeColor(color: Color3): void;
  47449. /**
  47450. * Exits VR and disposes of the vr experience helper
  47451. */
  47452. dispose(): void;
  47453. /**
  47454. * Gets the name of the VRExperienceHelper class
  47455. * @returns "VRExperienceHelper"
  47456. */
  47457. getClassName(): string;
  47458. }
  47459. }
  47460. declare module "babylonjs/Cameras/VR/index" {
  47461. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  47462. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  47463. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  47464. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  47465. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  47466. export * from "babylonjs/Cameras/VR/webVRCamera";
  47467. }
  47468. declare module "babylonjs/Cameras/RigModes/index" {
  47469. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  47470. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  47471. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  47472. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  47473. }
  47474. declare module "babylonjs/Cameras/index" {
  47475. export * from "babylonjs/Cameras/Inputs/index";
  47476. export * from "babylonjs/Cameras/cameraInputsManager";
  47477. export * from "babylonjs/Cameras/camera";
  47478. export * from "babylonjs/Cameras/targetCamera";
  47479. export * from "babylonjs/Cameras/freeCamera";
  47480. export * from "babylonjs/Cameras/freeCameraInputsManager";
  47481. export * from "babylonjs/Cameras/touchCamera";
  47482. export * from "babylonjs/Cameras/arcRotateCamera";
  47483. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  47484. export * from "babylonjs/Cameras/deviceOrientationCamera";
  47485. export * from "babylonjs/Cameras/flyCamera";
  47486. export * from "babylonjs/Cameras/flyCameraInputsManager";
  47487. export * from "babylonjs/Cameras/followCamera";
  47488. export * from "babylonjs/Cameras/followCameraInputsManager";
  47489. export * from "babylonjs/Cameras/gamepadCamera";
  47490. export * from "babylonjs/Cameras/Stereoscopic/index";
  47491. export * from "babylonjs/Cameras/universalCamera";
  47492. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  47493. export * from "babylonjs/Cameras/VR/index";
  47494. export * from "babylonjs/Cameras/RigModes/index";
  47495. }
  47496. declare module "babylonjs/Collisions/index" {
  47497. export * from "babylonjs/Collisions/collider";
  47498. export * from "babylonjs/Collisions/collisionCoordinator";
  47499. export * from "babylonjs/Collisions/pickingInfo";
  47500. export * from "babylonjs/Collisions/intersectionInfo";
  47501. export * from "babylonjs/Collisions/meshCollisionData";
  47502. }
  47503. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  47504. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  47505. import { Vector3 } from "babylonjs/Maths/math.vector";
  47506. import { Ray } from "babylonjs/Culling/ray";
  47507. import { Plane } from "babylonjs/Maths/math.plane";
  47508. /**
  47509. * Contains an array of blocks representing the octree
  47510. */
  47511. export interface IOctreeContainer<T> {
  47512. /**
  47513. * Blocks within the octree
  47514. */
  47515. blocks: Array<OctreeBlock<T>>;
  47516. }
  47517. /**
  47518. * Class used to store a cell in an octree
  47519. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47520. */
  47521. export class OctreeBlock<T> {
  47522. /**
  47523. * Gets the content of the current block
  47524. */
  47525. entries: T[];
  47526. /**
  47527. * Gets the list of block children
  47528. */
  47529. blocks: Array<OctreeBlock<T>>;
  47530. private _depth;
  47531. private _maxDepth;
  47532. private _capacity;
  47533. private _minPoint;
  47534. private _maxPoint;
  47535. private _boundingVectors;
  47536. private _creationFunc;
  47537. /**
  47538. * Creates a new block
  47539. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  47540. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  47541. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  47542. * @param depth defines the current depth of this block in the octree
  47543. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  47544. * @param creationFunc defines a callback to call when an element is added to the block
  47545. */
  47546. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  47547. /**
  47548. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  47549. */
  47550. get capacity(): number;
  47551. /**
  47552. * Gets the minimum vector (in world space) of the block's bounding box
  47553. */
  47554. get minPoint(): Vector3;
  47555. /**
  47556. * Gets the maximum vector (in world space) of the block's bounding box
  47557. */
  47558. get maxPoint(): Vector3;
  47559. /**
  47560. * Add a new element to this block
  47561. * @param entry defines the element to add
  47562. */
  47563. addEntry(entry: T): void;
  47564. /**
  47565. * Remove an element from this block
  47566. * @param entry defines the element to remove
  47567. */
  47568. removeEntry(entry: T): void;
  47569. /**
  47570. * Add an array of elements to this block
  47571. * @param entries defines the array of elements to add
  47572. */
  47573. addEntries(entries: T[]): void;
  47574. /**
  47575. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  47576. * @param frustumPlanes defines the frustum planes to test
  47577. * @param selection defines the array to store current content if selection is positive
  47578. * @param allowDuplicate defines if the selection array can contains duplicated entries
  47579. */
  47580. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  47581. /**
  47582. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  47583. * @param sphereCenter defines the bounding sphere center
  47584. * @param sphereRadius defines the bounding sphere radius
  47585. * @param selection defines the array to store current content if selection is positive
  47586. * @param allowDuplicate defines if the selection array can contains duplicated entries
  47587. */
  47588. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  47589. /**
  47590. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  47591. * @param ray defines the ray to test with
  47592. * @param selection defines the array to store current content if selection is positive
  47593. */
  47594. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  47595. /**
  47596. * Subdivide the content into child blocks (this block will then be empty)
  47597. */
  47598. createInnerBlocks(): void;
  47599. /**
  47600. * @hidden
  47601. */
  47602. 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;
  47603. }
  47604. }
  47605. declare module "babylonjs/Culling/Octrees/octree" {
  47606. import { SmartArray } from "babylonjs/Misc/smartArray";
  47607. import { Vector3 } from "babylonjs/Maths/math.vector";
  47608. import { SubMesh } from "babylonjs/Meshes/subMesh";
  47609. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47610. import { Ray } from "babylonjs/Culling/ray";
  47611. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  47612. import { Plane } from "babylonjs/Maths/math.plane";
  47613. /**
  47614. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  47615. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47616. */
  47617. export class Octree<T> {
  47618. /** 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.) */
  47619. maxDepth: number;
  47620. /**
  47621. * Blocks within the octree containing objects
  47622. */
  47623. blocks: Array<OctreeBlock<T>>;
  47624. /**
  47625. * Content stored in the octree
  47626. */
  47627. dynamicContent: T[];
  47628. private _maxBlockCapacity;
  47629. private _selectionContent;
  47630. private _creationFunc;
  47631. /**
  47632. * Creates a octree
  47633. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47634. * @param creationFunc function to be used to instatiate the octree
  47635. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  47636. * @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.)
  47637. */
  47638. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  47639. /** 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.) */
  47640. maxDepth?: number);
  47641. /**
  47642. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  47643. * @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);
  47644. * @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);
  47645. * @param entries meshes to be added to the octree blocks
  47646. */
  47647. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  47648. /**
  47649. * Adds a mesh to the octree
  47650. * @param entry Mesh to add to the octree
  47651. */
  47652. addMesh(entry: T): void;
  47653. /**
  47654. * Remove an element from the octree
  47655. * @param entry defines the element to remove
  47656. */
  47657. removeMesh(entry: T): void;
  47658. /**
  47659. * Selects an array of meshes within the frustum
  47660. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  47661. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  47662. * @returns array of meshes within the frustum
  47663. */
  47664. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  47665. /**
  47666. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  47667. * @param sphereCenter defines the bounding sphere center
  47668. * @param sphereRadius defines the bounding sphere radius
  47669. * @param allowDuplicate defines if the selection array can contains duplicated entries
  47670. * @returns an array of objects that intersect the sphere
  47671. */
  47672. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  47673. /**
  47674. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  47675. * @param ray defines the ray to test with
  47676. * @returns array of intersected objects
  47677. */
  47678. intersectsRay(ray: Ray): SmartArray<T>;
  47679. /**
  47680. * Adds a mesh into the octree block if it intersects the block
  47681. */
  47682. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  47683. /**
  47684. * Adds a submesh into the octree block if it intersects the block
  47685. */
  47686. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  47687. }
  47688. }
  47689. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  47690. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  47691. import { Scene } from "babylonjs/scene";
  47692. import { SubMesh } from "babylonjs/Meshes/subMesh";
  47693. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47694. import { Ray } from "babylonjs/Culling/ray";
  47695. import { Octree } from "babylonjs/Culling/Octrees/octree";
  47696. import { Collider } from "babylonjs/Collisions/collider";
  47697. module "babylonjs/scene" {
  47698. interface Scene {
  47699. /**
  47700. * @hidden
  47701. * Backing Filed
  47702. */
  47703. _selectionOctree: Octree<AbstractMesh>;
  47704. /**
  47705. * Gets the octree used to boost mesh selection (picking)
  47706. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47707. */
  47708. selectionOctree: Octree<AbstractMesh>;
  47709. /**
  47710. * Creates or updates the octree used to boost selection (picking)
  47711. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47712. * @param maxCapacity defines the maximum capacity per leaf
  47713. * @param maxDepth defines the maximum depth of the octree
  47714. * @returns an octree of AbstractMesh
  47715. */
  47716. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  47717. }
  47718. }
  47719. module "babylonjs/Meshes/abstractMesh" {
  47720. interface AbstractMesh {
  47721. /**
  47722. * @hidden
  47723. * Backing Field
  47724. */
  47725. _submeshesOctree: Octree<SubMesh>;
  47726. /**
  47727. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  47728. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  47729. * @param maxCapacity defines the maximum size of each block (64 by default)
  47730. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  47731. * @returns the new octree
  47732. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  47733. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47734. */
  47735. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  47736. }
  47737. }
  47738. /**
  47739. * Defines the octree scene component responsible to manage any octrees
  47740. * in a given scene.
  47741. */
  47742. export class OctreeSceneComponent {
  47743. /**
  47744. * The component name help to identify the component in the list of scene components.
  47745. */
  47746. readonly name: string;
  47747. /**
  47748. * The scene the component belongs to.
  47749. */
  47750. scene: Scene;
  47751. /**
  47752. * Indicates if the meshes have been checked to make sure they are isEnabled()
  47753. */
  47754. readonly checksIsEnabled: boolean;
  47755. /**
  47756. * Creates a new instance of the component for the given scene
  47757. * @param scene Defines the scene to register the component in
  47758. */
  47759. constructor(scene: Scene);
  47760. /**
  47761. * Registers the component in a given scene
  47762. */
  47763. register(): void;
  47764. /**
  47765. * Return the list of active meshes
  47766. * @returns the list of active meshes
  47767. */
  47768. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  47769. /**
  47770. * Return the list of active sub meshes
  47771. * @param mesh The mesh to get the candidates sub meshes from
  47772. * @returns the list of active sub meshes
  47773. */
  47774. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  47775. private _tempRay;
  47776. /**
  47777. * Return the list of sub meshes intersecting with a given local ray
  47778. * @param mesh defines the mesh to find the submesh for
  47779. * @param localRay defines the ray in local space
  47780. * @returns the list of intersecting sub meshes
  47781. */
  47782. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  47783. /**
  47784. * Return the list of sub meshes colliding with a collider
  47785. * @param mesh defines the mesh to find the submesh for
  47786. * @param collider defines the collider to evaluate the collision against
  47787. * @returns the list of colliding sub meshes
  47788. */
  47789. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  47790. /**
  47791. * Rebuilds the elements related to this component in case of
  47792. * context lost for instance.
  47793. */
  47794. rebuild(): void;
  47795. /**
  47796. * Disposes the component and the associated ressources.
  47797. */
  47798. dispose(): void;
  47799. }
  47800. }
  47801. declare module "babylonjs/Culling/Octrees/index" {
  47802. export * from "babylonjs/Culling/Octrees/octree";
  47803. export * from "babylonjs/Culling/Octrees/octreeBlock";
  47804. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  47805. }
  47806. declare module "babylonjs/Culling/index" {
  47807. export * from "babylonjs/Culling/boundingBox";
  47808. export * from "babylonjs/Culling/boundingInfo";
  47809. export * from "babylonjs/Culling/boundingSphere";
  47810. export * from "babylonjs/Culling/Octrees/index";
  47811. export * from "babylonjs/Culling/ray";
  47812. }
  47813. declare module "babylonjs/Gizmos/gizmo" {
  47814. import { Nullable } from "babylonjs/types";
  47815. import { IDisposable } from "babylonjs/scene";
  47816. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47817. import { Mesh } from "babylonjs/Meshes/mesh";
  47818. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47819. /**
  47820. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  47821. */
  47822. export class Gizmo implements IDisposable {
  47823. /** The utility layer the gizmo will be added to */
  47824. gizmoLayer: UtilityLayerRenderer;
  47825. /**
  47826. * The root mesh of the gizmo
  47827. */
  47828. _rootMesh: Mesh;
  47829. private _attachedMesh;
  47830. /**
  47831. * Ratio for the scale of the gizmo (Default: 1)
  47832. */
  47833. scaleRatio: number;
  47834. /**
  47835. * If a custom mesh has been set (Default: false)
  47836. */
  47837. protected _customMeshSet: boolean;
  47838. /**
  47839. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  47840. * * When set, interactions will be enabled
  47841. */
  47842. get attachedMesh(): Nullable<AbstractMesh>;
  47843. set attachedMesh(value: Nullable<AbstractMesh>);
  47844. /**
  47845. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  47846. * @param mesh The mesh to replace the default mesh of the gizmo
  47847. */
  47848. setCustomMesh(mesh: Mesh): void;
  47849. /**
  47850. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  47851. */
  47852. updateGizmoRotationToMatchAttachedMesh: boolean;
  47853. /**
  47854. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  47855. */
  47856. updateGizmoPositionToMatchAttachedMesh: boolean;
  47857. /**
  47858. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  47859. */
  47860. updateScale: boolean;
  47861. protected _interactionsEnabled: boolean;
  47862. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47863. private _beforeRenderObserver;
  47864. private _tempVector;
  47865. /**
  47866. * Creates a gizmo
  47867. * @param gizmoLayer The utility layer the gizmo will be added to
  47868. */
  47869. constructor(
  47870. /** The utility layer the gizmo will be added to */
  47871. gizmoLayer?: UtilityLayerRenderer);
  47872. /**
  47873. * Updates the gizmo to match the attached mesh's position/rotation
  47874. */
  47875. protected _update(): void;
  47876. /**
  47877. * Disposes of the gizmo
  47878. */
  47879. dispose(): void;
  47880. }
  47881. }
  47882. declare module "babylonjs/Gizmos/planeDragGizmo" {
  47883. import { Observable } from "babylonjs/Misc/observable";
  47884. import { Nullable } from "babylonjs/types";
  47885. import { Vector3 } from "babylonjs/Maths/math.vector";
  47886. import { Color3 } from "babylonjs/Maths/math.color";
  47887. import { TransformNode } from "babylonjs/Meshes/transformNode";
  47888. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47889. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  47890. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47891. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47892. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  47893. import { Scene } from "babylonjs/scene";
  47894. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  47895. /**
  47896. * Single plane drag gizmo
  47897. */
  47898. export class PlaneDragGizmo extends Gizmo {
  47899. /**
  47900. * Drag behavior responsible for the gizmos dragging interactions
  47901. */
  47902. dragBehavior: PointerDragBehavior;
  47903. private _pointerObserver;
  47904. /**
  47905. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47906. */
  47907. snapDistance: number;
  47908. /**
  47909. * Event that fires each time the gizmo snaps to a new location.
  47910. * * snapDistance is the the change in distance
  47911. */
  47912. onSnapObservable: Observable<{
  47913. snapDistance: number;
  47914. }>;
  47915. private _plane;
  47916. private _coloredMaterial;
  47917. private _hoverMaterial;
  47918. private _isEnabled;
  47919. private _parent;
  47920. /** @hidden */
  47921. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  47922. /** @hidden */
  47923. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  47924. /**
  47925. * Creates a PlaneDragGizmo
  47926. * @param gizmoLayer The utility layer the gizmo will be added to
  47927. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  47928. * @param color The color of the gizmo
  47929. */
  47930. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  47931. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47932. /**
  47933. * If the gizmo is enabled
  47934. */
  47935. set isEnabled(value: boolean);
  47936. get isEnabled(): boolean;
  47937. /**
  47938. * Disposes of the gizmo
  47939. */
  47940. dispose(): void;
  47941. }
  47942. }
  47943. declare module "babylonjs/Gizmos/positionGizmo" {
  47944. import { Observable } from "babylonjs/Misc/observable";
  47945. import { Nullable } from "babylonjs/types";
  47946. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47947. import { Mesh } from "babylonjs/Meshes/mesh";
  47948. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47949. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  47950. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  47951. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47952. /**
  47953. * Gizmo that enables dragging a mesh along 3 axis
  47954. */
  47955. export class PositionGizmo extends Gizmo {
  47956. /**
  47957. * Internal gizmo used for interactions on the x axis
  47958. */
  47959. xGizmo: AxisDragGizmo;
  47960. /**
  47961. * Internal gizmo used for interactions on the y axis
  47962. */
  47963. yGizmo: AxisDragGizmo;
  47964. /**
  47965. * Internal gizmo used for interactions on the z axis
  47966. */
  47967. zGizmo: AxisDragGizmo;
  47968. /**
  47969. * Internal gizmo used for interactions on the yz plane
  47970. */
  47971. xPlaneGizmo: PlaneDragGizmo;
  47972. /**
  47973. * Internal gizmo used for interactions on the xz plane
  47974. */
  47975. yPlaneGizmo: PlaneDragGizmo;
  47976. /**
  47977. * Internal gizmo used for interactions on the xy plane
  47978. */
  47979. zPlaneGizmo: PlaneDragGizmo;
  47980. /**
  47981. * private variables
  47982. */
  47983. private _meshAttached;
  47984. private _updateGizmoRotationToMatchAttachedMesh;
  47985. private _snapDistance;
  47986. private _scaleRatio;
  47987. /** Fires an event when any of it's sub gizmos are dragged */
  47988. onDragStartObservable: Observable<unknown>;
  47989. /** Fires an event when any of it's sub gizmos are released from dragging */
  47990. onDragEndObservable: Observable<unknown>;
  47991. /**
  47992. * If set to true, planar drag is enabled
  47993. */
  47994. private _planarGizmoEnabled;
  47995. get attachedMesh(): Nullable<AbstractMesh>;
  47996. set attachedMesh(mesh: Nullable<AbstractMesh>);
  47997. /**
  47998. * Creates a PositionGizmo
  47999. * @param gizmoLayer The utility layer the gizmo will be added to
  48000. */
  48001. constructor(gizmoLayer?: UtilityLayerRenderer);
  48002. /**
  48003. * If the planar drag gizmo is enabled
  48004. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  48005. */
  48006. set planarGizmoEnabled(value: boolean);
  48007. get planarGizmoEnabled(): boolean;
  48008. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  48009. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  48010. /**
  48011. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  48012. */
  48013. set snapDistance(value: number);
  48014. get snapDistance(): number;
  48015. /**
  48016. * Ratio for the scale of the gizmo (Default: 1)
  48017. */
  48018. set scaleRatio(value: number);
  48019. get scaleRatio(): number;
  48020. /**
  48021. * Disposes of the gizmo
  48022. */
  48023. dispose(): void;
  48024. /**
  48025. * CustomMeshes are not supported by this gizmo
  48026. * @param mesh The mesh to replace the default mesh of the gizmo
  48027. */
  48028. setCustomMesh(mesh: Mesh): void;
  48029. }
  48030. }
  48031. declare module "babylonjs/Gizmos/axisDragGizmo" {
  48032. import { Observable } from "babylonjs/Misc/observable";
  48033. import { Nullable } from "babylonjs/types";
  48034. import { Vector3 } from "babylonjs/Maths/math.vector";
  48035. import { TransformNode } from "babylonjs/Meshes/transformNode";
  48036. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48037. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  48038. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  48039. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  48040. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  48041. import { Scene } from "babylonjs/scene";
  48042. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  48043. import { Color3 } from "babylonjs/Maths/math.color";
  48044. /**
  48045. * Single axis drag gizmo
  48046. */
  48047. export class AxisDragGizmo extends Gizmo {
  48048. /**
  48049. * Drag behavior responsible for the gizmos dragging interactions
  48050. */
  48051. dragBehavior: PointerDragBehavior;
  48052. private _pointerObserver;
  48053. /**
  48054. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  48055. */
  48056. snapDistance: number;
  48057. /**
  48058. * Event that fires each time the gizmo snaps to a new location.
  48059. * * snapDistance is the the change in distance
  48060. */
  48061. onSnapObservable: Observable<{
  48062. snapDistance: number;
  48063. }>;
  48064. private _isEnabled;
  48065. private _parent;
  48066. private _arrow;
  48067. private _coloredMaterial;
  48068. private _hoverMaterial;
  48069. /** @hidden */
  48070. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  48071. /** @hidden */
  48072. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  48073. /**
  48074. * Creates an AxisDragGizmo
  48075. * @param gizmoLayer The utility layer the gizmo will be added to
  48076. * @param dragAxis The axis which the gizmo will be able to drag on
  48077. * @param color The color of the gizmo
  48078. */
  48079. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  48080. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  48081. /**
  48082. * If the gizmo is enabled
  48083. */
  48084. set isEnabled(value: boolean);
  48085. get isEnabled(): boolean;
  48086. /**
  48087. * Disposes of the gizmo
  48088. */
  48089. dispose(): void;
  48090. }
  48091. }
  48092. declare module "babylonjs/Debug/axesViewer" {
  48093. import { Vector3 } from "babylonjs/Maths/math.vector";
  48094. import { Nullable } from "babylonjs/types";
  48095. import { Scene } from "babylonjs/scene";
  48096. import { TransformNode } from "babylonjs/Meshes/transformNode";
  48097. /**
  48098. * The Axes viewer will show 3 axes in a specific point in space
  48099. */
  48100. export class AxesViewer {
  48101. private _xAxis;
  48102. private _yAxis;
  48103. private _zAxis;
  48104. private _scaleLinesFactor;
  48105. private _instanced;
  48106. /**
  48107. * Gets the hosting scene
  48108. */
  48109. scene: Scene;
  48110. /**
  48111. * Gets or sets a number used to scale line length
  48112. */
  48113. scaleLines: number;
  48114. /** Gets the node hierarchy used to render x-axis */
  48115. get xAxis(): TransformNode;
  48116. /** Gets the node hierarchy used to render y-axis */
  48117. get yAxis(): TransformNode;
  48118. /** Gets the node hierarchy used to render z-axis */
  48119. get zAxis(): TransformNode;
  48120. /**
  48121. * Creates a new AxesViewer
  48122. * @param scene defines the hosting scene
  48123. * @param scaleLines defines a number used to scale line length (1 by default)
  48124. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  48125. * @param xAxis defines the node hierarchy used to render the x-axis
  48126. * @param yAxis defines the node hierarchy used to render the y-axis
  48127. * @param zAxis defines the node hierarchy used to render the z-axis
  48128. */
  48129. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  48130. /**
  48131. * Force the viewer to update
  48132. * @param position defines the position of the viewer
  48133. * @param xaxis defines the x axis of the viewer
  48134. * @param yaxis defines the y axis of the viewer
  48135. * @param zaxis defines the z axis of the viewer
  48136. */
  48137. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  48138. /**
  48139. * Creates an instance of this axes viewer.
  48140. * @returns a new axes viewer with instanced meshes
  48141. */
  48142. createInstance(): AxesViewer;
  48143. /** Releases resources */
  48144. dispose(): void;
  48145. private static _SetRenderingGroupId;
  48146. }
  48147. }
  48148. declare module "babylonjs/Debug/boneAxesViewer" {
  48149. import { Nullable } from "babylonjs/types";
  48150. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  48151. import { Vector3 } from "babylonjs/Maths/math.vector";
  48152. import { Mesh } from "babylonjs/Meshes/mesh";
  48153. import { Bone } from "babylonjs/Bones/bone";
  48154. import { Scene } from "babylonjs/scene";
  48155. /**
  48156. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  48157. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  48158. */
  48159. export class BoneAxesViewer extends AxesViewer {
  48160. /**
  48161. * Gets or sets the target mesh where to display the axes viewer
  48162. */
  48163. mesh: Nullable<Mesh>;
  48164. /**
  48165. * Gets or sets the target bone where to display the axes viewer
  48166. */
  48167. bone: Nullable<Bone>;
  48168. /** Gets current position */
  48169. pos: Vector3;
  48170. /** Gets direction of X axis */
  48171. xaxis: Vector3;
  48172. /** Gets direction of Y axis */
  48173. yaxis: Vector3;
  48174. /** Gets direction of Z axis */
  48175. zaxis: Vector3;
  48176. /**
  48177. * Creates a new BoneAxesViewer
  48178. * @param scene defines the hosting scene
  48179. * @param bone defines the target bone
  48180. * @param mesh defines the target mesh
  48181. * @param scaleLines defines a scaling factor for line length (1 by default)
  48182. */
  48183. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  48184. /**
  48185. * Force the viewer to update
  48186. */
  48187. update(): void;
  48188. /** Releases resources */
  48189. dispose(): void;
  48190. }
  48191. }
  48192. declare module "babylonjs/Debug/debugLayer" {
  48193. import { Scene } from "babylonjs/scene";
  48194. /**
  48195. * Interface used to define scene explorer extensibility option
  48196. */
  48197. export interface IExplorerExtensibilityOption {
  48198. /**
  48199. * Define the option label
  48200. */
  48201. label: string;
  48202. /**
  48203. * Defines the action to execute on click
  48204. */
  48205. action: (entity: any) => void;
  48206. }
  48207. /**
  48208. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  48209. */
  48210. export interface IExplorerExtensibilityGroup {
  48211. /**
  48212. * Defines a predicate to test if a given type mut be extended
  48213. */
  48214. predicate: (entity: any) => boolean;
  48215. /**
  48216. * Gets the list of options added to a type
  48217. */
  48218. entries: IExplorerExtensibilityOption[];
  48219. }
  48220. /**
  48221. * Interface used to define the options to use to create the Inspector
  48222. */
  48223. export interface IInspectorOptions {
  48224. /**
  48225. * Display in overlay mode (default: false)
  48226. */
  48227. overlay?: boolean;
  48228. /**
  48229. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  48230. */
  48231. globalRoot?: HTMLElement;
  48232. /**
  48233. * Display the Scene explorer
  48234. */
  48235. showExplorer?: boolean;
  48236. /**
  48237. * Display the property inspector
  48238. */
  48239. showInspector?: boolean;
  48240. /**
  48241. * Display in embed mode (both panes on the right)
  48242. */
  48243. embedMode?: boolean;
  48244. /**
  48245. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  48246. */
  48247. handleResize?: boolean;
  48248. /**
  48249. * Allow the panes to popup (default: true)
  48250. */
  48251. enablePopup?: boolean;
  48252. /**
  48253. * Allow the panes to be closed by users (default: true)
  48254. */
  48255. enableClose?: boolean;
  48256. /**
  48257. * Optional list of extensibility entries
  48258. */
  48259. explorerExtensibility?: IExplorerExtensibilityGroup[];
  48260. /**
  48261. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  48262. */
  48263. inspectorURL?: string;
  48264. /**
  48265. * Optional initial tab (default to DebugLayerTab.Properties)
  48266. */
  48267. initialTab?: DebugLayerTab;
  48268. }
  48269. module "babylonjs/scene" {
  48270. interface Scene {
  48271. /**
  48272. * @hidden
  48273. * Backing field
  48274. */
  48275. _debugLayer: DebugLayer;
  48276. /**
  48277. * Gets the debug layer (aka Inspector) associated with the scene
  48278. * @see http://doc.babylonjs.com/features/playground_debuglayer
  48279. */
  48280. debugLayer: DebugLayer;
  48281. }
  48282. }
  48283. /**
  48284. * Enum of inspector action tab
  48285. */
  48286. export enum DebugLayerTab {
  48287. /**
  48288. * Properties tag (default)
  48289. */
  48290. Properties = 0,
  48291. /**
  48292. * Debug tab
  48293. */
  48294. Debug = 1,
  48295. /**
  48296. * Statistics tab
  48297. */
  48298. Statistics = 2,
  48299. /**
  48300. * Tools tab
  48301. */
  48302. Tools = 3,
  48303. /**
  48304. * Settings tab
  48305. */
  48306. Settings = 4
  48307. }
  48308. /**
  48309. * The debug layer (aka Inspector) is the go to tool in order to better understand
  48310. * what is happening in your scene
  48311. * @see http://doc.babylonjs.com/features/playground_debuglayer
  48312. */
  48313. export class DebugLayer {
  48314. /**
  48315. * Define the url to get the inspector script from.
  48316. * By default it uses the babylonjs CDN.
  48317. * @ignoreNaming
  48318. */
  48319. static InspectorURL: string;
  48320. private _scene;
  48321. private BJSINSPECTOR;
  48322. private _onPropertyChangedObservable?;
  48323. /**
  48324. * Observable triggered when a property is changed through the inspector.
  48325. */
  48326. get onPropertyChangedObservable(): any;
  48327. /**
  48328. * Instantiates a new debug layer.
  48329. * The debug layer (aka Inspector) is the go to tool in order to better understand
  48330. * what is happening in your scene
  48331. * @see http://doc.babylonjs.com/features/playground_debuglayer
  48332. * @param scene Defines the scene to inspect
  48333. */
  48334. constructor(scene: Scene);
  48335. /** Creates the inspector window. */
  48336. private _createInspector;
  48337. /**
  48338. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  48339. * @param entity defines the entity to select
  48340. * @param lineContainerTitle defines the specific block to highlight
  48341. */
  48342. select(entity: any, lineContainerTitle?: string): void;
  48343. /** Get the inspector from bundle or global */
  48344. private _getGlobalInspector;
  48345. /**
  48346. * Get if the inspector is visible or not.
  48347. * @returns true if visible otherwise, false
  48348. */
  48349. isVisible(): boolean;
  48350. /**
  48351. * Hide the inspector and close its window.
  48352. */
  48353. hide(): void;
  48354. /**
  48355. * Launch the debugLayer.
  48356. * @param config Define the configuration of the inspector
  48357. * @return a promise fulfilled when the debug layer is visible
  48358. */
  48359. show(config?: IInspectorOptions): Promise<DebugLayer>;
  48360. }
  48361. }
  48362. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  48363. import { Nullable } from "babylonjs/types";
  48364. import { Scene } from "babylonjs/scene";
  48365. import { Vector4 } from "babylonjs/Maths/math.vector";
  48366. import { Color4 } from "babylonjs/Maths/math.color";
  48367. import { Mesh } from "babylonjs/Meshes/mesh";
  48368. /**
  48369. * Class containing static functions to help procedurally build meshes
  48370. */
  48371. export class BoxBuilder {
  48372. /**
  48373. * Creates a box mesh
  48374. * * The parameter `size` sets the size (float) of each box side (default 1)
  48375. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  48376. * * 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)
  48377. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  48378. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48379. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  48380. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48381. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  48382. * @param name defines the name of the mesh
  48383. * @param options defines the options used to create the mesh
  48384. * @param scene defines the hosting scene
  48385. * @returns the box mesh
  48386. */
  48387. static CreateBox(name: string, options: {
  48388. size?: number;
  48389. width?: number;
  48390. height?: number;
  48391. depth?: number;
  48392. faceUV?: Vector4[];
  48393. faceColors?: Color4[];
  48394. sideOrientation?: number;
  48395. frontUVs?: Vector4;
  48396. backUVs?: Vector4;
  48397. wrap?: boolean;
  48398. topBaseAt?: number;
  48399. bottomBaseAt?: number;
  48400. updatable?: boolean;
  48401. }, scene?: Nullable<Scene>): Mesh;
  48402. }
  48403. }
  48404. declare module "babylonjs/Debug/physicsViewer" {
  48405. import { Nullable } from "babylonjs/types";
  48406. import { Scene } from "babylonjs/scene";
  48407. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48408. import { Mesh } from "babylonjs/Meshes/mesh";
  48409. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  48410. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  48411. /**
  48412. * Used to show the physics impostor around the specific mesh
  48413. */
  48414. export class PhysicsViewer {
  48415. /** @hidden */
  48416. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  48417. /** @hidden */
  48418. protected _meshes: Array<Nullable<AbstractMesh>>;
  48419. /** @hidden */
  48420. protected _scene: Nullable<Scene>;
  48421. /** @hidden */
  48422. protected _numMeshes: number;
  48423. /** @hidden */
  48424. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  48425. private _renderFunction;
  48426. private _utilityLayer;
  48427. private _debugBoxMesh;
  48428. private _debugSphereMesh;
  48429. private _debugCylinderMesh;
  48430. private _debugMaterial;
  48431. private _debugMeshMeshes;
  48432. /**
  48433. * Creates a new PhysicsViewer
  48434. * @param scene defines the hosting scene
  48435. */
  48436. constructor(scene: Scene);
  48437. /** @hidden */
  48438. protected _updateDebugMeshes(): void;
  48439. /**
  48440. * Renders a specified physic impostor
  48441. * @param impostor defines the impostor to render
  48442. * @param targetMesh defines the mesh represented by the impostor
  48443. * @returns the new debug mesh used to render the impostor
  48444. */
  48445. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  48446. /**
  48447. * Hides a specified physic impostor
  48448. * @param impostor defines the impostor to hide
  48449. */
  48450. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  48451. private _getDebugMaterial;
  48452. private _getDebugBoxMesh;
  48453. private _getDebugSphereMesh;
  48454. private _getDebugCylinderMesh;
  48455. private _getDebugMeshMesh;
  48456. private _getDebugMesh;
  48457. /** Releases all resources */
  48458. dispose(): void;
  48459. }
  48460. }
  48461. declare module "babylonjs/Debug/rayHelper" {
  48462. import { Nullable } from "babylonjs/types";
  48463. import { Ray } from "babylonjs/Culling/ray";
  48464. import { Vector3 } from "babylonjs/Maths/math.vector";
  48465. import { Color3 } from "babylonjs/Maths/math.color";
  48466. import { Scene } from "babylonjs/scene";
  48467. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48468. import "babylonjs/Meshes/Builders/linesBuilder";
  48469. /**
  48470. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  48471. * in order to better appreciate the issue one might have.
  48472. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  48473. */
  48474. export class RayHelper {
  48475. /**
  48476. * Defines the ray we are currently tryin to visualize.
  48477. */
  48478. ray: Nullable<Ray>;
  48479. private _renderPoints;
  48480. private _renderLine;
  48481. private _renderFunction;
  48482. private _scene;
  48483. private _updateToMeshFunction;
  48484. private _attachedToMesh;
  48485. private _meshSpaceDirection;
  48486. private _meshSpaceOrigin;
  48487. /**
  48488. * Helper function to create a colored helper in a scene in one line.
  48489. * @param ray Defines the ray we are currently tryin to visualize
  48490. * @param scene Defines the scene the ray is used in
  48491. * @param color Defines the color we want to see the ray in
  48492. * @returns The newly created ray helper.
  48493. */
  48494. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  48495. /**
  48496. * Instantiate a new ray helper.
  48497. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  48498. * in order to better appreciate the issue one might have.
  48499. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  48500. * @param ray Defines the ray we are currently tryin to visualize
  48501. */
  48502. constructor(ray: Ray);
  48503. /**
  48504. * Shows the ray we are willing to debug.
  48505. * @param scene Defines the scene the ray needs to be rendered in
  48506. * @param color Defines the color the ray needs to be rendered in
  48507. */
  48508. show(scene: Scene, color?: Color3): void;
  48509. /**
  48510. * Hides the ray we are debugging.
  48511. */
  48512. hide(): void;
  48513. private _render;
  48514. /**
  48515. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  48516. * @param mesh Defines the mesh we want the helper attached to
  48517. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  48518. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  48519. * @param length Defines the length of the ray
  48520. */
  48521. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  48522. /**
  48523. * Detach the ray helper from the mesh it has previously been attached to.
  48524. */
  48525. detachFromMesh(): void;
  48526. private _updateToMesh;
  48527. /**
  48528. * Dispose the helper and release its associated resources.
  48529. */
  48530. dispose(): void;
  48531. }
  48532. }
  48533. declare module "babylonjs/Debug/skeletonViewer" {
  48534. import { Color3 } from "babylonjs/Maths/math.color";
  48535. import { Scene } from "babylonjs/scene";
  48536. import { Nullable } from "babylonjs/types";
  48537. import { Skeleton } from "babylonjs/Bones/skeleton";
  48538. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48539. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  48540. /**
  48541. * Class used to render a debug view of a given skeleton
  48542. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  48543. */
  48544. export class SkeletonViewer {
  48545. /** defines the skeleton to render */
  48546. skeleton: Skeleton;
  48547. /** defines the mesh attached to the skeleton */
  48548. mesh: AbstractMesh;
  48549. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  48550. autoUpdateBonesMatrices: boolean;
  48551. /** defines the rendering group id to use with the viewer */
  48552. renderingGroupId: number;
  48553. /** Gets or sets the color used to render the skeleton */
  48554. color: Color3;
  48555. private _scene;
  48556. private _debugLines;
  48557. private _debugMesh;
  48558. private _isEnabled;
  48559. private _renderFunction;
  48560. private _utilityLayer;
  48561. /**
  48562. * Returns the mesh used to render the bones
  48563. */
  48564. get debugMesh(): Nullable<LinesMesh>;
  48565. /**
  48566. * Creates a new SkeletonViewer
  48567. * @param skeleton defines the skeleton to render
  48568. * @param mesh defines the mesh attached to the skeleton
  48569. * @param scene defines the hosting scene
  48570. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  48571. * @param renderingGroupId defines the rendering group id to use with the viewer
  48572. */
  48573. constructor(
  48574. /** defines the skeleton to render */
  48575. skeleton: Skeleton,
  48576. /** defines the mesh attached to the skeleton */
  48577. mesh: AbstractMesh, scene: Scene,
  48578. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  48579. autoUpdateBonesMatrices?: boolean,
  48580. /** defines the rendering group id to use with the viewer */
  48581. renderingGroupId?: number);
  48582. /** Gets or sets a boolean indicating if the viewer is enabled */
  48583. set isEnabled(value: boolean);
  48584. get isEnabled(): boolean;
  48585. private _getBonePosition;
  48586. private _getLinesForBonesWithLength;
  48587. private _getLinesForBonesNoLength;
  48588. /** Update the viewer to sync with current skeleton state */
  48589. update(): void;
  48590. /** Release associated resources */
  48591. dispose(): void;
  48592. }
  48593. }
  48594. declare module "babylonjs/Debug/index" {
  48595. export * from "babylonjs/Debug/axesViewer";
  48596. export * from "babylonjs/Debug/boneAxesViewer";
  48597. export * from "babylonjs/Debug/debugLayer";
  48598. export * from "babylonjs/Debug/physicsViewer";
  48599. export * from "babylonjs/Debug/rayHelper";
  48600. export * from "babylonjs/Debug/skeletonViewer";
  48601. }
  48602. declare module "babylonjs/Engines/nullEngine" {
  48603. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  48604. import { Engine } from "babylonjs/Engines/engine";
  48605. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  48606. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  48607. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48608. import { Effect } from "babylonjs/Materials/effect";
  48609. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  48610. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  48611. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  48612. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  48613. /**
  48614. * Options to create the null engine
  48615. */
  48616. export class NullEngineOptions {
  48617. /**
  48618. * Render width (Default: 512)
  48619. */
  48620. renderWidth: number;
  48621. /**
  48622. * Render height (Default: 256)
  48623. */
  48624. renderHeight: number;
  48625. /**
  48626. * Texture size (Default: 512)
  48627. */
  48628. textureSize: number;
  48629. /**
  48630. * If delta time between frames should be constant
  48631. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  48632. */
  48633. deterministicLockstep: boolean;
  48634. /**
  48635. * Maximum about of steps between frames (Default: 4)
  48636. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  48637. */
  48638. lockstepMaxSteps: number;
  48639. }
  48640. /**
  48641. * The null engine class provides support for headless version of babylon.js.
  48642. * This can be used in server side scenario or for testing purposes
  48643. */
  48644. export class NullEngine extends Engine {
  48645. private _options;
  48646. /**
  48647. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  48648. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  48649. * @returns true if engine is in deterministic lock step mode
  48650. */
  48651. isDeterministicLockStep(): boolean;
  48652. /**
  48653. * Gets the max steps when engine is running in deterministic lock step
  48654. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  48655. * @returns the max steps
  48656. */
  48657. getLockstepMaxSteps(): number;
  48658. /**
  48659. * Gets the current hardware scaling level.
  48660. * By default the hardware scaling level is computed from the window device ratio.
  48661. * 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.
  48662. * @returns a number indicating the current hardware scaling level
  48663. */
  48664. getHardwareScalingLevel(): number;
  48665. constructor(options?: NullEngineOptions);
  48666. /**
  48667. * Creates a vertex buffer
  48668. * @param vertices the data for the vertex buffer
  48669. * @returns the new WebGL static buffer
  48670. */
  48671. createVertexBuffer(vertices: FloatArray): DataBuffer;
  48672. /**
  48673. * Creates a new index buffer
  48674. * @param indices defines the content of the index buffer
  48675. * @param updatable defines if the index buffer must be updatable
  48676. * @returns a new webGL buffer
  48677. */
  48678. createIndexBuffer(indices: IndicesArray): DataBuffer;
  48679. /**
  48680. * Clear the current render buffer or the current render target (if any is set up)
  48681. * @param color defines the color to use
  48682. * @param backBuffer defines if the back buffer must be cleared
  48683. * @param depth defines if the depth buffer must be cleared
  48684. * @param stencil defines if the stencil buffer must be cleared
  48685. */
  48686. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  48687. /**
  48688. * Gets the current render width
  48689. * @param useScreen defines if screen size must be used (or the current render target if any)
  48690. * @returns a number defining the current render width
  48691. */
  48692. getRenderWidth(useScreen?: boolean): number;
  48693. /**
  48694. * Gets the current render height
  48695. * @param useScreen defines if screen size must be used (or the current render target if any)
  48696. * @returns a number defining the current render height
  48697. */
  48698. getRenderHeight(useScreen?: boolean): number;
  48699. /**
  48700. * Set the WebGL's viewport
  48701. * @param viewport defines the viewport element to be used
  48702. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  48703. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  48704. */
  48705. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  48706. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  48707. /**
  48708. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  48709. * @param pipelineContext defines the pipeline context to use
  48710. * @param uniformsNames defines the list of uniform names
  48711. * @returns an array of webGL uniform locations
  48712. */
  48713. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  48714. /**
  48715. * Gets the lsit of active attributes for a given webGL program
  48716. * @param pipelineContext defines the pipeline context to use
  48717. * @param attributesNames defines the list of attribute names to get
  48718. * @returns an array of indices indicating the offset of each attribute
  48719. */
  48720. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  48721. /**
  48722. * Binds an effect to the webGL context
  48723. * @param effect defines the effect to bind
  48724. */
  48725. bindSamplers(effect: Effect): void;
  48726. /**
  48727. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  48728. * @param effect defines the effect to activate
  48729. */
  48730. enableEffect(effect: Effect): void;
  48731. /**
  48732. * Set various states to the webGL context
  48733. * @param culling defines backface culling state
  48734. * @param zOffset defines the value to apply to zOffset (0 by default)
  48735. * @param force defines if states must be applied even if cache is up to date
  48736. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  48737. */
  48738. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  48739. /**
  48740. * Set the value of an uniform to an array of int32
  48741. * @param uniform defines the webGL uniform location where to store the value
  48742. * @param array defines the array of int32 to store
  48743. */
  48744. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  48745. /**
  48746. * Set the value of an uniform to an array of int32 (stored as vec2)
  48747. * @param uniform defines the webGL uniform location where to store the value
  48748. * @param array defines the array of int32 to store
  48749. */
  48750. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  48751. /**
  48752. * Set the value of an uniform to an array of int32 (stored as vec3)
  48753. * @param uniform defines the webGL uniform location where to store the value
  48754. * @param array defines the array of int32 to store
  48755. */
  48756. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  48757. /**
  48758. * Set the value of an uniform to an array of int32 (stored as vec4)
  48759. * @param uniform defines the webGL uniform location where to store the value
  48760. * @param array defines the array of int32 to store
  48761. */
  48762. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  48763. /**
  48764. * Set the value of an uniform to an array of float32
  48765. * @param uniform defines the webGL uniform location where to store the value
  48766. * @param array defines the array of float32 to store
  48767. */
  48768. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  48769. /**
  48770. * Set the value of an uniform to an array of float32 (stored as vec2)
  48771. * @param uniform defines the webGL uniform location where to store the value
  48772. * @param array defines the array of float32 to store
  48773. */
  48774. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  48775. /**
  48776. * Set the value of an uniform to an array of float32 (stored as vec3)
  48777. * @param uniform defines the webGL uniform location where to store the value
  48778. * @param array defines the array of float32 to store
  48779. */
  48780. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  48781. /**
  48782. * Set the value of an uniform to an array of float32 (stored as vec4)
  48783. * @param uniform defines the webGL uniform location where to store the value
  48784. * @param array defines the array of float32 to store
  48785. */
  48786. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  48787. /**
  48788. * Set the value of an uniform to an array of number
  48789. * @param uniform defines the webGL uniform location where to store the value
  48790. * @param array defines the array of number to store
  48791. */
  48792. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  48793. /**
  48794. * Set the value of an uniform to an array of number (stored as vec2)
  48795. * @param uniform defines the webGL uniform location where to store the value
  48796. * @param array defines the array of number to store
  48797. */
  48798. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  48799. /**
  48800. * Set the value of an uniform to an array of number (stored as vec3)
  48801. * @param uniform defines the webGL uniform location where to store the value
  48802. * @param array defines the array of number to store
  48803. */
  48804. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  48805. /**
  48806. * Set the value of an uniform to an array of number (stored as vec4)
  48807. * @param uniform defines the webGL uniform location where to store the value
  48808. * @param array defines the array of number to store
  48809. */
  48810. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  48811. /**
  48812. * Set the value of an uniform to an array of float32 (stored as matrices)
  48813. * @param uniform defines the webGL uniform location where to store the value
  48814. * @param matrices defines the array of float32 to store
  48815. */
  48816. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  48817. /**
  48818. * Set the value of an uniform to a matrix (3x3)
  48819. * @param uniform defines the webGL uniform location where to store the value
  48820. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  48821. */
  48822. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  48823. /**
  48824. * Set the value of an uniform to a matrix (2x2)
  48825. * @param uniform defines the webGL uniform location where to store the value
  48826. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  48827. */
  48828. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  48829. /**
  48830. * Set the value of an uniform to a number (float)
  48831. * @param uniform defines the webGL uniform location where to store the value
  48832. * @param value defines the float number to store
  48833. */
  48834. setFloat(uniform: WebGLUniformLocation, value: number): void;
  48835. /**
  48836. * Set the value of an uniform to a vec2
  48837. * @param uniform defines the webGL uniform location where to store the value
  48838. * @param x defines the 1st component of the value
  48839. * @param y defines the 2nd component of the value
  48840. */
  48841. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  48842. /**
  48843. * Set the value of an uniform to a vec3
  48844. * @param uniform defines the webGL uniform location where to store the value
  48845. * @param x defines the 1st component of the value
  48846. * @param y defines the 2nd component of the value
  48847. * @param z defines the 3rd component of the value
  48848. */
  48849. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  48850. /**
  48851. * Set the value of an uniform to a boolean
  48852. * @param uniform defines the webGL uniform location where to store the value
  48853. * @param bool defines the boolean to store
  48854. */
  48855. setBool(uniform: WebGLUniformLocation, bool: number): void;
  48856. /**
  48857. * Set the value of an uniform to a vec4
  48858. * @param uniform defines the webGL uniform location where to store the value
  48859. * @param x defines the 1st component of the value
  48860. * @param y defines the 2nd component of the value
  48861. * @param z defines the 3rd component of the value
  48862. * @param w defines the 4th component of the value
  48863. */
  48864. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  48865. /**
  48866. * Sets the current alpha mode
  48867. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  48868. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  48869. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  48870. */
  48871. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  48872. /**
  48873. * Bind webGl buffers directly to the webGL context
  48874. * @param vertexBuffers defines the vertex buffer to bind
  48875. * @param indexBuffer defines the index buffer to bind
  48876. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  48877. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  48878. * @param effect defines the effect associated with the vertex buffer
  48879. */
  48880. bindBuffers(vertexBuffers: {
  48881. [key: string]: VertexBuffer;
  48882. }, indexBuffer: DataBuffer, effect: Effect): void;
  48883. /**
  48884. * Force the entire cache to be cleared
  48885. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  48886. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  48887. */
  48888. wipeCaches(bruteForce?: boolean): void;
  48889. /**
  48890. * Send a draw order
  48891. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  48892. * @param indexStart defines the starting index
  48893. * @param indexCount defines the number of index to draw
  48894. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  48895. */
  48896. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  48897. /**
  48898. * Draw a list of indexed primitives
  48899. * @param fillMode defines the primitive to use
  48900. * @param indexStart defines the starting index
  48901. * @param indexCount defines the number of index to draw
  48902. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  48903. */
  48904. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  48905. /**
  48906. * Draw a list of unindexed primitives
  48907. * @param fillMode defines the primitive to use
  48908. * @param verticesStart defines the index of first vertex to draw
  48909. * @param verticesCount defines the count of vertices to draw
  48910. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  48911. */
  48912. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  48913. /** @hidden */
  48914. _createTexture(): WebGLTexture;
  48915. /** @hidden */
  48916. _releaseTexture(texture: InternalTexture): void;
  48917. /**
  48918. * Usually called from Texture.ts.
  48919. * Passed information to create a WebGLTexture
  48920. * @param urlArg defines a value which contains one of the following:
  48921. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  48922. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  48923. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  48924. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  48925. * @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)
  48926. * @param scene needed for loading to the correct scene
  48927. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  48928. * @param onLoad optional callback to be called upon successful completion
  48929. * @param onError optional callback to be called upon failure
  48930. * @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
  48931. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  48932. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  48933. * @param forcedExtension defines the extension to use to pick the right loader
  48934. * @param mimeType defines an optional mime type
  48935. * @returns a InternalTexture for assignment back into BABYLON.Texture
  48936. */
  48937. 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;
  48938. /**
  48939. * Creates a new render target texture
  48940. * @param size defines the size of the texture
  48941. * @param options defines the options used to create the texture
  48942. * @returns a new render target texture stored in an InternalTexture
  48943. */
  48944. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  48945. /**
  48946. * Update the sampling mode of a given texture
  48947. * @param samplingMode defines the required sampling mode
  48948. * @param texture defines the texture to update
  48949. */
  48950. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  48951. /**
  48952. * Binds the frame buffer to the specified texture.
  48953. * @param texture The texture to render to or null for the default canvas
  48954. * @param faceIndex The face of the texture to render to in case of cube texture
  48955. * @param requiredWidth The width of the target to render to
  48956. * @param requiredHeight The height of the target to render to
  48957. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  48958. * @param lodLevel defines le lod level to bind to the frame buffer
  48959. */
  48960. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  48961. /**
  48962. * Unbind the current render target texture from the webGL context
  48963. * @param texture defines the render target texture to unbind
  48964. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  48965. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  48966. */
  48967. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  48968. /**
  48969. * Creates a dynamic vertex buffer
  48970. * @param vertices the data for the dynamic vertex buffer
  48971. * @returns the new WebGL dynamic buffer
  48972. */
  48973. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  48974. /**
  48975. * Update the content of a dynamic texture
  48976. * @param texture defines the texture to update
  48977. * @param canvas defines the canvas containing the source
  48978. * @param invertY defines if data must be stored with Y axis inverted
  48979. * @param premulAlpha defines if alpha is stored as premultiplied
  48980. * @param format defines the format of the data
  48981. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  48982. */
  48983. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  48984. /**
  48985. * Gets a boolean indicating if all created effects are ready
  48986. * @returns true if all effects are ready
  48987. */
  48988. areAllEffectsReady(): boolean;
  48989. /**
  48990. * @hidden
  48991. * Get the current error code of the webGL context
  48992. * @returns the error code
  48993. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  48994. */
  48995. getError(): number;
  48996. /** @hidden */
  48997. _getUnpackAlignement(): number;
  48998. /** @hidden */
  48999. _unpackFlipY(value: boolean): void;
  49000. /**
  49001. * Update a dynamic index buffer
  49002. * @param indexBuffer defines the target index buffer
  49003. * @param indices defines the data to update
  49004. * @param offset defines the offset in the target index buffer where update should start
  49005. */
  49006. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  49007. /**
  49008. * Updates a dynamic vertex buffer.
  49009. * @param vertexBuffer the vertex buffer to update
  49010. * @param vertices the data used to update the vertex buffer
  49011. * @param byteOffset the byte offset of the data (optional)
  49012. * @param byteLength the byte length of the data (optional)
  49013. */
  49014. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  49015. /** @hidden */
  49016. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  49017. /** @hidden */
  49018. _bindTexture(channel: number, texture: InternalTexture): void;
  49019. protected _deleteBuffer(buffer: WebGLBuffer): void;
  49020. /**
  49021. * 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
  49022. */
  49023. releaseEffects(): void;
  49024. displayLoadingUI(): void;
  49025. hideLoadingUI(): void;
  49026. /** @hidden */
  49027. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  49028. /** @hidden */
  49029. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  49030. /** @hidden */
  49031. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  49032. /** @hidden */
  49033. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  49034. }
  49035. }
  49036. declare module "babylonjs/Instrumentation/timeToken" {
  49037. import { Nullable } from "babylonjs/types";
  49038. /**
  49039. * @hidden
  49040. **/
  49041. export class _TimeToken {
  49042. _startTimeQuery: Nullable<WebGLQuery>;
  49043. _endTimeQuery: Nullable<WebGLQuery>;
  49044. _timeElapsedQuery: Nullable<WebGLQuery>;
  49045. _timeElapsedQueryEnded: boolean;
  49046. }
  49047. }
  49048. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  49049. import { Nullable, int } from "babylonjs/types";
  49050. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  49051. /** @hidden */
  49052. export class _OcclusionDataStorage {
  49053. /** @hidden */
  49054. occlusionInternalRetryCounter: number;
  49055. /** @hidden */
  49056. isOcclusionQueryInProgress: boolean;
  49057. /** @hidden */
  49058. isOccluded: boolean;
  49059. /** @hidden */
  49060. occlusionRetryCount: number;
  49061. /** @hidden */
  49062. occlusionType: number;
  49063. /** @hidden */
  49064. occlusionQueryAlgorithmType: number;
  49065. }
  49066. module "babylonjs/Engines/engine" {
  49067. interface Engine {
  49068. /**
  49069. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  49070. * @return the new query
  49071. */
  49072. createQuery(): WebGLQuery;
  49073. /**
  49074. * Delete and release a webGL query
  49075. * @param query defines the query to delete
  49076. * @return the current engine
  49077. */
  49078. deleteQuery(query: WebGLQuery): Engine;
  49079. /**
  49080. * Check if a given query has resolved and got its value
  49081. * @param query defines the query to check
  49082. * @returns true if the query got its value
  49083. */
  49084. isQueryResultAvailable(query: WebGLQuery): boolean;
  49085. /**
  49086. * Gets the value of a given query
  49087. * @param query defines the query to check
  49088. * @returns the value of the query
  49089. */
  49090. getQueryResult(query: WebGLQuery): number;
  49091. /**
  49092. * Initiates an occlusion query
  49093. * @param algorithmType defines the algorithm to use
  49094. * @param query defines the query to use
  49095. * @returns the current engine
  49096. * @see http://doc.babylonjs.com/features/occlusionquery
  49097. */
  49098. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  49099. /**
  49100. * Ends an occlusion query
  49101. * @see http://doc.babylonjs.com/features/occlusionquery
  49102. * @param algorithmType defines the algorithm to use
  49103. * @returns the current engine
  49104. */
  49105. endOcclusionQuery(algorithmType: number): Engine;
  49106. /**
  49107. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  49108. * Please note that only one query can be issued at a time
  49109. * @returns a time token used to track the time span
  49110. */
  49111. startTimeQuery(): Nullable<_TimeToken>;
  49112. /**
  49113. * Ends a time query
  49114. * @param token defines the token used to measure the time span
  49115. * @returns the time spent (in ns)
  49116. */
  49117. endTimeQuery(token: _TimeToken): int;
  49118. /** @hidden */
  49119. _currentNonTimestampToken: Nullable<_TimeToken>;
  49120. /** @hidden */
  49121. _createTimeQuery(): WebGLQuery;
  49122. /** @hidden */
  49123. _deleteTimeQuery(query: WebGLQuery): void;
  49124. /** @hidden */
  49125. _getGlAlgorithmType(algorithmType: number): number;
  49126. /** @hidden */
  49127. _getTimeQueryResult(query: WebGLQuery): any;
  49128. /** @hidden */
  49129. _getTimeQueryAvailability(query: WebGLQuery): any;
  49130. }
  49131. }
  49132. module "babylonjs/Meshes/abstractMesh" {
  49133. interface AbstractMesh {
  49134. /**
  49135. * Backing filed
  49136. * @hidden
  49137. */
  49138. __occlusionDataStorage: _OcclusionDataStorage;
  49139. /**
  49140. * Access property
  49141. * @hidden
  49142. */
  49143. _occlusionDataStorage: _OcclusionDataStorage;
  49144. /**
  49145. * 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.
  49146. * The default value is -1 which means don't break the query and wait till the result
  49147. * @see http://doc.babylonjs.com/features/occlusionquery
  49148. */
  49149. occlusionRetryCount: number;
  49150. /**
  49151. * 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:
  49152. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  49153. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  49154. * * 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.
  49155. * @see http://doc.babylonjs.com/features/occlusionquery
  49156. */
  49157. occlusionType: number;
  49158. /**
  49159. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  49160. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  49161. * * 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.
  49162. * @see http://doc.babylonjs.com/features/occlusionquery
  49163. */
  49164. occlusionQueryAlgorithmType: number;
  49165. /**
  49166. * 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
  49167. * @see http://doc.babylonjs.com/features/occlusionquery
  49168. */
  49169. isOccluded: boolean;
  49170. /**
  49171. * Flag to check the progress status of the query
  49172. * @see http://doc.babylonjs.com/features/occlusionquery
  49173. */
  49174. isOcclusionQueryInProgress: boolean;
  49175. }
  49176. }
  49177. }
  49178. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  49179. import { Nullable } from "babylonjs/types";
  49180. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  49181. /** @hidden */
  49182. export var _forceTransformFeedbackToBundle: boolean;
  49183. module "babylonjs/Engines/engine" {
  49184. interface Engine {
  49185. /**
  49186. * Creates a webGL transform feedback object
  49187. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  49188. * @returns the webGL transform feedback object
  49189. */
  49190. createTransformFeedback(): WebGLTransformFeedback;
  49191. /**
  49192. * Delete a webGL transform feedback object
  49193. * @param value defines the webGL transform feedback object to delete
  49194. */
  49195. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  49196. /**
  49197. * Bind a webGL transform feedback object to the webgl context
  49198. * @param value defines the webGL transform feedback object to bind
  49199. */
  49200. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  49201. /**
  49202. * Begins a transform feedback operation
  49203. * @param usePoints defines if points or triangles must be used
  49204. */
  49205. beginTransformFeedback(usePoints: boolean): void;
  49206. /**
  49207. * Ends a transform feedback operation
  49208. */
  49209. endTransformFeedback(): void;
  49210. /**
  49211. * Specify the varyings to use with transform feedback
  49212. * @param program defines the associated webGL program
  49213. * @param value defines the list of strings representing the varying names
  49214. */
  49215. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  49216. /**
  49217. * Bind a webGL buffer for a transform feedback operation
  49218. * @param value defines the webGL buffer to bind
  49219. */
  49220. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  49221. }
  49222. }
  49223. }
  49224. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  49225. import { Scene } from "babylonjs/scene";
  49226. import { Engine } from "babylonjs/Engines/engine";
  49227. import { Texture } from "babylonjs/Materials/Textures/texture";
  49228. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  49229. import "babylonjs/Engines/Extensions/engine.multiRender";
  49230. /**
  49231. * Creation options of the multi render target texture.
  49232. */
  49233. export interface IMultiRenderTargetOptions {
  49234. /**
  49235. * Define if the texture needs to create mip maps after render.
  49236. */
  49237. generateMipMaps?: boolean;
  49238. /**
  49239. * Define the types of all the draw buffers we want to create
  49240. */
  49241. types?: number[];
  49242. /**
  49243. * Define the sampling modes of all the draw buffers we want to create
  49244. */
  49245. samplingModes?: number[];
  49246. /**
  49247. * Define if a depth buffer is required
  49248. */
  49249. generateDepthBuffer?: boolean;
  49250. /**
  49251. * Define if a stencil buffer is required
  49252. */
  49253. generateStencilBuffer?: boolean;
  49254. /**
  49255. * Define if a depth texture is required instead of a depth buffer
  49256. */
  49257. generateDepthTexture?: boolean;
  49258. /**
  49259. * Define the number of desired draw buffers
  49260. */
  49261. textureCount?: number;
  49262. /**
  49263. * Define if aspect ratio should be adapted to the texture or stay the scene one
  49264. */
  49265. doNotChangeAspectRatio?: boolean;
  49266. /**
  49267. * Define the default type of the buffers we are creating
  49268. */
  49269. defaultType?: number;
  49270. }
  49271. /**
  49272. * A multi render target, like a render target provides the ability to render to a texture.
  49273. * Unlike the render target, it can render to several draw buffers in one draw.
  49274. * This is specially interesting in deferred rendering or for any effects requiring more than
  49275. * just one color from a single pass.
  49276. */
  49277. export class MultiRenderTarget extends RenderTargetTexture {
  49278. private _internalTextures;
  49279. private _textures;
  49280. private _multiRenderTargetOptions;
  49281. /**
  49282. * Get if draw buffers are currently supported by the used hardware and browser.
  49283. */
  49284. get isSupported(): boolean;
  49285. /**
  49286. * Get the list of textures generated by the multi render target.
  49287. */
  49288. get textures(): Texture[];
  49289. /**
  49290. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  49291. */
  49292. get depthTexture(): Texture;
  49293. /**
  49294. * Set the wrapping mode on U of all the textures we are rendering to.
  49295. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  49296. */
  49297. set wrapU(wrap: number);
  49298. /**
  49299. * Set the wrapping mode on V of all the textures we are rendering to.
  49300. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  49301. */
  49302. set wrapV(wrap: number);
  49303. /**
  49304. * Instantiate a new multi render target texture.
  49305. * A multi render target, like a render target provides the ability to render to a texture.
  49306. * Unlike the render target, it can render to several draw buffers in one draw.
  49307. * This is specially interesting in deferred rendering or for any effects requiring more than
  49308. * just one color from a single pass.
  49309. * @param name Define the name of the texture
  49310. * @param size Define the size of the buffers to render to
  49311. * @param count Define the number of target we are rendering into
  49312. * @param scene Define the scene the texture belongs to
  49313. * @param options Define the options used to create the multi render target
  49314. */
  49315. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  49316. /** @hidden */
  49317. _rebuild(): void;
  49318. private _createInternalTextures;
  49319. private _createTextures;
  49320. /**
  49321. * Define the number of samples used if MSAA is enabled.
  49322. */
  49323. get samples(): number;
  49324. set samples(value: number);
  49325. /**
  49326. * Resize all the textures in the multi render target.
  49327. * Be carrefull as it will recreate all the data in the new texture.
  49328. * @param size Define the new size
  49329. */
  49330. resize(size: any): void;
  49331. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  49332. /**
  49333. * Dispose the render targets and their associated resources
  49334. */
  49335. dispose(): void;
  49336. /**
  49337. * Release all the underlying texture used as draw buffers.
  49338. */
  49339. releaseInternalTextures(): void;
  49340. }
  49341. }
  49342. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  49343. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49344. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  49345. import { Nullable } from "babylonjs/types";
  49346. module "babylonjs/Engines/thinEngine" {
  49347. interface ThinEngine {
  49348. /**
  49349. * Unbind a list of render target textures from the webGL context
  49350. * This is used only when drawBuffer extension or webGL2 are active
  49351. * @param textures defines the render target textures to unbind
  49352. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  49353. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  49354. */
  49355. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  49356. /**
  49357. * Create a multi render target texture
  49358. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  49359. * @param size defines the size of the texture
  49360. * @param options defines the creation options
  49361. * @returns the cube texture as an InternalTexture
  49362. */
  49363. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  49364. /**
  49365. * Update the sample count for a given multiple render target texture
  49366. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  49367. * @param textures defines the textures to update
  49368. * @param samples defines the sample count to set
  49369. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  49370. */
  49371. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  49372. }
  49373. }
  49374. }
  49375. declare module "babylonjs/Engines/Extensions/engine.views" {
  49376. import { Camera } from "babylonjs/Cameras/camera";
  49377. import { Nullable } from "babylonjs/types";
  49378. /**
  49379. * Class used to define an additional view for the engine
  49380. * @see https://doc.babylonjs.com/how_to/multi_canvases
  49381. */
  49382. export class EngineView {
  49383. /** Defines the canvas where to render the view */
  49384. target: HTMLCanvasElement;
  49385. /** Defines an optional camera used to render the view (will use active camera else) */
  49386. camera?: Camera;
  49387. }
  49388. module "babylonjs/Engines/engine" {
  49389. interface Engine {
  49390. /**
  49391. * Gets or sets the HTML element to use for attaching events
  49392. */
  49393. inputElement: Nullable<HTMLElement>;
  49394. /**
  49395. * Gets the current engine view
  49396. * @see https://doc.babylonjs.com/how_to/multi_canvases
  49397. */
  49398. activeView: Nullable<EngineView>;
  49399. /** Gets or sets the list of views */
  49400. views: EngineView[];
  49401. /**
  49402. * Register a new child canvas
  49403. * @param canvas defines the canvas to register
  49404. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  49405. * @returns the associated view
  49406. */
  49407. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  49408. /**
  49409. * Remove a registered child canvas
  49410. * @param canvas defines the canvas to remove
  49411. * @returns the current engine
  49412. */
  49413. unRegisterView(canvas: HTMLCanvasElement): Engine;
  49414. }
  49415. }
  49416. }
  49417. declare module "babylonjs/Engines/Extensions/engine.textureSelector" {
  49418. import { Nullable } from "babylonjs/types";
  49419. module "babylonjs/Engines/engine" {
  49420. interface Engine {
  49421. /** @hidden */
  49422. _excludedCompressedTextures: string[];
  49423. /** @hidden */
  49424. _textureFormatInUse: string;
  49425. /**
  49426. * Gets the list of texture formats supported
  49427. */
  49428. readonly texturesSupported: Array<string>;
  49429. /**
  49430. * Gets the texture format in use
  49431. */
  49432. readonly textureFormatInUse: Nullable<string>;
  49433. /**
  49434. * Set the compressed texture extensions or file names to skip.
  49435. *
  49436. * @param skippedFiles defines the list of those texture files you want to skip
  49437. * Example: [".dds", ".env", "myfile.png"]
  49438. */
  49439. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  49440. /**
  49441. * Set the compressed texture format to use, based on the formats you have, and the formats
  49442. * supported by the hardware / browser.
  49443. *
  49444. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  49445. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  49446. * to API arguments needed to compressed textures. This puts the burden on the container
  49447. * generator to house the arcane code for determining these for current & future formats.
  49448. *
  49449. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  49450. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  49451. *
  49452. * Note: The result of this call is not taken into account when a texture is base64.
  49453. *
  49454. * @param formatsAvailable defines the list of those format families you have created
  49455. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  49456. *
  49457. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  49458. * @returns The extension selected.
  49459. */
  49460. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  49461. }
  49462. }
  49463. }
  49464. declare module "babylonjs/Engines/Extensions/index" {
  49465. export * from "babylonjs/Engines/Extensions/engine.alpha";
  49466. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  49467. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  49468. export * from "babylonjs/Engines/Extensions/engine.multiview";
  49469. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  49470. export * from "babylonjs/Engines/Extensions/engine.dynamicTexture";
  49471. export * from "babylonjs/Engines/Extensions/engine.videoTexture";
  49472. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  49473. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  49474. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  49475. export * from "babylonjs/Engines/Extensions/engine.renderTargetCube";
  49476. export * from "babylonjs/Engines/Extensions/engine.webVR";
  49477. export * from "babylonjs/Engines/Extensions/engine.uniformBuffer";
  49478. export * from "babylonjs/Engines/Extensions/engine.views";
  49479. import "babylonjs/Engines/Extensions/engine.textureSelector";
  49480. export * from "babylonjs/Engines/Extensions/engine.textureSelector";
  49481. }
  49482. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  49483. import { Nullable } from "babylonjs/types";
  49484. /**
  49485. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  49486. */
  49487. export interface CubeMapInfo {
  49488. /**
  49489. * The pixel array for the front face.
  49490. * This is stored in format, left to right, up to down format.
  49491. */
  49492. front: Nullable<ArrayBufferView>;
  49493. /**
  49494. * The pixel array for the back face.
  49495. * This is stored in format, left to right, up to down format.
  49496. */
  49497. back: Nullable<ArrayBufferView>;
  49498. /**
  49499. * The pixel array for the left face.
  49500. * This is stored in format, left to right, up to down format.
  49501. */
  49502. left: Nullable<ArrayBufferView>;
  49503. /**
  49504. * The pixel array for the right face.
  49505. * This is stored in format, left to right, up to down format.
  49506. */
  49507. right: Nullable<ArrayBufferView>;
  49508. /**
  49509. * The pixel array for the up face.
  49510. * This is stored in format, left to right, up to down format.
  49511. */
  49512. up: Nullable<ArrayBufferView>;
  49513. /**
  49514. * The pixel array for the down face.
  49515. * This is stored in format, left to right, up to down format.
  49516. */
  49517. down: Nullable<ArrayBufferView>;
  49518. /**
  49519. * The size of the cubemap stored.
  49520. *
  49521. * Each faces will be size * size pixels.
  49522. */
  49523. size: number;
  49524. /**
  49525. * The format of the texture.
  49526. *
  49527. * RGBA, RGB.
  49528. */
  49529. format: number;
  49530. /**
  49531. * The type of the texture data.
  49532. *
  49533. * UNSIGNED_INT, FLOAT.
  49534. */
  49535. type: number;
  49536. /**
  49537. * Specifies whether the texture is in gamma space.
  49538. */
  49539. gammaSpace: boolean;
  49540. }
  49541. /**
  49542. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  49543. */
  49544. export class PanoramaToCubeMapTools {
  49545. private static FACE_FRONT;
  49546. private static FACE_BACK;
  49547. private static FACE_RIGHT;
  49548. private static FACE_LEFT;
  49549. private static FACE_DOWN;
  49550. private static FACE_UP;
  49551. /**
  49552. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  49553. *
  49554. * @param float32Array The source data.
  49555. * @param inputWidth The width of the input panorama.
  49556. * @param inputHeight The height of the input panorama.
  49557. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  49558. * @return The cubemap data
  49559. */
  49560. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  49561. private static CreateCubemapTexture;
  49562. private static CalcProjectionSpherical;
  49563. }
  49564. }
  49565. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  49566. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  49567. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49568. import { Nullable } from "babylonjs/types";
  49569. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  49570. /**
  49571. * Helper class dealing with the extraction of spherical polynomial dataArray
  49572. * from a cube map.
  49573. */
  49574. export class CubeMapToSphericalPolynomialTools {
  49575. private static FileFaces;
  49576. /**
  49577. * Converts a texture to the according Spherical Polynomial data.
  49578. * This extracts the first 3 orders only as they are the only one used in the lighting.
  49579. *
  49580. * @param texture The texture to extract the information from.
  49581. * @return The Spherical Polynomial data.
  49582. */
  49583. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  49584. /**
  49585. * Converts a cubemap to the according Spherical Polynomial data.
  49586. * This extracts the first 3 orders only as they are the only one used in the lighting.
  49587. *
  49588. * @param cubeInfo The Cube map to extract the information from.
  49589. * @return The Spherical Polynomial data.
  49590. */
  49591. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  49592. }
  49593. }
  49594. declare module "babylonjs/Materials/Textures/baseTexture.polynomial" {
  49595. import { Nullable } from "babylonjs/types";
  49596. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  49597. module "babylonjs/Materials/Textures/baseTexture" {
  49598. interface BaseTexture {
  49599. /**
  49600. * Get the polynomial representation of the texture data.
  49601. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  49602. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  49603. */
  49604. sphericalPolynomial: Nullable<SphericalPolynomial>;
  49605. }
  49606. }
  49607. }
  49608. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  49609. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  49610. /** @hidden */
  49611. export var rgbdEncodePixelShader: {
  49612. name: string;
  49613. shader: string;
  49614. };
  49615. }
  49616. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  49617. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  49618. /** @hidden */
  49619. export var rgbdDecodePixelShader: {
  49620. name: string;
  49621. shader: string;
  49622. };
  49623. }
  49624. declare module "babylonjs/Misc/environmentTextureTools" {
  49625. import { Nullable } from "babylonjs/types";
  49626. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  49627. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49628. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  49629. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  49630. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  49631. import "babylonjs/Shaders/rgbdEncode.fragment";
  49632. import "babylonjs/Shaders/rgbdDecode.fragment";
  49633. /**
  49634. * Raw texture data and descriptor sufficient for WebGL texture upload
  49635. */
  49636. export interface EnvironmentTextureInfo {
  49637. /**
  49638. * Version of the environment map
  49639. */
  49640. version: number;
  49641. /**
  49642. * Width of image
  49643. */
  49644. width: number;
  49645. /**
  49646. * Irradiance information stored in the file.
  49647. */
  49648. irradiance: any;
  49649. /**
  49650. * Specular information stored in the file.
  49651. */
  49652. specular: any;
  49653. }
  49654. /**
  49655. * Defines One Image in the file. It requires only the position in the file
  49656. * as well as the length.
  49657. */
  49658. interface BufferImageData {
  49659. /**
  49660. * Length of the image data.
  49661. */
  49662. length: number;
  49663. /**
  49664. * Position of the data from the null terminator delimiting the end of the JSON.
  49665. */
  49666. position: number;
  49667. }
  49668. /**
  49669. * Defines the specular data enclosed in the file.
  49670. * This corresponds to the version 1 of the data.
  49671. */
  49672. export interface EnvironmentTextureSpecularInfoV1 {
  49673. /**
  49674. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  49675. */
  49676. specularDataPosition?: number;
  49677. /**
  49678. * This contains all the images data needed to reconstruct the cubemap.
  49679. */
  49680. mipmaps: Array<BufferImageData>;
  49681. /**
  49682. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  49683. */
  49684. lodGenerationScale: number;
  49685. }
  49686. /**
  49687. * Sets of helpers addressing the serialization and deserialization of environment texture
  49688. * stored in a BabylonJS env file.
  49689. * Those files are usually stored as .env files.
  49690. */
  49691. export class EnvironmentTextureTools {
  49692. /**
  49693. * Magic number identifying the env file.
  49694. */
  49695. private static _MagicBytes;
  49696. /**
  49697. * Gets the environment info from an env file.
  49698. * @param data The array buffer containing the .env bytes.
  49699. * @returns the environment file info (the json header) if successfully parsed.
  49700. */
  49701. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  49702. /**
  49703. * Creates an environment texture from a loaded cube texture.
  49704. * @param texture defines the cube texture to convert in env file
  49705. * @return a promise containing the environment data if succesfull.
  49706. */
  49707. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  49708. /**
  49709. * Creates a JSON representation of the spherical data.
  49710. * @param texture defines the texture containing the polynomials
  49711. * @return the JSON representation of the spherical info
  49712. */
  49713. private static _CreateEnvTextureIrradiance;
  49714. /**
  49715. * Creates the ArrayBufferViews used for initializing environment texture image data.
  49716. * @param data the image data
  49717. * @param info parameters that determine what views will be created for accessing the underlying buffer
  49718. * @return the views described by info providing access to the underlying buffer
  49719. */
  49720. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  49721. /**
  49722. * Uploads the texture info contained in the env file to the GPU.
  49723. * @param texture defines the internal texture to upload to
  49724. * @param data defines the data to load
  49725. * @param info defines the texture info retrieved through the GetEnvInfo method
  49726. * @returns a promise
  49727. */
  49728. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  49729. private static _OnImageReadyAsync;
  49730. /**
  49731. * Uploads the levels of image data to the GPU.
  49732. * @param texture defines the internal texture to upload to
  49733. * @param imageData defines the array buffer views of image data [mipmap][face]
  49734. * @returns a promise
  49735. */
  49736. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  49737. /**
  49738. * Uploads spherical polynomials information to the texture.
  49739. * @param texture defines the texture we are trying to upload the information to
  49740. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  49741. */
  49742. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  49743. /** @hidden */
  49744. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  49745. }
  49746. }
  49747. declare module "babylonjs/Maths/math.vertexFormat" {
  49748. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  49749. /**
  49750. * Contains position and normal vectors for a vertex
  49751. */
  49752. export class PositionNormalVertex {
  49753. /** the position of the vertex (defaut: 0,0,0) */
  49754. position: Vector3;
  49755. /** the normal of the vertex (defaut: 0,1,0) */
  49756. normal: Vector3;
  49757. /**
  49758. * Creates a PositionNormalVertex
  49759. * @param position the position of the vertex (defaut: 0,0,0)
  49760. * @param normal the normal of the vertex (defaut: 0,1,0)
  49761. */
  49762. constructor(
  49763. /** the position of the vertex (defaut: 0,0,0) */
  49764. position?: Vector3,
  49765. /** the normal of the vertex (defaut: 0,1,0) */
  49766. normal?: Vector3);
  49767. /**
  49768. * Clones the PositionNormalVertex
  49769. * @returns the cloned PositionNormalVertex
  49770. */
  49771. clone(): PositionNormalVertex;
  49772. }
  49773. /**
  49774. * Contains position, normal and uv vectors for a vertex
  49775. */
  49776. export class PositionNormalTextureVertex {
  49777. /** the position of the vertex (defaut: 0,0,0) */
  49778. position: Vector3;
  49779. /** the normal of the vertex (defaut: 0,1,0) */
  49780. normal: Vector3;
  49781. /** the uv of the vertex (default: 0,0) */
  49782. uv: Vector2;
  49783. /**
  49784. * Creates a PositionNormalTextureVertex
  49785. * @param position the position of the vertex (defaut: 0,0,0)
  49786. * @param normal the normal of the vertex (defaut: 0,1,0)
  49787. * @param uv the uv of the vertex (default: 0,0)
  49788. */
  49789. constructor(
  49790. /** the position of the vertex (defaut: 0,0,0) */
  49791. position?: Vector3,
  49792. /** the normal of the vertex (defaut: 0,1,0) */
  49793. normal?: Vector3,
  49794. /** the uv of the vertex (default: 0,0) */
  49795. uv?: Vector2);
  49796. /**
  49797. * Clones the PositionNormalTextureVertex
  49798. * @returns the cloned PositionNormalTextureVertex
  49799. */
  49800. clone(): PositionNormalTextureVertex;
  49801. }
  49802. }
  49803. declare module "babylonjs/Maths/math" {
  49804. export * from "babylonjs/Maths/math.axis";
  49805. export * from "babylonjs/Maths/math.color";
  49806. export * from "babylonjs/Maths/math.constants";
  49807. export * from "babylonjs/Maths/math.frustum";
  49808. export * from "babylonjs/Maths/math.path";
  49809. export * from "babylonjs/Maths/math.plane";
  49810. export * from "babylonjs/Maths/math.size";
  49811. export * from "babylonjs/Maths/math.vector";
  49812. export * from "babylonjs/Maths/math.vertexFormat";
  49813. export * from "babylonjs/Maths/math.viewport";
  49814. }
  49815. declare module "babylonjs/Engines/Native/nativeShaderProcessor" {
  49816. import { WebGL2ShaderProcessor } from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  49817. /** @hidden */
  49818. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  49819. private _genericAttributeLocation;
  49820. private _varyingLocationCount;
  49821. private _varyingLocationMap;
  49822. private _replacements;
  49823. private _textureCount;
  49824. private _uniforms;
  49825. lineProcessor(line: string): string;
  49826. attributeProcessor(attribute: string): string;
  49827. varyingProcessor(varying: string, isFragment: boolean): string;
  49828. uniformProcessor(uniform: string): string;
  49829. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  49830. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  49831. }
  49832. }
  49833. declare module "babylonjs/Engines/nativeEngine" {
  49834. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  49835. import { Engine } from "babylonjs/Engines/engine";
  49836. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  49837. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49838. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49839. import { Effect } from "babylonjs/Materials/effect";
  49840. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  49841. import { Matrix, Viewport, Color3 } from "babylonjs/Maths/math";
  49842. import { IColor4Like } from "babylonjs/Maths/math.like";
  49843. import { Scene } from "babylonjs/scene";
  49844. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  49845. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  49846. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  49847. /**
  49848. * Container for accessors for natively-stored mesh data buffers.
  49849. */
  49850. class NativeDataBuffer extends DataBuffer {
  49851. /**
  49852. * Accessor value used to identify/retrieve a natively-stored index buffer.
  49853. */
  49854. nativeIndexBuffer?: any;
  49855. /**
  49856. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  49857. */
  49858. nativeVertexBuffer?: any;
  49859. }
  49860. /** @hidden */
  49861. class NativeTexture extends InternalTexture {
  49862. getInternalTexture(): InternalTexture;
  49863. getViewCount(): number;
  49864. }
  49865. /** @hidden */
  49866. export class NativeEngine extends Engine {
  49867. private readonly _native;
  49868. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  49869. private readonly INVALID_HANDLE;
  49870. getHardwareScalingLevel(): number;
  49871. constructor();
  49872. /**
  49873. * Can be used to override the current requestAnimationFrame requester.
  49874. * @hidden
  49875. */
  49876. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  49877. /**
  49878. * Override default engine behavior.
  49879. * @param color
  49880. * @param backBuffer
  49881. * @param depth
  49882. * @param stencil
  49883. */
  49884. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  49885. /**
  49886. * Gets host document
  49887. * @returns the host document object
  49888. */
  49889. getHostDocument(): Nullable<Document>;
  49890. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  49891. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  49892. createVertexBuffer(data: DataArray): NativeDataBuffer;
  49893. recordVertexArrayObject(vertexBuffers: {
  49894. [key: string]: VertexBuffer;
  49895. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  49896. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  49897. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  49898. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  49899. /**
  49900. * Draw a list of indexed primitives
  49901. * @param fillMode defines the primitive to use
  49902. * @param indexStart defines the starting index
  49903. * @param indexCount defines the number of index to draw
  49904. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  49905. */
  49906. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  49907. /**
  49908. * Draw a list of unindexed primitives
  49909. * @param fillMode defines the primitive to use
  49910. * @param verticesStart defines the index of first vertex to draw
  49911. * @param verticesCount defines the count of vertices to draw
  49912. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  49913. */
  49914. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  49915. createPipelineContext(): IPipelineContext;
  49916. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  49917. /** @hidden */
  49918. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  49919. /** @hidden */
  49920. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  49921. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  49922. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  49923. protected _setProgram(program: WebGLProgram): void;
  49924. _releaseEffect(effect: Effect): void;
  49925. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  49926. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  49927. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  49928. bindSamplers(effect: Effect): void;
  49929. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  49930. getRenderWidth(useScreen?: boolean): number;
  49931. getRenderHeight(useScreen?: boolean): number;
  49932. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  49933. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  49934. /**
  49935. * Set the z offset to apply to current rendering
  49936. * @param value defines the offset to apply
  49937. */
  49938. setZOffset(value: number): void;
  49939. /**
  49940. * Gets the current value of the zOffset
  49941. * @returns the current zOffset state
  49942. */
  49943. getZOffset(): number;
  49944. /**
  49945. * Enable or disable depth buffering
  49946. * @param enable defines the state to set
  49947. */
  49948. setDepthBuffer(enable: boolean): void;
  49949. /**
  49950. * Gets a boolean indicating if depth writing is enabled
  49951. * @returns the current depth writing state
  49952. */
  49953. getDepthWrite(): boolean;
  49954. /**
  49955. * Enable or disable depth writing
  49956. * @param enable defines the state to set
  49957. */
  49958. setDepthWrite(enable: boolean): void;
  49959. /**
  49960. * Enable or disable color writing
  49961. * @param enable defines the state to set
  49962. */
  49963. setColorWrite(enable: boolean): void;
  49964. /**
  49965. * Gets a boolean indicating if color writing is enabled
  49966. * @returns the current color writing state
  49967. */
  49968. getColorWrite(): boolean;
  49969. /**
  49970. * Sets alpha constants used by some alpha blending modes
  49971. * @param r defines the red component
  49972. * @param g defines the green component
  49973. * @param b defines the blue component
  49974. * @param a defines the alpha component
  49975. */
  49976. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  49977. /**
  49978. * Sets the current alpha mode
  49979. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  49980. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  49981. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  49982. */
  49983. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  49984. /**
  49985. * Gets the current alpha mode
  49986. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  49987. * @returns the current alpha mode
  49988. */
  49989. getAlphaMode(): number;
  49990. setInt(uniform: WebGLUniformLocation, int: number): void;
  49991. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  49992. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  49993. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  49994. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  49995. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  49996. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  49997. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  49998. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  49999. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  50000. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  50001. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  50002. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  50003. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  50004. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  50005. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  50006. setFloat(uniform: WebGLUniformLocation, value: number): void;
  50007. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  50008. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  50009. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  50010. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  50011. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  50012. wipeCaches(bruteForce?: boolean): void;
  50013. _createTexture(): WebGLTexture;
  50014. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  50015. /**
  50016. * Usually called from Texture.ts.
  50017. * Passed information to create a WebGLTexture
  50018. * @param urlArg defines a value which contains one of the following:
  50019. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  50020. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  50021. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  50022. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  50023. * @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)
  50024. * @param scene needed for loading to the correct scene
  50025. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  50026. * @param onLoad optional callback to be called upon successful completion
  50027. * @param onError optional callback to be called upon failure
  50028. * @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
  50029. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  50030. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  50031. * @param forcedExtension defines the extension to use to pick the right loader
  50032. * @param mimeType defines an optional mime type
  50033. * @returns a InternalTexture for assignment back into BABYLON.Texture
  50034. */
  50035. 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;
  50036. /**
  50037. * Creates a cube texture
  50038. * @param rootUrl defines the url where the files to load is located
  50039. * @param scene defines the current scene
  50040. * @param files defines the list of files to load (1 per face)
  50041. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  50042. * @param onLoad defines an optional callback raised when the texture is loaded
  50043. * @param onError defines an optional callback raised if there is an issue to load the texture
  50044. * @param format defines the format of the data
  50045. * @param forcedExtension defines the extension to use to pick the right loader
  50046. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  50047. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  50048. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  50049. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  50050. * @returns the cube texture as an InternalTexture
  50051. */
  50052. 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;
  50053. private _getSamplingFilter;
  50054. private static _GetNativeTextureFormat;
  50055. createRenderTargetTexture(size: number | {
  50056. width: number;
  50057. height: number;
  50058. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  50059. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  50060. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  50061. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  50062. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  50063. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  50064. /**
  50065. * Updates a dynamic vertex buffer.
  50066. * @param vertexBuffer the vertex buffer to update
  50067. * @param data the data used to update the vertex buffer
  50068. * @param byteOffset the byte offset of the data (optional)
  50069. * @param byteLength the byte length of the data (optional)
  50070. */
  50071. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  50072. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  50073. private _updateAnisotropicLevel;
  50074. private _getAddressMode;
  50075. /** @hidden */
  50076. _bindTexture(channel: number, texture: InternalTexture): void;
  50077. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  50078. releaseEffects(): void;
  50079. /** @hidden */
  50080. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  50081. /** @hidden */
  50082. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  50083. /** @hidden */
  50084. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  50085. /** @hidden */
  50086. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  50087. }
  50088. }
  50089. declare module "babylonjs/Engines/index" {
  50090. export * from "babylonjs/Engines/constants";
  50091. export * from "babylonjs/Engines/engineCapabilities";
  50092. export * from "babylonjs/Engines/instancingAttributeInfo";
  50093. export * from "babylonjs/Engines/thinEngine";
  50094. export * from "babylonjs/Engines/engine";
  50095. export * from "babylonjs/Engines/engineStore";
  50096. export * from "babylonjs/Engines/nullEngine";
  50097. export * from "babylonjs/Engines/Extensions/index";
  50098. export * from "babylonjs/Engines/IPipelineContext";
  50099. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  50100. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  50101. export * from "babylonjs/Engines/nativeEngine";
  50102. }
  50103. declare module "babylonjs/Events/clipboardEvents" {
  50104. /**
  50105. * Gather the list of clipboard event types as constants.
  50106. */
  50107. export class ClipboardEventTypes {
  50108. /**
  50109. * The clipboard event is fired when a copy command is active (pressed).
  50110. */
  50111. static readonly COPY: number;
  50112. /**
  50113. * The clipboard event is fired when a cut command is active (pressed).
  50114. */
  50115. static readonly CUT: number;
  50116. /**
  50117. * The clipboard event is fired when a paste command is active (pressed).
  50118. */
  50119. static readonly PASTE: number;
  50120. }
  50121. /**
  50122. * This class is used to store clipboard related info for the onClipboardObservable event.
  50123. */
  50124. export class ClipboardInfo {
  50125. /**
  50126. * Defines the type of event (BABYLON.ClipboardEventTypes)
  50127. */
  50128. type: number;
  50129. /**
  50130. * Defines the related dom event
  50131. */
  50132. event: ClipboardEvent;
  50133. /**
  50134. *Creates an instance of ClipboardInfo.
  50135. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  50136. * @param event Defines the related dom event
  50137. */
  50138. constructor(
  50139. /**
  50140. * Defines the type of event (BABYLON.ClipboardEventTypes)
  50141. */
  50142. type: number,
  50143. /**
  50144. * Defines the related dom event
  50145. */
  50146. event: ClipboardEvent);
  50147. /**
  50148. * Get the clipboard event's type from the keycode.
  50149. * @param keyCode Defines the keyCode for the current keyboard event.
  50150. * @return {number}
  50151. */
  50152. static GetTypeFromCharacter(keyCode: number): number;
  50153. }
  50154. }
  50155. declare module "babylonjs/Events/index" {
  50156. export * from "babylonjs/Events/keyboardEvents";
  50157. export * from "babylonjs/Events/pointerEvents";
  50158. export * from "babylonjs/Events/clipboardEvents";
  50159. }
  50160. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  50161. import { Scene } from "babylonjs/scene";
  50162. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50163. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  50164. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  50165. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  50166. /**
  50167. * Google Daydream controller
  50168. */
  50169. export class DaydreamController extends WebVRController {
  50170. /**
  50171. * Base Url for the controller model.
  50172. */
  50173. static MODEL_BASE_URL: string;
  50174. /**
  50175. * File name for the controller model.
  50176. */
  50177. static MODEL_FILENAME: string;
  50178. /**
  50179. * Gamepad Id prefix used to identify Daydream Controller.
  50180. */
  50181. static readonly GAMEPAD_ID_PREFIX: string;
  50182. /**
  50183. * Creates a new DaydreamController from a gamepad
  50184. * @param vrGamepad the gamepad that the controller should be created from
  50185. */
  50186. constructor(vrGamepad: any);
  50187. /**
  50188. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  50189. * @param scene scene in which to add meshes
  50190. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  50191. */
  50192. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  50193. /**
  50194. * Called once for each button that changed state since the last frame
  50195. * @param buttonIdx Which button index changed
  50196. * @param state New state of the button
  50197. * @param changes Which properties on the state changed since last frame
  50198. */
  50199. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  50200. }
  50201. }
  50202. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  50203. import { Scene } from "babylonjs/scene";
  50204. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50205. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  50206. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  50207. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  50208. /**
  50209. * Gear VR Controller
  50210. */
  50211. export class GearVRController extends WebVRController {
  50212. /**
  50213. * Base Url for the controller model.
  50214. */
  50215. static MODEL_BASE_URL: string;
  50216. /**
  50217. * File name for the controller model.
  50218. */
  50219. static MODEL_FILENAME: string;
  50220. /**
  50221. * Gamepad Id prefix used to identify this controller.
  50222. */
  50223. static readonly GAMEPAD_ID_PREFIX: string;
  50224. private readonly _buttonIndexToObservableNameMap;
  50225. /**
  50226. * Creates a new GearVRController from a gamepad
  50227. * @param vrGamepad the gamepad that the controller should be created from
  50228. */
  50229. constructor(vrGamepad: any);
  50230. /**
  50231. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  50232. * @param scene scene in which to add meshes
  50233. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  50234. */
  50235. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  50236. /**
  50237. * Called once for each button that changed state since the last frame
  50238. * @param buttonIdx Which button index changed
  50239. * @param state New state of the button
  50240. * @param changes Which properties on the state changed since last frame
  50241. */
  50242. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  50243. }
  50244. }
  50245. declare module "babylonjs/Gamepads/Controllers/genericController" {
  50246. import { Scene } from "babylonjs/scene";
  50247. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50248. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  50249. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  50250. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  50251. /**
  50252. * Generic Controller
  50253. */
  50254. export class GenericController extends WebVRController {
  50255. /**
  50256. * Base Url for the controller model.
  50257. */
  50258. static readonly MODEL_BASE_URL: string;
  50259. /**
  50260. * File name for the controller model.
  50261. */
  50262. static readonly MODEL_FILENAME: string;
  50263. /**
  50264. * Creates a new GenericController from a gamepad
  50265. * @param vrGamepad the gamepad that the controller should be created from
  50266. */
  50267. constructor(vrGamepad: any);
  50268. /**
  50269. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  50270. * @param scene scene in which to add meshes
  50271. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  50272. */
  50273. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  50274. /**
  50275. * Called once for each button that changed state since the last frame
  50276. * @param buttonIdx Which button index changed
  50277. * @param state New state of the button
  50278. * @param changes Which properties on the state changed since last frame
  50279. */
  50280. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  50281. }
  50282. }
  50283. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  50284. import { Observable } from "babylonjs/Misc/observable";
  50285. import { Scene } from "babylonjs/scene";
  50286. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50287. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  50288. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  50289. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  50290. /**
  50291. * Oculus Touch Controller
  50292. */
  50293. export class OculusTouchController extends WebVRController {
  50294. /**
  50295. * Base Url for the controller model.
  50296. */
  50297. static MODEL_BASE_URL: string;
  50298. /**
  50299. * File name for the left controller model.
  50300. */
  50301. static MODEL_LEFT_FILENAME: string;
  50302. /**
  50303. * File name for the right controller model.
  50304. */
  50305. static MODEL_RIGHT_FILENAME: string;
  50306. /**
  50307. * Base Url for the Quest controller model.
  50308. */
  50309. static QUEST_MODEL_BASE_URL: string;
  50310. /**
  50311. * @hidden
  50312. * If the controllers are running on a device that needs the updated Quest controller models
  50313. */
  50314. static _IsQuest: boolean;
  50315. /**
  50316. * Fired when the secondary trigger on this controller is modified
  50317. */
  50318. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  50319. /**
  50320. * Fired when the thumb rest on this controller is modified
  50321. */
  50322. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  50323. /**
  50324. * Creates a new OculusTouchController from a gamepad
  50325. * @param vrGamepad the gamepad that the controller should be created from
  50326. */
  50327. constructor(vrGamepad: any);
  50328. /**
  50329. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  50330. * @param scene scene in which to add meshes
  50331. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  50332. */
  50333. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  50334. /**
  50335. * Fired when the A button on this controller is modified
  50336. */
  50337. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50338. /**
  50339. * Fired when the B button on this controller is modified
  50340. */
  50341. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50342. /**
  50343. * Fired when the X button on this controller is modified
  50344. */
  50345. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50346. /**
  50347. * Fired when the Y button on this controller is modified
  50348. */
  50349. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50350. /**
  50351. * Called once for each button that changed state since the last frame
  50352. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  50353. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  50354. * 2) secondary trigger (same)
  50355. * 3) A (right) X (left), touch, pressed = value
  50356. * 4) B / Y
  50357. * 5) thumb rest
  50358. * @param buttonIdx Which button index changed
  50359. * @param state New state of the button
  50360. * @param changes Which properties on the state changed since last frame
  50361. */
  50362. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  50363. }
  50364. }
  50365. declare module "babylonjs/Gamepads/Controllers/viveController" {
  50366. import { Scene } from "babylonjs/scene";
  50367. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50368. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  50369. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  50370. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  50371. import { Observable } from "babylonjs/Misc/observable";
  50372. /**
  50373. * Vive Controller
  50374. */
  50375. export class ViveController extends WebVRController {
  50376. /**
  50377. * Base Url for the controller model.
  50378. */
  50379. static MODEL_BASE_URL: string;
  50380. /**
  50381. * File name for the controller model.
  50382. */
  50383. static MODEL_FILENAME: string;
  50384. /**
  50385. * Creates a new ViveController from a gamepad
  50386. * @param vrGamepad the gamepad that the controller should be created from
  50387. */
  50388. constructor(vrGamepad: any);
  50389. /**
  50390. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  50391. * @param scene scene in which to add meshes
  50392. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  50393. */
  50394. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  50395. /**
  50396. * Fired when the left button on this controller is modified
  50397. */
  50398. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50399. /**
  50400. * Fired when the right button on this controller is modified
  50401. */
  50402. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50403. /**
  50404. * Fired when the menu button on this controller is modified
  50405. */
  50406. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50407. /**
  50408. * Called once for each button that changed state since the last frame
  50409. * Vive mapping:
  50410. * 0: touchpad
  50411. * 1: trigger
  50412. * 2: left AND right buttons
  50413. * 3: menu button
  50414. * @param buttonIdx Which button index changed
  50415. * @param state New state of the button
  50416. * @param changes Which properties on the state changed since last frame
  50417. */
  50418. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  50419. }
  50420. }
  50421. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  50422. import { Observable } from "babylonjs/Misc/observable";
  50423. import { Scene } from "babylonjs/scene";
  50424. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50425. import { Ray } from "babylonjs/Culling/ray";
  50426. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  50427. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  50428. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  50429. /**
  50430. * Defines the WindowsMotionController object that the state of the windows motion controller
  50431. */
  50432. export class WindowsMotionController extends WebVRController {
  50433. /**
  50434. * The base url used to load the left and right controller models
  50435. */
  50436. static MODEL_BASE_URL: string;
  50437. /**
  50438. * The name of the left controller model file
  50439. */
  50440. static MODEL_LEFT_FILENAME: string;
  50441. /**
  50442. * The name of the right controller model file
  50443. */
  50444. static MODEL_RIGHT_FILENAME: string;
  50445. /**
  50446. * The controller name prefix for this controller type
  50447. */
  50448. static readonly GAMEPAD_ID_PREFIX: string;
  50449. /**
  50450. * The controller id pattern for this controller type
  50451. */
  50452. private static readonly GAMEPAD_ID_PATTERN;
  50453. private _loadedMeshInfo;
  50454. protected readonly _mapping: {
  50455. buttons: string[];
  50456. buttonMeshNames: {
  50457. trigger: string;
  50458. menu: string;
  50459. grip: string;
  50460. thumbstick: string;
  50461. trackpad: string;
  50462. };
  50463. buttonObservableNames: {
  50464. trigger: string;
  50465. menu: string;
  50466. grip: string;
  50467. thumbstick: string;
  50468. trackpad: string;
  50469. };
  50470. axisMeshNames: string[];
  50471. pointingPoseMeshName: string;
  50472. };
  50473. /**
  50474. * Fired when the trackpad on this controller is clicked
  50475. */
  50476. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  50477. /**
  50478. * Fired when the trackpad on this controller is modified
  50479. */
  50480. onTrackpadValuesChangedObservable: Observable<StickValues>;
  50481. /**
  50482. * The current x and y values of this controller's trackpad
  50483. */
  50484. trackpad: StickValues;
  50485. /**
  50486. * Creates a new WindowsMotionController from a gamepad
  50487. * @param vrGamepad the gamepad that the controller should be created from
  50488. */
  50489. constructor(vrGamepad: any);
  50490. /**
  50491. * Fired when the trigger on this controller is modified
  50492. */
  50493. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50494. /**
  50495. * Fired when the menu button on this controller is modified
  50496. */
  50497. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50498. /**
  50499. * Fired when the grip button on this controller is modified
  50500. */
  50501. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50502. /**
  50503. * Fired when the thumbstick button on this controller is modified
  50504. */
  50505. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50506. /**
  50507. * Fired when the touchpad button on this controller is modified
  50508. */
  50509. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50510. /**
  50511. * Fired when the touchpad values on this controller are modified
  50512. */
  50513. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  50514. protected _updateTrackpad(): void;
  50515. /**
  50516. * Called once per frame by the engine.
  50517. */
  50518. update(): void;
  50519. /**
  50520. * Called once for each button that changed state since the last frame
  50521. * @param buttonIdx Which button index changed
  50522. * @param state New state of the button
  50523. * @param changes Which properties on the state changed since last frame
  50524. */
  50525. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  50526. /**
  50527. * Moves the buttons on the controller mesh based on their current state
  50528. * @param buttonName the name of the button to move
  50529. * @param buttonValue the value of the button which determines the buttons new position
  50530. */
  50531. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  50532. /**
  50533. * Moves the axis on the controller mesh based on its current state
  50534. * @param axis the index of the axis
  50535. * @param axisValue the value of the axis which determines the meshes new position
  50536. * @hidden
  50537. */
  50538. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  50539. /**
  50540. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  50541. * @param scene scene in which to add meshes
  50542. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  50543. */
  50544. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  50545. /**
  50546. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  50547. * can be transformed by button presses and axes values, based on this._mapping.
  50548. *
  50549. * @param scene scene in which the meshes exist
  50550. * @param meshes list of meshes that make up the controller model to process
  50551. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  50552. */
  50553. private processModel;
  50554. private createMeshInfo;
  50555. /**
  50556. * Gets the ray of the controller in the direction the controller is pointing
  50557. * @param length the length the resulting ray should be
  50558. * @returns a ray in the direction the controller is pointing
  50559. */
  50560. getForwardRay(length?: number): Ray;
  50561. /**
  50562. * Disposes of the controller
  50563. */
  50564. dispose(): void;
  50565. }
  50566. /**
  50567. * This class represents a new windows motion controller in XR.
  50568. */
  50569. export class XRWindowsMotionController extends WindowsMotionController {
  50570. /**
  50571. * Changing the original WIndowsMotionController mapping to fir the new mapping
  50572. */
  50573. protected readonly _mapping: {
  50574. buttons: string[];
  50575. buttonMeshNames: {
  50576. trigger: string;
  50577. menu: string;
  50578. grip: string;
  50579. thumbstick: string;
  50580. trackpad: string;
  50581. };
  50582. buttonObservableNames: {
  50583. trigger: string;
  50584. menu: string;
  50585. grip: string;
  50586. thumbstick: string;
  50587. trackpad: string;
  50588. };
  50589. axisMeshNames: string[];
  50590. pointingPoseMeshName: string;
  50591. };
  50592. /**
  50593. * Construct a new XR-Based windows motion controller
  50594. *
  50595. * @param gamepadInfo the gamepad object from the browser
  50596. */
  50597. constructor(gamepadInfo: any);
  50598. /**
  50599. * holds the thumbstick values (X,Y)
  50600. */
  50601. thumbstickValues: StickValues;
  50602. /**
  50603. * Fired when the thumbstick on this controller is clicked
  50604. */
  50605. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  50606. /**
  50607. * Fired when the thumbstick on this controller is modified
  50608. */
  50609. onThumbstickValuesChangedObservable: Observable<StickValues>;
  50610. /**
  50611. * Fired when the touchpad button on this controller is modified
  50612. */
  50613. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  50614. /**
  50615. * Fired when the touchpad values on this controller are modified
  50616. */
  50617. onTrackpadValuesChangedObservable: Observable<StickValues>;
  50618. /**
  50619. * Fired when the thumbstick button on this controller is modified
  50620. * here to prevent breaking changes
  50621. */
  50622. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50623. /**
  50624. * updating the thumbstick(!) and not the trackpad.
  50625. * This is named this way due to the difference between WebVR and XR and to avoid
  50626. * changing the parent class.
  50627. */
  50628. protected _updateTrackpad(): void;
  50629. /**
  50630. * Disposes the class with joy
  50631. */
  50632. dispose(): void;
  50633. }
  50634. }
  50635. declare module "babylonjs/Gamepads/Controllers/index" {
  50636. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  50637. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  50638. export * from "babylonjs/Gamepads/Controllers/genericController";
  50639. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  50640. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  50641. export * from "babylonjs/Gamepads/Controllers/viveController";
  50642. export * from "babylonjs/Gamepads/Controllers/webVRController";
  50643. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  50644. }
  50645. declare module "babylonjs/Gamepads/index" {
  50646. export * from "babylonjs/Gamepads/Controllers/index";
  50647. export * from "babylonjs/Gamepads/gamepad";
  50648. export * from "babylonjs/Gamepads/gamepadManager";
  50649. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  50650. export * from "babylonjs/Gamepads/xboxGamepad";
  50651. export * from "babylonjs/Gamepads/dualShockGamepad";
  50652. }
  50653. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  50654. import { Scene } from "babylonjs/scene";
  50655. import { Vector4 } from "babylonjs/Maths/math.vector";
  50656. import { Color4 } from "babylonjs/Maths/math.color";
  50657. import { Mesh } from "babylonjs/Meshes/mesh";
  50658. import { Nullable } from "babylonjs/types";
  50659. /**
  50660. * Class containing static functions to help procedurally build meshes
  50661. */
  50662. export class PolyhedronBuilder {
  50663. /**
  50664. * Creates a polyhedron mesh
  50665. * * 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
  50666. * * The parameter `size` (positive float, default 1) sets the polygon size
  50667. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  50668. * * 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`
  50669. * * 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
  50670. * * 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)`)
  50671. * * 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
  50672. * * 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
  50673. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50674. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50675. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50676. * @param name defines the name of the mesh
  50677. * @param options defines the options used to create the mesh
  50678. * @param scene defines the hosting scene
  50679. * @returns the polyhedron mesh
  50680. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  50681. */
  50682. static CreatePolyhedron(name: string, options: {
  50683. type?: number;
  50684. size?: number;
  50685. sizeX?: number;
  50686. sizeY?: number;
  50687. sizeZ?: number;
  50688. custom?: any;
  50689. faceUV?: Vector4[];
  50690. faceColors?: Color4[];
  50691. flat?: boolean;
  50692. updatable?: boolean;
  50693. sideOrientation?: number;
  50694. frontUVs?: Vector4;
  50695. backUVs?: Vector4;
  50696. }, scene?: Nullable<Scene>): Mesh;
  50697. }
  50698. }
  50699. declare module "babylonjs/Gizmos/scaleGizmo" {
  50700. import { Observable } from "babylonjs/Misc/observable";
  50701. import { Nullable } from "babylonjs/types";
  50702. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50703. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50704. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  50705. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50706. /**
  50707. * Gizmo that enables scaling a mesh along 3 axis
  50708. */
  50709. export class ScaleGizmo extends Gizmo {
  50710. /**
  50711. * Internal gizmo used for interactions on the x axis
  50712. */
  50713. xGizmo: AxisScaleGizmo;
  50714. /**
  50715. * Internal gizmo used for interactions on the y axis
  50716. */
  50717. yGizmo: AxisScaleGizmo;
  50718. /**
  50719. * Internal gizmo used for interactions on the z axis
  50720. */
  50721. zGizmo: AxisScaleGizmo;
  50722. /**
  50723. * Internal gizmo used to scale all axis equally
  50724. */
  50725. uniformScaleGizmo: AxisScaleGizmo;
  50726. private _meshAttached;
  50727. private _updateGizmoRotationToMatchAttachedMesh;
  50728. private _snapDistance;
  50729. private _scaleRatio;
  50730. private _uniformScalingMesh;
  50731. private _octahedron;
  50732. private _sensitivity;
  50733. /** Fires an event when any of it's sub gizmos are dragged */
  50734. onDragStartObservable: Observable<unknown>;
  50735. /** Fires an event when any of it's sub gizmos are released from dragging */
  50736. onDragEndObservable: Observable<unknown>;
  50737. get attachedMesh(): Nullable<AbstractMesh>;
  50738. set attachedMesh(mesh: Nullable<AbstractMesh>);
  50739. /**
  50740. * Creates a ScaleGizmo
  50741. * @param gizmoLayer The utility layer the gizmo will be added to
  50742. */
  50743. constructor(gizmoLayer?: UtilityLayerRenderer);
  50744. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  50745. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  50746. /**
  50747. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50748. */
  50749. set snapDistance(value: number);
  50750. get snapDistance(): number;
  50751. /**
  50752. * Ratio for the scale of the gizmo (Default: 1)
  50753. */
  50754. set scaleRatio(value: number);
  50755. get scaleRatio(): number;
  50756. /**
  50757. * Sensitivity factor for dragging (Default: 1)
  50758. */
  50759. set sensitivity(value: number);
  50760. get sensitivity(): number;
  50761. /**
  50762. * Disposes of the gizmo
  50763. */
  50764. dispose(): void;
  50765. }
  50766. }
  50767. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  50768. import { Observable } from "babylonjs/Misc/observable";
  50769. import { Nullable } from "babylonjs/types";
  50770. import { Vector3 } from "babylonjs/Maths/math.vector";
  50771. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50772. import { Mesh } from "babylonjs/Meshes/mesh";
  50773. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  50774. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50775. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50776. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  50777. import { Color3 } from "babylonjs/Maths/math.color";
  50778. /**
  50779. * Single axis scale gizmo
  50780. */
  50781. export class AxisScaleGizmo extends Gizmo {
  50782. /**
  50783. * Drag behavior responsible for the gizmos dragging interactions
  50784. */
  50785. dragBehavior: PointerDragBehavior;
  50786. private _pointerObserver;
  50787. /**
  50788. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50789. */
  50790. snapDistance: number;
  50791. /**
  50792. * Event that fires each time the gizmo snaps to a new location.
  50793. * * snapDistance is the the change in distance
  50794. */
  50795. onSnapObservable: Observable<{
  50796. snapDistance: number;
  50797. }>;
  50798. /**
  50799. * If the scaling operation should be done on all axis (default: false)
  50800. */
  50801. uniformScaling: boolean;
  50802. /**
  50803. * Custom sensitivity value for the drag strength
  50804. */
  50805. sensitivity: number;
  50806. private _isEnabled;
  50807. private _parent;
  50808. private _arrow;
  50809. private _coloredMaterial;
  50810. private _hoverMaterial;
  50811. /**
  50812. * Creates an AxisScaleGizmo
  50813. * @param gizmoLayer The utility layer the gizmo will be added to
  50814. * @param dragAxis The axis which the gizmo will be able to scale on
  50815. * @param color The color of the gizmo
  50816. */
  50817. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  50818. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  50819. /**
  50820. * If the gizmo is enabled
  50821. */
  50822. set isEnabled(value: boolean);
  50823. get isEnabled(): boolean;
  50824. /**
  50825. * Disposes of the gizmo
  50826. */
  50827. dispose(): void;
  50828. /**
  50829. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  50830. * @param mesh The mesh to replace the default mesh of the gizmo
  50831. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  50832. */
  50833. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  50834. }
  50835. }
  50836. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  50837. import { Observable } from "babylonjs/Misc/observable";
  50838. import { Nullable } from "babylonjs/types";
  50839. import { Vector3 } from "babylonjs/Maths/math.vector";
  50840. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50841. import { Mesh } from "babylonjs/Meshes/mesh";
  50842. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50843. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50844. import { Color3 } from "babylonjs/Maths/math.color";
  50845. import "babylonjs/Meshes/Builders/boxBuilder";
  50846. /**
  50847. * Bounding box gizmo
  50848. */
  50849. export class BoundingBoxGizmo extends Gizmo {
  50850. private _lineBoundingBox;
  50851. private _rotateSpheresParent;
  50852. private _scaleBoxesParent;
  50853. private _boundingDimensions;
  50854. private _renderObserver;
  50855. private _pointerObserver;
  50856. private _scaleDragSpeed;
  50857. private _tmpQuaternion;
  50858. private _tmpVector;
  50859. private _tmpRotationMatrix;
  50860. /**
  50861. * 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)
  50862. */
  50863. ignoreChildren: boolean;
  50864. /**
  50865. * 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)
  50866. */
  50867. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  50868. /**
  50869. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  50870. */
  50871. rotationSphereSize: number;
  50872. /**
  50873. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  50874. */
  50875. scaleBoxSize: number;
  50876. /**
  50877. * 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)
  50878. */
  50879. fixedDragMeshScreenSize: boolean;
  50880. /**
  50881. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  50882. */
  50883. fixedDragMeshScreenSizeDistanceFactor: number;
  50884. /**
  50885. * Fired when a rotation sphere or scale box is dragged
  50886. */
  50887. onDragStartObservable: Observable<{}>;
  50888. /**
  50889. * Fired when a scale box is dragged
  50890. */
  50891. onScaleBoxDragObservable: Observable<{}>;
  50892. /**
  50893. * Fired when a scale box drag is ended
  50894. */
  50895. onScaleBoxDragEndObservable: Observable<{}>;
  50896. /**
  50897. * Fired when a rotation sphere is dragged
  50898. */
  50899. onRotationSphereDragObservable: Observable<{}>;
  50900. /**
  50901. * Fired when a rotation sphere drag is ended
  50902. */
  50903. onRotationSphereDragEndObservable: Observable<{}>;
  50904. /**
  50905. * 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)
  50906. */
  50907. scalePivot: Nullable<Vector3>;
  50908. /**
  50909. * Mesh used as a pivot to rotate the attached mesh
  50910. */
  50911. private _anchorMesh;
  50912. private _existingMeshScale;
  50913. private _dragMesh;
  50914. private pointerDragBehavior;
  50915. private coloredMaterial;
  50916. private hoverColoredMaterial;
  50917. /**
  50918. * Sets the color of the bounding box gizmo
  50919. * @param color the color to set
  50920. */
  50921. setColor(color: Color3): void;
  50922. /**
  50923. * Creates an BoundingBoxGizmo
  50924. * @param gizmoLayer The utility layer the gizmo will be added to
  50925. * @param color The color of the gizmo
  50926. */
  50927. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  50928. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  50929. private _selectNode;
  50930. /**
  50931. * Updates the bounding box information for the Gizmo
  50932. */
  50933. updateBoundingBox(): void;
  50934. private _updateRotationSpheres;
  50935. private _updateScaleBoxes;
  50936. /**
  50937. * Enables rotation on the specified axis and disables rotation on the others
  50938. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  50939. */
  50940. setEnabledRotationAxis(axis: string): void;
  50941. /**
  50942. * Enables/disables scaling
  50943. * @param enable if scaling should be enabled
  50944. * @param homogeneousScaling defines if scaling should only be homogeneous
  50945. */
  50946. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  50947. private _updateDummy;
  50948. /**
  50949. * Enables a pointer drag behavior on the bounding box of the gizmo
  50950. */
  50951. enableDragBehavior(): void;
  50952. /**
  50953. * Disposes of the gizmo
  50954. */
  50955. dispose(): void;
  50956. /**
  50957. * 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)
  50958. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  50959. * @returns the bounding box mesh with the passed in mesh as a child
  50960. */
  50961. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  50962. /**
  50963. * CustomMeshes are not supported by this gizmo
  50964. * @param mesh The mesh to replace the default mesh of the gizmo
  50965. */
  50966. setCustomMesh(mesh: Mesh): void;
  50967. }
  50968. }
  50969. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  50970. import { Observable } from "babylonjs/Misc/observable";
  50971. import { Nullable } from "babylonjs/types";
  50972. import { Vector3 } from "babylonjs/Maths/math.vector";
  50973. import { Color3 } from "babylonjs/Maths/math.color";
  50974. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50975. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  50976. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50977. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50978. import "babylonjs/Meshes/Builders/linesBuilder";
  50979. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  50980. /**
  50981. * Single plane rotation gizmo
  50982. */
  50983. export class PlaneRotationGizmo extends Gizmo {
  50984. /**
  50985. * Drag behavior responsible for the gizmos dragging interactions
  50986. */
  50987. dragBehavior: PointerDragBehavior;
  50988. private _pointerObserver;
  50989. /**
  50990. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  50991. */
  50992. snapDistance: number;
  50993. /**
  50994. * Event that fires each time the gizmo snaps to a new location.
  50995. * * snapDistance is the the change in distance
  50996. */
  50997. onSnapObservable: Observable<{
  50998. snapDistance: number;
  50999. }>;
  51000. private _isEnabled;
  51001. private _parent;
  51002. /**
  51003. * Creates a PlaneRotationGizmo
  51004. * @param gizmoLayer The utility layer the gizmo will be added to
  51005. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  51006. * @param color The color of the gizmo
  51007. * @param tessellation Amount of tessellation to be used when creating rotation circles
  51008. * @param useEulerRotation Use and update Euler angle instead of quaternion
  51009. */
  51010. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  51011. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  51012. /**
  51013. * If the gizmo is enabled
  51014. */
  51015. set isEnabled(value: boolean);
  51016. get isEnabled(): boolean;
  51017. /**
  51018. * Disposes of the gizmo
  51019. */
  51020. dispose(): void;
  51021. }
  51022. }
  51023. declare module "babylonjs/Gizmos/rotationGizmo" {
  51024. import { Observable } from "babylonjs/Misc/observable";
  51025. import { Nullable } from "babylonjs/types";
  51026. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51027. import { Mesh } from "babylonjs/Meshes/mesh";
  51028. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  51029. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  51030. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  51031. /**
  51032. * Gizmo that enables rotating a mesh along 3 axis
  51033. */
  51034. export class RotationGizmo extends Gizmo {
  51035. /**
  51036. * Internal gizmo used for interactions on the x axis
  51037. */
  51038. xGizmo: PlaneRotationGizmo;
  51039. /**
  51040. * Internal gizmo used for interactions on the y axis
  51041. */
  51042. yGizmo: PlaneRotationGizmo;
  51043. /**
  51044. * Internal gizmo used for interactions on the z axis
  51045. */
  51046. zGizmo: PlaneRotationGizmo;
  51047. /** Fires an event when any of it's sub gizmos are dragged */
  51048. onDragStartObservable: Observable<unknown>;
  51049. /** Fires an event when any of it's sub gizmos are released from dragging */
  51050. onDragEndObservable: Observable<unknown>;
  51051. private _meshAttached;
  51052. get attachedMesh(): Nullable<AbstractMesh>;
  51053. set attachedMesh(mesh: Nullable<AbstractMesh>);
  51054. /**
  51055. * Creates a RotationGizmo
  51056. * @param gizmoLayer The utility layer the gizmo will be added to
  51057. * @param tessellation Amount of tessellation to be used when creating rotation circles
  51058. * @param useEulerRotation Use and update Euler angle instead of quaternion
  51059. */
  51060. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  51061. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  51062. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  51063. /**
  51064. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  51065. */
  51066. set snapDistance(value: number);
  51067. get snapDistance(): number;
  51068. /**
  51069. * Ratio for the scale of the gizmo (Default: 1)
  51070. */
  51071. set scaleRatio(value: number);
  51072. get scaleRatio(): number;
  51073. /**
  51074. * Disposes of the gizmo
  51075. */
  51076. dispose(): void;
  51077. /**
  51078. * CustomMeshes are not supported by this gizmo
  51079. * @param mesh The mesh to replace the default mesh of the gizmo
  51080. */
  51081. setCustomMesh(mesh: Mesh): void;
  51082. }
  51083. }
  51084. declare module "babylonjs/Gizmos/gizmoManager" {
  51085. import { Observable } from "babylonjs/Misc/observable";
  51086. import { Nullable } from "babylonjs/types";
  51087. import { Scene, IDisposable } from "babylonjs/scene";
  51088. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51089. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  51090. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  51091. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  51092. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  51093. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  51094. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  51095. /**
  51096. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  51097. */
  51098. export class GizmoManager implements IDisposable {
  51099. private scene;
  51100. /**
  51101. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  51102. */
  51103. gizmos: {
  51104. positionGizmo: Nullable<PositionGizmo>;
  51105. rotationGizmo: Nullable<RotationGizmo>;
  51106. scaleGizmo: Nullable<ScaleGizmo>;
  51107. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  51108. };
  51109. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  51110. clearGizmoOnEmptyPointerEvent: boolean;
  51111. /** Fires an event when the manager is attached to a mesh */
  51112. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  51113. private _gizmosEnabled;
  51114. private _pointerObserver;
  51115. private _attachedMesh;
  51116. private _boundingBoxColor;
  51117. private _defaultUtilityLayer;
  51118. private _defaultKeepDepthUtilityLayer;
  51119. /**
  51120. * When bounding box gizmo is enabled, this can be used to track drag/end events
  51121. */
  51122. boundingBoxDragBehavior: SixDofDragBehavior;
  51123. /**
  51124. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  51125. */
  51126. attachableMeshes: Nullable<Array<AbstractMesh>>;
  51127. /**
  51128. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  51129. */
  51130. usePointerToAttachGizmos: boolean;
  51131. /**
  51132. * Utility layer that the bounding box gizmo belongs to
  51133. */
  51134. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  51135. /**
  51136. * Utility layer that all gizmos besides bounding box belong to
  51137. */
  51138. get utilityLayer(): UtilityLayerRenderer;
  51139. /**
  51140. * Instatiates a gizmo manager
  51141. * @param scene the scene to overlay the gizmos on top of
  51142. */
  51143. constructor(scene: Scene);
  51144. /**
  51145. * Attaches a set of gizmos to the specified mesh
  51146. * @param mesh The mesh the gizmo's should be attached to
  51147. */
  51148. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  51149. /**
  51150. * If the position gizmo is enabled
  51151. */
  51152. set positionGizmoEnabled(value: boolean);
  51153. get positionGizmoEnabled(): boolean;
  51154. /**
  51155. * If the rotation gizmo is enabled
  51156. */
  51157. set rotationGizmoEnabled(value: boolean);
  51158. get rotationGizmoEnabled(): boolean;
  51159. /**
  51160. * If the scale gizmo is enabled
  51161. */
  51162. set scaleGizmoEnabled(value: boolean);
  51163. get scaleGizmoEnabled(): boolean;
  51164. /**
  51165. * If the boundingBox gizmo is enabled
  51166. */
  51167. set boundingBoxGizmoEnabled(value: boolean);
  51168. get boundingBoxGizmoEnabled(): boolean;
  51169. /**
  51170. * Disposes of the gizmo manager
  51171. */
  51172. dispose(): void;
  51173. }
  51174. }
  51175. declare module "babylonjs/Lights/directionalLight" {
  51176. import { Camera } from "babylonjs/Cameras/camera";
  51177. import { Scene } from "babylonjs/scene";
  51178. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  51179. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51180. import { Light } from "babylonjs/Lights/light";
  51181. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  51182. import { Effect } from "babylonjs/Materials/effect";
  51183. /**
  51184. * A directional light is defined by a direction (what a surprise!).
  51185. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  51186. * 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.
  51187. * Documentation: https://doc.babylonjs.com/babylon101/lights
  51188. */
  51189. export class DirectionalLight extends ShadowLight {
  51190. private _shadowFrustumSize;
  51191. /**
  51192. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  51193. */
  51194. get shadowFrustumSize(): number;
  51195. /**
  51196. * Specifies a fix frustum size for the shadow generation.
  51197. */
  51198. set shadowFrustumSize(value: number);
  51199. private _shadowOrthoScale;
  51200. /**
  51201. * Gets the shadow projection scale against the optimal computed one.
  51202. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  51203. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  51204. */
  51205. get shadowOrthoScale(): number;
  51206. /**
  51207. * Sets the shadow projection scale against the optimal computed one.
  51208. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  51209. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  51210. */
  51211. set shadowOrthoScale(value: number);
  51212. /**
  51213. * Automatically compute the projection matrix to best fit (including all the casters)
  51214. * on each frame.
  51215. */
  51216. autoUpdateExtends: boolean;
  51217. /**
  51218. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  51219. * on each frame. autoUpdateExtends must be set to true for this to work
  51220. */
  51221. autoCalcShadowZBounds: boolean;
  51222. private _orthoLeft;
  51223. private _orthoRight;
  51224. private _orthoTop;
  51225. private _orthoBottom;
  51226. /**
  51227. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  51228. * The directional light is emitted from everywhere in the given direction.
  51229. * It can cast shadows.
  51230. * Documentation : https://doc.babylonjs.com/babylon101/lights
  51231. * @param name The friendly name of the light
  51232. * @param direction The direction of the light
  51233. * @param scene The scene the light belongs to
  51234. */
  51235. constructor(name: string, direction: Vector3, scene: Scene);
  51236. /**
  51237. * Returns the string "DirectionalLight".
  51238. * @return The class name
  51239. */
  51240. getClassName(): string;
  51241. /**
  51242. * Returns the integer 1.
  51243. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  51244. */
  51245. getTypeID(): number;
  51246. /**
  51247. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  51248. * Returns the DirectionalLight Shadow projection matrix.
  51249. */
  51250. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  51251. /**
  51252. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  51253. * Returns the DirectionalLight Shadow projection matrix.
  51254. */
  51255. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  51256. /**
  51257. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  51258. * Returns the DirectionalLight Shadow projection matrix.
  51259. */
  51260. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  51261. protected _buildUniformLayout(): void;
  51262. /**
  51263. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  51264. * @param effect The effect to update
  51265. * @param lightIndex The index of the light in the effect to update
  51266. * @returns The directional light
  51267. */
  51268. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  51269. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  51270. /**
  51271. * Gets the minZ used for shadow according to both the scene and the light.
  51272. *
  51273. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  51274. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  51275. * @param activeCamera The camera we are returning the min for
  51276. * @returns the depth min z
  51277. */
  51278. getDepthMinZ(activeCamera: Camera): number;
  51279. /**
  51280. * Gets the maxZ 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 max for
  51285. * @returns the depth max z
  51286. */
  51287. getDepthMaxZ(activeCamera: Camera): number;
  51288. /**
  51289. * Prepares the list of defines specific to the light type.
  51290. * @param defines the list of defines
  51291. * @param lightIndex defines the index of the light for the effect
  51292. */
  51293. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  51294. }
  51295. }
  51296. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  51297. import { Mesh } from "babylonjs/Meshes/mesh";
  51298. /**
  51299. * Class containing static functions to help procedurally build meshes
  51300. */
  51301. export class HemisphereBuilder {
  51302. /**
  51303. * Creates a hemisphere mesh
  51304. * @param name defines the name of the mesh
  51305. * @param options defines the options used to create the mesh
  51306. * @param scene defines the hosting scene
  51307. * @returns the hemisphere mesh
  51308. */
  51309. static CreateHemisphere(name: string, options: {
  51310. segments?: number;
  51311. diameter?: number;
  51312. sideOrientation?: number;
  51313. }, scene: any): Mesh;
  51314. }
  51315. }
  51316. declare module "babylonjs/Lights/spotLight" {
  51317. import { Nullable } from "babylonjs/types";
  51318. import { Scene } from "babylonjs/scene";
  51319. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  51320. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51321. import { Effect } from "babylonjs/Materials/effect";
  51322. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51323. import { Light } from "babylonjs/Lights/light";
  51324. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  51325. /**
  51326. * A spot light is defined by a position, a direction, an angle, and an exponent.
  51327. * These values define a cone of light starting from the position, emitting toward the direction.
  51328. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  51329. * and the exponent defines the speed of the decay of the light with distance (reach).
  51330. * Documentation: https://doc.babylonjs.com/babylon101/lights
  51331. */
  51332. export class SpotLight extends ShadowLight {
  51333. private _angle;
  51334. private _innerAngle;
  51335. private _cosHalfAngle;
  51336. private _lightAngleScale;
  51337. private _lightAngleOffset;
  51338. /**
  51339. * Gets the cone angle of the spot light in Radians.
  51340. */
  51341. get angle(): number;
  51342. /**
  51343. * Sets the cone angle of the spot light in Radians.
  51344. */
  51345. set angle(value: number);
  51346. /**
  51347. * Only used in gltf falloff mode, this defines the angle where
  51348. * the directional falloff will start before cutting at angle which could be seen
  51349. * as outer angle.
  51350. */
  51351. get innerAngle(): number;
  51352. /**
  51353. * Only used in gltf falloff mode, this defines the angle where
  51354. * the directional falloff will start before cutting at angle which could be seen
  51355. * as outer angle.
  51356. */
  51357. set innerAngle(value: number);
  51358. private _shadowAngleScale;
  51359. /**
  51360. * Allows scaling the angle of the light for shadow generation only.
  51361. */
  51362. get shadowAngleScale(): number;
  51363. /**
  51364. * Allows scaling the angle of the light for shadow generation only.
  51365. */
  51366. set shadowAngleScale(value: number);
  51367. /**
  51368. * The light decay speed with the distance from the emission spot.
  51369. */
  51370. exponent: number;
  51371. private _projectionTextureMatrix;
  51372. /**
  51373. * Allows reading the projecton texture
  51374. */
  51375. get projectionTextureMatrix(): Matrix;
  51376. protected _projectionTextureLightNear: number;
  51377. /**
  51378. * Gets the near clip of the Spotlight for texture projection.
  51379. */
  51380. get projectionTextureLightNear(): number;
  51381. /**
  51382. * Sets the near clip of the Spotlight for texture projection.
  51383. */
  51384. set projectionTextureLightNear(value: number);
  51385. protected _projectionTextureLightFar: number;
  51386. /**
  51387. * Gets the far clip of the Spotlight for texture projection.
  51388. */
  51389. get projectionTextureLightFar(): number;
  51390. /**
  51391. * Sets the far clip of the Spotlight for texture projection.
  51392. */
  51393. set projectionTextureLightFar(value: number);
  51394. protected _projectionTextureUpDirection: Vector3;
  51395. /**
  51396. * Gets the Up vector of the Spotlight for texture projection.
  51397. */
  51398. get projectionTextureUpDirection(): Vector3;
  51399. /**
  51400. * Sets the Up vector of the Spotlight for texture projection.
  51401. */
  51402. set projectionTextureUpDirection(value: Vector3);
  51403. private _projectionTexture;
  51404. /**
  51405. * Gets the projection texture of the light.
  51406. */
  51407. get projectionTexture(): Nullable<BaseTexture>;
  51408. /**
  51409. * Sets the projection texture of the light.
  51410. */
  51411. set projectionTexture(value: Nullable<BaseTexture>);
  51412. private _projectionTextureViewLightDirty;
  51413. private _projectionTextureProjectionLightDirty;
  51414. private _projectionTextureDirty;
  51415. private _projectionTextureViewTargetVector;
  51416. private _projectionTextureViewLightMatrix;
  51417. private _projectionTextureProjectionLightMatrix;
  51418. private _projectionTextureScalingMatrix;
  51419. /**
  51420. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  51421. * It can cast shadows.
  51422. * Documentation : https://doc.babylonjs.com/babylon101/lights
  51423. * @param name The light friendly name
  51424. * @param position The position of the spot light in the scene
  51425. * @param direction The direction of the light in the scene
  51426. * @param angle The cone angle of the light in Radians
  51427. * @param exponent The light decay speed with the distance from the emission spot
  51428. * @param scene The scene the lights belongs to
  51429. */
  51430. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  51431. /**
  51432. * Returns the string "SpotLight".
  51433. * @returns the class name
  51434. */
  51435. getClassName(): string;
  51436. /**
  51437. * Returns the integer 2.
  51438. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  51439. */
  51440. getTypeID(): number;
  51441. /**
  51442. * Overrides the direction setter to recompute the projection texture view light Matrix.
  51443. */
  51444. protected _setDirection(value: Vector3): void;
  51445. /**
  51446. * Overrides the position setter to recompute the projection texture view light Matrix.
  51447. */
  51448. protected _setPosition(value: Vector3): void;
  51449. /**
  51450. * 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.
  51451. * Returns the SpotLight.
  51452. */
  51453. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  51454. protected _computeProjectionTextureViewLightMatrix(): void;
  51455. protected _computeProjectionTextureProjectionLightMatrix(): void;
  51456. /**
  51457. * Main function for light texture projection matrix computing.
  51458. */
  51459. protected _computeProjectionTextureMatrix(): void;
  51460. protected _buildUniformLayout(): void;
  51461. private _computeAngleValues;
  51462. /**
  51463. * Sets the passed Effect "effect" with the Light textures.
  51464. * @param effect The effect to update
  51465. * @param lightIndex The index of the light in the effect to update
  51466. * @returns The light
  51467. */
  51468. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  51469. /**
  51470. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  51471. * @param effect The effect to update
  51472. * @param lightIndex The index of the light in the effect to update
  51473. * @returns The spot light
  51474. */
  51475. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  51476. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  51477. /**
  51478. * Disposes the light and the associated resources.
  51479. */
  51480. dispose(): void;
  51481. /**
  51482. * Prepares the list of defines specific to the light type.
  51483. * @param defines the list of defines
  51484. * @param lightIndex defines the index of the light for the effect
  51485. */
  51486. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  51487. }
  51488. }
  51489. declare module "babylonjs/Gizmos/lightGizmo" {
  51490. import { Nullable } from "babylonjs/types";
  51491. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  51492. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  51493. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  51494. import { Light } from "babylonjs/Lights/light";
  51495. /**
  51496. * Gizmo that enables viewing a light
  51497. */
  51498. export class LightGizmo extends Gizmo {
  51499. private _lightMesh;
  51500. private _material;
  51501. private _cachedPosition;
  51502. private _cachedForward;
  51503. private _attachedMeshParent;
  51504. /**
  51505. * Creates a LightGizmo
  51506. * @param gizmoLayer The utility layer the gizmo will be added to
  51507. */
  51508. constructor(gizmoLayer?: UtilityLayerRenderer);
  51509. private _light;
  51510. /**
  51511. * The light that the gizmo is attached to
  51512. */
  51513. set light(light: Nullable<Light>);
  51514. get light(): Nullable<Light>;
  51515. /**
  51516. * Gets the material used to render the light gizmo
  51517. */
  51518. get material(): StandardMaterial;
  51519. /**
  51520. * @hidden
  51521. * Updates the gizmo to match the attached mesh's position/rotation
  51522. */
  51523. protected _update(): void;
  51524. private static _Scale;
  51525. /**
  51526. * Creates the lines for a light mesh
  51527. */
  51528. private static _CreateLightLines;
  51529. /**
  51530. * Disposes of the light gizmo
  51531. */
  51532. dispose(): void;
  51533. private static _CreateHemisphericLightMesh;
  51534. private static _CreatePointLightMesh;
  51535. private static _CreateSpotLightMesh;
  51536. private static _CreateDirectionalLightMesh;
  51537. }
  51538. }
  51539. declare module "babylonjs/Gizmos/index" {
  51540. export * from "babylonjs/Gizmos/axisDragGizmo";
  51541. export * from "babylonjs/Gizmos/axisScaleGizmo";
  51542. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  51543. export * from "babylonjs/Gizmos/gizmo";
  51544. export * from "babylonjs/Gizmos/gizmoManager";
  51545. export * from "babylonjs/Gizmos/planeRotationGizmo";
  51546. export * from "babylonjs/Gizmos/positionGizmo";
  51547. export * from "babylonjs/Gizmos/rotationGizmo";
  51548. export * from "babylonjs/Gizmos/scaleGizmo";
  51549. export * from "babylonjs/Gizmos/lightGizmo";
  51550. export * from "babylonjs/Gizmos/planeDragGizmo";
  51551. }
  51552. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  51553. /** @hidden */
  51554. export var backgroundFragmentDeclaration: {
  51555. name: string;
  51556. shader: string;
  51557. };
  51558. }
  51559. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  51560. /** @hidden */
  51561. export var backgroundUboDeclaration: {
  51562. name: string;
  51563. shader: string;
  51564. };
  51565. }
  51566. declare module "babylonjs/Shaders/background.fragment" {
  51567. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  51568. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  51569. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  51570. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  51571. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  51572. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  51573. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  51574. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  51575. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  51576. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  51577. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  51578. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  51579. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  51580. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  51581. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  51582. /** @hidden */
  51583. export var backgroundPixelShader: {
  51584. name: string;
  51585. shader: string;
  51586. };
  51587. }
  51588. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  51589. /** @hidden */
  51590. export var backgroundVertexDeclaration: {
  51591. name: string;
  51592. shader: string;
  51593. };
  51594. }
  51595. declare module "babylonjs/Shaders/background.vertex" {
  51596. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  51597. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  51598. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  51599. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  51600. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  51601. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  51602. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  51603. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  51604. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  51605. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  51606. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  51607. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  51608. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  51609. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  51610. /** @hidden */
  51611. export var backgroundVertexShader: {
  51612. name: string;
  51613. shader: string;
  51614. };
  51615. }
  51616. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  51617. import { Nullable, int, float } from "babylonjs/types";
  51618. import { Scene } from "babylonjs/scene";
  51619. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  51620. import { SubMesh } from "babylonjs/Meshes/subMesh";
  51621. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51622. import { Mesh } from "babylonjs/Meshes/mesh";
  51623. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  51624. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  51625. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  51626. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51627. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  51628. import { Color3 } from "babylonjs/Maths/math.color";
  51629. import "babylonjs/Shaders/background.fragment";
  51630. import "babylonjs/Shaders/background.vertex";
  51631. /**
  51632. * Background material used to create an efficient environement around your scene.
  51633. */
  51634. export class BackgroundMaterial extends PushMaterial {
  51635. /**
  51636. * Standard reflectance value at parallel view angle.
  51637. */
  51638. static StandardReflectance0: number;
  51639. /**
  51640. * Standard reflectance value at grazing angle.
  51641. */
  51642. static StandardReflectance90: number;
  51643. protected _primaryColor: Color3;
  51644. /**
  51645. * Key light Color (multiply against the environement texture)
  51646. */
  51647. primaryColor: Color3;
  51648. protected __perceptualColor: Nullable<Color3>;
  51649. /**
  51650. * Experimental Internal Use Only.
  51651. *
  51652. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  51653. * This acts as a helper to set the primary color to a more "human friendly" value.
  51654. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  51655. * output color as close as possible from the chosen value.
  51656. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  51657. * part of lighting setup.)
  51658. */
  51659. get _perceptualColor(): Nullable<Color3>;
  51660. set _perceptualColor(value: Nullable<Color3>);
  51661. protected _primaryColorShadowLevel: float;
  51662. /**
  51663. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  51664. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  51665. */
  51666. get primaryColorShadowLevel(): float;
  51667. set primaryColorShadowLevel(value: float);
  51668. protected _primaryColorHighlightLevel: float;
  51669. /**
  51670. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  51671. * The primary color is used at the level chosen to define what the white area would look.
  51672. */
  51673. get primaryColorHighlightLevel(): float;
  51674. set primaryColorHighlightLevel(value: float);
  51675. protected _reflectionTexture: Nullable<BaseTexture>;
  51676. /**
  51677. * Reflection Texture used in the material.
  51678. * Should be author in a specific way for the best result (refer to the documentation).
  51679. */
  51680. reflectionTexture: Nullable<BaseTexture>;
  51681. protected _reflectionBlur: float;
  51682. /**
  51683. * Reflection Texture level of blur.
  51684. *
  51685. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  51686. * texture twice.
  51687. */
  51688. reflectionBlur: float;
  51689. protected _diffuseTexture: Nullable<BaseTexture>;
  51690. /**
  51691. * Diffuse Texture used in the material.
  51692. * Should be author in a specific way for the best result (refer to the documentation).
  51693. */
  51694. diffuseTexture: Nullable<BaseTexture>;
  51695. protected _shadowLights: Nullable<IShadowLight[]>;
  51696. /**
  51697. * Specify the list of lights casting shadow on the material.
  51698. * All scene shadow lights will be included if null.
  51699. */
  51700. shadowLights: Nullable<IShadowLight[]>;
  51701. protected _shadowLevel: float;
  51702. /**
  51703. * Helps adjusting the shadow to a softer level if required.
  51704. * 0 means black shadows and 1 means no shadows.
  51705. */
  51706. shadowLevel: float;
  51707. protected _sceneCenter: Vector3;
  51708. /**
  51709. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  51710. * It is usually zero but might be interesting to modify according to your setup.
  51711. */
  51712. sceneCenter: Vector3;
  51713. protected _opacityFresnel: boolean;
  51714. /**
  51715. * This helps specifying that the material is falling off to the sky box at grazing angle.
  51716. * This helps ensuring a nice transition when the camera goes under the ground.
  51717. */
  51718. opacityFresnel: boolean;
  51719. protected _reflectionFresnel: boolean;
  51720. /**
  51721. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  51722. * This helps adding a mirror texture on the ground.
  51723. */
  51724. reflectionFresnel: boolean;
  51725. protected _reflectionFalloffDistance: number;
  51726. /**
  51727. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  51728. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  51729. */
  51730. reflectionFalloffDistance: number;
  51731. protected _reflectionAmount: number;
  51732. /**
  51733. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  51734. */
  51735. reflectionAmount: number;
  51736. protected _reflectionReflectance0: number;
  51737. /**
  51738. * This specifies the weight of the reflection at grazing angle.
  51739. */
  51740. reflectionReflectance0: number;
  51741. protected _reflectionReflectance90: number;
  51742. /**
  51743. * This specifies the weight of the reflection at a perpendicular point of view.
  51744. */
  51745. reflectionReflectance90: number;
  51746. /**
  51747. * Sets the reflection reflectance fresnel values according to the default standard
  51748. * empirically know to work well :-)
  51749. */
  51750. set reflectionStandardFresnelWeight(value: number);
  51751. protected _useRGBColor: boolean;
  51752. /**
  51753. * Helps to directly use the maps channels instead of their level.
  51754. */
  51755. useRGBColor: boolean;
  51756. protected _enableNoise: boolean;
  51757. /**
  51758. * This helps reducing the banding effect that could occur on the background.
  51759. */
  51760. enableNoise: boolean;
  51761. /**
  51762. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  51763. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  51764. * Recommended to be keep at 1.0 except for special cases.
  51765. */
  51766. get fovMultiplier(): number;
  51767. set fovMultiplier(value: number);
  51768. private _fovMultiplier;
  51769. /**
  51770. * Enable the FOV adjustment feature controlled by fovMultiplier.
  51771. */
  51772. useEquirectangularFOV: boolean;
  51773. private _maxSimultaneousLights;
  51774. /**
  51775. * Number of Simultaneous lights allowed on the material.
  51776. */
  51777. maxSimultaneousLights: int;
  51778. /**
  51779. * Default configuration related to image processing available in the Background Material.
  51780. */
  51781. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  51782. /**
  51783. * Keep track of the image processing observer to allow dispose and replace.
  51784. */
  51785. private _imageProcessingObserver;
  51786. /**
  51787. * Attaches a new image processing configuration to the PBR Material.
  51788. * @param configuration (if null the scene configuration will be use)
  51789. */
  51790. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  51791. /**
  51792. * Gets the image processing configuration used either in this material.
  51793. */
  51794. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  51795. /**
  51796. * Sets the Default image processing configuration used either in the this material.
  51797. *
  51798. * If sets to null, the scene one is in use.
  51799. */
  51800. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  51801. /**
  51802. * Gets wether the color curves effect is enabled.
  51803. */
  51804. get cameraColorCurvesEnabled(): boolean;
  51805. /**
  51806. * Sets wether the color curves effect is enabled.
  51807. */
  51808. set cameraColorCurvesEnabled(value: boolean);
  51809. /**
  51810. * Gets wether the color grading effect is enabled.
  51811. */
  51812. get cameraColorGradingEnabled(): boolean;
  51813. /**
  51814. * Gets wether the color grading effect is enabled.
  51815. */
  51816. set cameraColorGradingEnabled(value: boolean);
  51817. /**
  51818. * Gets wether tonemapping is enabled or not.
  51819. */
  51820. get cameraToneMappingEnabled(): boolean;
  51821. /**
  51822. * Sets wether tonemapping is enabled or not
  51823. */
  51824. set cameraToneMappingEnabled(value: boolean);
  51825. /**
  51826. * The camera exposure used on this material.
  51827. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  51828. * This corresponds to a photographic exposure.
  51829. */
  51830. get cameraExposure(): float;
  51831. /**
  51832. * The camera exposure used on this material.
  51833. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  51834. * This corresponds to a photographic exposure.
  51835. */
  51836. set cameraExposure(value: float);
  51837. /**
  51838. * Gets The camera contrast used on this material.
  51839. */
  51840. get cameraContrast(): float;
  51841. /**
  51842. * Sets The camera contrast used on this material.
  51843. */
  51844. set cameraContrast(value: float);
  51845. /**
  51846. * Gets the Color Grading 2D Lookup Texture.
  51847. */
  51848. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  51849. /**
  51850. * Sets the Color Grading 2D Lookup Texture.
  51851. */
  51852. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  51853. /**
  51854. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  51855. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  51856. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  51857. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  51858. */
  51859. get cameraColorCurves(): Nullable<ColorCurves>;
  51860. /**
  51861. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  51862. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  51863. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  51864. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  51865. */
  51866. set cameraColorCurves(value: Nullable<ColorCurves>);
  51867. /**
  51868. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  51869. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  51870. */
  51871. switchToBGR: boolean;
  51872. private _renderTargets;
  51873. private _reflectionControls;
  51874. private _white;
  51875. private _primaryShadowColor;
  51876. private _primaryHighlightColor;
  51877. /**
  51878. * Instantiates a Background Material in the given scene
  51879. * @param name The friendly name of the material
  51880. * @param scene The scene to add the material to
  51881. */
  51882. constructor(name: string, scene: Scene);
  51883. /**
  51884. * Gets a boolean indicating that current material needs to register RTT
  51885. */
  51886. get hasRenderTargetTextures(): boolean;
  51887. /**
  51888. * The entire material has been created in order to prevent overdraw.
  51889. * @returns false
  51890. */
  51891. needAlphaTesting(): boolean;
  51892. /**
  51893. * The entire material has been created in order to prevent overdraw.
  51894. * @returns true if blending is enable
  51895. */
  51896. needAlphaBlending(): boolean;
  51897. /**
  51898. * Checks wether the material is ready to be rendered for a given mesh.
  51899. * @param mesh The mesh to render
  51900. * @param subMesh The submesh to check against
  51901. * @param useInstances Specify wether or not the material is used with instances
  51902. * @returns true if all the dependencies are ready (Textures, Effects...)
  51903. */
  51904. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  51905. /**
  51906. * Compute the primary color according to the chosen perceptual color.
  51907. */
  51908. private _computePrimaryColorFromPerceptualColor;
  51909. /**
  51910. * Compute the highlights and shadow colors according to their chosen levels.
  51911. */
  51912. private _computePrimaryColors;
  51913. /**
  51914. * Build the uniform buffer used in the material.
  51915. */
  51916. buildUniformLayout(): void;
  51917. /**
  51918. * Unbind the material.
  51919. */
  51920. unbind(): void;
  51921. /**
  51922. * Bind only the world matrix to the material.
  51923. * @param world The world matrix to bind.
  51924. */
  51925. bindOnlyWorldMatrix(world: Matrix): void;
  51926. /**
  51927. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  51928. * @param world The world matrix to bind.
  51929. * @param subMesh The submesh to bind for.
  51930. */
  51931. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  51932. /**
  51933. * Checks to see if a texture is used in the material.
  51934. * @param texture - Base texture to use.
  51935. * @returns - Boolean specifying if a texture is used in the material.
  51936. */
  51937. hasTexture(texture: BaseTexture): boolean;
  51938. /**
  51939. * Dispose the material.
  51940. * @param forceDisposeEffect Force disposal of the associated effect.
  51941. * @param forceDisposeTextures Force disposal of the associated textures.
  51942. */
  51943. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  51944. /**
  51945. * Clones the material.
  51946. * @param name The cloned name.
  51947. * @returns The cloned material.
  51948. */
  51949. clone(name: string): BackgroundMaterial;
  51950. /**
  51951. * Serializes the current material to its JSON representation.
  51952. * @returns The JSON representation.
  51953. */
  51954. serialize(): any;
  51955. /**
  51956. * Gets the class name of the material
  51957. * @returns "BackgroundMaterial"
  51958. */
  51959. getClassName(): string;
  51960. /**
  51961. * Parse a JSON input to create back a background material.
  51962. * @param source The JSON data to parse
  51963. * @param scene The scene to create the parsed material in
  51964. * @param rootUrl The root url of the assets the material depends upon
  51965. * @returns the instantiated BackgroundMaterial.
  51966. */
  51967. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  51968. }
  51969. }
  51970. declare module "babylonjs/Helpers/environmentHelper" {
  51971. import { Observable } from "babylonjs/Misc/observable";
  51972. import { Nullable } from "babylonjs/types";
  51973. import { Scene } from "babylonjs/scene";
  51974. import { Vector3 } from "babylonjs/Maths/math.vector";
  51975. import { Color3 } from "babylonjs/Maths/math.color";
  51976. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51977. import { Mesh } from "babylonjs/Meshes/mesh";
  51978. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51979. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  51980. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  51981. import "babylonjs/Meshes/Builders/planeBuilder";
  51982. import "babylonjs/Meshes/Builders/boxBuilder";
  51983. /**
  51984. * Represents the different options available during the creation of
  51985. * a Environment helper.
  51986. *
  51987. * This can control the default ground, skybox and image processing setup of your scene.
  51988. */
  51989. export interface IEnvironmentHelperOptions {
  51990. /**
  51991. * Specifies whether or not to create a ground.
  51992. * True by default.
  51993. */
  51994. createGround: boolean;
  51995. /**
  51996. * Specifies the ground size.
  51997. * 15 by default.
  51998. */
  51999. groundSize: number;
  52000. /**
  52001. * The texture used on the ground for the main color.
  52002. * Comes from the BabylonJS CDN by default.
  52003. *
  52004. * Remarks: Can be either a texture or a url.
  52005. */
  52006. groundTexture: string | BaseTexture;
  52007. /**
  52008. * The color mixed in the ground texture by default.
  52009. * BabylonJS clearColor by default.
  52010. */
  52011. groundColor: Color3;
  52012. /**
  52013. * Specifies the ground opacity.
  52014. * 1 by default.
  52015. */
  52016. groundOpacity: number;
  52017. /**
  52018. * Enables the ground to receive shadows.
  52019. * True by default.
  52020. */
  52021. enableGroundShadow: boolean;
  52022. /**
  52023. * Helps preventing the shadow to be fully black on the ground.
  52024. * 0.5 by default.
  52025. */
  52026. groundShadowLevel: number;
  52027. /**
  52028. * Creates a mirror texture attach to the ground.
  52029. * false by default.
  52030. */
  52031. enableGroundMirror: boolean;
  52032. /**
  52033. * Specifies the ground mirror size ratio.
  52034. * 0.3 by default as the default kernel is 64.
  52035. */
  52036. groundMirrorSizeRatio: number;
  52037. /**
  52038. * Specifies the ground mirror blur kernel size.
  52039. * 64 by default.
  52040. */
  52041. groundMirrorBlurKernel: number;
  52042. /**
  52043. * Specifies the ground mirror visibility amount.
  52044. * 1 by default
  52045. */
  52046. groundMirrorAmount: number;
  52047. /**
  52048. * Specifies the ground mirror reflectance weight.
  52049. * This uses the standard weight of the background material to setup the fresnel effect
  52050. * of the mirror.
  52051. * 1 by default.
  52052. */
  52053. groundMirrorFresnelWeight: number;
  52054. /**
  52055. * Specifies the ground mirror Falloff distance.
  52056. * This can helps reducing the size of the reflection.
  52057. * 0 by Default.
  52058. */
  52059. groundMirrorFallOffDistance: number;
  52060. /**
  52061. * Specifies the ground mirror texture type.
  52062. * Unsigned Int by Default.
  52063. */
  52064. groundMirrorTextureType: number;
  52065. /**
  52066. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  52067. * the shown objects.
  52068. */
  52069. groundYBias: number;
  52070. /**
  52071. * Specifies whether or not to create a skybox.
  52072. * True by default.
  52073. */
  52074. createSkybox: boolean;
  52075. /**
  52076. * Specifies the skybox size.
  52077. * 20 by default.
  52078. */
  52079. skyboxSize: number;
  52080. /**
  52081. * The texture used on the skybox for the main color.
  52082. * Comes from the BabylonJS CDN by default.
  52083. *
  52084. * Remarks: Can be either a texture or a url.
  52085. */
  52086. skyboxTexture: string | BaseTexture;
  52087. /**
  52088. * The color mixed in the skybox texture by default.
  52089. * BabylonJS clearColor by default.
  52090. */
  52091. skyboxColor: Color3;
  52092. /**
  52093. * The background rotation around the Y axis of the scene.
  52094. * This helps aligning the key lights of your scene with the background.
  52095. * 0 by default.
  52096. */
  52097. backgroundYRotation: number;
  52098. /**
  52099. * Compute automatically the size of the elements to best fit with the scene.
  52100. */
  52101. sizeAuto: boolean;
  52102. /**
  52103. * Default position of the rootMesh if autoSize is not true.
  52104. */
  52105. rootPosition: Vector3;
  52106. /**
  52107. * Sets up the image processing in the scene.
  52108. * true by default.
  52109. */
  52110. setupImageProcessing: boolean;
  52111. /**
  52112. * The texture used as your environment texture in the scene.
  52113. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  52114. *
  52115. * Remarks: Can be either a texture or a url.
  52116. */
  52117. environmentTexture: string | BaseTexture;
  52118. /**
  52119. * The value of the exposure to apply to the scene.
  52120. * 0.6 by default if setupImageProcessing is true.
  52121. */
  52122. cameraExposure: number;
  52123. /**
  52124. * The value of the contrast to apply to the scene.
  52125. * 1.6 by default if setupImageProcessing is true.
  52126. */
  52127. cameraContrast: number;
  52128. /**
  52129. * Specifies whether or not tonemapping should be enabled in the scene.
  52130. * true by default if setupImageProcessing is true.
  52131. */
  52132. toneMappingEnabled: boolean;
  52133. }
  52134. /**
  52135. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  52136. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  52137. * It also helps with the default setup of your imageProcessing configuration.
  52138. */
  52139. export class EnvironmentHelper {
  52140. /**
  52141. * Default ground texture URL.
  52142. */
  52143. private static _groundTextureCDNUrl;
  52144. /**
  52145. * Default skybox texture URL.
  52146. */
  52147. private static _skyboxTextureCDNUrl;
  52148. /**
  52149. * Default environment texture URL.
  52150. */
  52151. private static _environmentTextureCDNUrl;
  52152. /**
  52153. * Creates the default options for the helper.
  52154. */
  52155. private static _getDefaultOptions;
  52156. private _rootMesh;
  52157. /**
  52158. * Gets the root mesh created by the helper.
  52159. */
  52160. get rootMesh(): Mesh;
  52161. private _skybox;
  52162. /**
  52163. * Gets the skybox created by the helper.
  52164. */
  52165. get skybox(): Nullable<Mesh>;
  52166. private _skyboxTexture;
  52167. /**
  52168. * Gets the skybox texture created by the helper.
  52169. */
  52170. get skyboxTexture(): Nullable<BaseTexture>;
  52171. private _skyboxMaterial;
  52172. /**
  52173. * Gets the skybox material created by the helper.
  52174. */
  52175. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  52176. private _ground;
  52177. /**
  52178. * Gets the ground mesh created by the helper.
  52179. */
  52180. get ground(): Nullable<Mesh>;
  52181. private _groundTexture;
  52182. /**
  52183. * Gets the ground texture created by the helper.
  52184. */
  52185. get groundTexture(): Nullable<BaseTexture>;
  52186. private _groundMirror;
  52187. /**
  52188. * Gets the ground mirror created by the helper.
  52189. */
  52190. get groundMirror(): Nullable<MirrorTexture>;
  52191. /**
  52192. * Gets the ground mirror render list to helps pushing the meshes
  52193. * you wish in the ground reflection.
  52194. */
  52195. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  52196. private _groundMaterial;
  52197. /**
  52198. * Gets the ground material created by the helper.
  52199. */
  52200. get groundMaterial(): Nullable<BackgroundMaterial>;
  52201. /**
  52202. * Stores the creation options.
  52203. */
  52204. private readonly _scene;
  52205. private _options;
  52206. /**
  52207. * This observable will be notified with any error during the creation of the environment,
  52208. * mainly texture creation errors.
  52209. */
  52210. onErrorObservable: Observable<{
  52211. message?: string;
  52212. exception?: any;
  52213. }>;
  52214. /**
  52215. * constructor
  52216. * @param options Defines the options we want to customize the helper
  52217. * @param scene The scene to add the material to
  52218. */
  52219. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  52220. /**
  52221. * Updates the background according to the new options
  52222. * @param options
  52223. */
  52224. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  52225. /**
  52226. * Sets the primary color of all the available elements.
  52227. * @param color the main color to affect to the ground and the background
  52228. */
  52229. setMainColor(color: Color3): void;
  52230. /**
  52231. * Setup the image processing according to the specified options.
  52232. */
  52233. private _setupImageProcessing;
  52234. /**
  52235. * Setup the environment texture according to the specified options.
  52236. */
  52237. private _setupEnvironmentTexture;
  52238. /**
  52239. * Setup the background according to the specified options.
  52240. */
  52241. private _setupBackground;
  52242. /**
  52243. * Get the scene sizes according to the setup.
  52244. */
  52245. private _getSceneSize;
  52246. /**
  52247. * Setup the ground according to the specified options.
  52248. */
  52249. private _setupGround;
  52250. /**
  52251. * Setup the ground material according to the specified options.
  52252. */
  52253. private _setupGroundMaterial;
  52254. /**
  52255. * Setup the ground diffuse texture according to the specified options.
  52256. */
  52257. private _setupGroundDiffuseTexture;
  52258. /**
  52259. * Setup the ground mirror texture according to the specified options.
  52260. */
  52261. private _setupGroundMirrorTexture;
  52262. /**
  52263. * Setup the ground to receive the mirror texture.
  52264. */
  52265. private _setupMirrorInGroundMaterial;
  52266. /**
  52267. * Setup the skybox according to the specified options.
  52268. */
  52269. private _setupSkybox;
  52270. /**
  52271. * Setup the skybox material according to the specified options.
  52272. */
  52273. private _setupSkyboxMaterial;
  52274. /**
  52275. * Setup the skybox reflection texture according to the specified options.
  52276. */
  52277. private _setupSkyboxReflectionTexture;
  52278. private _errorHandler;
  52279. /**
  52280. * Dispose all the elements created by the Helper.
  52281. */
  52282. dispose(): void;
  52283. }
  52284. }
  52285. declare module "babylonjs/Helpers/photoDome" {
  52286. import { Observable } from "babylonjs/Misc/observable";
  52287. import { Nullable } from "babylonjs/types";
  52288. import { Scene } from "babylonjs/scene";
  52289. import { TransformNode } from "babylonjs/Meshes/transformNode";
  52290. import { Mesh } from "babylonjs/Meshes/mesh";
  52291. import { Texture } from "babylonjs/Materials/Textures/texture";
  52292. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  52293. import "babylonjs/Meshes/Builders/sphereBuilder";
  52294. /**
  52295. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  52296. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  52297. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  52298. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  52299. */
  52300. export class PhotoDome extends TransformNode {
  52301. /**
  52302. * Define the image as a Monoscopic panoramic 360 image.
  52303. */
  52304. static readonly MODE_MONOSCOPIC: number;
  52305. /**
  52306. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  52307. */
  52308. static readonly MODE_TOPBOTTOM: number;
  52309. /**
  52310. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  52311. */
  52312. static readonly MODE_SIDEBYSIDE: number;
  52313. private _useDirectMapping;
  52314. /**
  52315. * The texture being displayed on the sphere
  52316. */
  52317. protected _photoTexture: Texture;
  52318. /**
  52319. * Gets or sets the texture being displayed on the sphere
  52320. */
  52321. get photoTexture(): Texture;
  52322. set photoTexture(value: Texture);
  52323. /**
  52324. * Observable raised when an error occured while loading the 360 image
  52325. */
  52326. onLoadErrorObservable: Observable<string>;
  52327. /**
  52328. * The skybox material
  52329. */
  52330. protected _material: BackgroundMaterial;
  52331. /**
  52332. * The surface used for the skybox
  52333. */
  52334. protected _mesh: Mesh;
  52335. /**
  52336. * Gets the mesh used for the skybox.
  52337. */
  52338. get mesh(): Mesh;
  52339. /**
  52340. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  52341. * Also see the options.resolution property.
  52342. */
  52343. get fovMultiplier(): number;
  52344. set fovMultiplier(value: number);
  52345. private _imageMode;
  52346. /**
  52347. * Gets or set the current video mode for the video. It can be:
  52348. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  52349. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  52350. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  52351. */
  52352. get imageMode(): number;
  52353. set imageMode(value: number);
  52354. /**
  52355. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  52356. * @param name Element's name, child elements will append suffixes for their own names.
  52357. * @param urlsOfPhoto defines the url of the photo to display
  52358. * @param options defines an object containing optional or exposed sub element properties
  52359. * @param onError defines a callback called when an error occured while loading the texture
  52360. */
  52361. constructor(name: string, urlOfPhoto: string, options: {
  52362. resolution?: number;
  52363. size?: number;
  52364. useDirectMapping?: boolean;
  52365. faceForward?: boolean;
  52366. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  52367. private _onBeforeCameraRenderObserver;
  52368. private _changeImageMode;
  52369. /**
  52370. * Releases resources associated with this node.
  52371. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  52372. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  52373. */
  52374. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  52375. }
  52376. }
  52377. declare module "babylonjs/Misc/rgbdTextureTools" {
  52378. import "babylonjs/Shaders/rgbdDecode.fragment";
  52379. import "babylonjs/Engines/Extensions/engine.renderTarget";
  52380. import { Texture } from "babylonjs/Materials/Textures/texture";
  52381. /**
  52382. * Class used to host RGBD texture specific utilities
  52383. */
  52384. export class RGBDTextureTools {
  52385. /**
  52386. * Expand the RGBD Texture from RGBD to Half Float if possible.
  52387. * @param texture the texture to expand.
  52388. */
  52389. static ExpandRGBDTexture(texture: Texture): void;
  52390. }
  52391. }
  52392. declare module "babylonjs/Misc/brdfTextureTools" {
  52393. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52394. import { Scene } from "babylonjs/scene";
  52395. /**
  52396. * Class used to host texture specific utilities
  52397. */
  52398. export class BRDFTextureTools {
  52399. /**
  52400. * Prevents texture cache collision
  52401. */
  52402. private static _instanceNumber;
  52403. /**
  52404. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  52405. * @param scene defines the hosting scene
  52406. * @returns the environment BRDF texture
  52407. */
  52408. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  52409. private static _environmentBRDFBase64Texture;
  52410. }
  52411. }
  52412. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  52413. import { Nullable } from "babylonjs/types";
  52414. import { Color3 } from "babylonjs/Maths/math.color";
  52415. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52416. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  52417. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  52418. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  52419. import { Engine } from "babylonjs/Engines/engine";
  52420. import { Scene } from "babylonjs/scene";
  52421. /**
  52422. * @hidden
  52423. */
  52424. export interface IMaterialClearCoatDefines {
  52425. CLEARCOAT: boolean;
  52426. CLEARCOAT_DEFAULTIOR: boolean;
  52427. CLEARCOAT_TEXTURE: boolean;
  52428. CLEARCOAT_TEXTUREDIRECTUV: number;
  52429. CLEARCOAT_BUMP: boolean;
  52430. CLEARCOAT_BUMPDIRECTUV: number;
  52431. CLEARCOAT_TINT: boolean;
  52432. CLEARCOAT_TINT_TEXTURE: boolean;
  52433. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  52434. /** @hidden */
  52435. _areTexturesDirty: boolean;
  52436. }
  52437. /**
  52438. * Define the code related to the clear coat parameters of the pbr material.
  52439. */
  52440. export class PBRClearCoatConfiguration {
  52441. /**
  52442. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  52443. * The default fits with a polyurethane material.
  52444. */
  52445. private static readonly _DefaultIndexOfRefraction;
  52446. private _isEnabled;
  52447. /**
  52448. * Defines if the clear coat is enabled in the material.
  52449. */
  52450. isEnabled: boolean;
  52451. /**
  52452. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  52453. */
  52454. intensity: number;
  52455. /**
  52456. * Defines the clear coat layer roughness.
  52457. */
  52458. roughness: number;
  52459. private _indexOfRefraction;
  52460. /**
  52461. * Defines the index of refraction of the clear coat.
  52462. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  52463. * The default fits with a polyurethane material.
  52464. * Changing the default value is more performance intensive.
  52465. */
  52466. indexOfRefraction: number;
  52467. private _texture;
  52468. /**
  52469. * Stores the clear coat values in a texture.
  52470. */
  52471. texture: Nullable<BaseTexture>;
  52472. private _bumpTexture;
  52473. /**
  52474. * Define the clear coat specific bump texture.
  52475. */
  52476. bumpTexture: Nullable<BaseTexture>;
  52477. private _isTintEnabled;
  52478. /**
  52479. * Defines if the clear coat tint is enabled in the material.
  52480. */
  52481. isTintEnabled: boolean;
  52482. /**
  52483. * Defines the clear coat tint of the material.
  52484. * This is only use if tint is enabled
  52485. */
  52486. tintColor: Color3;
  52487. /**
  52488. * Defines the distance at which the tint color should be found in the
  52489. * clear coat media.
  52490. * This is only use if tint is enabled
  52491. */
  52492. tintColorAtDistance: number;
  52493. /**
  52494. * Defines the clear coat layer thickness.
  52495. * This is only use if tint is enabled
  52496. */
  52497. tintThickness: number;
  52498. private _tintTexture;
  52499. /**
  52500. * Stores the clear tint values in a texture.
  52501. * rgb is tint
  52502. * a is a thickness factor
  52503. */
  52504. tintTexture: Nullable<BaseTexture>;
  52505. /** @hidden */
  52506. private _internalMarkAllSubMeshesAsTexturesDirty;
  52507. /** @hidden */
  52508. _markAllSubMeshesAsTexturesDirty(): void;
  52509. /**
  52510. * Instantiate a new istance of clear coat configuration.
  52511. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  52512. */
  52513. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  52514. /**
  52515. * Gets wehter the submesh is ready to be used or not.
  52516. * @param defines the list of "defines" to update.
  52517. * @param scene defines the scene the material belongs to.
  52518. * @param engine defines the engine the material belongs to.
  52519. * @param disableBumpMap defines wether the material disables bump or not.
  52520. * @returns - boolean indicating that the submesh is ready or not.
  52521. */
  52522. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  52523. /**
  52524. * Checks to see if a texture is used in the material.
  52525. * @param defines the list of "defines" to update.
  52526. * @param scene defines the scene to the material belongs to.
  52527. */
  52528. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  52529. /**
  52530. * Binds the material data.
  52531. * @param uniformBuffer defines the Uniform buffer to fill in.
  52532. * @param scene defines the scene the material belongs to.
  52533. * @param engine defines the engine the material belongs to.
  52534. * @param disableBumpMap defines wether the material disables bump or not.
  52535. * @param isFrozen defines wether the material is frozen or not.
  52536. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  52537. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  52538. */
  52539. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  52540. /**
  52541. * Checks to see if a texture is used in the material.
  52542. * @param texture - Base texture to use.
  52543. * @returns - Boolean specifying if a texture is used in the material.
  52544. */
  52545. hasTexture(texture: BaseTexture): boolean;
  52546. /**
  52547. * Returns an array of the actively used textures.
  52548. * @param activeTextures Array of BaseTextures
  52549. */
  52550. getActiveTextures(activeTextures: BaseTexture[]): void;
  52551. /**
  52552. * Returns the animatable textures.
  52553. * @param animatables Array of animatable textures.
  52554. */
  52555. getAnimatables(animatables: IAnimatable[]): void;
  52556. /**
  52557. * Disposes the resources of the material.
  52558. * @param forceDisposeTextures - Forces the disposal of all textures.
  52559. */
  52560. dispose(forceDisposeTextures?: boolean): void;
  52561. /**
  52562. * Get the current class name of the texture useful for serialization or dynamic coding.
  52563. * @returns "PBRClearCoatConfiguration"
  52564. */
  52565. getClassName(): string;
  52566. /**
  52567. * Add fallbacks to the effect fallbacks list.
  52568. * @param defines defines the Base texture to use.
  52569. * @param fallbacks defines the current fallback list.
  52570. * @param currentRank defines the current fallback rank.
  52571. * @returns the new fallback rank.
  52572. */
  52573. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  52574. /**
  52575. * Add the required uniforms to the current list.
  52576. * @param uniforms defines the current uniform list.
  52577. */
  52578. static AddUniforms(uniforms: string[]): void;
  52579. /**
  52580. * Add the required samplers to the current list.
  52581. * @param samplers defines the current sampler list.
  52582. */
  52583. static AddSamplers(samplers: string[]): void;
  52584. /**
  52585. * Add the required uniforms to the current buffer.
  52586. * @param uniformBuffer defines the current uniform buffer.
  52587. */
  52588. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  52589. /**
  52590. * Makes a duplicate of the current configuration into another one.
  52591. * @param clearCoatConfiguration define the config where to copy the info
  52592. */
  52593. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  52594. /**
  52595. * Serializes this clear coat configuration.
  52596. * @returns - An object with the serialized config.
  52597. */
  52598. serialize(): any;
  52599. /**
  52600. * Parses a anisotropy Configuration from a serialized object.
  52601. * @param source - Serialized object.
  52602. * @param scene Defines the scene we are parsing for
  52603. * @param rootUrl Defines the rootUrl to load from
  52604. */
  52605. parse(source: any, scene: Scene, rootUrl: string): void;
  52606. }
  52607. }
  52608. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  52609. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  52610. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52611. import { Vector2 } from "babylonjs/Maths/math.vector";
  52612. import { Scene } from "babylonjs/scene";
  52613. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52614. import { Nullable } from "babylonjs/types";
  52615. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  52616. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  52617. /**
  52618. * @hidden
  52619. */
  52620. export interface IMaterialAnisotropicDefines {
  52621. ANISOTROPIC: boolean;
  52622. ANISOTROPIC_TEXTURE: boolean;
  52623. ANISOTROPIC_TEXTUREDIRECTUV: number;
  52624. MAINUV1: boolean;
  52625. _areTexturesDirty: boolean;
  52626. _needUVs: boolean;
  52627. }
  52628. /**
  52629. * Define the code related to the anisotropic parameters of the pbr material.
  52630. */
  52631. export class PBRAnisotropicConfiguration {
  52632. private _isEnabled;
  52633. /**
  52634. * Defines if the anisotropy is enabled in the material.
  52635. */
  52636. isEnabled: boolean;
  52637. /**
  52638. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  52639. */
  52640. intensity: number;
  52641. /**
  52642. * Defines if the effect is along the tangents, bitangents or in between.
  52643. * By default, the effect is "strectching" the highlights along the tangents.
  52644. */
  52645. direction: Vector2;
  52646. private _texture;
  52647. /**
  52648. * Stores the anisotropy values in a texture.
  52649. * rg is direction (like normal from -1 to 1)
  52650. * b is a intensity
  52651. */
  52652. texture: Nullable<BaseTexture>;
  52653. /** @hidden */
  52654. private _internalMarkAllSubMeshesAsTexturesDirty;
  52655. /** @hidden */
  52656. _markAllSubMeshesAsTexturesDirty(): void;
  52657. /**
  52658. * Instantiate a new istance of anisotropy configuration.
  52659. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  52660. */
  52661. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  52662. /**
  52663. * Specifies that the submesh is ready to be used.
  52664. * @param defines the list of "defines" to update.
  52665. * @param scene defines the scene the material belongs to.
  52666. * @returns - boolean indicating that the submesh is ready or not.
  52667. */
  52668. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  52669. /**
  52670. * Checks to see if a texture is used in the material.
  52671. * @param defines the list of "defines" to update.
  52672. * @param mesh the mesh we are preparing the defines for.
  52673. * @param scene defines the scene the material belongs to.
  52674. */
  52675. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  52676. /**
  52677. * Binds the material data.
  52678. * @param uniformBuffer defines the Uniform buffer to fill in.
  52679. * @param scene defines the scene the material belongs to.
  52680. * @param isFrozen defines wether the material is frozen or not.
  52681. */
  52682. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  52683. /**
  52684. * Checks to see if a texture is used in the material.
  52685. * @param texture - Base texture to use.
  52686. * @returns - Boolean specifying if a texture is used in the material.
  52687. */
  52688. hasTexture(texture: BaseTexture): boolean;
  52689. /**
  52690. * Returns an array of the actively used textures.
  52691. * @param activeTextures Array of BaseTextures
  52692. */
  52693. getActiveTextures(activeTextures: BaseTexture[]): void;
  52694. /**
  52695. * Returns the animatable textures.
  52696. * @param animatables Array of animatable textures.
  52697. */
  52698. getAnimatables(animatables: IAnimatable[]): void;
  52699. /**
  52700. * Disposes the resources of the material.
  52701. * @param forceDisposeTextures - Forces the disposal of all textures.
  52702. */
  52703. dispose(forceDisposeTextures?: boolean): void;
  52704. /**
  52705. * Get the current class name of the texture useful for serialization or dynamic coding.
  52706. * @returns "PBRAnisotropicConfiguration"
  52707. */
  52708. getClassName(): string;
  52709. /**
  52710. * Add fallbacks to the effect fallbacks list.
  52711. * @param defines defines the Base texture to use.
  52712. * @param fallbacks defines the current fallback list.
  52713. * @param currentRank defines the current fallback rank.
  52714. * @returns the new fallback rank.
  52715. */
  52716. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  52717. /**
  52718. * Add the required uniforms to the current list.
  52719. * @param uniforms defines the current uniform list.
  52720. */
  52721. static AddUniforms(uniforms: string[]): void;
  52722. /**
  52723. * Add the required uniforms to the current buffer.
  52724. * @param uniformBuffer defines the current uniform buffer.
  52725. */
  52726. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  52727. /**
  52728. * Add the required samplers to the current list.
  52729. * @param samplers defines the current sampler list.
  52730. */
  52731. static AddSamplers(samplers: string[]): void;
  52732. /**
  52733. * Makes a duplicate of the current configuration into another one.
  52734. * @param anisotropicConfiguration define the config where to copy the info
  52735. */
  52736. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  52737. /**
  52738. * Serializes this anisotropy configuration.
  52739. * @returns - An object with the serialized config.
  52740. */
  52741. serialize(): any;
  52742. /**
  52743. * Parses a anisotropy Configuration from a serialized object.
  52744. * @param source - Serialized object.
  52745. * @param scene Defines the scene we are parsing for
  52746. * @param rootUrl Defines the rootUrl to load from
  52747. */
  52748. parse(source: any, scene: Scene, rootUrl: string): void;
  52749. }
  52750. }
  52751. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  52752. import { Scene } from "babylonjs/scene";
  52753. /**
  52754. * @hidden
  52755. */
  52756. export interface IMaterialBRDFDefines {
  52757. BRDF_V_HEIGHT_CORRELATED: boolean;
  52758. MS_BRDF_ENERGY_CONSERVATION: boolean;
  52759. SPHERICAL_HARMONICS: boolean;
  52760. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  52761. /** @hidden */
  52762. _areMiscDirty: boolean;
  52763. }
  52764. /**
  52765. * Define the code related to the BRDF parameters of the pbr material.
  52766. */
  52767. export class PBRBRDFConfiguration {
  52768. /**
  52769. * Default value used for the energy conservation.
  52770. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  52771. */
  52772. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  52773. /**
  52774. * Default value used for the Smith Visibility Height Correlated mode.
  52775. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  52776. */
  52777. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  52778. /**
  52779. * Default value used for the IBL diffuse part.
  52780. * This can help switching back to the polynomials mode globally which is a tiny bit
  52781. * less GPU intensive at the drawback of a lower quality.
  52782. */
  52783. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  52784. /**
  52785. * Default value used for activating energy conservation for the specular workflow.
  52786. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  52787. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  52788. */
  52789. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  52790. private _useEnergyConservation;
  52791. /**
  52792. * Defines if the material uses energy conservation.
  52793. */
  52794. useEnergyConservation: boolean;
  52795. private _useSmithVisibilityHeightCorrelated;
  52796. /**
  52797. * LEGACY Mode set to false
  52798. * Defines if the material uses height smith correlated visibility term.
  52799. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  52800. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  52801. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  52802. * Not relying on height correlated will also disable energy conservation.
  52803. */
  52804. useSmithVisibilityHeightCorrelated: boolean;
  52805. private _useSphericalHarmonics;
  52806. /**
  52807. * LEGACY Mode set to false
  52808. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  52809. * diffuse part of the IBL.
  52810. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  52811. * to the ground truth.
  52812. */
  52813. useSphericalHarmonics: boolean;
  52814. private _useSpecularGlossinessInputEnergyConservation;
  52815. /**
  52816. * Defines if the material uses energy conservation, when the specular workflow is active.
  52817. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  52818. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  52819. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  52820. */
  52821. useSpecularGlossinessInputEnergyConservation: boolean;
  52822. /** @hidden */
  52823. private _internalMarkAllSubMeshesAsMiscDirty;
  52824. /** @hidden */
  52825. _markAllSubMeshesAsMiscDirty(): void;
  52826. /**
  52827. * Instantiate a new istance of clear coat configuration.
  52828. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  52829. */
  52830. constructor(markAllSubMeshesAsMiscDirty: () => void);
  52831. /**
  52832. * Checks to see if a texture is used in the material.
  52833. * @param defines the list of "defines" to update.
  52834. */
  52835. prepareDefines(defines: IMaterialBRDFDefines): void;
  52836. /**
  52837. * Get the current class name of the texture useful for serialization or dynamic coding.
  52838. * @returns "PBRClearCoatConfiguration"
  52839. */
  52840. getClassName(): string;
  52841. /**
  52842. * Makes a duplicate of the current configuration into another one.
  52843. * @param brdfConfiguration define the config where to copy the info
  52844. */
  52845. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  52846. /**
  52847. * Serializes this BRDF configuration.
  52848. * @returns - An object with the serialized config.
  52849. */
  52850. serialize(): any;
  52851. /**
  52852. * Parses a anisotropy Configuration from a serialized object.
  52853. * @param source - Serialized object.
  52854. * @param scene Defines the scene we are parsing for
  52855. * @param rootUrl Defines the rootUrl to load from
  52856. */
  52857. parse(source: any, scene: Scene, rootUrl: string): void;
  52858. }
  52859. }
  52860. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  52861. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  52862. import { Color3 } from "babylonjs/Maths/math.color";
  52863. import { Scene } from "babylonjs/scene";
  52864. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52865. import { Nullable } from "babylonjs/types";
  52866. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  52867. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  52868. /**
  52869. * @hidden
  52870. */
  52871. export interface IMaterialSheenDefines {
  52872. SHEEN: boolean;
  52873. SHEEN_TEXTURE: boolean;
  52874. SHEEN_TEXTUREDIRECTUV: number;
  52875. SHEEN_LINKWITHALBEDO: boolean;
  52876. SHEEN_ROUGHNESS: boolean;
  52877. SHEEN_ALBEDOSCALING: boolean;
  52878. /** @hidden */
  52879. _areTexturesDirty: boolean;
  52880. }
  52881. /**
  52882. * Define the code related to the Sheen parameters of the pbr material.
  52883. */
  52884. export class PBRSheenConfiguration {
  52885. private _isEnabled;
  52886. /**
  52887. * Defines if the material uses sheen.
  52888. */
  52889. isEnabled: boolean;
  52890. private _linkSheenWithAlbedo;
  52891. /**
  52892. * Defines if the sheen is linked to the sheen color.
  52893. */
  52894. linkSheenWithAlbedo: boolean;
  52895. /**
  52896. * Defines the sheen intensity.
  52897. */
  52898. intensity: number;
  52899. /**
  52900. * Defines the sheen color.
  52901. */
  52902. color: Color3;
  52903. private _texture;
  52904. /**
  52905. * Stores the sheen tint values in a texture.
  52906. * rgb is tint
  52907. * a is a intensity
  52908. */
  52909. texture: Nullable<BaseTexture>;
  52910. private _roughness;
  52911. /**
  52912. * Defines the sheen roughness.
  52913. * It is not taken into account if linkSheenWithAlbedo is true.
  52914. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  52915. */
  52916. roughness: Nullable<number>;
  52917. private _albedoScaling;
  52918. /**
  52919. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  52920. * It allows the strength of the sheen effect to not depend on the base color of the material,
  52921. * making it easier to setup and tweak the effect
  52922. */
  52923. albedoScaling: boolean;
  52924. /** @hidden */
  52925. private _internalMarkAllSubMeshesAsTexturesDirty;
  52926. /** @hidden */
  52927. _markAllSubMeshesAsTexturesDirty(): void;
  52928. /**
  52929. * Instantiate a new istance of clear coat configuration.
  52930. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  52931. */
  52932. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  52933. /**
  52934. * Specifies that the submesh is ready to be used.
  52935. * @param defines the list of "defines" to update.
  52936. * @param scene defines the scene the material belongs to.
  52937. * @returns - boolean indicating that the submesh is ready or not.
  52938. */
  52939. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  52940. /**
  52941. * Checks to see if a texture is used in the material.
  52942. * @param defines the list of "defines" to update.
  52943. * @param scene defines the scene the material belongs to.
  52944. */
  52945. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  52946. /**
  52947. * Binds the material data.
  52948. * @param uniformBuffer defines the Uniform buffer to fill in.
  52949. * @param scene defines the scene the material belongs to.
  52950. * @param isFrozen defines wether the material is frozen or not.
  52951. */
  52952. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  52953. /**
  52954. * Checks to see if a texture is used in the material.
  52955. * @param texture - Base texture to use.
  52956. * @returns - Boolean specifying if a texture is used in the material.
  52957. */
  52958. hasTexture(texture: BaseTexture): boolean;
  52959. /**
  52960. * Returns an array of the actively used textures.
  52961. * @param activeTextures Array of BaseTextures
  52962. */
  52963. getActiveTextures(activeTextures: BaseTexture[]): void;
  52964. /**
  52965. * Returns the animatable textures.
  52966. * @param animatables Array of animatable textures.
  52967. */
  52968. getAnimatables(animatables: IAnimatable[]): void;
  52969. /**
  52970. * Disposes the resources of the material.
  52971. * @param forceDisposeTextures - Forces the disposal of all textures.
  52972. */
  52973. dispose(forceDisposeTextures?: boolean): void;
  52974. /**
  52975. * Get the current class name of the texture useful for serialization or dynamic coding.
  52976. * @returns "PBRSheenConfiguration"
  52977. */
  52978. getClassName(): string;
  52979. /**
  52980. * Add fallbacks to the effect fallbacks list.
  52981. * @param defines defines the Base texture to use.
  52982. * @param fallbacks defines the current fallback list.
  52983. * @param currentRank defines the current fallback rank.
  52984. * @returns the new fallback rank.
  52985. */
  52986. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  52987. /**
  52988. * Add the required uniforms to the current list.
  52989. * @param uniforms defines the current uniform list.
  52990. */
  52991. static AddUniforms(uniforms: string[]): void;
  52992. /**
  52993. * Add the required uniforms to the current buffer.
  52994. * @param uniformBuffer defines the current uniform buffer.
  52995. */
  52996. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  52997. /**
  52998. * Add the required samplers to the current list.
  52999. * @param samplers defines the current sampler list.
  53000. */
  53001. static AddSamplers(samplers: string[]): void;
  53002. /**
  53003. * Makes a duplicate of the current configuration into another one.
  53004. * @param sheenConfiguration define the config where to copy the info
  53005. */
  53006. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  53007. /**
  53008. * Serializes this BRDF configuration.
  53009. * @returns - An object with the serialized config.
  53010. */
  53011. serialize(): any;
  53012. /**
  53013. * Parses a anisotropy Configuration from a serialized object.
  53014. * @param source - Serialized object.
  53015. * @param scene Defines the scene we are parsing for
  53016. * @param rootUrl Defines the rootUrl to load from
  53017. */
  53018. parse(source: any, scene: Scene, rootUrl: string): void;
  53019. }
  53020. }
  53021. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  53022. import { Nullable } from "babylonjs/types";
  53023. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  53024. import { Color3 } from "babylonjs/Maths/math.color";
  53025. import { SmartArray } from "babylonjs/Misc/smartArray";
  53026. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53027. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  53028. import { Effect } from "babylonjs/Materials/effect";
  53029. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  53030. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  53031. import { Engine } from "babylonjs/Engines/engine";
  53032. import { Scene } from "babylonjs/scene";
  53033. /**
  53034. * @hidden
  53035. */
  53036. export interface IMaterialSubSurfaceDefines {
  53037. SUBSURFACE: boolean;
  53038. SS_REFRACTION: boolean;
  53039. SS_TRANSLUCENCY: boolean;
  53040. SS_SCATERRING: boolean;
  53041. SS_THICKNESSANDMASK_TEXTURE: boolean;
  53042. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  53043. SS_REFRACTIONMAP_3D: boolean;
  53044. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  53045. SS_LODINREFRACTIONALPHA: boolean;
  53046. SS_GAMMAREFRACTION: boolean;
  53047. SS_RGBDREFRACTION: boolean;
  53048. SS_LINEARSPECULARREFRACTION: boolean;
  53049. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  53050. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  53051. /** @hidden */
  53052. _areTexturesDirty: boolean;
  53053. }
  53054. /**
  53055. * Define the code related to the sub surface parameters of the pbr material.
  53056. */
  53057. export class PBRSubSurfaceConfiguration {
  53058. private _isRefractionEnabled;
  53059. /**
  53060. * Defines if the refraction is enabled in the material.
  53061. */
  53062. isRefractionEnabled: boolean;
  53063. private _isTranslucencyEnabled;
  53064. /**
  53065. * Defines if the translucency is enabled in the material.
  53066. */
  53067. isTranslucencyEnabled: boolean;
  53068. private _isScatteringEnabled;
  53069. /**
  53070. * Defines the refraction intensity of the material.
  53071. * The refraction when enabled replaces the Diffuse part of the material.
  53072. * The intensity helps transitionning between diffuse and refraction.
  53073. */
  53074. refractionIntensity: number;
  53075. /**
  53076. * Defines the translucency intensity of the material.
  53077. * When translucency has been enabled, this defines how much of the "translucency"
  53078. * is addded to the diffuse part of the material.
  53079. */
  53080. translucencyIntensity: number;
  53081. /**
  53082. * Defines the scattering intensity of the material.
  53083. * When scattering has been enabled, this defines how much of the "scattered light"
  53084. * is addded to the diffuse part of the material.
  53085. */
  53086. scatteringIntensity: number;
  53087. private _thicknessTexture;
  53088. /**
  53089. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  53090. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  53091. * 0 would mean minimumThickness
  53092. * 1 would mean maximumThickness
  53093. * The other channels might be use as a mask to vary the different effects intensity.
  53094. */
  53095. thicknessTexture: Nullable<BaseTexture>;
  53096. private _refractionTexture;
  53097. /**
  53098. * Defines the texture to use for refraction.
  53099. */
  53100. refractionTexture: Nullable<BaseTexture>;
  53101. private _indexOfRefraction;
  53102. /**
  53103. * Defines the index of refraction used in the material.
  53104. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  53105. */
  53106. indexOfRefraction: number;
  53107. private _invertRefractionY;
  53108. /**
  53109. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  53110. */
  53111. invertRefractionY: boolean;
  53112. private _linkRefractionWithTransparency;
  53113. /**
  53114. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  53115. * Materials half opaque for instance using refraction could benefit from this control.
  53116. */
  53117. linkRefractionWithTransparency: boolean;
  53118. /**
  53119. * Defines the minimum thickness stored in the thickness map.
  53120. * If no thickness map is defined, this value will be used to simulate thickness.
  53121. */
  53122. minimumThickness: number;
  53123. /**
  53124. * Defines the maximum thickness stored in the thickness map.
  53125. */
  53126. maximumThickness: number;
  53127. /**
  53128. * Defines the volume tint of the material.
  53129. * This is used for both translucency and scattering.
  53130. */
  53131. tintColor: Color3;
  53132. /**
  53133. * Defines the distance at which the tint color should be found in the media.
  53134. * This is used for refraction only.
  53135. */
  53136. tintColorAtDistance: number;
  53137. /**
  53138. * Defines how far each channel transmit through the media.
  53139. * It is defined as a color to simplify it selection.
  53140. */
  53141. diffusionDistance: Color3;
  53142. private _useMaskFromThicknessTexture;
  53143. /**
  53144. * Stores the intensity of the different subsurface effects in the thickness texture.
  53145. * * the green channel is the translucency intensity.
  53146. * * the blue channel is the scattering intensity.
  53147. * * the alpha channel is the refraction intensity.
  53148. */
  53149. useMaskFromThicknessTexture: boolean;
  53150. /** @hidden */
  53151. private _internalMarkAllSubMeshesAsTexturesDirty;
  53152. /** @hidden */
  53153. _markAllSubMeshesAsTexturesDirty(): void;
  53154. /**
  53155. * Instantiate a new istance of sub surface configuration.
  53156. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  53157. */
  53158. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  53159. /**
  53160. * Gets wehter the submesh is ready to be used or not.
  53161. * @param defines the list of "defines" to update.
  53162. * @param scene defines the scene the material belongs to.
  53163. * @returns - boolean indicating that the submesh is ready or not.
  53164. */
  53165. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  53166. /**
  53167. * Checks to see if a texture is used in the material.
  53168. * @param defines the list of "defines" to update.
  53169. * @param scene defines the scene to the material belongs to.
  53170. */
  53171. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  53172. /**
  53173. * Binds the material data.
  53174. * @param uniformBuffer defines the Uniform buffer to fill in.
  53175. * @param scene defines the scene the material belongs to.
  53176. * @param engine defines the engine the material belongs to.
  53177. * @param isFrozen defines wether the material is frozen or not.
  53178. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  53179. */
  53180. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  53181. /**
  53182. * Unbinds the material from the mesh.
  53183. * @param activeEffect defines the effect that should be unbound from.
  53184. * @returns true if unbound, otherwise false
  53185. */
  53186. unbind(activeEffect: Effect): boolean;
  53187. /**
  53188. * Returns the texture used for refraction or null if none is used.
  53189. * @param scene defines the scene the material belongs to.
  53190. * @returns - Refraction texture if present. If no refraction texture and refraction
  53191. * is linked with transparency, returns environment texture. Otherwise, returns null.
  53192. */
  53193. private _getRefractionTexture;
  53194. /**
  53195. * Returns true if alpha blending should be disabled.
  53196. */
  53197. get disableAlphaBlending(): boolean;
  53198. /**
  53199. * Fills the list of render target textures.
  53200. * @param renderTargets the list of render targets to update
  53201. */
  53202. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  53203. /**
  53204. * Checks to see if a texture is used in the material.
  53205. * @param texture - Base texture to use.
  53206. * @returns - Boolean specifying if a texture is used in the material.
  53207. */
  53208. hasTexture(texture: BaseTexture): boolean;
  53209. /**
  53210. * Gets a boolean indicating that current material needs to register RTT
  53211. * @returns true if this uses a render target otherwise false.
  53212. */
  53213. hasRenderTargetTextures(): boolean;
  53214. /**
  53215. * Returns an array of the actively used textures.
  53216. * @param activeTextures Array of BaseTextures
  53217. */
  53218. getActiveTextures(activeTextures: BaseTexture[]): void;
  53219. /**
  53220. * Returns the animatable textures.
  53221. * @param animatables Array of animatable textures.
  53222. */
  53223. getAnimatables(animatables: IAnimatable[]): void;
  53224. /**
  53225. * Disposes the resources of the material.
  53226. * @param forceDisposeTextures - Forces the disposal of all textures.
  53227. */
  53228. dispose(forceDisposeTextures?: boolean): void;
  53229. /**
  53230. * Get the current class name of the texture useful for serialization or dynamic coding.
  53231. * @returns "PBRSubSurfaceConfiguration"
  53232. */
  53233. getClassName(): string;
  53234. /**
  53235. * Add fallbacks to the effect fallbacks list.
  53236. * @param defines defines the Base texture to use.
  53237. * @param fallbacks defines the current fallback list.
  53238. * @param currentRank defines the current fallback rank.
  53239. * @returns the new fallback rank.
  53240. */
  53241. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  53242. /**
  53243. * Add the required uniforms to the current list.
  53244. * @param uniforms defines the current uniform list.
  53245. */
  53246. static AddUniforms(uniforms: string[]): void;
  53247. /**
  53248. * Add the required samplers to the current list.
  53249. * @param samplers defines the current sampler list.
  53250. */
  53251. static AddSamplers(samplers: string[]): void;
  53252. /**
  53253. * Add the required uniforms to the current buffer.
  53254. * @param uniformBuffer defines the current uniform buffer.
  53255. */
  53256. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  53257. /**
  53258. * Makes a duplicate of the current configuration into another one.
  53259. * @param configuration define the config where to copy the info
  53260. */
  53261. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  53262. /**
  53263. * Serializes this Sub Surface configuration.
  53264. * @returns - An object with the serialized config.
  53265. */
  53266. serialize(): any;
  53267. /**
  53268. * Parses a anisotropy Configuration from a serialized object.
  53269. * @param source - Serialized object.
  53270. * @param scene Defines the scene we are parsing for
  53271. * @param rootUrl Defines the rootUrl to load from
  53272. */
  53273. parse(source: any, scene: Scene, rootUrl: string): void;
  53274. }
  53275. }
  53276. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  53277. /** @hidden */
  53278. export var pbrFragmentDeclaration: {
  53279. name: string;
  53280. shader: string;
  53281. };
  53282. }
  53283. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  53284. /** @hidden */
  53285. export var pbrUboDeclaration: {
  53286. name: string;
  53287. shader: string;
  53288. };
  53289. }
  53290. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  53291. /** @hidden */
  53292. export var pbrFragmentExtraDeclaration: {
  53293. name: string;
  53294. shader: string;
  53295. };
  53296. }
  53297. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  53298. /** @hidden */
  53299. export var pbrFragmentSamplersDeclaration: {
  53300. name: string;
  53301. shader: string;
  53302. };
  53303. }
  53304. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  53305. /** @hidden */
  53306. export var pbrHelperFunctions: {
  53307. name: string;
  53308. shader: string;
  53309. };
  53310. }
  53311. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  53312. /** @hidden */
  53313. export var harmonicsFunctions: {
  53314. name: string;
  53315. shader: string;
  53316. };
  53317. }
  53318. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  53319. /** @hidden */
  53320. export var pbrDirectLightingSetupFunctions: {
  53321. name: string;
  53322. shader: string;
  53323. };
  53324. }
  53325. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  53326. /** @hidden */
  53327. export var pbrDirectLightingFalloffFunctions: {
  53328. name: string;
  53329. shader: string;
  53330. };
  53331. }
  53332. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  53333. /** @hidden */
  53334. export var pbrBRDFFunctions: {
  53335. name: string;
  53336. shader: string;
  53337. };
  53338. }
  53339. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  53340. /** @hidden */
  53341. export var pbrDirectLightingFunctions: {
  53342. name: string;
  53343. shader: string;
  53344. };
  53345. }
  53346. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  53347. /** @hidden */
  53348. export var pbrIBLFunctions: {
  53349. name: string;
  53350. shader: string;
  53351. };
  53352. }
  53353. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAlbedoOpacity" {
  53354. /** @hidden */
  53355. export var pbrBlockAlbedoOpacity: {
  53356. name: string;
  53357. shader: string;
  53358. };
  53359. }
  53360. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectivity" {
  53361. /** @hidden */
  53362. export var pbrBlockReflectivity: {
  53363. name: string;
  53364. shader: string;
  53365. };
  53366. }
  53367. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAmbientOcclusion" {
  53368. /** @hidden */
  53369. export var pbrBlockAmbientOcclusion: {
  53370. name: string;
  53371. shader: string;
  53372. };
  53373. }
  53374. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAlphaFresnel" {
  53375. /** @hidden */
  53376. export var pbrBlockAlphaFresnel: {
  53377. name: string;
  53378. shader: string;
  53379. };
  53380. }
  53381. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAnisotropic" {
  53382. /** @hidden */
  53383. export var pbrBlockAnisotropic: {
  53384. name: string;
  53385. shader: string;
  53386. };
  53387. }
  53388. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflection" {
  53389. /** @hidden */
  53390. export var pbrBlockReflection: {
  53391. name: string;
  53392. shader: string;
  53393. };
  53394. }
  53395. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockSheen" {
  53396. /** @hidden */
  53397. export var pbrBlockSheen: {
  53398. name: string;
  53399. shader: string;
  53400. };
  53401. }
  53402. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockClearcoat" {
  53403. /** @hidden */
  53404. export var pbrBlockClearcoat: {
  53405. name: string;
  53406. shader: string;
  53407. };
  53408. }
  53409. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockSubSurface" {
  53410. /** @hidden */
  53411. export var pbrBlockSubSurface: {
  53412. name: string;
  53413. shader: string;
  53414. };
  53415. }
  53416. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockNormalGeometric" {
  53417. /** @hidden */
  53418. export var pbrBlockNormalGeometric: {
  53419. name: string;
  53420. shader: string;
  53421. };
  53422. }
  53423. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockNormalFinal" {
  53424. /** @hidden */
  53425. export var pbrBlockNormalFinal: {
  53426. name: string;
  53427. shader: string;
  53428. };
  53429. }
  53430. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockGeometryInfo" {
  53431. /** @hidden */
  53432. export var pbrBlockGeometryInfo: {
  53433. name: string;
  53434. shader: string;
  53435. };
  53436. }
  53437. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance0" {
  53438. /** @hidden */
  53439. export var pbrBlockReflectance0: {
  53440. name: string;
  53441. shader: string;
  53442. };
  53443. }
  53444. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance" {
  53445. /** @hidden */
  53446. export var pbrBlockReflectance: {
  53447. name: string;
  53448. shader: string;
  53449. };
  53450. }
  53451. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockDirectLighting" {
  53452. /** @hidden */
  53453. export var pbrBlockDirectLighting: {
  53454. name: string;
  53455. shader: string;
  53456. };
  53457. }
  53458. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalLitComponents" {
  53459. /** @hidden */
  53460. export var pbrBlockFinalLitComponents: {
  53461. name: string;
  53462. shader: string;
  53463. };
  53464. }
  53465. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalUnlitComponents" {
  53466. /** @hidden */
  53467. export var pbrBlockFinalUnlitComponents: {
  53468. name: string;
  53469. shader: string;
  53470. };
  53471. }
  53472. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalColorComposition" {
  53473. /** @hidden */
  53474. export var pbrBlockFinalColorComposition: {
  53475. name: string;
  53476. shader: string;
  53477. };
  53478. }
  53479. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockImageProcessing" {
  53480. /** @hidden */
  53481. export var pbrBlockImageProcessing: {
  53482. name: string;
  53483. shader: string;
  53484. };
  53485. }
  53486. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  53487. /** @hidden */
  53488. export var pbrDebug: {
  53489. name: string;
  53490. shader: string;
  53491. };
  53492. }
  53493. declare module "babylonjs/Shaders/pbr.fragment" {
  53494. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  53495. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  53496. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  53497. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  53498. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  53499. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  53500. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  53501. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  53502. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  53503. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  53504. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  53505. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  53506. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  53507. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  53508. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  53509. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  53510. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  53511. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  53512. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  53513. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  53514. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  53515. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  53516. import "babylonjs/Shaders/ShadersInclude/pbrBlockAlbedoOpacity";
  53517. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectivity";
  53518. import "babylonjs/Shaders/ShadersInclude/pbrBlockAmbientOcclusion";
  53519. import "babylonjs/Shaders/ShadersInclude/pbrBlockAlphaFresnel";
  53520. import "babylonjs/Shaders/ShadersInclude/pbrBlockAnisotropic";
  53521. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflection";
  53522. import "babylonjs/Shaders/ShadersInclude/pbrBlockSheen";
  53523. import "babylonjs/Shaders/ShadersInclude/pbrBlockClearcoat";
  53524. import "babylonjs/Shaders/ShadersInclude/pbrBlockSubSurface";
  53525. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  53526. import "babylonjs/Shaders/ShadersInclude/pbrBlockNormalGeometric";
  53527. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  53528. import "babylonjs/Shaders/ShadersInclude/pbrBlockNormalFinal";
  53529. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  53530. import "babylonjs/Shaders/ShadersInclude/pbrBlockGeometryInfo";
  53531. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance0";
  53532. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance";
  53533. import "babylonjs/Shaders/ShadersInclude/pbrBlockDirectLighting";
  53534. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  53535. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalLitComponents";
  53536. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalUnlitComponents";
  53537. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalColorComposition";
  53538. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  53539. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  53540. import "babylonjs/Shaders/ShadersInclude/pbrBlockImageProcessing";
  53541. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  53542. /** @hidden */
  53543. export var pbrPixelShader: {
  53544. name: string;
  53545. shader: string;
  53546. };
  53547. }
  53548. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  53549. /** @hidden */
  53550. export var pbrVertexDeclaration: {
  53551. name: string;
  53552. shader: string;
  53553. };
  53554. }
  53555. declare module "babylonjs/Shaders/pbr.vertex" {
  53556. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  53557. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  53558. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  53559. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  53560. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  53561. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  53562. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  53563. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  53564. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  53565. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  53566. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  53567. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  53568. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  53569. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  53570. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  53571. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  53572. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  53573. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  53574. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  53575. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  53576. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  53577. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  53578. /** @hidden */
  53579. export var pbrVertexShader: {
  53580. name: string;
  53581. shader: string;
  53582. };
  53583. }
  53584. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  53585. import { Nullable } from "babylonjs/types";
  53586. import { Scene } from "babylonjs/scene";
  53587. import { Matrix } from "babylonjs/Maths/math.vector";
  53588. import { SubMesh } from "babylonjs/Meshes/subMesh";
  53589. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53590. import { Mesh } from "babylonjs/Meshes/mesh";
  53591. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  53592. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  53593. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  53594. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  53595. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  53596. import { Color3 } from "babylonjs/Maths/math.color";
  53597. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  53598. import { Material, IMaterialCompilationOptions } from "babylonjs/Materials/material";
  53599. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  53600. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  53601. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53602. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  53603. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  53604. import "babylonjs/Shaders/pbr.fragment";
  53605. import "babylonjs/Shaders/pbr.vertex";
  53606. /**
  53607. * Manages the defines for the PBR Material.
  53608. * @hidden
  53609. */
  53610. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  53611. PBR: boolean;
  53612. MAINUV1: boolean;
  53613. MAINUV2: boolean;
  53614. UV1: boolean;
  53615. UV2: boolean;
  53616. ALBEDO: boolean;
  53617. GAMMAALBEDO: boolean;
  53618. ALBEDODIRECTUV: number;
  53619. VERTEXCOLOR: boolean;
  53620. AMBIENT: boolean;
  53621. AMBIENTDIRECTUV: number;
  53622. AMBIENTINGRAYSCALE: boolean;
  53623. OPACITY: boolean;
  53624. VERTEXALPHA: boolean;
  53625. OPACITYDIRECTUV: number;
  53626. OPACITYRGB: boolean;
  53627. ALPHATEST: boolean;
  53628. DEPTHPREPASS: boolean;
  53629. ALPHABLEND: boolean;
  53630. ALPHAFROMALBEDO: boolean;
  53631. ALPHATESTVALUE: string;
  53632. SPECULAROVERALPHA: boolean;
  53633. RADIANCEOVERALPHA: boolean;
  53634. ALPHAFRESNEL: boolean;
  53635. LINEARALPHAFRESNEL: boolean;
  53636. PREMULTIPLYALPHA: boolean;
  53637. EMISSIVE: boolean;
  53638. EMISSIVEDIRECTUV: number;
  53639. REFLECTIVITY: boolean;
  53640. REFLECTIVITYDIRECTUV: number;
  53641. SPECULARTERM: boolean;
  53642. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  53643. MICROSURFACEAUTOMATIC: boolean;
  53644. LODBASEDMICROSFURACE: boolean;
  53645. MICROSURFACEMAP: boolean;
  53646. MICROSURFACEMAPDIRECTUV: number;
  53647. METALLICWORKFLOW: boolean;
  53648. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  53649. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  53650. METALLNESSSTOREINMETALMAPBLUE: boolean;
  53651. AOSTOREINMETALMAPRED: boolean;
  53652. METALLICF0FACTORFROMMETALLICMAP: boolean;
  53653. ENVIRONMENTBRDF: boolean;
  53654. ENVIRONMENTBRDF_RGBD: boolean;
  53655. NORMAL: boolean;
  53656. TANGENT: boolean;
  53657. BUMP: boolean;
  53658. BUMPDIRECTUV: number;
  53659. OBJECTSPACE_NORMALMAP: boolean;
  53660. PARALLAX: boolean;
  53661. PARALLAXOCCLUSION: boolean;
  53662. NORMALXYSCALE: boolean;
  53663. LIGHTMAP: boolean;
  53664. LIGHTMAPDIRECTUV: number;
  53665. USELIGHTMAPASSHADOWMAP: boolean;
  53666. GAMMALIGHTMAP: boolean;
  53667. RGBDLIGHTMAP: boolean;
  53668. REFLECTION: boolean;
  53669. REFLECTIONMAP_3D: boolean;
  53670. REFLECTIONMAP_SPHERICAL: boolean;
  53671. REFLECTIONMAP_PLANAR: boolean;
  53672. REFLECTIONMAP_CUBIC: boolean;
  53673. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  53674. REFLECTIONMAP_PROJECTION: boolean;
  53675. REFLECTIONMAP_SKYBOX: boolean;
  53676. REFLECTIONMAP_EXPLICIT: boolean;
  53677. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  53678. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  53679. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  53680. INVERTCUBICMAP: boolean;
  53681. USESPHERICALFROMREFLECTIONMAP: boolean;
  53682. USEIRRADIANCEMAP: boolean;
  53683. SPHERICAL_HARMONICS: boolean;
  53684. USESPHERICALINVERTEX: boolean;
  53685. REFLECTIONMAP_OPPOSITEZ: boolean;
  53686. LODINREFLECTIONALPHA: boolean;
  53687. GAMMAREFLECTION: boolean;
  53688. RGBDREFLECTION: boolean;
  53689. LINEARSPECULARREFLECTION: boolean;
  53690. RADIANCEOCCLUSION: boolean;
  53691. HORIZONOCCLUSION: boolean;
  53692. INSTANCES: boolean;
  53693. NUM_BONE_INFLUENCERS: number;
  53694. BonesPerMesh: number;
  53695. BONETEXTURE: boolean;
  53696. NONUNIFORMSCALING: boolean;
  53697. MORPHTARGETS: boolean;
  53698. MORPHTARGETS_NORMAL: boolean;
  53699. MORPHTARGETS_TANGENT: boolean;
  53700. MORPHTARGETS_UV: boolean;
  53701. NUM_MORPH_INFLUENCERS: number;
  53702. IMAGEPROCESSING: boolean;
  53703. VIGNETTE: boolean;
  53704. VIGNETTEBLENDMODEMULTIPLY: boolean;
  53705. VIGNETTEBLENDMODEOPAQUE: boolean;
  53706. TONEMAPPING: boolean;
  53707. TONEMAPPING_ACES: boolean;
  53708. CONTRAST: boolean;
  53709. COLORCURVES: boolean;
  53710. COLORGRADING: boolean;
  53711. COLORGRADING3D: boolean;
  53712. SAMPLER3DGREENDEPTH: boolean;
  53713. SAMPLER3DBGRMAP: boolean;
  53714. IMAGEPROCESSINGPOSTPROCESS: boolean;
  53715. EXPOSURE: boolean;
  53716. MULTIVIEW: boolean;
  53717. USEPHYSICALLIGHTFALLOFF: boolean;
  53718. USEGLTFLIGHTFALLOFF: boolean;
  53719. TWOSIDEDLIGHTING: boolean;
  53720. SHADOWFLOAT: boolean;
  53721. CLIPPLANE: boolean;
  53722. CLIPPLANE2: boolean;
  53723. CLIPPLANE3: boolean;
  53724. CLIPPLANE4: boolean;
  53725. CLIPPLANE5: boolean;
  53726. CLIPPLANE6: boolean;
  53727. POINTSIZE: boolean;
  53728. FOG: boolean;
  53729. LOGARITHMICDEPTH: boolean;
  53730. FORCENORMALFORWARD: boolean;
  53731. SPECULARAA: boolean;
  53732. CLEARCOAT: boolean;
  53733. CLEARCOAT_DEFAULTIOR: boolean;
  53734. CLEARCOAT_TEXTURE: boolean;
  53735. CLEARCOAT_TEXTUREDIRECTUV: number;
  53736. CLEARCOAT_BUMP: boolean;
  53737. CLEARCOAT_BUMPDIRECTUV: number;
  53738. CLEARCOAT_TINT: boolean;
  53739. CLEARCOAT_TINT_TEXTURE: boolean;
  53740. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  53741. ANISOTROPIC: boolean;
  53742. ANISOTROPIC_TEXTURE: boolean;
  53743. ANISOTROPIC_TEXTUREDIRECTUV: number;
  53744. BRDF_V_HEIGHT_CORRELATED: boolean;
  53745. MS_BRDF_ENERGY_CONSERVATION: boolean;
  53746. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  53747. SHEEN: boolean;
  53748. SHEEN_TEXTURE: boolean;
  53749. SHEEN_TEXTUREDIRECTUV: number;
  53750. SHEEN_LINKWITHALBEDO: boolean;
  53751. SHEEN_ROUGHNESS: boolean;
  53752. SHEEN_ALBEDOSCALING: boolean;
  53753. SUBSURFACE: boolean;
  53754. SS_REFRACTION: boolean;
  53755. SS_TRANSLUCENCY: boolean;
  53756. SS_SCATERRING: boolean;
  53757. SS_THICKNESSANDMASK_TEXTURE: boolean;
  53758. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  53759. SS_REFRACTIONMAP_3D: boolean;
  53760. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  53761. SS_LODINREFRACTIONALPHA: boolean;
  53762. SS_GAMMAREFRACTION: boolean;
  53763. SS_RGBDREFRACTION: boolean;
  53764. SS_LINEARSPECULARREFRACTION: boolean;
  53765. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  53766. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  53767. UNLIT: boolean;
  53768. DEBUGMODE: number;
  53769. /**
  53770. * Initializes the PBR Material defines.
  53771. */
  53772. constructor();
  53773. /**
  53774. * Resets the PBR Material defines.
  53775. */
  53776. reset(): void;
  53777. }
  53778. /**
  53779. * The Physically based material base class of BJS.
  53780. *
  53781. * This offers the main features of a standard PBR material.
  53782. * For more information, please refer to the documentation :
  53783. * https://doc.babylonjs.com/how_to/physically_based_rendering
  53784. */
  53785. export abstract class PBRBaseMaterial extends PushMaterial {
  53786. /**
  53787. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  53788. */
  53789. static readonly PBRMATERIAL_OPAQUE: number;
  53790. /**
  53791. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  53792. */
  53793. static readonly PBRMATERIAL_ALPHATEST: number;
  53794. /**
  53795. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  53796. */
  53797. static readonly PBRMATERIAL_ALPHABLEND: number;
  53798. /**
  53799. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  53800. * They are also discarded below the alpha cutoff threshold to improve performances.
  53801. */
  53802. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  53803. /**
  53804. * Defines the default value of how much AO map is occluding the analytical lights
  53805. * (point spot...).
  53806. */
  53807. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  53808. /**
  53809. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  53810. */
  53811. static readonly LIGHTFALLOFF_PHYSICAL: number;
  53812. /**
  53813. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  53814. * to enhance interoperability with other engines.
  53815. */
  53816. static readonly LIGHTFALLOFF_GLTF: number;
  53817. /**
  53818. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  53819. * to enhance interoperability with other materials.
  53820. */
  53821. static readonly LIGHTFALLOFF_STANDARD: number;
  53822. /**
  53823. * Intensity of the direct lights e.g. the four lights available in your scene.
  53824. * This impacts both the direct diffuse and specular highlights.
  53825. */
  53826. protected _directIntensity: number;
  53827. /**
  53828. * Intensity of the emissive part of the material.
  53829. * This helps controlling the emissive effect without modifying the emissive color.
  53830. */
  53831. protected _emissiveIntensity: number;
  53832. /**
  53833. * Intensity of the environment e.g. how much the environment will light the object
  53834. * either through harmonics for rough material or through the refelction for shiny ones.
  53835. */
  53836. protected _environmentIntensity: number;
  53837. /**
  53838. * This is a special control allowing the reduction of the specular highlights coming from the
  53839. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  53840. */
  53841. protected _specularIntensity: number;
  53842. /**
  53843. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  53844. */
  53845. private _lightingInfos;
  53846. /**
  53847. * Debug Control allowing disabling the bump map on this material.
  53848. */
  53849. protected _disableBumpMap: boolean;
  53850. /**
  53851. * AKA Diffuse Texture in standard nomenclature.
  53852. */
  53853. protected _albedoTexture: Nullable<BaseTexture>;
  53854. /**
  53855. * AKA Occlusion Texture in other nomenclature.
  53856. */
  53857. protected _ambientTexture: Nullable<BaseTexture>;
  53858. /**
  53859. * AKA Occlusion Texture Intensity in other nomenclature.
  53860. */
  53861. protected _ambientTextureStrength: number;
  53862. /**
  53863. * Defines how much the AO map is occluding the analytical lights (point spot...).
  53864. * 1 means it completely occludes it
  53865. * 0 mean it has no impact
  53866. */
  53867. protected _ambientTextureImpactOnAnalyticalLights: number;
  53868. /**
  53869. * Stores the alpha values in a texture.
  53870. */
  53871. protected _opacityTexture: Nullable<BaseTexture>;
  53872. /**
  53873. * Stores the reflection values in a texture.
  53874. */
  53875. protected _reflectionTexture: Nullable<BaseTexture>;
  53876. /**
  53877. * Stores the emissive values in a texture.
  53878. */
  53879. protected _emissiveTexture: Nullable<BaseTexture>;
  53880. /**
  53881. * AKA Specular texture in other nomenclature.
  53882. */
  53883. protected _reflectivityTexture: Nullable<BaseTexture>;
  53884. /**
  53885. * Used to switch from specular/glossiness to metallic/roughness workflow.
  53886. */
  53887. protected _metallicTexture: Nullable<BaseTexture>;
  53888. /**
  53889. * Specifies the metallic scalar of the metallic/roughness workflow.
  53890. * Can also be used to scale the metalness values of the metallic texture.
  53891. */
  53892. protected _metallic: Nullable<number>;
  53893. /**
  53894. * Specifies the roughness scalar of the metallic/roughness workflow.
  53895. * Can also be used to scale the roughness values of the metallic texture.
  53896. */
  53897. protected _roughness: Nullable<number>;
  53898. /**
  53899. * Specifies the an F0 factor to help configuring the material F0.
  53900. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  53901. * to 0.5 the previously hard coded value stays the same.
  53902. * Can also be used to scale the F0 values of the metallic texture.
  53903. */
  53904. protected _metallicF0Factor: number;
  53905. /**
  53906. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  53907. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  53908. * your expectation as it multiplies with the texture data.
  53909. */
  53910. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  53911. /**
  53912. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  53913. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  53914. */
  53915. protected _microSurfaceTexture: Nullable<BaseTexture>;
  53916. /**
  53917. * Stores surface normal data used to displace a mesh in a texture.
  53918. */
  53919. protected _bumpTexture: Nullable<BaseTexture>;
  53920. /**
  53921. * Stores the pre-calculated light information of a mesh in a texture.
  53922. */
  53923. protected _lightmapTexture: Nullable<BaseTexture>;
  53924. /**
  53925. * The color of a material in ambient lighting.
  53926. */
  53927. protected _ambientColor: Color3;
  53928. /**
  53929. * AKA Diffuse Color in other nomenclature.
  53930. */
  53931. protected _albedoColor: Color3;
  53932. /**
  53933. * AKA Specular Color in other nomenclature.
  53934. */
  53935. protected _reflectivityColor: Color3;
  53936. /**
  53937. * The color applied when light is reflected from a material.
  53938. */
  53939. protected _reflectionColor: Color3;
  53940. /**
  53941. * The color applied when light is emitted from a material.
  53942. */
  53943. protected _emissiveColor: Color3;
  53944. /**
  53945. * AKA Glossiness in other nomenclature.
  53946. */
  53947. protected _microSurface: number;
  53948. /**
  53949. * Specifies that the material will use the light map as a show map.
  53950. */
  53951. protected _useLightmapAsShadowmap: boolean;
  53952. /**
  53953. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  53954. * makes the reflect vector face the model (under horizon).
  53955. */
  53956. protected _useHorizonOcclusion: boolean;
  53957. /**
  53958. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  53959. * too much the area relying on ambient texture to define their ambient occlusion.
  53960. */
  53961. protected _useRadianceOcclusion: boolean;
  53962. /**
  53963. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  53964. */
  53965. protected _useAlphaFromAlbedoTexture: boolean;
  53966. /**
  53967. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  53968. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  53969. */
  53970. protected _useSpecularOverAlpha: boolean;
  53971. /**
  53972. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  53973. */
  53974. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  53975. /**
  53976. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  53977. */
  53978. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  53979. /**
  53980. * Specifies if the metallic texture contains the roughness information in its green channel.
  53981. */
  53982. protected _useRoughnessFromMetallicTextureGreen: boolean;
  53983. /**
  53984. * Specifies if the metallic texture contains the metallness information in its blue channel.
  53985. */
  53986. protected _useMetallnessFromMetallicTextureBlue: boolean;
  53987. /**
  53988. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  53989. */
  53990. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  53991. /**
  53992. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  53993. */
  53994. protected _useAmbientInGrayScale: boolean;
  53995. /**
  53996. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  53997. * The material will try to infer what glossiness each pixel should be.
  53998. */
  53999. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  54000. /**
  54001. * Defines the falloff type used in this material.
  54002. * It by default is Physical.
  54003. */
  54004. protected _lightFalloff: number;
  54005. /**
  54006. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  54007. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  54008. */
  54009. protected _useRadianceOverAlpha: boolean;
  54010. /**
  54011. * Allows using an object space normal map (instead of tangent space).
  54012. */
  54013. protected _useObjectSpaceNormalMap: boolean;
  54014. /**
  54015. * Allows using the bump map in parallax mode.
  54016. */
  54017. protected _useParallax: boolean;
  54018. /**
  54019. * Allows using the bump map in parallax occlusion mode.
  54020. */
  54021. protected _useParallaxOcclusion: boolean;
  54022. /**
  54023. * Controls the scale bias of the parallax mode.
  54024. */
  54025. protected _parallaxScaleBias: number;
  54026. /**
  54027. * If sets to true, disables all the lights affecting the material.
  54028. */
  54029. protected _disableLighting: boolean;
  54030. /**
  54031. * Number of Simultaneous lights allowed on the material.
  54032. */
  54033. protected _maxSimultaneousLights: number;
  54034. /**
  54035. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  54036. */
  54037. protected _invertNormalMapX: boolean;
  54038. /**
  54039. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  54040. */
  54041. protected _invertNormalMapY: boolean;
  54042. /**
  54043. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  54044. */
  54045. protected _twoSidedLighting: boolean;
  54046. /**
  54047. * Defines the alpha limits in alpha test mode.
  54048. */
  54049. protected _alphaCutOff: number;
  54050. /**
  54051. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  54052. */
  54053. protected _forceAlphaTest: boolean;
  54054. /**
  54055. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  54056. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  54057. */
  54058. protected _useAlphaFresnel: boolean;
  54059. /**
  54060. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  54061. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  54062. */
  54063. protected _useLinearAlphaFresnel: boolean;
  54064. /**
  54065. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  54066. * from cos thetav and roughness:
  54067. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  54068. */
  54069. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  54070. /**
  54071. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  54072. */
  54073. protected _forceIrradianceInFragment: boolean;
  54074. /**
  54075. * Force normal to face away from face.
  54076. */
  54077. protected _forceNormalForward: boolean;
  54078. /**
  54079. * Enables specular anti aliasing in the PBR shader.
  54080. * It will both interacts on the Geometry for analytical and IBL lighting.
  54081. * It also prefilter the roughness map based on the bump values.
  54082. */
  54083. protected _enableSpecularAntiAliasing: boolean;
  54084. /**
  54085. * Default configuration related to image processing available in the PBR Material.
  54086. */
  54087. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  54088. /**
  54089. * Keep track of the image processing observer to allow dispose and replace.
  54090. */
  54091. private _imageProcessingObserver;
  54092. /**
  54093. * Attaches a new image processing configuration to the PBR Material.
  54094. * @param configuration
  54095. */
  54096. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  54097. /**
  54098. * Stores the available render targets.
  54099. */
  54100. private _renderTargets;
  54101. /**
  54102. * Sets the global ambient color for the material used in lighting calculations.
  54103. */
  54104. private _globalAmbientColor;
  54105. /**
  54106. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  54107. */
  54108. private _useLogarithmicDepth;
  54109. /**
  54110. * If set to true, no lighting calculations will be applied.
  54111. */
  54112. private _unlit;
  54113. private _debugMode;
  54114. /**
  54115. * @hidden
  54116. * This is reserved for the inspector.
  54117. * Defines the material debug mode.
  54118. * It helps seeing only some components of the material while troubleshooting.
  54119. */
  54120. debugMode: number;
  54121. /**
  54122. * @hidden
  54123. * This is reserved for the inspector.
  54124. * Specify from where on screen the debug mode should start.
  54125. * The value goes from -1 (full screen) to 1 (not visible)
  54126. * It helps with side by side comparison against the final render
  54127. * This defaults to -1
  54128. */
  54129. private debugLimit;
  54130. /**
  54131. * @hidden
  54132. * This is reserved for the inspector.
  54133. * As the default viewing range might not be enough (if the ambient is really small for instance)
  54134. * You can use the factor to better multiply the final value.
  54135. */
  54136. private debugFactor;
  54137. /**
  54138. * Defines the clear coat layer parameters for the material.
  54139. */
  54140. readonly clearCoat: PBRClearCoatConfiguration;
  54141. /**
  54142. * Defines the anisotropic parameters for the material.
  54143. */
  54144. readonly anisotropy: PBRAnisotropicConfiguration;
  54145. /**
  54146. * Defines the BRDF parameters for the material.
  54147. */
  54148. readonly brdf: PBRBRDFConfiguration;
  54149. /**
  54150. * Defines the Sheen parameters for the material.
  54151. */
  54152. readonly sheen: PBRSheenConfiguration;
  54153. /**
  54154. * Defines the SubSurface parameters for the material.
  54155. */
  54156. readonly subSurface: PBRSubSurfaceConfiguration;
  54157. /**
  54158. * Custom callback helping to override the default shader used in the material.
  54159. */
  54160. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines, attributes?: string[]) => string;
  54161. protected _rebuildInParallel: boolean;
  54162. /**
  54163. * Instantiates a new PBRMaterial instance.
  54164. *
  54165. * @param name The material name
  54166. * @param scene The scene the material will be use in.
  54167. */
  54168. constructor(name: string, scene: Scene);
  54169. /**
  54170. * Gets a boolean indicating that current material needs to register RTT
  54171. */
  54172. get hasRenderTargetTextures(): boolean;
  54173. /**
  54174. * Gets the name of the material class.
  54175. */
  54176. getClassName(): string;
  54177. /**
  54178. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  54179. */
  54180. get useLogarithmicDepth(): boolean;
  54181. /**
  54182. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  54183. */
  54184. set useLogarithmicDepth(value: boolean);
  54185. /**
  54186. * Returns true if alpha blending should be disabled.
  54187. */
  54188. protected get _disableAlphaBlending(): boolean;
  54189. /**
  54190. * Specifies whether or not this material should be rendered in alpha blend mode.
  54191. */
  54192. needAlphaBlending(): boolean;
  54193. /**
  54194. * Specifies whether or not this material should be rendered in alpha test mode.
  54195. */
  54196. needAlphaTesting(): boolean;
  54197. /**
  54198. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  54199. */
  54200. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  54201. /**
  54202. * Gets the texture used for the alpha test.
  54203. */
  54204. getAlphaTestTexture(): Nullable<BaseTexture>;
  54205. /**
  54206. * Specifies that the submesh is ready to be used.
  54207. * @param mesh - BJS mesh.
  54208. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  54209. * @param useInstances - Specifies that instances should be used.
  54210. * @returns - boolean indicating that the submesh is ready or not.
  54211. */
  54212. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  54213. /**
  54214. * Specifies if the material uses metallic roughness workflow.
  54215. * @returns boolean specifiying if the material uses metallic roughness workflow.
  54216. */
  54217. isMetallicWorkflow(): boolean;
  54218. private _prepareEffect;
  54219. private _prepareDefines;
  54220. /**
  54221. * Force shader compilation
  54222. */
  54223. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  54224. /**
  54225. * Initializes the uniform buffer layout for the shader.
  54226. */
  54227. buildUniformLayout(): void;
  54228. /**
  54229. * Unbinds the material from the mesh
  54230. */
  54231. unbind(): void;
  54232. /**
  54233. * Binds the submesh data.
  54234. * @param world - The world matrix.
  54235. * @param mesh - The BJS mesh.
  54236. * @param subMesh - A submesh of the BJS mesh.
  54237. */
  54238. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  54239. /**
  54240. * Returns the animatable textures.
  54241. * @returns - Array of animatable textures.
  54242. */
  54243. getAnimatables(): IAnimatable[];
  54244. /**
  54245. * Returns the texture used for reflections.
  54246. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  54247. */
  54248. private _getReflectionTexture;
  54249. /**
  54250. * Returns an array of the actively used textures.
  54251. * @returns - Array of BaseTextures
  54252. */
  54253. getActiveTextures(): BaseTexture[];
  54254. /**
  54255. * Checks to see if a texture is used in the material.
  54256. * @param texture - Base texture to use.
  54257. * @returns - Boolean specifying if a texture is used in the material.
  54258. */
  54259. hasTexture(texture: BaseTexture): boolean;
  54260. /**
  54261. * Disposes the resources of the material.
  54262. * @param forceDisposeEffect - Forces the disposal of effects.
  54263. * @param forceDisposeTextures - Forces the disposal of all textures.
  54264. */
  54265. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  54266. }
  54267. }
  54268. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  54269. import { Nullable } from "babylonjs/types";
  54270. import { Scene } from "babylonjs/scene";
  54271. import { Color3 } from "babylonjs/Maths/math.color";
  54272. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  54273. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  54274. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54275. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  54276. /**
  54277. * The Physically based material of BJS.
  54278. *
  54279. * This offers the main features of a standard PBR material.
  54280. * For more information, please refer to the documentation :
  54281. * https://doc.babylonjs.com/how_to/physically_based_rendering
  54282. */
  54283. export class PBRMaterial extends PBRBaseMaterial {
  54284. /**
  54285. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  54286. */
  54287. static readonly PBRMATERIAL_OPAQUE: number;
  54288. /**
  54289. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  54290. */
  54291. static readonly PBRMATERIAL_ALPHATEST: number;
  54292. /**
  54293. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  54294. */
  54295. static readonly PBRMATERIAL_ALPHABLEND: number;
  54296. /**
  54297. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  54298. * They are also discarded below the alpha cutoff threshold to improve performances.
  54299. */
  54300. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  54301. /**
  54302. * Defines the default value of how much AO map is occluding the analytical lights
  54303. * (point spot...).
  54304. */
  54305. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  54306. /**
  54307. * Intensity of the direct lights e.g. the four lights available in your scene.
  54308. * This impacts both the direct diffuse and specular highlights.
  54309. */
  54310. directIntensity: number;
  54311. /**
  54312. * Intensity of the emissive part of the material.
  54313. * This helps controlling the emissive effect without modifying the emissive color.
  54314. */
  54315. emissiveIntensity: number;
  54316. /**
  54317. * Intensity of the environment e.g. how much the environment will light the object
  54318. * either through harmonics for rough material or through the refelction for shiny ones.
  54319. */
  54320. environmentIntensity: number;
  54321. /**
  54322. * This is a special control allowing the reduction of the specular highlights coming from the
  54323. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  54324. */
  54325. specularIntensity: number;
  54326. /**
  54327. * Debug Control allowing disabling the bump map on this material.
  54328. */
  54329. disableBumpMap: boolean;
  54330. /**
  54331. * AKA Diffuse Texture in standard nomenclature.
  54332. */
  54333. albedoTexture: BaseTexture;
  54334. /**
  54335. * AKA Occlusion Texture in other nomenclature.
  54336. */
  54337. ambientTexture: BaseTexture;
  54338. /**
  54339. * AKA Occlusion Texture Intensity in other nomenclature.
  54340. */
  54341. ambientTextureStrength: number;
  54342. /**
  54343. * Defines how much the AO map is occluding the analytical lights (point spot...).
  54344. * 1 means it completely occludes it
  54345. * 0 mean it has no impact
  54346. */
  54347. ambientTextureImpactOnAnalyticalLights: number;
  54348. /**
  54349. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  54350. */
  54351. opacityTexture: BaseTexture;
  54352. /**
  54353. * Stores the reflection values in a texture.
  54354. */
  54355. reflectionTexture: Nullable<BaseTexture>;
  54356. /**
  54357. * Stores the emissive values in a texture.
  54358. */
  54359. emissiveTexture: BaseTexture;
  54360. /**
  54361. * AKA Specular texture in other nomenclature.
  54362. */
  54363. reflectivityTexture: BaseTexture;
  54364. /**
  54365. * Used to switch from specular/glossiness to metallic/roughness workflow.
  54366. */
  54367. metallicTexture: BaseTexture;
  54368. /**
  54369. * Specifies the metallic scalar of the metallic/roughness workflow.
  54370. * Can also be used to scale the metalness values of the metallic texture.
  54371. */
  54372. metallic: Nullable<number>;
  54373. /**
  54374. * Specifies the roughness scalar of the metallic/roughness workflow.
  54375. * Can also be used to scale the roughness values of the metallic texture.
  54376. */
  54377. roughness: Nullable<number>;
  54378. /**
  54379. * Specifies the an F0 factor to help configuring the material F0.
  54380. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  54381. * to 0.5 the previously hard coded value stays the same.
  54382. * Can also be used to scale the F0 values of the metallic texture.
  54383. */
  54384. metallicF0Factor: number;
  54385. /**
  54386. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  54387. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  54388. * your expectation as it multiplies with the texture data.
  54389. */
  54390. useMetallicF0FactorFromMetallicTexture: boolean;
  54391. /**
  54392. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  54393. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  54394. */
  54395. microSurfaceTexture: BaseTexture;
  54396. /**
  54397. * Stores surface normal data used to displace a mesh in a texture.
  54398. */
  54399. bumpTexture: BaseTexture;
  54400. /**
  54401. * Stores the pre-calculated light information of a mesh in a texture.
  54402. */
  54403. lightmapTexture: BaseTexture;
  54404. /**
  54405. * Stores the refracted light information in a texture.
  54406. */
  54407. get refractionTexture(): Nullable<BaseTexture>;
  54408. set refractionTexture(value: Nullable<BaseTexture>);
  54409. /**
  54410. * The color of a material in ambient lighting.
  54411. */
  54412. ambientColor: Color3;
  54413. /**
  54414. * AKA Diffuse Color in other nomenclature.
  54415. */
  54416. albedoColor: Color3;
  54417. /**
  54418. * AKA Specular Color in other nomenclature.
  54419. */
  54420. reflectivityColor: Color3;
  54421. /**
  54422. * The color reflected from the material.
  54423. */
  54424. reflectionColor: Color3;
  54425. /**
  54426. * The color emitted from the material.
  54427. */
  54428. emissiveColor: Color3;
  54429. /**
  54430. * AKA Glossiness in other nomenclature.
  54431. */
  54432. microSurface: number;
  54433. /**
  54434. * source material index of refraction (IOR)' / 'destination material IOR.
  54435. */
  54436. get indexOfRefraction(): number;
  54437. set indexOfRefraction(value: number);
  54438. /**
  54439. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  54440. */
  54441. get invertRefractionY(): boolean;
  54442. set invertRefractionY(value: boolean);
  54443. /**
  54444. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  54445. * Materials half opaque for instance using refraction could benefit from this control.
  54446. */
  54447. get linkRefractionWithTransparency(): boolean;
  54448. set linkRefractionWithTransparency(value: boolean);
  54449. /**
  54450. * If true, the light map contains occlusion information instead of lighting info.
  54451. */
  54452. useLightmapAsShadowmap: boolean;
  54453. /**
  54454. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  54455. */
  54456. useAlphaFromAlbedoTexture: boolean;
  54457. /**
  54458. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  54459. */
  54460. forceAlphaTest: boolean;
  54461. /**
  54462. * Defines the alpha limits in alpha test mode.
  54463. */
  54464. alphaCutOff: number;
  54465. /**
  54466. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  54467. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  54468. */
  54469. useSpecularOverAlpha: boolean;
  54470. /**
  54471. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  54472. */
  54473. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  54474. /**
  54475. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  54476. */
  54477. useRoughnessFromMetallicTextureAlpha: boolean;
  54478. /**
  54479. * Specifies if the metallic texture contains the roughness information in its green channel.
  54480. */
  54481. useRoughnessFromMetallicTextureGreen: boolean;
  54482. /**
  54483. * Specifies if the metallic texture contains the metallness information in its blue channel.
  54484. */
  54485. useMetallnessFromMetallicTextureBlue: boolean;
  54486. /**
  54487. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  54488. */
  54489. useAmbientOcclusionFromMetallicTextureRed: boolean;
  54490. /**
  54491. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  54492. */
  54493. useAmbientInGrayScale: boolean;
  54494. /**
  54495. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  54496. * The material will try to infer what glossiness each pixel should be.
  54497. */
  54498. useAutoMicroSurfaceFromReflectivityMap: boolean;
  54499. /**
  54500. * BJS is using an harcoded light falloff based on a manually sets up range.
  54501. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  54502. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  54503. */
  54504. get usePhysicalLightFalloff(): boolean;
  54505. /**
  54506. * BJS is using an harcoded light falloff based on a manually sets up range.
  54507. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  54508. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  54509. */
  54510. set usePhysicalLightFalloff(value: boolean);
  54511. /**
  54512. * In order to support the falloff compatibility with gltf, a special mode has been added
  54513. * to reproduce the gltf light falloff.
  54514. */
  54515. get useGLTFLightFalloff(): boolean;
  54516. /**
  54517. * In order to support the falloff compatibility with gltf, a special mode has been added
  54518. * to reproduce the gltf light falloff.
  54519. */
  54520. set useGLTFLightFalloff(value: boolean);
  54521. /**
  54522. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  54523. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  54524. */
  54525. useRadianceOverAlpha: boolean;
  54526. /**
  54527. * Allows using an object space normal map (instead of tangent space).
  54528. */
  54529. useObjectSpaceNormalMap: boolean;
  54530. /**
  54531. * Allows using the bump map in parallax mode.
  54532. */
  54533. useParallax: boolean;
  54534. /**
  54535. * Allows using the bump map in parallax occlusion mode.
  54536. */
  54537. useParallaxOcclusion: boolean;
  54538. /**
  54539. * Controls the scale bias of the parallax mode.
  54540. */
  54541. parallaxScaleBias: number;
  54542. /**
  54543. * If sets to true, disables all the lights affecting the material.
  54544. */
  54545. disableLighting: boolean;
  54546. /**
  54547. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  54548. */
  54549. forceIrradianceInFragment: boolean;
  54550. /**
  54551. * Number of Simultaneous lights allowed on the material.
  54552. */
  54553. maxSimultaneousLights: number;
  54554. /**
  54555. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  54556. */
  54557. invertNormalMapX: boolean;
  54558. /**
  54559. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  54560. */
  54561. invertNormalMapY: boolean;
  54562. /**
  54563. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  54564. */
  54565. twoSidedLighting: boolean;
  54566. /**
  54567. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  54568. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  54569. */
  54570. useAlphaFresnel: boolean;
  54571. /**
  54572. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  54573. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  54574. */
  54575. useLinearAlphaFresnel: boolean;
  54576. /**
  54577. * Let user defines the brdf lookup texture used for IBL.
  54578. * A default 8bit version is embedded but you could point at :
  54579. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  54580. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  54581. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  54582. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  54583. */
  54584. environmentBRDFTexture: Nullable<BaseTexture>;
  54585. /**
  54586. * Force normal to face away from face.
  54587. */
  54588. forceNormalForward: boolean;
  54589. /**
  54590. * Enables specular anti aliasing in the PBR shader.
  54591. * It will both interacts on the Geometry for analytical and IBL lighting.
  54592. * It also prefilter the roughness map based on the bump values.
  54593. */
  54594. enableSpecularAntiAliasing: boolean;
  54595. /**
  54596. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  54597. * makes the reflect vector face the model (under horizon).
  54598. */
  54599. useHorizonOcclusion: boolean;
  54600. /**
  54601. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  54602. * too much the area relying on ambient texture to define their ambient occlusion.
  54603. */
  54604. useRadianceOcclusion: boolean;
  54605. /**
  54606. * If set to true, no lighting calculations will be applied.
  54607. */
  54608. unlit: boolean;
  54609. /**
  54610. * Gets the image processing configuration used either in this material.
  54611. */
  54612. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  54613. /**
  54614. * Sets the Default image processing configuration used either in the this material.
  54615. *
  54616. * If sets to null, the scene one is in use.
  54617. */
  54618. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  54619. /**
  54620. * Gets wether the color curves effect is enabled.
  54621. */
  54622. get cameraColorCurvesEnabled(): boolean;
  54623. /**
  54624. * Sets wether the color curves effect is enabled.
  54625. */
  54626. set cameraColorCurvesEnabled(value: boolean);
  54627. /**
  54628. * Gets wether the color grading effect is enabled.
  54629. */
  54630. get cameraColorGradingEnabled(): boolean;
  54631. /**
  54632. * Gets wether the color grading effect is enabled.
  54633. */
  54634. set cameraColorGradingEnabled(value: boolean);
  54635. /**
  54636. * Gets wether tonemapping is enabled or not.
  54637. */
  54638. get cameraToneMappingEnabled(): boolean;
  54639. /**
  54640. * Sets wether tonemapping is enabled or not
  54641. */
  54642. set cameraToneMappingEnabled(value: boolean);
  54643. /**
  54644. * The camera exposure used on this material.
  54645. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  54646. * This corresponds to a photographic exposure.
  54647. */
  54648. get cameraExposure(): number;
  54649. /**
  54650. * The camera exposure used on this material.
  54651. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  54652. * This corresponds to a photographic exposure.
  54653. */
  54654. set cameraExposure(value: number);
  54655. /**
  54656. * Gets The camera contrast used on this material.
  54657. */
  54658. get cameraContrast(): number;
  54659. /**
  54660. * Sets The camera contrast used on this material.
  54661. */
  54662. set cameraContrast(value: number);
  54663. /**
  54664. * Gets the Color Grading 2D Lookup Texture.
  54665. */
  54666. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  54667. /**
  54668. * Sets the Color Grading 2D Lookup Texture.
  54669. */
  54670. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  54671. /**
  54672. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  54673. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  54674. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  54675. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  54676. */
  54677. get cameraColorCurves(): Nullable<ColorCurves>;
  54678. /**
  54679. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  54680. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  54681. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  54682. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  54683. */
  54684. set cameraColorCurves(value: Nullable<ColorCurves>);
  54685. /**
  54686. * Instantiates a new PBRMaterial instance.
  54687. *
  54688. * @param name The material name
  54689. * @param scene The scene the material will be use in.
  54690. */
  54691. constructor(name: string, scene: Scene);
  54692. /**
  54693. * Returns the name of this material class.
  54694. */
  54695. getClassName(): string;
  54696. /**
  54697. * Makes a duplicate of the current material.
  54698. * @param name - name to use for the new material.
  54699. */
  54700. clone(name: string): PBRMaterial;
  54701. /**
  54702. * Serializes this PBR Material.
  54703. * @returns - An object with the serialized material.
  54704. */
  54705. serialize(): any;
  54706. /**
  54707. * Parses a PBR Material from a serialized object.
  54708. * @param source - Serialized object.
  54709. * @param scene - BJS scene instance.
  54710. * @param rootUrl - url for the scene object
  54711. * @returns - PBRMaterial
  54712. */
  54713. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  54714. }
  54715. }
  54716. declare module "babylonjs/Misc/dds" {
  54717. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  54718. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54719. import { Nullable } from "babylonjs/types";
  54720. import { Scene } from "babylonjs/scene";
  54721. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  54722. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  54723. /**
  54724. * Direct draw surface info
  54725. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  54726. */
  54727. export interface DDSInfo {
  54728. /**
  54729. * Width of the texture
  54730. */
  54731. width: number;
  54732. /**
  54733. * Width of the texture
  54734. */
  54735. height: number;
  54736. /**
  54737. * Number of Mipmaps for the texture
  54738. * @see https://en.wikipedia.org/wiki/Mipmap
  54739. */
  54740. mipmapCount: number;
  54741. /**
  54742. * If the textures format is a known fourCC format
  54743. * @see https://www.fourcc.org/
  54744. */
  54745. isFourCC: boolean;
  54746. /**
  54747. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  54748. */
  54749. isRGB: boolean;
  54750. /**
  54751. * If the texture is a lumincance format
  54752. */
  54753. isLuminance: boolean;
  54754. /**
  54755. * If this is a cube texture
  54756. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  54757. */
  54758. isCube: boolean;
  54759. /**
  54760. * If the texture is a compressed format eg. FOURCC_DXT1
  54761. */
  54762. isCompressed: boolean;
  54763. /**
  54764. * The dxgiFormat of the texture
  54765. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  54766. */
  54767. dxgiFormat: number;
  54768. /**
  54769. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  54770. */
  54771. textureType: number;
  54772. /**
  54773. * Sphericle polynomial created for the dds texture
  54774. */
  54775. sphericalPolynomial?: SphericalPolynomial;
  54776. }
  54777. /**
  54778. * Class used to provide DDS decompression tools
  54779. */
  54780. export class DDSTools {
  54781. /**
  54782. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  54783. */
  54784. static StoreLODInAlphaChannel: boolean;
  54785. /**
  54786. * Gets DDS information from an array buffer
  54787. * @param data defines the array buffer view to read data from
  54788. * @returns the DDS information
  54789. */
  54790. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  54791. private static _FloatView;
  54792. private static _Int32View;
  54793. private static _ToHalfFloat;
  54794. private static _FromHalfFloat;
  54795. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  54796. private static _GetHalfFloatRGBAArrayBuffer;
  54797. private static _GetFloatRGBAArrayBuffer;
  54798. private static _GetFloatAsUIntRGBAArrayBuffer;
  54799. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  54800. private static _GetRGBAArrayBuffer;
  54801. private static _ExtractLongWordOrder;
  54802. private static _GetRGBArrayBuffer;
  54803. private static _GetLuminanceArrayBuffer;
  54804. /**
  54805. * Uploads DDS Levels to a Babylon Texture
  54806. * @hidden
  54807. */
  54808. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  54809. }
  54810. module "babylonjs/Engines/thinEngine" {
  54811. interface ThinEngine {
  54812. /**
  54813. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  54814. * @param rootUrl defines the url where the file to load is located
  54815. * @param scene defines the current scene
  54816. * @param lodScale defines scale to apply to the mip map selection
  54817. * @param lodOffset defines offset to apply to the mip map selection
  54818. * @param onLoad defines an optional callback raised when the texture is loaded
  54819. * @param onError defines an optional callback raised if there is an issue to load the texture
  54820. * @param format defines the format of the data
  54821. * @param forcedExtension defines the extension to use to pick the right loader
  54822. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  54823. * @returns the cube texture as an InternalTexture
  54824. */
  54825. 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;
  54826. }
  54827. }
  54828. }
  54829. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  54830. import { Nullable } from "babylonjs/types";
  54831. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54832. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  54833. /**
  54834. * Implementation of the DDS Texture Loader.
  54835. * @hidden
  54836. */
  54837. export class _DDSTextureLoader implements IInternalTextureLoader {
  54838. /**
  54839. * Defines wether the loader supports cascade loading the different faces.
  54840. */
  54841. readonly supportCascades: boolean;
  54842. /**
  54843. * This returns if the loader support the current file information.
  54844. * @param extension defines the file extension of the file being loaded
  54845. * @returns true if the loader can load the specified file
  54846. */
  54847. canLoad(extension: string): boolean;
  54848. /**
  54849. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  54850. * @param data contains the texture data
  54851. * @param texture defines the BabylonJS internal texture
  54852. * @param createPolynomials will be true if polynomials have been requested
  54853. * @param onLoad defines the callback to trigger once the texture is ready
  54854. * @param onError defines the callback to trigger in case of error
  54855. */
  54856. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  54857. /**
  54858. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  54859. * @param data contains the texture data
  54860. * @param texture defines the BabylonJS internal texture
  54861. * @param callback defines the method to call once ready to upload
  54862. */
  54863. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  54864. }
  54865. }
  54866. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  54867. import { Nullable } from "babylonjs/types";
  54868. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54869. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  54870. /**
  54871. * Implementation of the ENV Texture Loader.
  54872. * @hidden
  54873. */
  54874. export class _ENVTextureLoader implements IInternalTextureLoader {
  54875. /**
  54876. * Defines wether the loader supports cascade loading the different faces.
  54877. */
  54878. readonly supportCascades: boolean;
  54879. /**
  54880. * This returns if the loader support the current file information.
  54881. * @param extension defines the file extension of the file being loaded
  54882. * @returns true if the loader can load the specified file
  54883. */
  54884. canLoad(extension: string): boolean;
  54885. /**
  54886. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  54887. * @param data contains the texture data
  54888. * @param texture defines the BabylonJS internal texture
  54889. * @param createPolynomials will be true if polynomials have been requested
  54890. * @param onLoad defines the callback to trigger once the texture is ready
  54891. * @param onError defines the callback to trigger in case of error
  54892. */
  54893. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  54894. /**
  54895. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  54896. * @param data contains the texture data
  54897. * @param texture defines the BabylonJS internal texture
  54898. * @param callback defines the method to call once ready to upload
  54899. */
  54900. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  54901. }
  54902. }
  54903. declare module "babylonjs/Misc/khronosTextureContainer" {
  54904. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54905. /**
  54906. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  54907. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  54908. */
  54909. export class KhronosTextureContainer {
  54910. /** contents of the KTX container file */
  54911. data: ArrayBufferView;
  54912. private static HEADER_LEN;
  54913. private static COMPRESSED_2D;
  54914. private static COMPRESSED_3D;
  54915. private static TEX_2D;
  54916. private static TEX_3D;
  54917. /**
  54918. * Gets the openGL type
  54919. */
  54920. glType: number;
  54921. /**
  54922. * Gets the openGL type size
  54923. */
  54924. glTypeSize: number;
  54925. /**
  54926. * Gets the openGL format
  54927. */
  54928. glFormat: number;
  54929. /**
  54930. * Gets the openGL internal format
  54931. */
  54932. glInternalFormat: number;
  54933. /**
  54934. * Gets the base internal format
  54935. */
  54936. glBaseInternalFormat: number;
  54937. /**
  54938. * Gets image width in pixel
  54939. */
  54940. pixelWidth: number;
  54941. /**
  54942. * Gets image height in pixel
  54943. */
  54944. pixelHeight: number;
  54945. /**
  54946. * Gets image depth in pixels
  54947. */
  54948. pixelDepth: number;
  54949. /**
  54950. * Gets the number of array elements
  54951. */
  54952. numberOfArrayElements: number;
  54953. /**
  54954. * Gets the number of faces
  54955. */
  54956. numberOfFaces: number;
  54957. /**
  54958. * Gets the number of mipmap levels
  54959. */
  54960. numberOfMipmapLevels: number;
  54961. /**
  54962. * Gets the bytes of key value data
  54963. */
  54964. bytesOfKeyValueData: number;
  54965. /**
  54966. * Gets the load type
  54967. */
  54968. loadType: number;
  54969. /**
  54970. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  54971. */
  54972. isInvalid: boolean;
  54973. /**
  54974. * Creates a new KhronosTextureContainer
  54975. * @param data contents of the KTX container file
  54976. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  54977. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  54978. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  54979. */
  54980. constructor(
  54981. /** contents of the KTX container file */
  54982. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  54983. /**
  54984. * Uploads KTX content to a Babylon Texture.
  54985. * It is assumed that the texture has already been created & is currently bound
  54986. * @hidden
  54987. */
  54988. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  54989. private _upload2DCompressedLevels;
  54990. /**
  54991. * Checks if the given data starts with a KTX file identifier.
  54992. * @param data the data to check
  54993. * @returns true if the data is a KTX file or false otherwise
  54994. */
  54995. static IsValid(data: ArrayBufferView): boolean;
  54996. }
  54997. }
  54998. declare module "babylonjs/Misc/khronosTextureContainer2" {
  54999. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  55000. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  55001. /**
  55002. * Class for loading KTX2 files
  55003. * !!! Experimental Extension Subject to Changes !!!
  55004. * @hidden
  55005. */
  55006. export class KhronosTextureContainer2 {
  55007. private static _ModulePromise;
  55008. private static _TranscodeFormat;
  55009. constructor(engine: ThinEngine);
  55010. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  55011. private _determineTranscodeFormat;
  55012. /**
  55013. * Checks if the given data starts with a KTX2 file identifier.
  55014. * @param data the data to check
  55015. * @returns true if the data is a KTX2 file or false otherwise
  55016. */
  55017. static IsValid(data: ArrayBufferView): boolean;
  55018. }
  55019. }
  55020. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  55021. import { Nullable } from "babylonjs/types";
  55022. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  55023. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  55024. /**
  55025. * Implementation of the KTX Texture Loader.
  55026. * @hidden
  55027. */
  55028. export class _KTXTextureLoader implements IInternalTextureLoader {
  55029. /**
  55030. * Defines wether the loader supports cascade loading the different faces.
  55031. */
  55032. readonly supportCascades: boolean;
  55033. /**
  55034. * This returns if the loader support the current file information.
  55035. * @param extension defines the file extension of the file being loaded
  55036. * @returns true if the loader can load the specified file
  55037. */
  55038. canLoad(extension: string): boolean;
  55039. /**
  55040. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  55041. * @param data contains the texture data
  55042. * @param texture defines the BabylonJS internal texture
  55043. * @param createPolynomials will be true if polynomials have been requested
  55044. * @param onLoad defines the callback to trigger once the texture is ready
  55045. * @param onError defines the callback to trigger in case of error
  55046. */
  55047. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  55048. /**
  55049. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  55050. * @param data contains the texture data
  55051. * @param texture defines the BabylonJS internal texture
  55052. * @param callback defines the method to call once ready to upload
  55053. */
  55054. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  55055. }
  55056. }
  55057. declare module "babylonjs/Helpers/sceneHelpers" {
  55058. import { Nullable } from "babylonjs/types";
  55059. import { Mesh } from "babylonjs/Meshes/mesh";
  55060. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55061. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  55062. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  55063. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  55064. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  55065. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  55066. import "babylonjs/Meshes/Builders/boxBuilder";
  55067. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/XR/webXRDefaultExperience";
  55068. /** @hidden */
  55069. export var _forceSceneHelpersToBundle: boolean;
  55070. module "babylonjs/scene" {
  55071. interface Scene {
  55072. /**
  55073. * Creates a default light for the scene.
  55074. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  55075. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  55076. */
  55077. createDefaultLight(replace?: boolean): void;
  55078. /**
  55079. * Creates a default camera for the scene.
  55080. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  55081. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  55082. * @param replace has default false, when true replaces the active camera in the scene
  55083. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  55084. */
  55085. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  55086. /**
  55087. * Creates a default camera and a default light.
  55088. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  55089. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  55090. * @param replace has the default false, when true replaces the active camera/light in the scene
  55091. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  55092. */
  55093. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  55094. /**
  55095. * Creates a new sky box
  55096. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  55097. * @param environmentTexture defines the texture to use as environment texture
  55098. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  55099. * @param scale defines the overall scale of the skybox
  55100. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  55101. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  55102. * @returns a new mesh holding the sky box
  55103. */
  55104. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  55105. /**
  55106. * Creates a new environment
  55107. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  55108. * @param options defines the options you can use to configure the environment
  55109. * @returns the new EnvironmentHelper
  55110. */
  55111. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  55112. /**
  55113. * Creates a new VREXperienceHelper
  55114. * @see http://doc.babylonjs.com/how_to/webvr_helper
  55115. * @param webVROptions defines the options used to create the new VREXperienceHelper
  55116. * @returns a new VREXperienceHelper
  55117. */
  55118. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  55119. /**
  55120. * Creates a new WebXRDefaultExperience
  55121. * @see http://doc.babylonjs.com/how_to/webxr
  55122. * @param options experience options
  55123. * @returns a promise for a new WebXRDefaultExperience
  55124. */
  55125. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  55126. }
  55127. }
  55128. }
  55129. declare module "babylonjs/Helpers/videoDome" {
  55130. import { Scene } from "babylonjs/scene";
  55131. import { TransformNode } from "babylonjs/Meshes/transformNode";
  55132. import { Mesh } from "babylonjs/Meshes/mesh";
  55133. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  55134. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  55135. import "babylonjs/Meshes/Builders/sphereBuilder";
  55136. /**
  55137. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  55138. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  55139. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  55140. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  55141. */
  55142. export class VideoDome extends TransformNode {
  55143. /**
  55144. * Define the video source as a Monoscopic panoramic 360 video.
  55145. */
  55146. static readonly MODE_MONOSCOPIC: number;
  55147. /**
  55148. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  55149. */
  55150. static readonly MODE_TOPBOTTOM: number;
  55151. /**
  55152. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  55153. */
  55154. static readonly MODE_SIDEBYSIDE: number;
  55155. private _halfDome;
  55156. private _useDirectMapping;
  55157. /**
  55158. * The video texture being displayed on the sphere
  55159. */
  55160. protected _videoTexture: VideoTexture;
  55161. /**
  55162. * Gets the video texture being displayed on the sphere
  55163. */
  55164. get videoTexture(): VideoTexture;
  55165. /**
  55166. * The skybox material
  55167. */
  55168. protected _material: BackgroundMaterial;
  55169. /**
  55170. * The surface used for the skybox
  55171. */
  55172. protected _mesh: Mesh;
  55173. /**
  55174. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  55175. */
  55176. private _halfDomeMask;
  55177. /**
  55178. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  55179. * Also see the options.resolution property.
  55180. */
  55181. get fovMultiplier(): number;
  55182. set fovMultiplier(value: number);
  55183. private _videoMode;
  55184. /**
  55185. * Gets or set the current video mode for the video. It can be:
  55186. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  55187. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  55188. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  55189. */
  55190. get videoMode(): number;
  55191. set videoMode(value: number);
  55192. /**
  55193. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  55194. *
  55195. */
  55196. get halfDome(): boolean;
  55197. /**
  55198. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  55199. */
  55200. set halfDome(enabled: boolean);
  55201. /**
  55202. * Oberserver used in Stereoscopic VR Mode.
  55203. */
  55204. private _onBeforeCameraRenderObserver;
  55205. /**
  55206. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  55207. * @param name Element's name, child elements will append suffixes for their own names.
  55208. * @param urlsOrVideo defines the url(s) or the video element to use
  55209. * @param options An object containing optional or exposed sub element properties
  55210. */
  55211. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  55212. resolution?: number;
  55213. clickToPlay?: boolean;
  55214. autoPlay?: boolean;
  55215. loop?: boolean;
  55216. size?: number;
  55217. poster?: string;
  55218. faceForward?: boolean;
  55219. useDirectMapping?: boolean;
  55220. halfDomeMode?: boolean;
  55221. }, scene: Scene);
  55222. private _changeVideoMode;
  55223. /**
  55224. * Releases resources associated with this node.
  55225. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  55226. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  55227. */
  55228. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  55229. }
  55230. }
  55231. declare module "babylonjs/Helpers/index" {
  55232. export * from "babylonjs/Helpers/environmentHelper";
  55233. export * from "babylonjs/Helpers/photoDome";
  55234. export * from "babylonjs/Helpers/sceneHelpers";
  55235. export * from "babylonjs/Helpers/videoDome";
  55236. }
  55237. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  55238. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  55239. import { IDisposable } from "babylonjs/scene";
  55240. import { Engine } from "babylonjs/Engines/engine";
  55241. /**
  55242. * This class can be used to get instrumentation data from a Babylon engine
  55243. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  55244. */
  55245. export class EngineInstrumentation implements IDisposable {
  55246. /**
  55247. * Define the instrumented engine.
  55248. */
  55249. engine: Engine;
  55250. private _captureGPUFrameTime;
  55251. private _gpuFrameTimeToken;
  55252. private _gpuFrameTime;
  55253. private _captureShaderCompilationTime;
  55254. private _shaderCompilationTime;
  55255. private _onBeginFrameObserver;
  55256. private _onEndFrameObserver;
  55257. private _onBeforeShaderCompilationObserver;
  55258. private _onAfterShaderCompilationObserver;
  55259. /**
  55260. * Gets the perf counter used for GPU frame time
  55261. */
  55262. get gpuFrameTimeCounter(): PerfCounter;
  55263. /**
  55264. * Gets the GPU frame time capture status
  55265. */
  55266. get captureGPUFrameTime(): boolean;
  55267. /**
  55268. * Enable or disable the GPU frame time capture
  55269. */
  55270. set captureGPUFrameTime(value: boolean);
  55271. /**
  55272. * Gets the perf counter used for shader compilation time
  55273. */
  55274. get shaderCompilationTimeCounter(): PerfCounter;
  55275. /**
  55276. * Gets the shader compilation time capture status
  55277. */
  55278. get captureShaderCompilationTime(): boolean;
  55279. /**
  55280. * Enable or disable the shader compilation time capture
  55281. */
  55282. set captureShaderCompilationTime(value: boolean);
  55283. /**
  55284. * Instantiates a new engine instrumentation.
  55285. * This class can be used to get instrumentation data from a Babylon engine
  55286. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  55287. * @param engine Defines the engine to instrument
  55288. */
  55289. constructor(
  55290. /**
  55291. * Define the instrumented engine.
  55292. */
  55293. engine: Engine);
  55294. /**
  55295. * Dispose and release associated resources.
  55296. */
  55297. dispose(): void;
  55298. }
  55299. }
  55300. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  55301. import { Scene, IDisposable } from "babylonjs/scene";
  55302. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  55303. /**
  55304. * This class can be used to get instrumentation data from a Babylon engine
  55305. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  55306. */
  55307. export class SceneInstrumentation implements IDisposable {
  55308. /**
  55309. * Defines the scene to instrument
  55310. */
  55311. scene: Scene;
  55312. private _captureActiveMeshesEvaluationTime;
  55313. private _activeMeshesEvaluationTime;
  55314. private _captureRenderTargetsRenderTime;
  55315. private _renderTargetsRenderTime;
  55316. private _captureFrameTime;
  55317. private _frameTime;
  55318. private _captureRenderTime;
  55319. private _renderTime;
  55320. private _captureInterFrameTime;
  55321. private _interFrameTime;
  55322. private _captureParticlesRenderTime;
  55323. private _particlesRenderTime;
  55324. private _captureSpritesRenderTime;
  55325. private _spritesRenderTime;
  55326. private _capturePhysicsTime;
  55327. private _physicsTime;
  55328. private _captureAnimationsTime;
  55329. private _animationsTime;
  55330. private _captureCameraRenderTime;
  55331. private _cameraRenderTime;
  55332. private _onBeforeActiveMeshesEvaluationObserver;
  55333. private _onAfterActiveMeshesEvaluationObserver;
  55334. private _onBeforeRenderTargetsRenderObserver;
  55335. private _onAfterRenderTargetsRenderObserver;
  55336. private _onAfterRenderObserver;
  55337. private _onBeforeDrawPhaseObserver;
  55338. private _onAfterDrawPhaseObserver;
  55339. private _onBeforeAnimationsObserver;
  55340. private _onBeforeParticlesRenderingObserver;
  55341. private _onAfterParticlesRenderingObserver;
  55342. private _onBeforeSpritesRenderingObserver;
  55343. private _onAfterSpritesRenderingObserver;
  55344. private _onBeforePhysicsObserver;
  55345. private _onAfterPhysicsObserver;
  55346. private _onAfterAnimationsObserver;
  55347. private _onBeforeCameraRenderObserver;
  55348. private _onAfterCameraRenderObserver;
  55349. /**
  55350. * Gets the perf counter used for active meshes evaluation time
  55351. */
  55352. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  55353. /**
  55354. * Gets the active meshes evaluation time capture status
  55355. */
  55356. get captureActiveMeshesEvaluationTime(): boolean;
  55357. /**
  55358. * Enable or disable the active meshes evaluation time capture
  55359. */
  55360. set captureActiveMeshesEvaluationTime(value: boolean);
  55361. /**
  55362. * Gets the perf counter used for render targets render time
  55363. */
  55364. get renderTargetsRenderTimeCounter(): PerfCounter;
  55365. /**
  55366. * Gets the render targets render time capture status
  55367. */
  55368. get captureRenderTargetsRenderTime(): boolean;
  55369. /**
  55370. * Enable or disable the render targets render time capture
  55371. */
  55372. set captureRenderTargetsRenderTime(value: boolean);
  55373. /**
  55374. * Gets the perf counter used for particles render time
  55375. */
  55376. get particlesRenderTimeCounter(): PerfCounter;
  55377. /**
  55378. * Gets the particles render time capture status
  55379. */
  55380. get captureParticlesRenderTime(): boolean;
  55381. /**
  55382. * Enable or disable the particles render time capture
  55383. */
  55384. set captureParticlesRenderTime(value: boolean);
  55385. /**
  55386. * Gets the perf counter used for sprites render time
  55387. */
  55388. get spritesRenderTimeCounter(): PerfCounter;
  55389. /**
  55390. * Gets the sprites render time capture status
  55391. */
  55392. get captureSpritesRenderTime(): boolean;
  55393. /**
  55394. * Enable or disable the sprites render time capture
  55395. */
  55396. set captureSpritesRenderTime(value: boolean);
  55397. /**
  55398. * Gets the perf counter used for physics time
  55399. */
  55400. get physicsTimeCounter(): PerfCounter;
  55401. /**
  55402. * Gets the physics time capture status
  55403. */
  55404. get capturePhysicsTime(): boolean;
  55405. /**
  55406. * Enable or disable the physics time capture
  55407. */
  55408. set capturePhysicsTime(value: boolean);
  55409. /**
  55410. * Gets the perf counter used for animations time
  55411. */
  55412. get animationsTimeCounter(): PerfCounter;
  55413. /**
  55414. * Gets the animations time capture status
  55415. */
  55416. get captureAnimationsTime(): boolean;
  55417. /**
  55418. * Enable or disable the animations time capture
  55419. */
  55420. set captureAnimationsTime(value: boolean);
  55421. /**
  55422. * Gets the perf counter used for frame time capture
  55423. */
  55424. get frameTimeCounter(): PerfCounter;
  55425. /**
  55426. * Gets the frame time capture status
  55427. */
  55428. get captureFrameTime(): boolean;
  55429. /**
  55430. * Enable or disable the frame time capture
  55431. */
  55432. set captureFrameTime(value: boolean);
  55433. /**
  55434. * Gets the perf counter used for inter-frames time capture
  55435. */
  55436. get interFrameTimeCounter(): PerfCounter;
  55437. /**
  55438. * Gets the inter-frames time capture status
  55439. */
  55440. get captureInterFrameTime(): boolean;
  55441. /**
  55442. * Enable or disable the inter-frames time capture
  55443. */
  55444. set captureInterFrameTime(value: boolean);
  55445. /**
  55446. * Gets the perf counter used for render time capture
  55447. */
  55448. get renderTimeCounter(): PerfCounter;
  55449. /**
  55450. * Gets the render time capture status
  55451. */
  55452. get captureRenderTime(): boolean;
  55453. /**
  55454. * Enable or disable the render time capture
  55455. */
  55456. set captureRenderTime(value: boolean);
  55457. /**
  55458. * Gets the perf counter used for camera render time capture
  55459. */
  55460. get cameraRenderTimeCounter(): PerfCounter;
  55461. /**
  55462. * Gets the camera render time capture status
  55463. */
  55464. get captureCameraRenderTime(): boolean;
  55465. /**
  55466. * Enable or disable the camera render time capture
  55467. */
  55468. set captureCameraRenderTime(value: boolean);
  55469. /**
  55470. * Gets the perf counter used for draw calls
  55471. */
  55472. get drawCallsCounter(): PerfCounter;
  55473. /**
  55474. * Instantiates a new scene instrumentation.
  55475. * This class can be used to get instrumentation data from a Babylon engine
  55476. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  55477. * @param scene Defines the scene to instrument
  55478. */
  55479. constructor(
  55480. /**
  55481. * Defines the scene to instrument
  55482. */
  55483. scene: Scene);
  55484. /**
  55485. * Dispose and release associated resources.
  55486. */
  55487. dispose(): void;
  55488. }
  55489. }
  55490. declare module "babylonjs/Instrumentation/index" {
  55491. export * from "babylonjs/Instrumentation/engineInstrumentation";
  55492. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  55493. export * from "babylonjs/Instrumentation/timeToken";
  55494. }
  55495. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  55496. /** @hidden */
  55497. export var glowMapGenerationPixelShader: {
  55498. name: string;
  55499. shader: string;
  55500. };
  55501. }
  55502. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  55503. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  55504. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  55505. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  55506. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  55507. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  55508. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  55509. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  55510. /** @hidden */
  55511. export var glowMapGenerationVertexShader: {
  55512. name: string;
  55513. shader: string;
  55514. };
  55515. }
  55516. declare module "babylonjs/Layers/effectLayer" {
  55517. import { Observable } from "babylonjs/Misc/observable";
  55518. import { Nullable } from "babylonjs/types";
  55519. import { Camera } from "babylonjs/Cameras/camera";
  55520. import { Scene } from "babylonjs/scene";
  55521. import { ISize } from "babylonjs/Maths/math.size";
  55522. import { Color4 } from "babylonjs/Maths/math.color";
  55523. import { Engine } from "babylonjs/Engines/engine";
  55524. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55525. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55526. import { Mesh } from "babylonjs/Meshes/mesh";
  55527. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  55528. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55529. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  55530. import { Effect } from "babylonjs/Materials/effect";
  55531. import { Material } from "babylonjs/Materials/material";
  55532. import "babylonjs/Shaders/glowMapGeneration.fragment";
  55533. import "babylonjs/Shaders/glowMapGeneration.vertex";
  55534. /**
  55535. * Effect layer options. This helps customizing the behaviour
  55536. * of the effect layer.
  55537. */
  55538. export interface IEffectLayerOptions {
  55539. /**
  55540. * Multiplication factor apply to the canvas size to compute the render target size
  55541. * used to generated the objects (the smaller the faster).
  55542. */
  55543. mainTextureRatio: number;
  55544. /**
  55545. * Enforces a fixed size texture to ensure effect stability across devices.
  55546. */
  55547. mainTextureFixedSize?: number;
  55548. /**
  55549. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  55550. */
  55551. alphaBlendingMode: number;
  55552. /**
  55553. * The camera attached to the layer.
  55554. */
  55555. camera: Nullable<Camera>;
  55556. /**
  55557. * The rendering group to draw the layer in.
  55558. */
  55559. renderingGroupId: number;
  55560. }
  55561. /**
  55562. * The effect layer Helps adding post process effect blended with the main pass.
  55563. *
  55564. * This can be for instance use to generate glow or higlight effects on the scene.
  55565. *
  55566. * The effect layer class can not be used directly and is intented to inherited from to be
  55567. * customized per effects.
  55568. */
  55569. export abstract class EffectLayer {
  55570. private _vertexBuffers;
  55571. private _indexBuffer;
  55572. private _cachedDefines;
  55573. private _effectLayerMapGenerationEffect;
  55574. private _effectLayerOptions;
  55575. private _mergeEffect;
  55576. protected _scene: Scene;
  55577. protected _engine: Engine;
  55578. protected _maxSize: number;
  55579. protected _mainTextureDesiredSize: ISize;
  55580. protected _mainTexture: RenderTargetTexture;
  55581. protected _shouldRender: boolean;
  55582. protected _postProcesses: PostProcess[];
  55583. protected _textures: BaseTexture[];
  55584. protected _emissiveTextureAndColor: {
  55585. texture: Nullable<BaseTexture>;
  55586. color: Color4;
  55587. };
  55588. /**
  55589. * The name of the layer
  55590. */
  55591. name: string;
  55592. /**
  55593. * The clear color of the texture used to generate the glow map.
  55594. */
  55595. neutralColor: Color4;
  55596. /**
  55597. * Specifies whether the highlight layer is enabled or not.
  55598. */
  55599. isEnabled: boolean;
  55600. /**
  55601. * Gets the camera attached to the layer.
  55602. */
  55603. get camera(): Nullable<Camera>;
  55604. /**
  55605. * Gets the rendering group id the layer should render in.
  55606. */
  55607. get renderingGroupId(): number;
  55608. set renderingGroupId(renderingGroupId: number);
  55609. /**
  55610. * An event triggered when the effect layer has been disposed.
  55611. */
  55612. onDisposeObservable: Observable<EffectLayer>;
  55613. /**
  55614. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  55615. */
  55616. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  55617. /**
  55618. * An event triggered when the generated texture is being merged in the scene.
  55619. */
  55620. onBeforeComposeObservable: Observable<EffectLayer>;
  55621. /**
  55622. * An event triggered when the mesh is rendered into the effect render target.
  55623. */
  55624. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  55625. /**
  55626. * An event triggered after the mesh has been rendered into the effect render target.
  55627. */
  55628. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  55629. /**
  55630. * An event triggered when the generated texture has been merged in the scene.
  55631. */
  55632. onAfterComposeObservable: Observable<EffectLayer>;
  55633. /**
  55634. * An event triggered when the efffect layer changes its size.
  55635. */
  55636. onSizeChangedObservable: Observable<EffectLayer>;
  55637. /** @hidden */
  55638. static _SceneComponentInitialization: (scene: Scene) => void;
  55639. /**
  55640. * Instantiates a new effect Layer and references it in the scene.
  55641. * @param name The name of the layer
  55642. * @param scene The scene to use the layer in
  55643. */
  55644. constructor(
  55645. /** The Friendly of the effect in the scene */
  55646. name: string, scene: Scene);
  55647. /**
  55648. * Get the effect name of the layer.
  55649. * @return The effect name
  55650. */
  55651. abstract getEffectName(): string;
  55652. /**
  55653. * Checks for the readiness of the element composing the layer.
  55654. * @param subMesh the mesh to check for
  55655. * @param useInstances specify whether or not to use instances to render the mesh
  55656. * @return true if ready otherwise, false
  55657. */
  55658. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  55659. /**
  55660. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  55661. * @returns true if the effect requires stencil during the main canvas render pass.
  55662. */
  55663. abstract needStencil(): boolean;
  55664. /**
  55665. * Create the merge effect. This is the shader use to blit the information back
  55666. * to the main canvas at the end of the scene rendering.
  55667. * @returns The effect containing the shader used to merge the effect on the main canvas
  55668. */
  55669. protected abstract _createMergeEffect(): Effect;
  55670. /**
  55671. * Creates the render target textures and post processes used in the effect layer.
  55672. */
  55673. protected abstract _createTextureAndPostProcesses(): void;
  55674. /**
  55675. * Implementation specific of rendering the generating effect on the main canvas.
  55676. * @param effect The effect used to render through
  55677. */
  55678. protected abstract _internalRender(effect: Effect): void;
  55679. /**
  55680. * Sets the required values for both the emissive texture and and the main color.
  55681. */
  55682. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  55683. /**
  55684. * Free any resources and references associated to a mesh.
  55685. * Internal use
  55686. * @param mesh The mesh to free.
  55687. */
  55688. abstract _disposeMesh(mesh: Mesh): void;
  55689. /**
  55690. * Serializes this layer (Glow or Highlight for example)
  55691. * @returns a serialized layer object
  55692. */
  55693. abstract serialize?(): any;
  55694. /**
  55695. * Initializes the effect layer with the required options.
  55696. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  55697. */
  55698. protected _init(options: Partial<IEffectLayerOptions>): void;
  55699. /**
  55700. * Generates the index buffer of the full screen quad blending to the main canvas.
  55701. */
  55702. private _generateIndexBuffer;
  55703. /**
  55704. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  55705. */
  55706. private _generateVertexBuffer;
  55707. /**
  55708. * Sets the main texture desired size which is the closest power of two
  55709. * of the engine canvas size.
  55710. */
  55711. private _setMainTextureSize;
  55712. /**
  55713. * Creates the main texture for the effect layer.
  55714. */
  55715. protected _createMainTexture(): void;
  55716. /**
  55717. * Adds specific effects defines.
  55718. * @param defines The defines to add specifics to.
  55719. */
  55720. protected _addCustomEffectDefines(defines: string[]): void;
  55721. /**
  55722. * Checks for the readiness of the element composing the layer.
  55723. * @param subMesh the mesh to check for
  55724. * @param useInstances specify whether or not to use instances to render the mesh
  55725. * @param emissiveTexture the associated emissive texture used to generate the glow
  55726. * @return true if ready otherwise, false
  55727. */
  55728. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  55729. /**
  55730. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  55731. */
  55732. render(): void;
  55733. /**
  55734. * Determine if a given mesh will be used in the current effect.
  55735. * @param mesh mesh to test
  55736. * @returns true if the mesh will be used
  55737. */
  55738. hasMesh(mesh: AbstractMesh): boolean;
  55739. /**
  55740. * Returns true if the layer contains information to display, otherwise false.
  55741. * @returns true if the glow layer should be rendered
  55742. */
  55743. shouldRender(): boolean;
  55744. /**
  55745. * Returns true if the mesh should render, otherwise false.
  55746. * @param mesh The mesh to render
  55747. * @returns true if it should render otherwise false
  55748. */
  55749. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  55750. /**
  55751. * Returns true if the mesh can be rendered, otherwise false.
  55752. * @param mesh The mesh to render
  55753. * @param material The material used on the mesh
  55754. * @returns true if it can be rendered otherwise false
  55755. */
  55756. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  55757. /**
  55758. * Returns true if the mesh should render, otherwise false.
  55759. * @param mesh The mesh to render
  55760. * @returns true if it should render otherwise false
  55761. */
  55762. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  55763. /**
  55764. * Renders the submesh passed in parameter to the generation map.
  55765. */
  55766. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  55767. /**
  55768. * Defines whether the current material of the mesh should be use to render the effect.
  55769. * @param mesh defines the current mesh to render
  55770. */
  55771. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  55772. /**
  55773. * Rebuild the required buffers.
  55774. * @hidden Internal use only.
  55775. */
  55776. _rebuild(): void;
  55777. /**
  55778. * Dispose only the render target textures and post process.
  55779. */
  55780. private _disposeTextureAndPostProcesses;
  55781. /**
  55782. * Dispose the highlight layer and free resources.
  55783. */
  55784. dispose(): void;
  55785. /**
  55786. * Gets the class name of the effect layer
  55787. * @returns the string with the class name of the effect layer
  55788. */
  55789. getClassName(): string;
  55790. /**
  55791. * Creates an effect layer from parsed effect layer data
  55792. * @param parsedEffectLayer defines effect layer data
  55793. * @param scene defines the current scene
  55794. * @param rootUrl defines the root URL containing the effect layer information
  55795. * @returns a parsed effect Layer
  55796. */
  55797. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  55798. }
  55799. }
  55800. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  55801. import { Scene } from "babylonjs/scene";
  55802. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  55803. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  55804. import { AbstractScene } from "babylonjs/abstractScene";
  55805. module "babylonjs/abstractScene" {
  55806. interface AbstractScene {
  55807. /**
  55808. * The list of effect layers (highlights/glow) added to the scene
  55809. * @see http://doc.babylonjs.com/how_to/highlight_layer
  55810. * @see http://doc.babylonjs.com/how_to/glow_layer
  55811. */
  55812. effectLayers: Array<EffectLayer>;
  55813. /**
  55814. * Removes the given effect layer from this scene.
  55815. * @param toRemove defines the effect layer to remove
  55816. * @returns the index of the removed effect layer
  55817. */
  55818. removeEffectLayer(toRemove: EffectLayer): number;
  55819. /**
  55820. * Adds the given effect layer to this scene
  55821. * @param newEffectLayer defines the effect layer to add
  55822. */
  55823. addEffectLayer(newEffectLayer: EffectLayer): void;
  55824. }
  55825. }
  55826. /**
  55827. * Defines the layer scene component responsible to manage any effect layers
  55828. * in a given scene.
  55829. */
  55830. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  55831. /**
  55832. * The component name helpfull to identify the component in the list of scene components.
  55833. */
  55834. readonly name: string;
  55835. /**
  55836. * The scene the component belongs to.
  55837. */
  55838. scene: Scene;
  55839. private _engine;
  55840. private _renderEffects;
  55841. private _needStencil;
  55842. private _previousStencilState;
  55843. /**
  55844. * Creates a new instance of the component for the given scene
  55845. * @param scene Defines the scene to register the component in
  55846. */
  55847. constructor(scene: Scene);
  55848. /**
  55849. * Registers the component in a given scene
  55850. */
  55851. register(): void;
  55852. /**
  55853. * Rebuilds the elements related to this component in case of
  55854. * context lost for instance.
  55855. */
  55856. rebuild(): void;
  55857. /**
  55858. * Serializes the component data to the specified json object
  55859. * @param serializationObject The object to serialize to
  55860. */
  55861. serialize(serializationObject: any): void;
  55862. /**
  55863. * Adds all the elements from the container to the scene
  55864. * @param container the container holding the elements
  55865. */
  55866. addFromContainer(container: AbstractScene): void;
  55867. /**
  55868. * Removes all the elements in the container from the scene
  55869. * @param container contains the elements to remove
  55870. * @param dispose if the removed element should be disposed (default: false)
  55871. */
  55872. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  55873. /**
  55874. * Disposes the component and the associated ressources.
  55875. */
  55876. dispose(): void;
  55877. private _isReadyForMesh;
  55878. private _renderMainTexture;
  55879. private _setStencil;
  55880. private _setStencilBack;
  55881. private _draw;
  55882. private _drawCamera;
  55883. private _drawRenderingGroup;
  55884. }
  55885. }
  55886. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  55887. /** @hidden */
  55888. export var glowMapMergePixelShader: {
  55889. name: string;
  55890. shader: string;
  55891. };
  55892. }
  55893. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  55894. /** @hidden */
  55895. export var glowMapMergeVertexShader: {
  55896. name: string;
  55897. shader: string;
  55898. };
  55899. }
  55900. declare module "babylonjs/Layers/glowLayer" {
  55901. import { Nullable } from "babylonjs/types";
  55902. import { Camera } from "babylonjs/Cameras/camera";
  55903. import { Scene } from "babylonjs/scene";
  55904. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55905. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55906. import { Mesh } from "babylonjs/Meshes/mesh";
  55907. import { Texture } from "babylonjs/Materials/Textures/texture";
  55908. import { Effect } from "babylonjs/Materials/effect";
  55909. import { Material } from "babylonjs/Materials/material";
  55910. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  55911. import { Color4 } from "babylonjs/Maths/math.color";
  55912. import "babylonjs/Shaders/glowMapMerge.fragment";
  55913. import "babylonjs/Shaders/glowMapMerge.vertex";
  55914. import "babylonjs/Layers/effectLayerSceneComponent";
  55915. module "babylonjs/abstractScene" {
  55916. interface AbstractScene {
  55917. /**
  55918. * Return a the first highlight layer of the scene with a given name.
  55919. * @param name The name of the highlight layer to look for.
  55920. * @return The highlight layer if found otherwise null.
  55921. */
  55922. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  55923. }
  55924. }
  55925. /**
  55926. * Glow layer options. This helps customizing the behaviour
  55927. * of the glow layer.
  55928. */
  55929. export interface IGlowLayerOptions {
  55930. /**
  55931. * Multiplication factor apply to the canvas size to compute the render target size
  55932. * used to generated the glowing objects (the smaller the faster).
  55933. */
  55934. mainTextureRatio: number;
  55935. /**
  55936. * Enforces a fixed size texture to ensure resize independant blur.
  55937. */
  55938. mainTextureFixedSize?: number;
  55939. /**
  55940. * How big is the kernel of the blur texture.
  55941. */
  55942. blurKernelSize: number;
  55943. /**
  55944. * The camera attached to the layer.
  55945. */
  55946. camera: Nullable<Camera>;
  55947. /**
  55948. * Enable MSAA by chosing the number of samples.
  55949. */
  55950. mainTextureSamples?: number;
  55951. /**
  55952. * The rendering group to draw the layer in.
  55953. */
  55954. renderingGroupId: number;
  55955. }
  55956. /**
  55957. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  55958. *
  55959. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  55960. *
  55961. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  55962. */
  55963. export class GlowLayer extends EffectLayer {
  55964. /**
  55965. * Effect Name of the layer.
  55966. */
  55967. static readonly EffectName: string;
  55968. /**
  55969. * The default blur kernel size used for the glow.
  55970. */
  55971. static DefaultBlurKernelSize: number;
  55972. /**
  55973. * The default texture size ratio used for the glow.
  55974. */
  55975. static DefaultTextureRatio: number;
  55976. /**
  55977. * Sets the kernel size of the blur.
  55978. */
  55979. set blurKernelSize(value: number);
  55980. /**
  55981. * Gets the kernel size of the blur.
  55982. */
  55983. get blurKernelSize(): number;
  55984. /**
  55985. * Sets the glow intensity.
  55986. */
  55987. set intensity(value: number);
  55988. /**
  55989. * Gets the glow intensity.
  55990. */
  55991. get intensity(): number;
  55992. private _options;
  55993. private _intensity;
  55994. private _horizontalBlurPostprocess1;
  55995. private _verticalBlurPostprocess1;
  55996. private _horizontalBlurPostprocess2;
  55997. private _verticalBlurPostprocess2;
  55998. private _blurTexture1;
  55999. private _blurTexture2;
  56000. private _postProcesses1;
  56001. private _postProcesses2;
  56002. private _includedOnlyMeshes;
  56003. private _excludedMeshes;
  56004. private _meshesUsingTheirOwnMaterials;
  56005. /**
  56006. * Callback used to let the user override the color selection on a per mesh basis
  56007. */
  56008. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  56009. /**
  56010. * Callback used to let the user override the texture selection on a per mesh basis
  56011. */
  56012. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  56013. /**
  56014. * Instantiates a new glow Layer and references it to the scene.
  56015. * @param name The name of the layer
  56016. * @param scene The scene to use the layer in
  56017. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  56018. */
  56019. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  56020. /**
  56021. * Get the effect name of the layer.
  56022. * @return The effect name
  56023. */
  56024. getEffectName(): string;
  56025. /**
  56026. * Create the merge effect. This is the shader use to blit the information back
  56027. * to the main canvas at the end of the scene rendering.
  56028. */
  56029. protected _createMergeEffect(): Effect;
  56030. /**
  56031. * Creates the render target textures and post processes used in the glow layer.
  56032. */
  56033. protected _createTextureAndPostProcesses(): void;
  56034. /**
  56035. * Checks for the readiness of the element composing the layer.
  56036. * @param subMesh the mesh to check for
  56037. * @param useInstances specify wether or not to use instances to render the mesh
  56038. * @param emissiveTexture the associated emissive texture used to generate the glow
  56039. * @return true if ready otherwise, false
  56040. */
  56041. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  56042. /**
  56043. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  56044. */
  56045. needStencil(): boolean;
  56046. /**
  56047. * Returns true if the mesh can be rendered, otherwise false.
  56048. * @param mesh The mesh to render
  56049. * @param material The material used on the mesh
  56050. * @returns true if it can be rendered otherwise false
  56051. */
  56052. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  56053. /**
  56054. * Implementation specific of rendering the generating effect on the main canvas.
  56055. * @param effect The effect used to render through
  56056. */
  56057. protected _internalRender(effect: Effect): void;
  56058. /**
  56059. * Sets the required values for both the emissive texture and and the main color.
  56060. */
  56061. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  56062. /**
  56063. * Returns true if the mesh should render, otherwise false.
  56064. * @param mesh The mesh to render
  56065. * @returns true if it should render otherwise false
  56066. */
  56067. protected _shouldRenderMesh(mesh: Mesh): boolean;
  56068. /**
  56069. * Adds specific effects defines.
  56070. * @param defines The defines to add specifics to.
  56071. */
  56072. protected _addCustomEffectDefines(defines: string[]): void;
  56073. /**
  56074. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  56075. * @param mesh The mesh to exclude from the glow layer
  56076. */
  56077. addExcludedMesh(mesh: Mesh): void;
  56078. /**
  56079. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  56080. * @param mesh The mesh to remove
  56081. */
  56082. removeExcludedMesh(mesh: Mesh): void;
  56083. /**
  56084. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  56085. * @param mesh The mesh to include in the glow layer
  56086. */
  56087. addIncludedOnlyMesh(mesh: Mesh): void;
  56088. /**
  56089. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  56090. * @param mesh The mesh to remove
  56091. */
  56092. removeIncludedOnlyMesh(mesh: Mesh): void;
  56093. /**
  56094. * Determine if a given mesh will be used in the glow layer
  56095. * @param mesh The mesh to test
  56096. * @returns true if the mesh will be highlighted by the current glow layer
  56097. */
  56098. hasMesh(mesh: AbstractMesh): boolean;
  56099. /**
  56100. * Defines whether the current material of the mesh should be use to render the effect.
  56101. * @param mesh defines the current mesh to render
  56102. */
  56103. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  56104. /**
  56105. * Add a mesh to be rendered through its own material and not with emissive only.
  56106. * @param mesh The mesh for which we need to use its material
  56107. */
  56108. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  56109. /**
  56110. * Remove a mesh from being rendered through its own material and not with emissive only.
  56111. * @param mesh The mesh for which we need to not use its material
  56112. */
  56113. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  56114. /**
  56115. * Free any resources and references associated to a mesh.
  56116. * Internal use
  56117. * @param mesh The mesh to free.
  56118. * @hidden
  56119. */
  56120. _disposeMesh(mesh: Mesh): void;
  56121. /**
  56122. * Gets the class name of the effect layer
  56123. * @returns the string with the class name of the effect layer
  56124. */
  56125. getClassName(): string;
  56126. /**
  56127. * Serializes this glow layer
  56128. * @returns a serialized glow layer object
  56129. */
  56130. serialize(): any;
  56131. /**
  56132. * Creates a Glow Layer from parsed glow layer data
  56133. * @param parsedGlowLayer defines glow layer data
  56134. * @param scene defines the current scene
  56135. * @param rootUrl defines the root URL containing the glow layer information
  56136. * @returns a parsed Glow Layer
  56137. */
  56138. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  56139. }
  56140. }
  56141. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  56142. /** @hidden */
  56143. export var glowBlurPostProcessPixelShader: {
  56144. name: string;
  56145. shader: string;
  56146. };
  56147. }
  56148. declare module "babylonjs/Layers/highlightLayer" {
  56149. import { Observable } from "babylonjs/Misc/observable";
  56150. import { Nullable } from "babylonjs/types";
  56151. import { Camera } from "babylonjs/Cameras/camera";
  56152. import { Scene } from "babylonjs/scene";
  56153. import { SubMesh } from "babylonjs/Meshes/subMesh";
  56154. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56155. import { Mesh } from "babylonjs/Meshes/mesh";
  56156. import { Effect } from "babylonjs/Materials/effect";
  56157. import { Material } from "babylonjs/Materials/material";
  56158. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  56159. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  56160. import "babylonjs/Shaders/glowMapMerge.fragment";
  56161. import "babylonjs/Shaders/glowMapMerge.vertex";
  56162. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  56163. module "babylonjs/abstractScene" {
  56164. interface AbstractScene {
  56165. /**
  56166. * Return a the first highlight layer of the scene with a given name.
  56167. * @param name The name of the highlight layer to look for.
  56168. * @return The highlight layer if found otherwise null.
  56169. */
  56170. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  56171. }
  56172. }
  56173. /**
  56174. * Highlight layer options. This helps customizing the behaviour
  56175. * of the highlight layer.
  56176. */
  56177. export interface IHighlightLayerOptions {
  56178. /**
  56179. * Multiplication factor apply to the canvas size to compute the render target size
  56180. * used to generated the glowing objects (the smaller the faster).
  56181. */
  56182. mainTextureRatio: number;
  56183. /**
  56184. * Enforces a fixed size texture to ensure resize independant blur.
  56185. */
  56186. mainTextureFixedSize?: number;
  56187. /**
  56188. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  56189. * of the picture to blur (the smaller the faster).
  56190. */
  56191. blurTextureSizeRatio: number;
  56192. /**
  56193. * How big in texel of the blur texture is the vertical blur.
  56194. */
  56195. blurVerticalSize: number;
  56196. /**
  56197. * How big in texel of the blur texture is the horizontal blur.
  56198. */
  56199. blurHorizontalSize: number;
  56200. /**
  56201. * Alpha blending mode used to apply the blur. Default is combine.
  56202. */
  56203. alphaBlendingMode: number;
  56204. /**
  56205. * The camera attached to the layer.
  56206. */
  56207. camera: Nullable<Camera>;
  56208. /**
  56209. * Should we display highlight as a solid stroke?
  56210. */
  56211. isStroke?: boolean;
  56212. /**
  56213. * The rendering group to draw the layer in.
  56214. */
  56215. renderingGroupId: number;
  56216. }
  56217. /**
  56218. * The highlight layer Helps adding a glow effect around a mesh.
  56219. *
  56220. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  56221. * glowy meshes to your scene.
  56222. *
  56223. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  56224. */
  56225. export class HighlightLayer extends EffectLayer {
  56226. name: string;
  56227. /**
  56228. * Effect Name of the highlight layer.
  56229. */
  56230. static readonly EffectName: string;
  56231. /**
  56232. * The neutral color used during the preparation of the glow effect.
  56233. * This is black by default as the blend operation is a blend operation.
  56234. */
  56235. static NeutralColor: Color4;
  56236. /**
  56237. * Stencil value used for glowing meshes.
  56238. */
  56239. static GlowingMeshStencilReference: number;
  56240. /**
  56241. * Stencil value used for the other meshes in the scene.
  56242. */
  56243. static NormalMeshStencilReference: number;
  56244. /**
  56245. * Specifies whether or not the inner glow is ACTIVE in the layer.
  56246. */
  56247. innerGlow: boolean;
  56248. /**
  56249. * Specifies whether or not the outer glow is ACTIVE in the layer.
  56250. */
  56251. outerGlow: boolean;
  56252. /**
  56253. * Specifies the horizontal size of the blur.
  56254. */
  56255. set blurHorizontalSize(value: number);
  56256. /**
  56257. * Specifies the vertical size of the blur.
  56258. */
  56259. set blurVerticalSize(value: number);
  56260. /**
  56261. * Gets the horizontal size of the blur.
  56262. */
  56263. get blurHorizontalSize(): number;
  56264. /**
  56265. * Gets the vertical size of the blur.
  56266. */
  56267. get blurVerticalSize(): number;
  56268. /**
  56269. * An event triggered when the highlight layer is being blurred.
  56270. */
  56271. onBeforeBlurObservable: Observable<HighlightLayer>;
  56272. /**
  56273. * An event triggered when the highlight layer has been blurred.
  56274. */
  56275. onAfterBlurObservable: Observable<HighlightLayer>;
  56276. private _instanceGlowingMeshStencilReference;
  56277. private _options;
  56278. private _downSamplePostprocess;
  56279. private _horizontalBlurPostprocess;
  56280. private _verticalBlurPostprocess;
  56281. private _blurTexture;
  56282. private _meshes;
  56283. private _excludedMeshes;
  56284. /**
  56285. * Instantiates a new highlight Layer and references it to the scene..
  56286. * @param name The name of the layer
  56287. * @param scene The scene to use the layer in
  56288. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  56289. */
  56290. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  56291. /**
  56292. * Get the effect name of the layer.
  56293. * @return The effect name
  56294. */
  56295. getEffectName(): string;
  56296. /**
  56297. * Create the merge effect. This is the shader use to blit the information back
  56298. * to the main canvas at the end of the scene rendering.
  56299. */
  56300. protected _createMergeEffect(): Effect;
  56301. /**
  56302. * Creates the render target textures and post processes used in the highlight layer.
  56303. */
  56304. protected _createTextureAndPostProcesses(): void;
  56305. /**
  56306. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  56307. */
  56308. needStencil(): boolean;
  56309. /**
  56310. * Checks for the readiness of the element composing the layer.
  56311. * @param subMesh the mesh to check for
  56312. * @param useInstances specify wether or not to use instances to render the mesh
  56313. * @param emissiveTexture the associated emissive texture used to generate the glow
  56314. * @return true if ready otherwise, false
  56315. */
  56316. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  56317. /**
  56318. * Implementation specific of rendering the generating effect on the main canvas.
  56319. * @param effect The effect used to render through
  56320. */
  56321. protected _internalRender(effect: Effect): void;
  56322. /**
  56323. * Returns true if the layer contains information to display, otherwise false.
  56324. */
  56325. shouldRender(): boolean;
  56326. /**
  56327. * Returns true if the mesh should render, otherwise false.
  56328. * @param mesh The mesh to render
  56329. * @returns true if it should render otherwise false
  56330. */
  56331. protected _shouldRenderMesh(mesh: Mesh): boolean;
  56332. /**
  56333. * Adds specific effects defines.
  56334. * @param defines The defines to add specifics to.
  56335. */
  56336. protected _addCustomEffectDefines(defines: string[]): void;
  56337. /**
  56338. * Sets the required values for both the emissive texture and and the main color.
  56339. */
  56340. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  56341. /**
  56342. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  56343. * @param mesh The mesh to exclude from the highlight layer
  56344. */
  56345. addExcludedMesh(mesh: Mesh): void;
  56346. /**
  56347. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  56348. * @param mesh The mesh to highlight
  56349. */
  56350. removeExcludedMesh(mesh: Mesh): void;
  56351. /**
  56352. * Determine if a given mesh will be highlighted by the current HighlightLayer
  56353. * @param mesh mesh to test
  56354. * @returns true if the mesh will be highlighted by the current HighlightLayer
  56355. */
  56356. hasMesh(mesh: AbstractMesh): boolean;
  56357. /**
  56358. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  56359. * @param mesh The mesh to highlight
  56360. * @param color The color of the highlight
  56361. * @param glowEmissiveOnly Extract the glow from the emissive texture
  56362. */
  56363. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  56364. /**
  56365. * Remove a mesh from the highlight layer in order to make it stop glowing.
  56366. * @param mesh The mesh to highlight
  56367. */
  56368. removeMesh(mesh: Mesh): void;
  56369. /**
  56370. * Remove all the meshes currently referenced in the highlight layer
  56371. */
  56372. removeAllMeshes(): void;
  56373. /**
  56374. * Force the stencil to the normal expected value for none glowing parts
  56375. */
  56376. private _defaultStencilReference;
  56377. /**
  56378. * Free any resources and references associated to a mesh.
  56379. * Internal use
  56380. * @param mesh The mesh to free.
  56381. * @hidden
  56382. */
  56383. _disposeMesh(mesh: Mesh): void;
  56384. /**
  56385. * Dispose the highlight layer and free resources.
  56386. */
  56387. dispose(): void;
  56388. /**
  56389. * Gets the class name of the effect layer
  56390. * @returns the string with the class name of the effect layer
  56391. */
  56392. getClassName(): string;
  56393. /**
  56394. * Serializes this Highlight layer
  56395. * @returns a serialized Highlight layer object
  56396. */
  56397. serialize(): any;
  56398. /**
  56399. * Creates a Highlight layer from parsed Highlight layer data
  56400. * @param parsedHightlightLayer defines the Highlight layer data
  56401. * @param scene defines the current scene
  56402. * @param rootUrl defines the root URL containing the Highlight layer information
  56403. * @returns a parsed Highlight layer
  56404. */
  56405. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  56406. }
  56407. }
  56408. declare module "babylonjs/Layers/layerSceneComponent" {
  56409. import { Scene } from "babylonjs/scene";
  56410. import { ISceneComponent } from "babylonjs/sceneComponent";
  56411. import { Layer } from "babylonjs/Layers/layer";
  56412. import { AbstractScene } from "babylonjs/abstractScene";
  56413. module "babylonjs/abstractScene" {
  56414. interface AbstractScene {
  56415. /**
  56416. * The list of layers (background and foreground) of the scene
  56417. */
  56418. layers: Array<Layer>;
  56419. }
  56420. }
  56421. /**
  56422. * Defines the layer scene component responsible to manage any layers
  56423. * in a given scene.
  56424. */
  56425. export class LayerSceneComponent implements ISceneComponent {
  56426. /**
  56427. * The component name helpfull to identify the component in the list of scene components.
  56428. */
  56429. readonly name: string;
  56430. /**
  56431. * The scene the component belongs to.
  56432. */
  56433. scene: Scene;
  56434. private _engine;
  56435. /**
  56436. * Creates a new instance of the component for the given scene
  56437. * @param scene Defines the scene to register the component in
  56438. */
  56439. constructor(scene: Scene);
  56440. /**
  56441. * Registers the component in a given scene
  56442. */
  56443. register(): void;
  56444. /**
  56445. * Rebuilds the elements related to this component in case of
  56446. * context lost for instance.
  56447. */
  56448. rebuild(): void;
  56449. /**
  56450. * Disposes the component and the associated ressources.
  56451. */
  56452. dispose(): void;
  56453. private _draw;
  56454. private _drawCameraPredicate;
  56455. private _drawCameraBackground;
  56456. private _drawCameraForeground;
  56457. private _drawRenderTargetPredicate;
  56458. private _drawRenderTargetBackground;
  56459. private _drawRenderTargetForeground;
  56460. /**
  56461. * Adds all the elements from the container to the scene
  56462. * @param container the container holding the elements
  56463. */
  56464. addFromContainer(container: AbstractScene): void;
  56465. /**
  56466. * Removes all the elements in the container from the scene
  56467. * @param container contains the elements to remove
  56468. * @param dispose if the removed element should be disposed (default: false)
  56469. */
  56470. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  56471. }
  56472. }
  56473. declare module "babylonjs/Shaders/layer.fragment" {
  56474. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  56475. /** @hidden */
  56476. export var layerPixelShader: {
  56477. name: string;
  56478. shader: string;
  56479. };
  56480. }
  56481. declare module "babylonjs/Shaders/layer.vertex" {
  56482. /** @hidden */
  56483. export var layerVertexShader: {
  56484. name: string;
  56485. shader: string;
  56486. };
  56487. }
  56488. declare module "babylonjs/Layers/layer" {
  56489. import { Observable } from "babylonjs/Misc/observable";
  56490. import { Nullable } from "babylonjs/types";
  56491. import { Scene } from "babylonjs/scene";
  56492. import { Vector2 } from "babylonjs/Maths/math.vector";
  56493. import { Color4 } from "babylonjs/Maths/math.color";
  56494. import { Texture } from "babylonjs/Materials/Textures/texture";
  56495. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  56496. import "babylonjs/Shaders/layer.fragment";
  56497. import "babylonjs/Shaders/layer.vertex";
  56498. /**
  56499. * This represents a full screen 2d layer.
  56500. * This can be useful to display a picture in the background of your scene for instance.
  56501. * @see https://www.babylonjs-playground.com/#08A2BS#1
  56502. */
  56503. export class Layer {
  56504. /**
  56505. * Define the name of the layer.
  56506. */
  56507. name: string;
  56508. /**
  56509. * Define the texture the layer should display.
  56510. */
  56511. texture: Nullable<Texture>;
  56512. /**
  56513. * Is the layer in background or foreground.
  56514. */
  56515. isBackground: boolean;
  56516. /**
  56517. * Define the color of the layer (instead of texture).
  56518. */
  56519. color: Color4;
  56520. /**
  56521. * Define the scale of the layer in order to zoom in out of the texture.
  56522. */
  56523. scale: Vector2;
  56524. /**
  56525. * Define an offset for the layer in order to shift the texture.
  56526. */
  56527. offset: Vector2;
  56528. /**
  56529. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  56530. */
  56531. alphaBlendingMode: number;
  56532. /**
  56533. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  56534. * Alpha test will not mix with the background color in case of transparency.
  56535. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  56536. */
  56537. alphaTest: boolean;
  56538. /**
  56539. * Define a mask to restrict the layer to only some of the scene cameras.
  56540. */
  56541. layerMask: number;
  56542. /**
  56543. * Define the list of render target the layer is visible into.
  56544. */
  56545. renderTargetTextures: RenderTargetTexture[];
  56546. /**
  56547. * Define if the layer is only used in renderTarget or if it also
  56548. * renders in the main frame buffer of the canvas.
  56549. */
  56550. renderOnlyInRenderTargetTextures: boolean;
  56551. private _scene;
  56552. private _vertexBuffers;
  56553. private _indexBuffer;
  56554. private _effect;
  56555. private _previousDefines;
  56556. /**
  56557. * An event triggered when the layer is disposed.
  56558. */
  56559. onDisposeObservable: Observable<Layer>;
  56560. private _onDisposeObserver;
  56561. /**
  56562. * Back compatibility with callback before the onDisposeObservable existed.
  56563. * The set callback will be triggered when the layer has been disposed.
  56564. */
  56565. set onDispose(callback: () => void);
  56566. /**
  56567. * An event triggered before rendering the scene
  56568. */
  56569. onBeforeRenderObservable: Observable<Layer>;
  56570. private _onBeforeRenderObserver;
  56571. /**
  56572. * Back compatibility with callback before the onBeforeRenderObservable existed.
  56573. * The set callback will be triggered just before rendering the layer.
  56574. */
  56575. set onBeforeRender(callback: () => void);
  56576. /**
  56577. * An event triggered after rendering the scene
  56578. */
  56579. onAfterRenderObservable: Observable<Layer>;
  56580. private _onAfterRenderObserver;
  56581. /**
  56582. * Back compatibility with callback before the onAfterRenderObservable existed.
  56583. * The set callback will be triggered just after rendering the layer.
  56584. */
  56585. set onAfterRender(callback: () => void);
  56586. /**
  56587. * Instantiates a new layer.
  56588. * This represents a full screen 2d layer.
  56589. * This can be useful to display a picture in the background of your scene for instance.
  56590. * @see https://www.babylonjs-playground.com/#08A2BS#1
  56591. * @param name Define the name of the layer in the scene
  56592. * @param imgUrl Define the url of the texture to display in the layer
  56593. * @param scene Define the scene the layer belongs to
  56594. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  56595. * @param color Defines a color for the layer
  56596. */
  56597. constructor(
  56598. /**
  56599. * Define the name of the layer.
  56600. */
  56601. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  56602. private _createIndexBuffer;
  56603. /** @hidden */
  56604. _rebuild(): void;
  56605. /**
  56606. * Renders the layer in the scene.
  56607. */
  56608. render(): void;
  56609. /**
  56610. * Disposes and releases the associated ressources.
  56611. */
  56612. dispose(): void;
  56613. }
  56614. }
  56615. declare module "babylonjs/Layers/index" {
  56616. export * from "babylonjs/Layers/effectLayer";
  56617. export * from "babylonjs/Layers/effectLayerSceneComponent";
  56618. export * from "babylonjs/Layers/glowLayer";
  56619. export * from "babylonjs/Layers/highlightLayer";
  56620. export * from "babylonjs/Layers/layer";
  56621. export * from "babylonjs/Layers/layerSceneComponent";
  56622. }
  56623. declare module "babylonjs/Shaders/lensFlare.fragment" {
  56624. /** @hidden */
  56625. export var lensFlarePixelShader: {
  56626. name: string;
  56627. shader: string;
  56628. };
  56629. }
  56630. declare module "babylonjs/Shaders/lensFlare.vertex" {
  56631. /** @hidden */
  56632. export var lensFlareVertexShader: {
  56633. name: string;
  56634. shader: string;
  56635. };
  56636. }
  56637. declare module "babylonjs/LensFlares/lensFlareSystem" {
  56638. import { Scene } from "babylonjs/scene";
  56639. import { Vector3 } from "babylonjs/Maths/math.vector";
  56640. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56641. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  56642. import "babylonjs/Shaders/lensFlare.fragment";
  56643. import "babylonjs/Shaders/lensFlare.vertex";
  56644. import { Viewport } from "babylonjs/Maths/math.viewport";
  56645. /**
  56646. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  56647. * It is usually composed of several `lensFlare`.
  56648. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56649. */
  56650. export class LensFlareSystem {
  56651. /**
  56652. * Define the name of the lens flare system
  56653. */
  56654. name: string;
  56655. /**
  56656. * List of lens flares used in this system.
  56657. */
  56658. lensFlares: LensFlare[];
  56659. /**
  56660. * Define a limit from the border the lens flare can be visible.
  56661. */
  56662. borderLimit: number;
  56663. /**
  56664. * Define a viewport border we do not want to see the lens flare in.
  56665. */
  56666. viewportBorder: number;
  56667. /**
  56668. * Define a predicate which could limit the list of meshes able to occlude the effect.
  56669. */
  56670. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  56671. /**
  56672. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  56673. */
  56674. layerMask: number;
  56675. /**
  56676. * Define the id of the lens flare system in the scene.
  56677. * (equal to name by default)
  56678. */
  56679. id: string;
  56680. private _scene;
  56681. private _emitter;
  56682. private _vertexBuffers;
  56683. private _indexBuffer;
  56684. private _effect;
  56685. private _positionX;
  56686. private _positionY;
  56687. private _isEnabled;
  56688. /** @hidden */
  56689. static _SceneComponentInitialization: (scene: Scene) => void;
  56690. /**
  56691. * Instantiates a lens flare system.
  56692. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  56693. * It is usually composed of several `lensFlare`.
  56694. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56695. * @param name Define the name of the lens flare system in the scene
  56696. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  56697. * @param scene Define the scene the lens flare system belongs to
  56698. */
  56699. constructor(
  56700. /**
  56701. * Define the name of the lens flare system
  56702. */
  56703. name: string, emitter: any, scene: Scene);
  56704. /**
  56705. * Define if the lens flare system is enabled.
  56706. */
  56707. get isEnabled(): boolean;
  56708. set isEnabled(value: boolean);
  56709. /**
  56710. * Get the scene the effects belongs to.
  56711. * @returns the scene holding the lens flare system
  56712. */
  56713. getScene(): Scene;
  56714. /**
  56715. * Get the emitter of the lens flare system.
  56716. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  56717. * @returns the emitter of the lens flare system
  56718. */
  56719. getEmitter(): any;
  56720. /**
  56721. * Set the emitter of the lens flare system.
  56722. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  56723. * @param newEmitter Define the new emitter of the system
  56724. */
  56725. setEmitter(newEmitter: any): void;
  56726. /**
  56727. * Get the lens flare system emitter position.
  56728. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  56729. * @returns the position
  56730. */
  56731. getEmitterPosition(): Vector3;
  56732. /**
  56733. * @hidden
  56734. */
  56735. computeEffectivePosition(globalViewport: Viewport): boolean;
  56736. /** @hidden */
  56737. _isVisible(): boolean;
  56738. /**
  56739. * @hidden
  56740. */
  56741. render(): boolean;
  56742. /**
  56743. * Dispose and release the lens flare with its associated resources.
  56744. */
  56745. dispose(): void;
  56746. /**
  56747. * Parse a lens flare system from a JSON repressentation
  56748. * @param parsedLensFlareSystem Define the JSON to parse
  56749. * @param scene Define the scene the parsed system should be instantiated in
  56750. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  56751. * @returns the parsed system
  56752. */
  56753. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  56754. /**
  56755. * Serialize the current Lens Flare System into a JSON representation.
  56756. * @returns the serialized JSON
  56757. */
  56758. serialize(): any;
  56759. }
  56760. }
  56761. declare module "babylonjs/LensFlares/lensFlare" {
  56762. import { Nullable } from "babylonjs/types";
  56763. import { Color3 } from "babylonjs/Maths/math.color";
  56764. import { Texture } from "babylonjs/Materials/Textures/texture";
  56765. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  56766. /**
  56767. * This represents one of the lens effect in a `lensFlareSystem`.
  56768. * It controls one of the indiviual texture used in the effect.
  56769. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56770. */
  56771. export class LensFlare {
  56772. /**
  56773. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  56774. */
  56775. size: number;
  56776. /**
  56777. * 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.
  56778. */
  56779. position: number;
  56780. /**
  56781. * Define the lens color.
  56782. */
  56783. color: Color3;
  56784. /**
  56785. * Define the lens texture.
  56786. */
  56787. texture: Nullable<Texture>;
  56788. /**
  56789. * Define the alpha mode to render this particular lens.
  56790. */
  56791. alphaMode: number;
  56792. private _system;
  56793. /**
  56794. * Creates a new Lens Flare.
  56795. * This represents one of the lens effect in a `lensFlareSystem`.
  56796. * It controls one of the indiviual texture used in the effect.
  56797. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56798. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  56799. * @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.
  56800. * @param color Define the lens color
  56801. * @param imgUrl Define the lens texture url
  56802. * @param system Define the `lensFlareSystem` this flare is part of
  56803. * @returns The newly created Lens Flare
  56804. */
  56805. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  56806. /**
  56807. * Instantiates a new Lens Flare.
  56808. * This represents one of the lens effect in a `lensFlareSystem`.
  56809. * It controls one of the indiviual texture used in the effect.
  56810. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56811. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  56812. * @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.
  56813. * @param color Define the lens color
  56814. * @param imgUrl Define the lens texture url
  56815. * @param system Define the `lensFlareSystem` this flare is part of
  56816. */
  56817. constructor(
  56818. /**
  56819. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  56820. */
  56821. size: number,
  56822. /**
  56823. * 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.
  56824. */
  56825. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  56826. /**
  56827. * Dispose and release the lens flare with its associated resources.
  56828. */
  56829. dispose(): void;
  56830. }
  56831. }
  56832. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  56833. import { Nullable } from "babylonjs/types";
  56834. import { Scene } from "babylonjs/scene";
  56835. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  56836. import { AbstractScene } from "babylonjs/abstractScene";
  56837. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  56838. module "babylonjs/abstractScene" {
  56839. interface AbstractScene {
  56840. /**
  56841. * The list of lens flare system added to the scene
  56842. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56843. */
  56844. lensFlareSystems: Array<LensFlareSystem>;
  56845. /**
  56846. * Removes the given lens flare system from this scene.
  56847. * @param toRemove The lens flare system to remove
  56848. * @returns The index of the removed lens flare system
  56849. */
  56850. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  56851. /**
  56852. * Adds the given lens flare system to this scene
  56853. * @param newLensFlareSystem The lens flare system to add
  56854. */
  56855. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  56856. /**
  56857. * Gets a lens flare system using its name
  56858. * @param name defines the name to look for
  56859. * @returns the lens flare system or null if not found
  56860. */
  56861. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  56862. /**
  56863. * Gets a lens flare system using its id
  56864. * @param id defines the id to look for
  56865. * @returns the lens flare system or null if not found
  56866. */
  56867. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  56868. }
  56869. }
  56870. /**
  56871. * Defines the lens flare scene component responsible to manage any lens flares
  56872. * in a given scene.
  56873. */
  56874. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  56875. /**
  56876. * The component name helpfull to identify the component in the list of scene components.
  56877. */
  56878. readonly name: string;
  56879. /**
  56880. * The scene the component belongs to.
  56881. */
  56882. scene: Scene;
  56883. /**
  56884. * Creates a new instance of the component for the given scene
  56885. * @param scene Defines the scene to register the component in
  56886. */
  56887. constructor(scene: Scene);
  56888. /**
  56889. * Registers the component in a given scene
  56890. */
  56891. register(): void;
  56892. /**
  56893. * Rebuilds the elements related to this component in case of
  56894. * context lost for instance.
  56895. */
  56896. rebuild(): void;
  56897. /**
  56898. * Adds all the elements from the container to the scene
  56899. * @param container the container holding the elements
  56900. */
  56901. addFromContainer(container: AbstractScene): void;
  56902. /**
  56903. * Removes all the elements in the container from the scene
  56904. * @param container contains the elements to remove
  56905. * @param dispose if the removed element should be disposed (default: false)
  56906. */
  56907. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  56908. /**
  56909. * Serializes the component data to the specified json object
  56910. * @param serializationObject The object to serialize to
  56911. */
  56912. serialize(serializationObject: any): void;
  56913. /**
  56914. * Disposes the component and the associated ressources.
  56915. */
  56916. dispose(): void;
  56917. private _draw;
  56918. }
  56919. }
  56920. declare module "babylonjs/LensFlares/index" {
  56921. export * from "babylonjs/LensFlares/lensFlare";
  56922. export * from "babylonjs/LensFlares/lensFlareSystem";
  56923. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  56924. }
  56925. declare module "babylonjs/Shaders/depth.fragment" {
  56926. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  56927. /** @hidden */
  56928. export var depthPixelShader: {
  56929. name: string;
  56930. shader: string;
  56931. };
  56932. }
  56933. declare module "babylonjs/Shaders/depth.vertex" {
  56934. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  56935. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  56936. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  56937. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  56938. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  56939. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  56940. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  56941. /** @hidden */
  56942. export var depthVertexShader: {
  56943. name: string;
  56944. shader: string;
  56945. };
  56946. }
  56947. declare module "babylonjs/Rendering/depthRenderer" {
  56948. import { Nullable } from "babylonjs/types";
  56949. import { SubMesh } from "babylonjs/Meshes/subMesh";
  56950. import { Scene } from "babylonjs/scene";
  56951. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  56952. import { Camera } from "babylonjs/Cameras/camera";
  56953. import "babylonjs/Shaders/depth.fragment";
  56954. import "babylonjs/Shaders/depth.vertex";
  56955. /**
  56956. * This represents a depth renderer in Babylon.
  56957. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  56958. */
  56959. export class DepthRenderer {
  56960. private _scene;
  56961. private _depthMap;
  56962. private _effect;
  56963. private readonly _storeNonLinearDepth;
  56964. private readonly _clearColor;
  56965. /** Get if the depth renderer is using packed depth or not */
  56966. readonly isPacked: boolean;
  56967. private _cachedDefines;
  56968. private _camera;
  56969. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  56970. enabled: boolean;
  56971. /**
  56972. * Specifiess that the depth renderer will only be used within
  56973. * the camera it is created for.
  56974. * This can help forcing its rendering during the camera processing.
  56975. */
  56976. useOnlyInActiveCamera: boolean;
  56977. /** @hidden */
  56978. static _SceneComponentInitialization: (scene: Scene) => void;
  56979. /**
  56980. * Instantiates a depth renderer
  56981. * @param scene The scene the renderer belongs to
  56982. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  56983. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  56984. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  56985. */
  56986. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  56987. /**
  56988. * Creates the depth rendering effect and checks if the effect is ready.
  56989. * @param subMesh The submesh to be used to render the depth map of
  56990. * @param useInstances If multiple world instances should be used
  56991. * @returns if the depth renderer is ready to render the depth map
  56992. */
  56993. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  56994. /**
  56995. * Gets the texture which the depth map will be written to.
  56996. * @returns The depth map texture
  56997. */
  56998. getDepthMap(): RenderTargetTexture;
  56999. /**
  57000. * Disposes of the depth renderer.
  57001. */
  57002. dispose(): void;
  57003. }
  57004. }
  57005. declare module "babylonjs/Shaders/minmaxRedux.fragment" {
  57006. /** @hidden */
  57007. export var minmaxReduxPixelShader: {
  57008. name: string;
  57009. shader: string;
  57010. };
  57011. }
  57012. declare module "babylonjs/Misc/minMaxReducer" {
  57013. import { Nullable } from "babylonjs/types";
  57014. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  57015. import { Camera } from "babylonjs/Cameras/camera";
  57016. import { Observer } from "babylonjs/Misc/observable";
  57017. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  57018. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  57019. import { Observable } from "babylonjs/Misc/observable";
  57020. import "babylonjs/Shaders/minmaxRedux.fragment";
  57021. /**
  57022. * This class computes a min/max reduction from a texture: it means it computes the minimum
  57023. * and maximum values from all values of the texture.
  57024. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  57025. * The source values are read from the red channel of the texture.
  57026. */
  57027. export class MinMaxReducer {
  57028. /**
  57029. * Observable triggered when the computation has been performed
  57030. */
  57031. onAfterReductionPerformed: Observable<{
  57032. min: number;
  57033. max: number;
  57034. }>;
  57035. protected _camera: Camera;
  57036. protected _sourceTexture: Nullable<RenderTargetTexture>;
  57037. protected _reductionSteps: Nullable<Array<PostProcess>>;
  57038. protected _postProcessManager: PostProcessManager;
  57039. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  57040. protected _forceFullscreenViewport: boolean;
  57041. /**
  57042. * Creates a min/max reducer
  57043. * @param camera The camera to use for the post processes
  57044. */
  57045. constructor(camera: Camera);
  57046. /**
  57047. * Gets the texture used to read the values from.
  57048. */
  57049. get sourceTexture(): Nullable<RenderTargetTexture>;
  57050. /**
  57051. * Sets the source texture to read the values from.
  57052. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  57053. * because in such textures '1' value must not be taken into account to compute the maximum
  57054. * as this value is used to clear the texture.
  57055. * Note that the computation is not activated by calling this function, you must call activate() for that!
  57056. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  57057. * @param depthRedux Indicates if the texture is a depth texture or not
  57058. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  57059. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  57060. */
  57061. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  57062. /**
  57063. * Defines the refresh rate of the computation.
  57064. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  57065. */
  57066. get refreshRate(): number;
  57067. set refreshRate(value: number);
  57068. protected _activated: boolean;
  57069. /**
  57070. * Gets the activation status of the reducer
  57071. */
  57072. get activated(): boolean;
  57073. /**
  57074. * Activates the reduction computation.
  57075. * When activated, the observers registered in onAfterReductionPerformed are
  57076. * called after the compuation is performed
  57077. */
  57078. activate(): void;
  57079. /**
  57080. * Deactivates the reduction computation.
  57081. */
  57082. deactivate(): void;
  57083. /**
  57084. * Disposes the min/max reducer
  57085. * @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.
  57086. */
  57087. dispose(disposeAll?: boolean): void;
  57088. }
  57089. }
  57090. declare module "babylonjs/Misc/depthReducer" {
  57091. import { Nullable } from "babylonjs/types";
  57092. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  57093. import { Camera } from "babylonjs/Cameras/camera";
  57094. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  57095. import { MinMaxReducer } from "babylonjs/Misc/minMaxReducer";
  57096. /**
  57097. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  57098. */
  57099. export class DepthReducer extends MinMaxReducer {
  57100. private _depthRenderer;
  57101. private _depthRendererId;
  57102. /**
  57103. * Gets the depth renderer used for the computation.
  57104. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  57105. */
  57106. get depthRenderer(): Nullable<DepthRenderer>;
  57107. /**
  57108. * Creates a depth reducer
  57109. * @param camera The camera used to render the depth texture
  57110. */
  57111. constructor(camera: Camera);
  57112. /**
  57113. * Sets the depth renderer to use to generate the depth map
  57114. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  57115. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  57116. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  57117. */
  57118. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  57119. /** @hidden */
  57120. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  57121. /**
  57122. * Activates the reduction computation.
  57123. * When activated, the observers registered in onAfterReductionPerformed are
  57124. * called after the compuation is performed
  57125. */
  57126. activate(): void;
  57127. /**
  57128. * Deactivates the reduction computation.
  57129. */
  57130. deactivate(): void;
  57131. /**
  57132. * Disposes the depth reducer
  57133. * @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.
  57134. */
  57135. dispose(disposeAll?: boolean): void;
  57136. }
  57137. }
  57138. declare module "babylonjs/Lights/Shadows/cascadedShadowGenerator" {
  57139. import { Nullable } from "babylonjs/types";
  57140. import { Scene } from "babylonjs/scene";
  57141. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  57142. import { SubMesh } from "babylonjs/Meshes/subMesh";
  57143. import { Effect } from "babylonjs/Materials/effect";
  57144. import "babylonjs/Shaders/shadowMap.fragment";
  57145. import "babylonjs/Shaders/shadowMap.vertex";
  57146. import "babylonjs/Shaders/depthBoxBlur.fragment";
  57147. import { ShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  57148. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  57149. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  57150. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  57151. /**
  57152. * A CSM implementation allowing casting shadows on large scenes.
  57153. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  57154. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  57155. */
  57156. export class CascadedShadowGenerator extends ShadowGenerator {
  57157. private static readonly frustumCornersNDCSpace;
  57158. /**
  57159. * Name of the CSM class
  57160. */
  57161. static CLASSNAME: string;
  57162. /**
  57163. * Defines the default number of cascades used by the CSM.
  57164. */
  57165. static readonly DEFAULT_CASCADES_COUNT: number;
  57166. /**
  57167. * Defines the minimum number of cascades used by the CSM.
  57168. */
  57169. static readonly MIN_CASCADES_COUNT: number;
  57170. /**
  57171. * Defines the maximum number of cascades used by the CSM.
  57172. */
  57173. static readonly MAX_CASCADES_COUNT: number;
  57174. protected _validateFilter(filter: number): number;
  57175. /**
  57176. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  57177. */
  57178. penumbraDarkness: number;
  57179. private _numCascades;
  57180. /**
  57181. * Gets or set the number of cascades used by the CSM.
  57182. */
  57183. get numCascades(): number;
  57184. set numCascades(value: number);
  57185. /**
  57186. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  57187. * The trade off is that you loose some precision in the shadow rendering when enabling this setting.
  57188. */
  57189. stabilizeCascades: boolean;
  57190. private _freezeShadowCastersBoundingInfo;
  57191. private _freezeShadowCastersBoundingInfoObservable;
  57192. /**
  57193. * Enables or disables the shadow casters bounding info computation.
  57194. * If your shadow casters don't move, you can disable this feature.
  57195. * If it is enabled, the bounding box computation is done every frame.
  57196. */
  57197. get freezeShadowCastersBoundingInfo(): boolean;
  57198. set freezeShadowCastersBoundingInfo(freeze: boolean);
  57199. private _scbiMin;
  57200. private _scbiMax;
  57201. protected _computeShadowCastersBoundingInfo(): void;
  57202. protected _shadowCastersBoundingInfo: BoundingInfo;
  57203. /**
  57204. * Gets or sets the shadow casters bounding info.
  57205. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  57206. * so that the system won't overwrite the bounds you provide
  57207. */
  57208. get shadowCastersBoundingInfo(): BoundingInfo;
  57209. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  57210. protected _breaksAreDirty: boolean;
  57211. protected _minDistance: number;
  57212. protected _maxDistance: number;
  57213. /**
  57214. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  57215. *
  57216. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  57217. * If you don't know these values, simply leave them to their defaults and don't call this function.
  57218. * @param min minimal distance for the breaks (default to 0.)
  57219. * @param max maximal distance for the breaks (default to 1.)
  57220. */
  57221. setMinMaxDistance(min: number, max: number): void;
  57222. /** Gets the minimal distance used in the cascade break computation */
  57223. get minDistance(): number;
  57224. /** Gets the maximal distance used in the cascade break computation */
  57225. get maxDistance(): number;
  57226. /**
  57227. * Gets the class name of that object
  57228. * @returns "CascadedShadowGenerator"
  57229. */
  57230. getClassName(): string;
  57231. private _cascadeMinExtents;
  57232. private _cascadeMaxExtents;
  57233. /**
  57234. * Gets a cascade minimum extents
  57235. * @param cascadeIndex index of the cascade
  57236. * @returns the minimum cascade extents
  57237. */
  57238. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  57239. /**
  57240. * Gets a cascade maximum extents
  57241. * @param cascadeIndex index of the cascade
  57242. * @returns the maximum cascade extents
  57243. */
  57244. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  57245. private _cascades;
  57246. private _currentLayer;
  57247. private _viewSpaceFrustumsZ;
  57248. private _viewMatrices;
  57249. private _projectionMatrices;
  57250. private _transformMatrices;
  57251. private _transformMatricesAsArray;
  57252. private _frustumLengths;
  57253. private _lightSizeUVCorrection;
  57254. private _depthCorrection;
  57255. private _frustumCornersWorldSpace;
  57256. private _frustumCenter;
  57257. private _shadowCameraPos;
  57258. private _shadowMaxZ;
  57259. /**
  57260. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  57261. * It defaults to camera.maxZ
  57262. */
  57263. get shadowMaxZ(): number;
  57264. /**
  57265. * Sets the shadow max z distance.
  57266. */
  57267. set shadowMaxZ(value: number);
  57268. protected _debug: boolean;
  57269. /**
  57270. * Gets or sets the debug flag.
  57271. * When enabled, the cascades are materialized by different colors on the screen.
  57272. */
  57273. get debug(): boolean;
  57274. set debug(dbg: boolean);
  57275. private _depthClamp;
  57276. /**
  57277. * Gets or sets the depth clamping value.
  57278. *
  57279. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  57280. * to account for the shadow casters far away.
  57281. *
  57282. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  57283. */
  57284. get depthClamp(): boolean;
  57285. set depthClamp(value: boolean);
  57286. private _cascadeBlendPercentage;
  57287. /**
  57288. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  57289. * It defaults to 0.1 (10% blending).
  57290. */
  57291. get cascadeBlendPercentage(): number;
  57292. set cascadeBlendPercentage(value: number);
  57293. private _lambda;
  57294. /**
  57295. * Gets or set the lambda parameter.
  57296. * This parameter is used to split the camera frustum and create the cascades.
  57297. * 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.
  57298. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  57299. */
  57300. get lambda(): number;
  57301. set lambda(value: number);
  57302. /**
  57303. * Gets the view matrix corresponding to a given cascade
  57304. * @param cascadeNum cascade to retrieve the view matrix from
  57305. * @returns the cascade view matrix
  57306. */
  57307. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  57308. /**
  57309. * Gets the projection matrix corresponding to a given cascade
  57310. * @param cascadeNum cascade to retrieve the projection matrix from
  57311. * @returns the cascade projection matrix
  57312. */
  57313. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  57314. /**
  57315. * Gets the transformation matrix corresponding to a given cascade
  57316. * @param cascadeNum cascade to retrieve the transformation matrix from
  57317. * @returns the cascade transformation matrix
  57318. */
  57319. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  57320. private _depthRenderer;
  57321. /**
  57322. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  57323. *
  57324. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  57325. *
  57326. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  57327. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  57328. * @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
  57329. */
  57330. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  57331. private _depthReducer;
  57332. private _autoCalcDepthBounds;
  57333. /**
  57334. * Gets or sets the autoCalcDepthBounds property.
  57335. *
  57336. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  57337. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  57338. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  57339. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  57340. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  57341. */
  57342. get autoCalcDepthBounds(): boolean;
  57343. set autoCalcDepthBounds(value: boolean);
  57344. /**
  57345. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  57346. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  57347. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  57348. * for setting the refresh rate on the renderer yourself!
  57349. */
  57350. get autoCalcDepthBoundsRefreshRate(): number;
  57351. set autoCalcDepthBoundsRefreshRate(value: number);
  57352. /**
  57353. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  57354. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  57355. * you change the camera near/far planes!
  57356. */
  57357. splitFrustum(): void;
  57358. private _splitFrustum;
  57359. private _computeMatrices;
  57360. private _computeFrustumInWorldSpace;
  57361. private _computeCascadeFrustum;
  57362. /**
  57363. * Support test.
  57364. */
  57365. static get IsSupported(): boolean;
  57366. /** @hidden */
  57367. static _SceneComponentInitialization: (scene: Scene) => void;
  57368. /**
  57369. * Creates a Cascaded Shadow Generator object.
  57370. * A ShadowGenerator is the required tool to use the shadows.
  57371. * Each directional light casting shadows needs to use its own ShadowGenerator.
  57372. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  57373. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  57374. * @param light The directional light object generating the shadows.
  57375. * @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.
  57376. */
  57377. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  57378. protected _initializeGenerator(): void;
  57379. protected _createTargetRenderTexture(): void;
  57380. protected _initializeShadowMap(): void;
  57381. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect): void;
  57382. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  57383. /**
  57384. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  57385. * @param defines Defines of the material we want to update
  57386. * @param lightIndex Index of the light in the enabled light list of the material
  57387. */
  57388. prepareDefines(defines: any, lightIndex: number): void;
  57389. /**
  57390. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  57391. * defined in the generator but impacting the effect).
  57392. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  57393. * @param effect The effect we are binfing the information for
  57394. */
  57395. bindShadowLight(lightIndex: string, effect: Effect): void;
  57396. /**
  57397. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  57398. * (eq to view projection * shadow projection matrices)
  57399. * @returns The transform matrix used to create the shadow map
  57400. */
  57401. getTransformMatrix(): Matrix;
  57402. /**
  57403. * Disposes the ShadowGenerator.
  57404. * Returns nothing.
  57405. */
  57406. dispose(): void;
  57407. /**
  57408. * Serializes the shadow generator setup to a json object.
  57409. * @returns The serialized JSON object
  57410. */
  57411. serialize(): any;
  57412. /**
  57413. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  57414. * @param parsedShadowGenerator The JSON object to parse
  57415. * @param scene The scene to create the shadow map for
  57416. * @returns The parsed shadow generator
  57417. */
  57418. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  57419. }
  57420. }
  57421. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  57422. import { Scene } from "babylonjs/scene";
  57423. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  57424. import { AbstractScene } from "babylonjs/abstractScene";
  57425. /**
  57426. * Defines the shadow generator component responsible to manage any shadow generators
  57427. * in a given scene.
  57428. */
  57429. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  57430. /**
  57431. * The component name helpfull to identify the component in the list of scene components.
  57432. */
  57433. readonly name: string;
  57434. /**
  57435. * The scene the component belongs to.
  57436. */
  57437. scene: Scene;
  57438. /**
  57439. * Creates a new instance of the component for the given scene
  57440. * @param scene Defines the scene to register the component in
  57441. */
  57442. constructor(scene: Scene);
  57443. /**
  57444. * Registers the component in a given scene
  57445. */
  57446. register(): void;
  57447. /**
  57448. * Rebuilds the elements related to this component in case of
  57449. * context lost for instance.
  57450. */
  57451. rebuild(): void;
  57452. /**
  57453. * Serializes the component data to the specified json object
  57454. * @param serializationObject The object to serialize to
  57455. */
  57456. serialize(serializationObject: any): void;
  57457. /**
  57458. * Adds all the elements from the container to the scene
  57459. * @param container the container holding the elements
  57460. */
  57461. addFromContainer(container: AbstractScene): void;
  57462. /**
  57463. * Removes all the elements in the container from the scene
  57464. * @param container contains the elements to remove
  57465. * @param dispose if the removed element should be disposed (default: false)
  57466. */
  57467. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  57468. /**
  57469. * Rebuilds the elements related to this component in case of
  57470. * context lost for instance.
  57471. */
  57472. dispose(): void;
  57473. private _gatherRenderTargets;
  57474. }
  57475. }
  57476. declare module "babylonjs/Lights/Shadows/index" {
  57477. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  57478. export * from "babylonjs/Lights/Shadows/cascadedShadowGenerator";
  57479. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  57480. }
  57481. declare module "babylonjs/Lights/pointLight" {
  57482. import { Scene } from "babylonjs/scene";
  57483. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  57484. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57485. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  57486. import { Effect } from "babylonjs/Materials/effect";
  57487. /**
  57488. * A point light is a light defined by an unique point in world space.
  57489. * The light is emitted in every direction from this point.
  57490. * A good example of a point light is a standard light bulb.
  57491. * Documentation: https://doc.babylonjs.com/babylon101/lights
  57492. */
  57493. export class PointLight extends ShadowLight {
  57494. private _shadowAngle;
  57495. /**
  57496. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  57497. * This specifies what angle the shadow will use to be created.
  57498. *
  57499. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  57500. */
  57501. get shadowAngle(): number;
  57502. /**
  57503. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  57504. * This specifies what angle the shadow will use to be created.
  57505. *
  57506. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  57507. */
  57508. set shadowAngle(value: number);
  57509. /**
  57510. * Gets the direction if it has been set.
  57511. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  57512. */
  57513. get direction(): Vector3;
  57514. /**
  57515. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  57516. */
  57517. set direction(value: Vector3);
  57518. /**
  57519. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  57520. * A PointLight emits the light in every direction.
  57521. * It can cast shadows.
  57522. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  57523. * ```javascript
  57524. * var pointLight = new PointLight("pl", camera.position, scene);
  57525. * ```
  57526. * Documentation : https://doc.babylonjs.com/babylon101/lights
  57527. * @param name The light friendly name
  57528. * @param position The position of the point light in the scene
  57529. * @param scene The scene the lights belongs to
  57530. */
  57531. constructor(name: string, position: Vector3, scene: Scene);
  57532. /**
  57533. * Returns the string "PointLight"
  57534. * @returns the class name
  57535. */
  57536. getClassName(): string;
  57537. /**
  57538. * Returns the integer 0.
  57539. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  57540. */
  57541. getTypeID(): number;
  57542. /**
  57543. * Specifies wether or not the shadowmap should be a cube texture.
  57544. * @returns true if the shadowmap needs to be a cube texture.
  57545. */
  57546. needCube(): boolean;
  57547. /**
  57548. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  57549. * @param faceIndex The index of the face we are computed the direction to generate shadow
  57550. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  57551. */
  57552. getShadowDirection(faceIndex?: number): Vector3;
  57553. /**
  57554. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  57555. * - fov = PI / 2
  57556. * - aspect ratio : 1.0
  57557. * - z-near and far equal to the active camera minZ and maxZ.
  57558. * Returns the PointLight.
  57559. */
  57560. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  57561. protected _buildUniformLayout(): void;
  57562. /**
  57563. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  57564. * @param effect The effect to update
  57565. * @param lightIndex The index of the light in the effect to update
  57566. * @returns The point light
  57567. */
  57568. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  57569. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  57570. /**
  57571. * Prepares the list of defines specific to the light type.
  57572. * @param defines the list of defines
  57573. * @param lightIndex defines the index of the light for the effect
  57574. */
  57575. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  57576. }
  57577. }
  57578. declare module "babylonjs/Lights/index" {
  57579. export * from "babylonjs/Lights/light";
  57580. export * from "babylonjs/Lights/shadowLight";
  57581. export * from "babylonjs/Lights/Shadows/index";
  57582. export * from "babylonjs/Lights/directionalLight";
  57583. export * from "babylonjs/Lights/hemisphericLight";
  57584. export * from "babylonjs/Lights/pointLight";
  57585. export * from "babylonjs/Lights/spotLight";
  57586. }
  57587. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  57588. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  57589. /**
  57590. * Header information of HDR texture files.
  57591. */
  57592. export interface HDRInfo {
  57593. /**
  57594. * The height of the texture in pixels.
  57595. */
  57596. height: number;
  57597. /**
  57598. * The width of the texture in pixels.
  57599. */
  57600. width: number;
  57601. /**
  57602. * The index of the beginning of the data in the binary file.
  57603. */
  57604. dataPosition: number;
  57605. }
  57606. /**
  57607. * This groups tools to convert HDR texture to native colors array.
  57608. */
  57609. export class HDRTools {
  57610. private static Ldexp;
  57611. private static Rgbe2float;
  57612. private static readStringLine;
  57613. /**
  57614. * Reads header information from an RGBE texture stored in a native array.
  57615. * More information on this format are available here:
  57616. * https://en.wikipedia.org/wiki/RGBE_image_format
  57617. *
  57618. * @param uint8array The binary file stored in native array.
  57619. * @return The header information.
  57620. */
  57621. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  57622. /**
  57623. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  57624. * This RGBE texture needs to store the information as a panorama.
  57625. *
  57626. * More information on this format are available here:
  57627. * https://en.wikipedia.org/wiki/RGBE_image_format
  57628. *
  57629. * @param buffer The binary file stored in an array buffer.
  57630. * @param size The expected size of the extracted cubemap.
  57631. * @return The Cube Map information.
  57632. */
  57633. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  57634. /**
  57635. * Returns the pixels data extracted from an RGBE texture.
  57636. * This pixels will be stored left to right up to down in the R G B order in one array.
  57637. *
  57638. * More information on this format are available here:
  57639. * https://en.wikipedia.org/wiki/RGBE_image_format
  57640. *
  57641. * @param uint8array The binary file stored in an array buffer.
  57642. * @param hdrInfo The header information of the file.
  57643. * @return The pixels data in RGB right to left up to down order.
  57644. */
  57645. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  57646. private static RGBE_ReadPixels_RLE;
  57647. }
  57648. }
  57649. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  57650. import { Nullable } from "babylonjs/types";
  57651. import { Scene } from "babylonjs/scene";
  57652. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  57653. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57654. import "babylonjs/Engines/Extensions/engine.rawTexture";
  57655. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  57656. /**
  57657. * This represents a texture coming from an HDR input.
  57658. *
  57659. * The only supported format is currently panorama picture stored in RGBE format.
  57660. * Example of such files can be found on HDRLib: http://hdrlib.com/
  57661. */
  57662. export class HDRCubeTexture extends BaseTexture {
  57663. private static _facesMapping;
  57664. private _generateHarmonics;
  57665. private _noMipmap;
  57666. private _textureMatrix;
  57667. private _size;
  57668. private _onLoad;
  57669. private _onError;
  57670. /**
  57671. * The texture URL.
  57672. */
  57673. url: string;
  57674. /**
  57675. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  57676. */
  57677. coordinatesMode: number;
  57678. protected _isBlocking: boolean;
  57679. /**
  57680. * Sets wether or not the texture is blocking during loading.
  57681. */
  57682. set isBlocking(value: boolean);
  57683. /**
  57684. * Gets wether or not the texture is blocking during loading.
  57685. */
  57686. get isBlocking(): boolean;
  57687. protected _rotationY: number;
  57688. /**
  57689. * Sets texture matrix rotation angle around Y axis in radians.
  57690. */
  57691. set rotationY(value: number);
  57692. /**
  57693. * Gets texture matrix rotation angle around Y axis radians.
  57694. */
  57695. get rotationY(): number;
  57696. /**
  57697. * Gets or sets the center of the bounding box associated with the cube texture
  57698. * It must define where the camera used to render the texture was set
  57699. */
  57700. boundingBoxPosition: Vector3;
  57701. private _boundingBoxSize;
  57702. /**
  57703. * Gets or sets the size of the bounding box associated with the cube texture
  57704. * When defined, the cubemap will switch to local mode
  57705. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  57706. * @example https://www.babylonjs-playground.com/#RNASML
  57707. */
  57708. set boundingBoxSize(value: Vector3);
  57709. get boundingBoxSize(): Vector3;
  57710. /**
  57711. * Instantiates an HDRTexture from the following parameters.
  57712. *
  57713. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  57714. * @param scene The scene the texture will be used in
  57715. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  57716. * @param noMipmap Forces to not generate the mipmap if true
  57717. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  57718. * @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)
  57719. * @param reserved Reserved flag for internal use.
  57720. */
  57721. 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>);
  57722. /**
  57723. * Get the current class name of the texture useful for serialization or dynamic coding.
  57724. * @returns "HDRCubeTexture"
  57725. */
  57726. getClassName(): string;
  57727. /**
  57728. * Occurs when the file is raw .hdr file.
  57729. */
  57730. private loadTexture;
  57731. clone(): HDRCubeTexture;
  57732. delayLoad(): void;
  57733. /**
  57734. * Get the texture reflection matrix used to rotate/transform the reflection.
  57735. * @returns the reflection matrix
  57736. */
  57737. getReflectionTextureMatrix(): Matrix;
  57738. /**
  57739. * Set the texture reflection matrix used to rotate/transform the reflection.
  57740. * @param value Define the reflection matrix to set
  57741. */
  57742. setReflectionTextureMatrix(value: Matrix): void;
  57743. /**
  57744. * Parses a JSON representation of an HDR Texture in order to create the texture
  57745. * @param parsedTexture Define the JSON representation
  57746. * @param scene Define the scene the texture should be created in
  57747. * @param rootUrl Define the root url in case we need to load relative dependencies
  57748. * @returns the newly created texture after parsing
  57749. */
  57750. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  57751. serialize(): any;
  57752. }
  57753. }
  57754. declare module "babylonjs/Physics/physicsEngine" {
  57755. import { Nullable } from "babylonjs/types";
  57756. import { Vector3 } from "babylonjs/Maths/math.vector";
  57757. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  57758. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  57759. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  57760. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  57761. /**
  57762. * Class used to control physics engine
  57763. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  57764. */
  57765. export class PhysicsEngine implements IPhysicsEngine {
  57766. private _physicsPlugin;
  57767. /**
  57768. * Global value used to control the smallest number supported by the simulation
  57769. */
  57770. static Epsilon: number;
  57771. private _impostors;
  57772. private _joints;
  57773. private _subTimeStep;
  57774. /**
  57775. * Gets the gravity vector used by the simulation
  57776. */
  57777. gravity: Vector3;
  57778. /**
  57779. * Factory used to create the default physics plugin.
  57780. * @returns The default physics plugin
  57781. */
  57782. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  57783. /**
  57784. * Creates a new Physics Engine
  57785. * @param gravity defines the gravity vector used by the simulation
  57786. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  57787. */
  57788. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  57789. /**
  57790. * Sets the gravity vector used by the simulation
  57791. * @param gravity defines the gravity vector to use
  57792. */
  57793. setGravity(gravity: Vector3): void;
  57794. /**
  57795. * Set the time step of the physics engine.
  57796. * Default is 1/60.
  57797. * To slow it down, enter 1/600 for example.
  57798. * To speed it up, 1/30
  57799. * @param newTimeStep defines the new timestep to apply to this world.
  57800. */
  57801. setTimeStep(newTimeStep?: number): void;
  57802. /**
  57803. * Get the time step of the physics engine.
  57804. * @returns the current time step
  57805. */
  57806. getTimeStep(): number;
  57807. /**
  57808. * Set the sub time step of the physics engine.
  57809. * Default is 0 meaning there is no sub steps
  57810. * To increase physics resolution precision, set a small value (like 1 ms)
  57811. * @param subTimeStep defines the new sub timestep used for physics resolution.
  57812. */
  57813. setSubTimeStep(subTimeStep?: number): void;
  57814. /**
  57815. * Get the sub time step of the physics engine.
  57816. * @returns the current sub time step
  57817. */
  57818. getSubTimeStep(): number;
  57819. /**
  57820. * Release all resources
  57821. */
  57822. dispose(): void;
  57823. /**
  57824. * Gets the name of the current physics plugin
  57825. * @returns the name of the plugin
  57826. */
  57827. getPhysicsPluginName(): string;
  57828. /**
  57829. * Adding a new impostor for the impostor tracking.
  57830. * This will be done by the impostor itself.
  57831. * @param impostor the impostor to add
  57832. */
  57833. addImpostor(impostor: PhysicsImpostor): void;
  57834. /**
  57835. * Remove an impostor from the engine.
  57836. * This impostor and its mesh will not longer be updated by the physics engine.
  57837. * @param impostor the impostor to remove
  57838. */
  57839. removeImpostor(impostor: PhysicsImpostor): void;
  57840. /**
  57841. * Add a joint to the physics engine
  57842. * @param mainImpostor defines the main impostor to which the joint is added.
  57843. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  57844. * @param joint defines the joint that will connect both impostors.
  57845. */
  57846. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  57847. /**
  57848. * Removes a joint from the simulation
  57849. * @param mainImpostor defines the impostor used with the joint
  57850. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  57851. * @param joint defines the joint to remove
  57852. */
  57853. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  57854. /**
  57855. * Called by the scene. No need to call it.
  57856. * @param delta defines the timespam between frames
  57857. */
  57858. _step(delta: number): void;
  57859. /**
  57860. * Gets the current plugin used to run the simulation
  57861. * @returns current plugin
  57862. */
  57863. getPhysicsPlugin(): IPhysicsEnginePlugin;
  57864. /**
  57865. * Gets the list of physic impostors
  57866. * @returns an array of PhysicsImpostor
  57867. */
  57868. getImpostors(): Array<PhysicsImpostor>;
  57869. /**
  57870. * Gets the impostor for a physics enabled object
  57871. * @param object defines the object impersonated by the impostor
  57872. * @returns the PhysicsImpostor or null if not found
  57873. */
  57874. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  57875. /**
  57876. * Gets the impostor for a physics body object
  57877. * @param body defines physics body used by the impostor
  57878. * @returns the PhysicsImpostor or null if not found
  57879. */
  57880. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  57881. /**
  57882. * Does a raycast in the physics world
  57883. * @param from when should the ray start?
  57884. * @param to when should the ray end?
  57885. * @returns PhysicsRaycastResult
  57886. */
  57887. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  57888. }
  57889. }
  57890. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  57891. import { Nullable } from "babylonjs/types";
  57892. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  57893. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57894. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  57895. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  57896. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  57897. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  57898. /** @hidden */
  57899. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  57900. private _useDeltaForWorldStep;
  57901. world: any;
  57902. name: string;
  57903. private _physicsMaterials;
  57904. private _fixedTimeStep;
  57905. private _cannonRaycastResult;
  57906. private _raycastResult;
  57907. private _physicsBodysToRemoveAfterStep;
  57908. BJSCANNON: any;
  57909. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  57910. setGravity(gravity: Vector3): void;
  57911. setTimeStep(timeStep: number): void;
  57912. getTimeStep(): number;
  57913. executeStep(delta: number): void;
  57914. private _removeMarkedPhysicsBodiesFromWorld;
  57915. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  57916. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  57917. generatePhysicsBody(impostor: PhysicsImpostor): void;
  57918. private _processChildMeshes;
  57919. removePhysicsBody(impostor: PhysicsImpostor): void;
  57920. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  57921. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  57922. private _addMaterial;
  57923. private _checkWithEpsilon;
  57924. private _createShape;
  57925. private _createHeightmap;
  57926. private _minus90X;
  57927. private _plus90X;
  57928. private _tmpPosition;
  57929. private _tmpDeltaPosition;
  57930. private _tmpUnityRotation;
  57931. private _updatePhysicsBodyTransformation;
  57932. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  57933. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  57934. isSupported(): boolean;
  57935. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  57936. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  57937. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  57938. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  57939. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  57940. getBodyMass(impostor: PhysicsImpostor): number;
  57941. getBodyFriction(impostor: PhysicsImpostor): number;
  57942. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  57943. getBodyRestitution(impostor: PhysicsImpostor): number;
  57944. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  57945. sleepBody(impostor: PhysicsImpostor): void;
  57946. wakeUpBody(impostor: PhysicsImpostor): void;
  57947. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  57948. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  57949. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  57950. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  57951. getRadius(impostor: PhysicsImpostor): number;
  57952. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  57953. dispose(): void;
  57954. private _extendNamespace;
  57955. /**
  57956. * Does a raycast in the physics world
  57957. * @param from when should the ray start?
  57958. * @param to when should the ray end?
  57959. * @returns PhysicsRaycastResult
  57960. */
  57961. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  57962. }
  57963. }
  57964. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  57965. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  57966. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  57967. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  57968. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57969. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  57970. import { Nullable } from "babylonjs/types";
  57971. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  57972. /** @hidden */
  57973. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  57974. world: any;
  57975. name: string;
  57976. BJSOIMO: any;
  57977. private _raycastResult;
  57978. constructor(iterations?: number, oimoInjection?: any);
  57979. setGravity(gravity: Vector3): void;
  57980. setTimeStep(timeStep: number): void;
  57981. getTimeStep(): number;
  57982. private _tmpImpostorsArray;
  57983. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  57984. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  57985. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  57986. generatePhysicsBody(impostor: PhysicsImpostor): void;
  57987. private _tmpPositionVector;
  57988. removePhysicsBody(impostor: PhysicsImpostor): void;
  57989. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  57990. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  57991. isSupported(): boolean;
  57992. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  57993. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  57994. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  57995. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  57996. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  57997. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  57998. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  57999. getBodyMass(impostor: PhysicsImpostor): number;
  58000. getBodyFriction(impostor: PhysicsImpostor): number;
  58001. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  58002. getBodyRestitution(impostor: PhysicsImpostor): number;
  58003. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  58004. sleepBody(impostor: PhysicsImpostor): void;
  58005. wakeUpBody(impostor: PhysicsImpostor): void;
  58006. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  58007. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  58008. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  58009. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  58010. getRadius(impostor: PhysicsImpostor): number;
  58011. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  58012. dispose(): void;
  58013. /**
  58014. * Does a raycast in the physics world
  58015. * @param from when should the ray start?
  58016. * @param to when should the ray end?
  58017. * @returns PhysicsRaycastResult
  58018. */
  58019. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  58020. }
  58021. }
  58022. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  58023. import { Nullable } from "babylonjs/types";
  58024. import { Scene } from "babylonjs/scene";
  58025. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  58026. import { Color4 } from "babylonjs/Maths/math.color";
  58027. import { Mesh } from "babylonjs/Meshes/mesh";
  58028. /**
  58029. * Class containing static functions to help procedurally build meshes
  58030. */
  58031. export class RibbonBuilder {
  58032. /**
  58033. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  58034. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  58035. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  58036. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  58037. * * 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
  58038. * * 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
  58039. * * 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
  58040. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58041. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58042. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58043. * * 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
  58044. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  58045. * * 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
  58046. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  58047. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58048. * @param name defines the name of the mesh
  58049. * @param options defines the options used to create the mesh
  58050. * @param scene defines the hosting scene
  58051. * @returns the ribbon mesh
  58052. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  58053. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58054. */
  58055. static CreateRibbon(name: string, options: {
  58056. pathArray: Vector3[][];
  58057. closeArray?: boolean;
  58058. closePath?: boolean;
  58059. offset?: number;
  58060. updatable?: boolean;
  58061. sideOrientation?: number;
  58062. frontUVs?: Vector4;
  58063. backUVs?: Vector4;
  58064. instance?: Mesh;
  58065. invertUV?: boolean;
  58066. uvs?: Vector2[];
  58067. colors?: Color4[];
  58068. }, scene?: Nullable<Scene>): Mesh;
  58069. }
  58070. }
  58071. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  58072. import { Nullable } from "babylonjs/types";
  58073. import { Scene } from "babylonjs/scene";
  58074. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  58075. import { Mesh } from "babylonjs/Meshes/mesh";
  58076. /**
  58077. * Class containing static functions to help procedurally build meshes
  58078. */
  58079. export class ShapeBuilder {
  58080. /**
  58081. * 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.
  58082. * * 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.
  58083. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  58084. * * 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.
  58085. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  58086. * * 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
  58087. * * 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
  58088. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  58089. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58090. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58091. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  58092. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58093. * @param name defines the name of the mesh
  58094. * @param options defines the options used to create the mesh
  58095. * @param scene defines the hosting scene
  58096. * @returns the extruded shape mesh
  58097. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58098. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  58099. */
  58100. static ExtrudeShape(name: string, options: {
  58101. shape: Vector3[];
  58102. path: Vector3[];
  58103. scale?: number;
  58104. rotation?: number;
  58105. cap?: number;
  58106. updatable?: boolean;
  58107. sideOrientation?: number;
  58108. frontUVs?: Vector4;
  58109. backUVs?: Vector4;
  58110. instance?: Mesh;
  58111. invertUV?: boolean;
  58112. }, scene?: Nullable<Scene>): Mesh;
  58113. /**
  58114. * Creates an custom extruded shape mesh.
  58115. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  58116. * * 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.
  58117. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  58118. * * 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
  58119. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  58120. * * 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
  58121. * * It must returns a float value that will be the scale value applied to the shape on each path point
  58122. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  58123. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  58124. * * 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
  58125. * * 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
  58126. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  58127. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58128. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58129. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58130. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58131. * @param name defines the name of the mesh
  58132. * @param options defines the options used to create the mesh
  58133. * @param scene defines the hosting scene
  58134. * @returns the custom extruded shape mesh
  58135. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  58136. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58137. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  58138. */
  58139. static ExtrudeShapeCustom(name: string, options: {
  58140. shape: Vector3[];
  58141. path: Vector3[];
  58142. scaleFunction?: any;
  58143. rotationFunction?: any;
  58144. ribbonCloseArray?: boolean;
  58145. ribbonClosePath?: boolean;
  58146. cap?: number;
  58147. updatable?: boolean;
  58148. sideOrientation?: number;
  58149. frontUVs?: Vector4;
  58150. backUVs?: Vector4;
  58151. instance?: Mesh;
  58152. invertUV?: boolean;
  58153. }, scene?: Nullable<Scene>): Mesh;
  58154. private static _ExtrudeShapeGeneric;
  58155. }
  58156. }
  58157. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  58158. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  58159. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  58160. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  58161. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  58162. import { Nullable } from "babylonjs/types";
  58163. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58164. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  58165. /**
  58166. * AmmoJS Physics plugin
  58167. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  58168. * @see https://github.com/kripken/ammo.js/
  58169. */
  58170. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  58171. private _useDeltaForWorldStep;
  58172. /**
  58173. * Reference to the Ammo library
  58174. */
  58175. bjsAMMO: any;
  58176. /**
  58177. * Created ammoJS world which physics bodies are added to
  58178. */
  58179. world: any;
  58180. /**
  58181. * Name of the plugin
  58182. */
  58183. name: string;
  58184. private _timeStep;
  58185. private _fixedTimeStep;
  58186. private _maxSteps;
  58187. private _tmpQuaternion;
  58188. private _tmpAmmoTransform;
  58189. private _tmpAmmoQuaternion;
  58190. private _tmpAmmoConcreteContactResultCallback;
  58191. private _collisionConfiguration;
  58192. private _dispatcher;
  58193. private _overlappingPairCache;
  58194. private _solver;
  58195. private _softBodySolver;
  58196. private _tmpAmmoVectorA;
  58197. private _tmpAmmoVectorB;
  58198. private _tmpAmmoVectorC;
  58199. private _tmpAmmoVectorD;
  58200. private _tmpContactCallbackResult;
  58201. private _tmpAmmoVectorRCA;
  58202. private _tmpAmmoVectorRCB;
  58203. private _raycastResult;
  58204. private static readonly DISABLE_COLLISION_FLAG;
  58205. private static readonly KINEMATIC_FLAG;
  58206. private static readonly DISABLE_DEACTIVATION_FLAG;
  58207. /**
  58208. * Initializes the ammoJS plugin
  58209. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  58210. * @param ammoInjection can be used to inject your own ammo reference
  58211. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  58212. */
  58213. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  58214. /**
  58215. * Sets the gravity of the physics world (m/(s^2))
  58216. * @param gravity Gravity to set
  58217. */
  58218. setGravity(gravity: Vector3): void;
  58219. /**
  58220. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  58221. * @param timeStep timestep to use in seconds
  58222. */
  58223. setTimeStep(timeStep: number): void;
  58224. /**
  58225. * 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)
  58226. * @param fixedTimeStep fixedTimeStep to use in seconds
  58227. */
  58228. setFixedTimeStep(fixedTimeStep: number): void;
  58229. /**
  58230. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  58231. * @param maxSteps the maximum number of steps by the physics engine per frame
  58232. */
  58233. setMaxSteps(maxSteps: number): void;
  58234. /**
  58235. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  58236. * @returns the current timestep in seconds
  58237. */
  58238. getTimeStep(): number;
  58239. /**
  58240. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  58241. */
  58242. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  58243. private _isImpostorInContact;
  58244. private _isImpostorPairInContact;
  58245. private _stepSimulation;
  58246. /**
  58247. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  58248. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  58249. * After the step the babylon meshes are set to the position of the physics imposters
  58250. * @param delta amount of time to step forward
  58251. * @param impostors array of imposters to update before/after the step
  58252. */
  58253. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  58254. /**
  58255. * Update babylon mesh to match physics world object
  58256. * @param impostor imposter to match
  58257. */
  58258. private _afterSoftStep;
  58259. /**
  58260. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  58261. * @param impostor imposter to match
  58262. */
  58263. private _ropeStep;
  58264. /**
  58265. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  58266. * @param impostor imposter to match
  58267. */
  58268. private _softbodyOrClothStep;
  58269. private _tmpMatrix;
  58270. /**
  58271. * Applies an impulse on the imposter
  58272. * @param impostor imposter to apply impulse to
  58273. * @param force amount of force to be applied to the imposter
  58274. * @param contactPoint the location to apply the impulse on the imposter
  58275. */
  58276. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  58277. /**
  58278. * Applies a force on the imposter
  58279. * @param impostor imposter to apply force
  58280. * @param force amount of force to be applied to the imposter
  58281. * @param contactPoint the location to apply the force on the imposter
  58282. */
  58283. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  58284. /**
  58285. * Creates a physics body using the plugin
  58286. * @param impostor the imposter to create the physics body on
  58287. */
  58288. generatePhysicsBody(impostor: PhysicsImpostor): void;
  58289. /**
  58290. * Removes the physics body from the imposter and disposes of the body's memory
  58291. * @param impostor imposter to remove the physics body from
  58292. */
  58293. removePhysicsBody(impostor: PhysicsImpostor): void;
  58294. /**
  58295. * Generates a joint
  58296. * @param impostorJoint the imposter joint to create the joint with
  58297. */
  58298. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  58299. /**
  58300. * Removes a joint
  58301. * @param impostorJoint the imposter joint to remove the joint from
  58302. */
  58303. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  58304. private _addMeshVerts;
  58305. /**
  58306. * Initialise the soft body vertices to match its object's (mesh) vertices
  58307. * Softbody vertices (nodes) are in world space and to match this
  58308. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  58309. * @param impostor to create the softbody for
  58310. */
  58311. private _softVertexData;
  58312. /**
  58313. * Create an impostor's soft body
  58314. * @param impostor to create the softbody for
  58315. */
  58316. private _createSoftbody;
  58317. /**
  58318. * Create cloth for an impostor
  58319. * @param impostor to create the softbody for
  58320. */
  58321. private _createCloth;
  58322. /**
  58323. * Create rope for an impostor
  58324. * @param impostor to create the softbody for
  58325. */
  58326. private _createRope;
  58327. /**
  58328. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  58329. * @param impostor to create the custom physics shape for
  58330. */
  58331. private _createCustom;
  58332. private _addHullVerts;
  58333. private _createShape;
  58334. /**
  58335. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  58336. * @param impostor imposter containing the physics body and babylon object
  58337. */
  58338. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  58339. /**
  58340. * Sets the babylon object's position/rotation from the physics body's position/rotation
  58341. * @param impostor imposter containing the physics body and babylon object
  58342. * @param newPosition new position
  58343. * @param newRotation new rotation
  58344. */
  58345. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  58346. /**
  58347. * If this plugin is supported
  58348. * @returns true if its supported
  58349. */
  58350. isSupported(): boolean;
  58351. /**
  58352. * Sets the linear velocity of the physics body
  58353. * @param impostor imposter to set the velocity on
  58354. * @param velocity velocity to set
  58355. */
  58356. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  58357. /**
  58358. * Sets the angular velocity of the physics body
  58359. * @param impostor imposter to set the velocity on
  58360. * @param velocity velocity to set
  58361. */
  58362. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  58363. /**
  58364. * gets the linear velocity
  58365. * @param impostor imposter to get linear velocity from
  58366. * @returns linear velocity
  58367. */
  58368. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  58369. /**
  58370. * gets the angular velocity
  58371. * @param impostor imposter to get angular velocity from
  58372. * @returns angular velocity
  58373. */
  58374. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  58375. /**
  58376. * Sets the mass of physics body
  58377. * @param impostor imposter to set the mass on
  58378. * @param mass mass to set
  58379. */
  58380. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  58381. /**
  58382. * Gets the mass of the physics body
  58383. * @param impostor imposter to get the mass from
  58384. * @returns mass
  58385. */
  58386. getBodyMass(impostor: PhysicsImpostor): number;
  58387. /**
  58388. * Gets friction of the impostor
  58389. * @param impostor impostor to get friction from
  58390. * @returns friction value
  58391. */
  58392. getBodyFriction(impostor: PhysicsImpostor): number;
  58393. /**
  58394. * Sets friction of the impostor
  58395. * @param impostor impostor to set friction on
  58396. * @param friction friction value
  58397. */
  58398. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  58399. /**
  58400. * Gets restitution of the impostor
  58401. * @param impostor impostor to get restitution from
  58402. * @returns restitution value
  58403. */
  58404. getBodyRestitution(impostor: PhysicsImpostor): number;
  58405. /**
  58406. * Sets resitution of the impostor
  58407. * @param impostor impostor to set resitution on
  58408. * @param restitution resitution value
  58409. */
  58410. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  58411. /**
  58412. * Gets pressure inside the impostor
  58413. * @param impostor impostor to get pressure from
  58414. * @returns pressure value
  58415. */
  58416. getBodyPressure(impostor: PhysicsImpostor): number;
  58417. /**
  58418. * Sets pressure inside a soft body impostor
  58419. * Cloth and rope must remain 0 pressure
  58420. * @param impostor impostor to set pressure on
  58421. * @param pressure pressure value
  58422. */
  58423. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  58424. /**
  58425. * Gets stiffness of the impostor
  58426. * @param impostor impostor to get stiffness from
  58427. * @returns pressure value
  58428. */
  58429. getBodyStiffness(impostor: PhysicsImpostor): number;
  58430. /**
  58431. * Sets stiffness of the impostor
  58432. * @param impostor impostor to set stiffness on
  58433. * @param stiffness stiffness value from 0 to 1
  58434. */
  58435. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  58436. /**
  58437. * Gets velocityIterations of the impostor
  58438. * @param impostor impostor to get velocity iterations from
  58439. * @returns velocityIterations value
  58440. */
  58441. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  58442. /**
  58443. * Sets velocityIterations of the impostor
  58444. * @param impostor impostor to set velocity iterations on
  58445. * @param velocityIterations velocityIterations value
  58446. */
  58447. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  58448. /**
  58449. * Gets positionIterations of the impostor
  58450. * @param impostor impostor to get position iterations from
  58451. * @returns positionIterations value
  58452. */
  58453. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  58454. /**
  58455. * Sets positionIterations of the impostor
  58456. * @param impostor impostor to set position on
  58457. * @param positionIterations positionIterations value
  58458. */
  58459. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  58460. /**
  58461. * Append an anchor to a cloth object
  58462. * @param impostor is the cloth impostor to add anchor to
  58463. * @param otherImpostor is the rigid impostor to anchor to
  58464. * @param width ratio across width from 0 to 1
  58465. * @param height ratio up height from 0 to 1
  58466. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  58467. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  58468. */
  58469. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  58470. /**
  58471. * Append an hook to a rope object
  58472. * @param impostor is the rope impostor to add hook to
  58473. * @param otherImpostor is the rigid impostor to hook to
  58474. * @param length ratio along the rope from 0 to 1
  58475. * @param influence the elasticity between soft 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. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  58479. /**
  58480. * Sleeps the physics body and stops it from being active
  58481. * @param impostor impostor to sleep
  58482. */
  58483. sleepBody(impostor: PhysicsImpostor): void;
  58484. /**
  58485. * Activates the physics body
  58486. * @param impostor impostor to activate
  58487. */
  58488. wakeUpBody(impostor: PhysicsImpostor): void;
  58489. /**
  58490. * Updates the distance parameters of the joint
  58491. * @param joint joint to update
  58492. * @param maxDistance maximum distance of the joint
  58493. * @param minDistance minimum distance of the joint
  58494. */
  58495. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  58496. /**
  58497. * Sets a motor on the joint
  58498. * @param joint joint to set motor on
  58499. * @param speed speed of the motor
  58500. * @param maxForce maximum force of the motor
  58501. * @param motorIndex index of the motor
  58502. */
  58503. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  58504. /**
  58505. * Sets the motors limit
  58506. * @param joint joint to set limit on
  58507. * @param upperLimit upper limit
  58508. * @param lowerLimit lower limit
  58509. */
  58510. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  58511. /**
  58512. * Syncs the position and rotation of a mesh with the impostor
  58513. * @param mesh mesh to sync
  58514. * @param impostor impostor to update the mesh with
  58515. */
  58516. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  58517. /**
  58518. * Gets the radius of the impostor
  58519. * @param impostor impostor to get radius from
  58520. * @returns the radius
  58521. */
  58522. getRadius(impostor: PhysicsImpostor): number;
  58523. /**
  58524. * Gets the box size of the impostor
  58525. * @param impostor impostor to get box size from
  58526. * @param result the resulting box size
  58527. */
  58528. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  58529. /**
  58530. * Disposes of the impostor
  58531. */
  58532. dispose(): void;
  58533. /**
  58534. * Does a raycast in the physics world
  58535. * @param from when should the ray start?
  58536. * @param to when should the ray end?
  58537. * @returns PhysicsRaycastResult
  58538. */
  58539. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  58540. }
  58541. }
  58542. declare module "babylonjs/Probes/reflectionProbe" {
  58543. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  58544. import { Vector3 } from "babylonjs/Maths/math.vector";
  58545. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58546. import { Nullable } from "babylonjs/types";
  58547. import { Scene } from "babylonjs/scene";
  58548. module "babylonjs/abstractScene" {
  58549. interface AbstractScene {
  58550. /**
  58551. * The list of reflection probes added to the scene
  58552. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  58553. */
  58554. reflectionProbes: Array<ReflectionProbe>;
  58555. /**
  58556. * Removes the given reflection probe from this scene.
  58557. * @param toRemove The reflection probe to remove
  58558. * @returns The index of the removed reflection probe
  58559. */
  58560. removeReflectionProbe(toRemove: ReflectionProbe): number;
  58561. /**
  58562. * Adds the given reflection probe to this scene.
  58563. * @param newReflectionProbe The reflection probe to add
  58564. */
  58565. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  58566. }
  58567. }
  58568. /**
  58569. * Class used to generate realtime reflection / refraction cube textures
  58570. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  58571. */
  58572. export class ReflectionProbe {
  58573. /** defines the name of the probe */
  58574. name: string;
  58575. private _scene;
  58576. private _renderTargetTexture;
  58577. private _projectionMatrix;
  58578. private _viewMatrix;
  58579. private _target;
  58580. private _add;
  58581. private _attachedMesh;
  58582. private _invertYAxis;
  58583. /** Gets or sets probe position (center of the cube map) */
  58584. position: Vector3;
  58585. /**
  58586. * Creates a new reflection probe
  58587. * @param name defines the name of the probe
  58588. * @param size defines the texture resolution (for each face)
  58589. * @param scene defines the hosting scene
  58590. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  58591. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  58592. */
  58593. constructor(
  58594. /** defines the name of the probe */
  58595. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  58596. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  58597. get samples(): number;
  58598. set samples(value: number);
  58599. /** Gets or sets the refresh rate to use (on every frame by default) */
  58600. get refreshRate(): number;
  58601. set refreshRate(value: number);
  58602. /**
  58603. * Gets the hosting scene
  58604. * @returns a Scene
  58605. */
  58606. getScene(): Scene;
  58607. /** Gets the internal CubeTexture used to render to */
  58608. get cubeTexture(): RenderTargetTexture;
  58609. /** Gets the list of meshes to render */
  58610. get renderList(): Nullable<AbstractMesh[]>;
  58611. /**
  58612. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  58613. * @param mesh defines the mesh to attach to
  58614. */
  58615. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  58616. /**
  58617. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  58618. * @param renderingGroupId The rendering group id corresponding to its index
  58619. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  58620. */
  58621. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  58622. /**
  58623. * Clean all associated resources
  58624. */
  58625. dispose(): void;
  58626. /**
  58627. * Converts the reflection probe information to a readable string for debug purpose.
  58628. * @param fullDetails Supports for multiple levels of logging within scene loading
  58629. * @returns the human readable reflection probe info
  58630. */
  58631. toString(fullDetails?: boolean): string;
  58632. /**
  58633. * Get the class name of the relfection probe.
  58634. * @returns "ReflectionProbe"
  58635. */
  58636. getClassName(): string;
  58637. /**
  58638. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  58639. * @returns The JSON representation of the texture
  58640. */
  58641. serialize(): any;
  58642. /**
  58643. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  58644. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  58645. * @param scene Define the scene the parsed reflection probe should be instantiated in
  58646. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  58647. * @returns The parsed reflection probe if successful
  58648. */
  58649. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  58650. }
  58651. }
  58652. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  58653. /** @hidden */
  58654. export var _BabylonLoaderRegistered: boolean;
  58655. /**
  58656. * Helps setting up some configuration for the babylon file loader.
  58657. */
  58658. export class BabylonFileLoaderConfiguration {
  58659. /**
  58660. * The loader does not allow injecting custom physix engine into the plugins.
  58661. * Unfortunately in ES6, we need to manually inject them into the plugin.
  58662. * So you could set this variable to your engine import to make it work.
  58663. */
  58664. static LoaderInjectedPhysicsEngine: any;
  58665. }
  58666. }
  58667. declare module "babylonjs/Loading/Plugins/index" {
  58668. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  58669. }
  58670. declare module "babylonjs/Loading/index" {
  58671. export * from "babylonjs/Loading/loadingScreen";
  58672. export * from "babylonjs/Loading/Plugins/index";
  58673. export * from "babylonjs/Loading/sceneLoader";
  58674. export * from "babylonjs/Loading/sceneLoaderFlags";
  58675. }
  58676. declare module "babylonjs/Materials/Background/index" {
  58677. export * from "babylonjs/Materials/Background/backgroundMaterial";
  58678. }
  58679. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  58680. import { Scene } from "babylonjs/scene";
  58681. import { Color3 } from "babylonjs/Maths/math.color";
  58682. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  58683. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58684. /**
  58685. * The Physically based simple base material of BJS.
  58686. *
  58687. * This enables better naming and convention enforcements on top of the pbrMaterial.
  58688. * It is used as the base class for both the specGloss and metalRough conventions.
  58689. */
  58690. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  58691. /**
  58692. * Number of Simultaneous lights allowed on the material.
  58693. */
  58694. maxSimultaneousLights: number;
  58695. /**
  58696. * If sets to true, disables all the lights affecting the material.
  58697. */
  58698. disableLighting: boolean;
  58699. /**
  58700. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  58701. */
  58702. environmentTexture: BaseTexture;
  58703. /**
  58704. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  58705. */
  58706. invertNormalMapX: boolean;
  58707. /**
  58708. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  58709. */
  58710. invertNormalMapY: boolean;
  58711. /**
  58712. * Normal map used in the model.
  58713. */
  58714. normalTexture: BaseTexture;
  58715. /**
  58716. * Emissivie color used to self-illuminate the model.
  58717. */
  58718. emissiveColor: Color3;
  58719. /**
  58720. * Emissivie texture used to self-illuminate the model.
  58721. */
  58722. emissiveTexture: BaseTexture;
  58723. /**
  58724. * Occlusion Channel Strenght.
  58725. */
  58726. occlusionStrength: number;
  58727. /**
  58728. * Occlusion Texture of the material (adding extra occlusion effects).
  58729. */
  58730. occlusionTexture: BaseTexture;
  58731. /**
  58732. * Defines the alpha limits in alpha test mode.
  58733. */
  58734. alphaCutOff: number;
  58735. /**
  58736. * Gets the current double sided mode.
  58737. */
  58738. get doubleSided(): boolean;
  58739. /**
  58740. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  58741. */
  58742. set doubleSided(value: boolean);
  58743. /**
  58744. * Stores the pre-calculated light information of a mesh in a texture.
  58745. */
  58746. lightmapTexture: BaseTexture;
  58747. /**
  58748. * If true, the light map contains occlusion information instead of lighting info.
  58749. */
  58750. useLightmapAsShadowmap: boolean;
  58751. /**
  58752. * Instantiates a new PBRMaterial instance.
  58753. *
  58754. * @param name The material name
  58755. * @param scene The scene the material will be use in.
  58756. */
  58757. constructor(name: string, scene: Scene);
  58758. getClassName(): string;
  58759. }
  58760. }
  58761. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  58762. import { Scene } from "babylonjs/scene";
  58763. import { Color3 } from "babylonjs/Maths/math.color";
  58764. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58765. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  58766. /**
  58767. * The PBR material of BJS following the metal roughness convention.
  58768. *
  58769. * This fits to the PBR convention in the GLTF definition:
  58770. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  58771. */
  58772. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  58773. /**
  58774. * The base color has two different interpretations depending on the value of metalness.
  58775. * When the material is a metal, the base color is the specific measured reflectance value
  58776. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  58777. * of the material.
  58778. */
  58779. baseColor: Color3;
  58780. /**
  58781. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  58782. * well as opacity information in the alpha channel.
  58783. */
  58784. baseTexture: BaseTexture;
  58785. /**
  58786. * Specifies the metallic scalar value of the material.
  58787. * Can also be used to scale the metalness values of the metallic texture.
  58788. */
  58789. metallic: number;
  58790. /**
  58791. * Specifies the roughness scalar value of the material.
  58792. * Can also be used to scale the roughness values of the metallic texture.
  58793. */
  58794. roughness: number;
  58795. /**
  58796. * Texture containing both the metallic value in the B channel and the
  58797. * roughness value in the G channel to keep better precision.
  58798. */
  58799. metallicRoughnessTexture: BaseTexture;
  58800. /**
  58801. * Instantiates a new PBRMetalRoughnessMaterial instance.
  58802. *
  58803. * @param name The material name
  58804. * @param scene The scene the material will be use in.
  58805. */
  58806. constructor(name: string, scene: Scene);
  58807. /**
  58808. * Return the currrent class name of the material.
  58809. */
  58810. getClassName(): string;
  58811. /**
  58812. * Makes a duplicate of the current material.
  58813. * @param name - name to use for the new material.
  58814. */
  58815. clone(name: string): PBRMetallicRoughnessMaterial;
  58816. /**
  58817. * Serialize the material to a parsable JSON object.
  58818. */
  58819. serialize(): any;
  58820. /**
  58821. * Parses a JSON object correponding to the serialize function.
  58822. */
  58823. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  58824. }
  58825. }
  58826. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  58827. import { Scene } from "babylonjs/scene";
  58828. import { Color3 } from "babylonjs/Maths/math.color";
  58829. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58830. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  58831. /**
  58832. * The PBR material of BJS following the specular glossiness convention.
  58833. *
  58834. * This fits to the PBR convention in the GLTF definition:
  58835. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  58836. */
  58837. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  58838. /**
  58839. * Specifies the diffuse color of the material.
  58840. */
  58841. diffuseColor: Color3;
  58842. /**
  58843. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  58844. * channel.
  58845. */
  58846. diffuseTexture: BaseTexture;
  58847. /**
  58848. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  58849. */
  58850. specularColor: Color3;
  58851. /**
  58852. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  58853. */
  58854. glossiness: number;
  58855. /**
  58856. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  58857. */
  58858. specularGlossinessTexture: BaseTexture;
  58859. /**
  58860. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  58861. *
  58862. * @param name The material name
  58863. * @param scene The scene the material will be use in.
  58864. */
  58865. constructor(name: string, scene: Scene);
  58866. /**
  58867. * Return the currrent class name of the material.
  58868. */
  58869. getClassName(): string;
  58870. /**
  58871. * Makes a duplicate of the current material.
  58872. * @param name - name to use for the new material.
  58873. */
  58874. clone(name: string): PBRSpecularGlossinessMaterial;
  58875. /**
  58876. * Serialize the material to a parsable JSON object.
  58877. */
  58878. serialize(): any;
  58879. /**
  58880. * Parses a JSON object correponding to the serialize function.
  58881. */
  58882. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  58883. }
  58884. }
  58885. declare module "babylonjs/Materials/PBR/index" {
  58886. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  58887. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  58888. export * from "babylonjs/Materials/PBR/pbrMaterial";
  58889. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  58890. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  58891. }
  58892. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  58893. import { Nullable } from "babylonjs/types";
  58894. import { Scene } from "babylonjs/scene";
  58895. import { Matrix } from "babylonjs/Maths/math.vector";
  58896. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58897. /**
  58898. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  58899. * It can help converting any input color in a desired output one. This can then be used to create effects
  58900. * from sepia, black and white to sixties or futuristic rendering...
  58901. *
  58902. * The only supported format is currently 3dl.
  58903. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  58904. */
  58905. export class ColorGradingTexture extends BaseTexture {
  58906. /**
  58907. * The current texture matrix. (will always be identity in color grading texture)
  58908. */
  58909. private _textureMatrix;
  58910. /**
  58911. * The texture URL.
  58912. */
  58913. url: string;
  58914. /**
  58915. * Empty line regex stored for GC.
  58916. */
  58917. private static _noneEmptyLineRegex;
  58918. private _engine;
  58919. /**
  58920. * Instantiates a ColorGradingTexture from the following parameters.
  58921. *
  58922. * @param url The location of the color gradind data (currently only supporting 3dl)
  58923. * @param scene The scene the texture will be used in
  58924. */
  58925. constructor(url: string, scene: Scene);
  58926. /**
  58927. * Returns the texture matrix used in most of the material.
  58928. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  58929. */
  58930. getTextureMatrix(): Matrix;
  58931. /**
  58932. * Occurs when the file being loaded is a .3dl LUT file.
  58933. */
  58934. private load3dlTexture;
  58935. /**
  58936. * Starts the loading process of the texture.
  58937. */
  58938. private loadTexture;
  58939. /**
  58940. * Clones the color gradind texture.
  58941. */
  58942. clone(): ColorGradingTexture;
  58943. /**
  58944. * Called during delayed load for textures.
  58945. */
  58946. delayLoad(): void;
  58947. /**
  58948. * Parses a color grading texture serialized by Babylon.
  58949. * @param parsedTexture The texture information being parsedTexture
  58950. * @param scene The scene to load the texture in
  58951. * @param rootUrl The root url of the data assets to load
  58952. * @return A color gradind texture
  58953. */
  58954. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  58955. /**
  58956. * Serializes the LUT texture to json format.
  58957. */
  58958. serialize(): any;
  58959. }
  58960. }
  58961. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  58962. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58963. import { Scene } from "babylonjs/scene";
  58964. import { Nullable } from "babylonjs/types";
  58965. import "babylonjs/Engines/Extensions/engine.rawTexture";
  58966. /**
  58967. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  58968. */
  58969. export class EquiRectangularCubeTexture extends BaseTexture {
  58970. /** The six faces of the cube. */
  58971. private static _FacesMapping;
  58972. private _noMipmap;
  58973. private _onLoad;
  58974. private _onError;
  58975. /** The size of the cubemap. */
  58976. private _size;
  58977. /** The buffer of the image. */
  58978. private _buffer;
  58979. /** The width of the input image. */
  58980. private _width;
  58981. /** The height of the input image. */
  58982. private _height;
  58983. /** The URL to the image. */
  58984. url: string;
  58985. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  58986. coordinatesMode: number;
  58987. /**
  58988. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  58989. * @param url The location of the image
  58990. * @param scene The scene the texture will be used in
  58991. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  58992. * @param noMipmap Forces to not generate the mipmap if true
  58993. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  58994. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  58995. * @param onLoad — defines a callback called when texture is loaded
  58996. * @param onError — defines a callback called if there is an error
  58997. */
  58998. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  58999. /**
  59000. * Load the image data, by putting the image on a canvas and extracting its buffer.
  59001. */
  59002. private loadImage;
  59003. /**
  59004. * Convert the image buffer into a cubemap and create a CubeTexture.
  59005. */
  59006. private loadTexture;
  59007. /**
  59008. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  59009. * @param buffer The ArrayBuffer that should be converted.
  59010. * @returns The buffer as Float32Array.
  59011. */
  59012. private getFloat32ArrayFromArrayBuffer;
  59013. /**
  59014. * Get the current class name of the texture useful for serialization or dynamic coding.
  59015. * @returns "EquiRectangularCubeTexture"
  59016. */
  59017. getClassName(): string;
  59018. /**
  59019. * Create a clone of the current EquiRectangularCubeTexture and return it.
  59020. * @returns A clone of the current EquiRectangularCubeTexture.
  59021. */
  59022. clone(): EquiRectangularCubeTexture;
  59023. }
  59024. }
  59025. declare module "babylonjs/Misc/tga" {
  59026. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  59027. /**
  59028. * Based on jsTGALoader - Javascript loader for TGA file
  59029. * By Vincent Thibault
  59030. * @see http://blog.robrowser.com/javascript-tga-loader.html
  59031. */
  59032. export class TGATools {
  59033. private static _TYPE_INDEXED;
  59034. private static _TYPE_RGB;
  59035. private static _TYPE_GREY;
  59036. private static _TYPE_RLE_INDEXED;
  59037. private static _TYPE_RLE_RGB;
  59038. private static _TYPE_RLE_GREY;
  59039. private static _ORIGIN_MASK;
  59040. private static _ORIGIN_SHIFT;
  59041. private static _ORIGIN_BL;
  59042. private static _ORIGIN_BR;
  59043. private static _ORIGIN_UL;
  59044. private static _ORIGIN_UR;
  59045. /**
  59046. * Gets the header of a TGA file
  59047. * @param data defines the TGA data
  59048. * @returns the header
  59049. */
  59050. static GetTGAHeader(data: Uint8Array): any;
  59051. /**
  59052. * Uploads TGA content to a Babylon Texture
  59053. * @hidden
  59054. */
  59055. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  59056. /** @hidden */
  59057. 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;
  59058. /** @hidden */
  59059. 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;
  59060. /** @hidden */
  59061. 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;
  59062. /** @hidden */
  59063. 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;
  59064. /** @hidden */
  59065. 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;
  59066. /** @hidden */
  59067. 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;
  59068. }
  59069. }
  59070. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  59071. import { Nullable } from "babylonjs/types";
  59072. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  59073. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  59074. /**
  59075. * Implementation of the TGA Texture Loader.
  59076. * @hidden
  59077. */
  59078. export class _TGATextureLoader implements IInternalTextureLoader {
  59079. /**
  59080. * Defines wether the loader supports cascade loading the different faces.
  59081. */
  59082. readonly supportCascades: boolean;
  59083. /**
  59084. * This returns if the loader support the current file information.
  59085. * @param extension defines the file extension of the file being loaded
  59086. * @returns true if the loader can load the specified file
  59087. */
  59088. canLoad(extension: string): boolean;
  59089. /**
  59090. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  59091. * @param data contains the texture data
  59092. * @param texture defines the BabylonJS internal texture
  59093. * @param createPolynomials will be true if polynomials have been requested
  59094. * @param onLoad defines the callback to trigger once the texture is ready
  59095. * @param onError defines the callback to trigger in case of error
  59096. */
  59097. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  59098. /**
  59099. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  59100. * @param data contains the texture data
  59101. * @param texture defines the BabylonJS internal texture
  59102. * @param callback defines the method to call once ready to upload
  59103. */
  59104. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  59105. }
  59106. }
  59107. declare module "babylonjs/Misc/basis" {
  59108. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  59109. /**
  59110. * Info about the .basis files
  59111. */
  59112. class BasisFileInfo {
  59113. /**
  59114. * If the file has alpha
  59115. */
  59116. hasAlpha: boolean;
  59117. /**
  59118. * Info about each image of the basis file
  59119. */
  59120. images: Array<{
  59121. levels: Array<{
  59122. width: number;
  59123. height: number;
  59124. transcodedPixels: ArrayBufferView;
  59125. }>;
  59126. }>;
  59127. }
  59128. /**
  59129. * Result of transcoding a basis file
  59130. */
  59131. class TranscodeResult {
  59132. /**
  59133. * Info about the .basis file
  59134. */
  59135. fileInfo: BasisFileInfo;
  59136. /**
  59137. * Format to use when loading the file
  59138. */
  59139. format: number;
  59140. }
  59141. /**
  59142. * Configuration options for the Basis transcoder
  59143. */
  59144. export class BasisTranscodeConfiguration {
  59145. /**
  59146. * Supported compression formats used to determine the supported output format of the transcoder
  59147. */
  59148. supportedCompressionFormats?: {
  59149. /**
  59150. * etc1 compression format
  59151. */
  59152. etc1?: boolean;
  59153. /**
  59154. * s3tc compression format
  59155. */
  59156. s3tc?: boolean;
  59157. /**
  59158. * pvrtc compression format
  59159. */
  59160. pvrtc?: boolean;
  59161. /**
  59162. * etc2 compression format
  59163. */
  59164. etc2?: boolean;
  59165. };
  59166. /**
  59167. * If mipmap levels should be loaded for transcoded images (Default: true)
  59168. */
  59169. loadMipmapLevels?: boolean;
  59170. /**
  59171. * Index of a single image to load (Default: all images)
  59172. */
  59173. loadSingleImage?: number;
  59174. }
  59175. /**
  59176. * Used to load .Basis files
  59177. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  59178. */
  59179. export class BasisTools {
  59180. private static _IgnoreSupportedFormats;
  59181. /**
  59182. * URL to use when loading the basis transcoder
  59183. */
  59184. static JSModuleURL: string;
  59185. /**
  59186. * URL to use when loading the wasm module for the transcoder
  59187. */
  59188. static WasmModuleURL: string;
  59189. /**
  59190. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  59191. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  59192. * @returns internal format corresponding to the Basis format
  59193. */
  59194. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  59195. private static _WorkerPromise;
  59196. private static _Worker;
  59197. private static _actionId;
  59198. private static _CreateWorkerAsync;
  59199. /**
  59200. * Transcodes a loaded image file to compressed pixel data
  59201. * @param data image data to transcode
  59202. * @param config configuration options for the transcoding
  59203. * @returns a promise resulting in the transcoded image
  59204. */
  59205. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  59206. /**
  59207. * Loads a texture from the transcode result
  59208. * @param texture texture load to
  59209. * @param transcodeResult the result of transcoding the basis file to load from
  59210. */
  59211. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  59212. }
  59213. }
  59214. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  59215. import { Nullable } from "babylonjs/types";
  59216. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  59217. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  59218. /**
  59219. * Loader for .basis file format
  59220. */
  59221. export class _BasisTextureLoader implements IInternalTextureLoader {
  59222. /**
  59223. * Defines whether the loader supports cascade loading the different faces.
  59224. */
  59225. readonly supportCascades: boolean;
  59226. /**
  59227. * This returns if the loader support the current file information.
  59228. * @param extension defines the file extension of the file being loaded
  59229. * @returns true if the loader can load the specified file
  59230. */
  59231. canLoad(extension: string): boolean;
  59232. /**
  59233. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  59234. * @param data contains the texture data
  59235. * @param texture defines the BabylonJS internal texture
  59236. * @param createPolynomials will be true if polynomials have been requested
  59237. * @param onLoad defines the callback to trigger once the texture is ready
  59238. * @param onError defines the callback to trigger in case of error
  59239. */
  59240. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  59241. /**
  59242. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  59243. * @param data contains the texture data
  59244. * @param texture defines the BabylonJS internal texture
  59245. * @param callback defines the method to call once ready to upload
  59246. */
  59247. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  59248. }
  59249. }
  59250. declare module "babylonjs/Materials/Textures/Loaders/index" {
  59251. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  59252. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  59253. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  59254. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  59255. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  59256. }
  59257. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  59258. import { Scene } from "babylonjs/scene";
  59259. import { Texture } from "babylonjs/Materials/Textures/texture";
  59260. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  59261. /**
  59262. * Procedural texturing is a way to programmatically create a texture. There are 2 types of procedural textures: code-only, and code that references some classic 2D images, sometimes called 'refMaps' or 'sampler' images.
  59263. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  59264. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  59265. */
  59266. export class CustomProceduralTexture extends ProceduralTexture {
  59267. private _animate;
  59268. private _time;
  59269. private _config;
  59270. private _texturePath;
  59271. /**
  59272. * Instantiates a new Custom Procedural Texture.
  59273. * 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.
  59274. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  59275. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  59276. * @param name Define the name of the texture
  59277. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  59278. * @param size Define the size of the texture to create
  59279. * @param scene Define the scene the texture belongs to
  59280. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  59281. * @param generateMipMaps Define if the texture should creates mip maps or not
  59282. */
  59283. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  59284. private _loadJson;
  59285. /**
  59286. * Is the texture ready to be used ? (rendered at least once)
  59287. * @returns true if ready, otherwise, false.
  59288. */
  59289. isReady(): boolean;
  59290. /**
  59291. * Render the texture to its associated render target.
  59292. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  59293. */
  59294. render(useCameraPostProcess?: boolean): void;
  59295. /**
  59296. * Update the list of dependant textures samplers in the shader.
  59297. */
  59298. updateTextures(): void;
  59299. /**
  59300. * Update the uniform values of the procedural texture in the shader.
  59301. */
  59302. updateShaderUniforms(): void;
  59303. /**
  59304. * Define if the texture animates or not.
  59305. */
  59306. get animate(): boolean;
  59307. set animate(value: boolean);
  59308. }
  59309. }
  59310. declare module "babylonjs/Shaders/noise.fragment" {
  59311. /** @hidden */
  59312. export var noisePixelShader: {
  59313. name: string;
  59314. shader: string;
  59315. };
  59316. }
  59317. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  59318. import { Nullable } from "babylonjs/types";
  59319. import { Scene } from "babylonjs/scene";
  59320. import { Texture } from "babylonjs/Materials/Textures/texture";
  59321. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  59322. import "babylonjs/Shaders/noise.fragment";
  59323. /**
  59324. * Class used to generate noise procedural textures
  59325. */
  59326. export class NoiseProceduralTexture extends ProceduralTexture {
  59327. private _time;
  59328. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  59329. brightness: number;
  59330. /** Defines the number of octaves to process */
  59331. octaves: number;
  59332. /** Defines the level of persistence (0.8 by default) */
  59333. persistence: number;
  59334. /** Gets or sets animation speed factor (default is 1) */
  59335. animationSpeedFactor: number;
  59336. /**
  59337. * Creates a new NoiseProceduralTexture
  59338. * @param name defines the name fo the texture
  59339. * @param size defines the size of the texture (default is 256)
  59340. * @param scene defines the hosting scene
  59341. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  59342. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  59343. */
  59344. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  59345. private _updateShaderUniforms;
  59346. protected _getDefines(): string;
  59347. /** Generate the current state of the procedural texture */
  59348. render(useCameraPostProcess?: boolean): void;
  59349. /**
  59350. * Serializes this noise procedural texture
  59351. * @returns a serialized noise procedural texture object
  59352. */
  59353. serialize(): any;
  59354. /**
  59355. * Clone the texture.
  59356. * @returns the cloned texture
  59357. */
  59358. clone(): NoiseProceduralTexture;
  59359. /**
  59360. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  59361. * @param parsedTexture defines parsed texture data
  59362. * @param scene defines the current scene
  59363. * @param rootUrl defines the root URL containing noise procedural texture information
  59364. * @returns a parsed NoiseProceduralTexture
  59365. */
  59366. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  59367. }
  59368. }
  59369. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  59370. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  59371. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  59372. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  59373. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  59374. }
  59375. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  59376. import { Nullable } from "babylonjs/types";
  59377. import { Scene } from "babylonjs/scene";
  59378. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  59379. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  59380. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  59381. import "babylonjs/Engines/Extensions/engine.rawTexture";
  59382. /**
  59383. * Raw cube texture where the raw buffers are passed in
  59384. */
  59385. export class RawCubeTexture extends CubeTexture {
  59386. /**
  59387. * Creates a cube texture where the raw buffers are passed in.
  59388. * @param scene defines the scene the texture is attached to
  59389. * @param data defines the array of data to use to create each face
  59390. * @param size defines the size of the textures
  59391. * @param format defines the format of the data
  59392. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  59393. * @param generateMipMaps defines if the engine should generate the mip levels
  59394. * @param invertY defines if data must be stored with Y axis inverted
  59395. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  59396. * @param compression defines the compression used (null by default)
  59397. */
  59398. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  59399. /**
  59400. * Updates the raw cube texture.
  59401. * @param data defines the data to store
  59402. * @param format defines the data format
  59403. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  59404. * @param invertY defines if data must be stored with Y axis inverted
  59405. * @param compression defines the compression used (null by default)
  59406. * @param level defines which level of the texture to update
  59407. */
  59408. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  59409. /**
  59410. * Updates a raw cube texture with RGBD encoded data.
  59411. * @param data defines the array of data [mipmap][face] to use to create each face
  59412. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  59413. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  59414. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  59415. * @returns a promsie that resolves when the operation is complete
  59416. */
  59417. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  59418. /**
  59419. * Clones the raw cube texture.
  59420. * @return a new cube texture
  59421. */
  59422. clone(): CubeTexture;
  59423. /** @hidden */
  59424. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  59425. }
  59426. }
  59427. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  59428. import { Scene } from "babylonjs/scene";
  59429. import { Texture } from "babylonjs/Materials/Textures/texture";
  59430. import "babylonjs/Engines/Extensions/engine.rawTexture";
  59431. /**
  59432. * Class used to store 3D textures containing user data
  59433. */
  59434. export class RawTexture3D extends Texture {
  59435. /** Gets or sets the texture format to use */
  59436. format: number;
  59437. private _engine;
  59438. /**
  59439. * Create a new RawTexture3D
  59440. * @param data defines the data of the texture
  59441. * @param width defines the width of the texture
  59442. * @param height defines the height of the texture
  59443. * @param depth defines the depth of the texture
  59444. * @param format defines the texture format to use
  59445. * @param scene defines the hosting scene
  59446. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  59447. * @param invertY defines if texture must be stored with Y axis inverted
  59448. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  59449. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  59450. */
  59451. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  59452. /** Gets or sets the texture format to use */
  59453. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  59454. /**
  59455. * Update the texture with new data
  59456. * @param data defines the data to store in the texture
  59457. */
  59458. update(data: ArrayBufferView): void;
  59459. }
  59460. }
  59461. declare module "babylonjs/Materials/Textures/rawTexture2DArray" {
  59462. import { Scene } from "babylonjs/scene";
  59463. import { Texture } from "babylonjs/Materials/Textures/texture";
  59464. import "babylonjs/Engines/Extensions/engine.rawTexture";
  59465. /**
  59466. * Class used to store 2D array textures containing user data
  59467. */
  59468. export class RawTexture2DArray extends Texture {
  59469. /** Gets or sets the texture format to use */
  59470. format: number;
  59471. private _engine;
  59472. /**
  59473. * Create a new RawTexture2DArray
  59474. * @param data defines the data of the texture
  59475. * @param width defines the width of the texture
  59476. * @param height defines the height of the texture
  59477. * @param depth defines the number of layers of the texture
  59478. * @param format defines the texture format to use
  59479. * @param scene defines the hosting scene
  59480. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  59481. * @param invertY defines if texture must be stored with Y axis inverted
  59482. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  59483. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  59484. */
  59485. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  59486. /** Gets or sets the texture format to use */
  59487. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  59488. /**
  59489. * Update the texture with new data
  59490. * @param data defines the data to store in the texture
  59491. */
  59492. update(data: ArrayBufferView): void;
  59493. }
  59494. }
  59495. declare module "babylonjs/Materials/Textures/refractionTexture" {
  59496. import { Scene } from "babylonjs/scene";
  59497. import { Plane } from "babylonjs/Maths/math.plane";
  59498. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  59499. /**
  59500. * Creates a refraction texture used by refraction channel of the standard material.
  59501. * It is like a mirror but to see through a material.
  59502. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  59503. */
  59504. export class RefractionTexture extends RenderTargetTexture {
  59505. /**
  59506. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  59507. * 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.
  59508. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  59509. */
  59510. refractionPlane: Plane;
  59511. /**
  59512. * Define how deep under the surface we should see.
  59513. */
  59514. depth: number;
  59515. /**
  59516. * Creates a refraction texture used by refraction channel of the standard material.
  59517. * It is like a mirror but to see through a material.
  59518. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  59519. * @param name Define the texture name
  59520. * @param size Define the size of the underlying texture
  59521. * @param scene Define the scene the refraction belongs to
  59522. * @param generateMipMaps Define if we need to generate mips level for the refraction
  59523. */
  59524. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  59525. /**
  59526. * Clone the refraction texture.
  59527. * @returns the cloned texture
  59528. */
  59529. clone(): RefractionTexture;
  59530. /**
  59531. * Serialize the texture to a JSON representation you could use in Parse later on
  59532. * @returns the serialized JSON representation
  59533. */
  59534. serialize(): any;
  59535. }
  59536. }
  59537. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  59538. import { Nullable } from "babylonjs/types";
  59539. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59540. import { Matrix } from "babylonjs/Maths/math.vector";
  59541. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  59542. import "babylonjs/Engines/Extensions/engine.videoTexture";
  59543. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  59544. import { Scene } from "babylonjs/scene";
  59545. /**
  59546. * Defines the options related to the creation of an HtmlElementTexture
  59547. */
  59548. export interface IHtmlElementTextureOptions {
  59549. /**
  59550. * Defines wether mip maps should be created or not.
  59551. */
  59552. generateMipMaps?: boolean;
  59553. /**
  59554. * Defines the sampling mode of the texture.
  59555. */
  59556. samplingMode?: number;
  59557. /**
  59558. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  59559. */
  59560. engine: Nullable<ThinEngine>;
  59561. /**
  59562. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  59563. */
  59564. scene: Nullable<Scene>;
  59565. }
  59566. /**
  59567. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  59568. * To be as efficient as possible depending on your constraints nothing aside the first upload
  59569. * is automatically managed.
  59570. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  59571. * in your application.
  59572. *
  59573. * As the update is not automatic, you need to call them manually.
  59574. */
  59575. export class HtmlElementTexture extends BaseTexture {
  59576. /**
  59577. * The texture URL.
  59578. */
  59579. element: HTMLVideoElement | HTMLCanvasElement;
  59580. private static readonly DefaultOptions;
  59581. private _textureMatrix;
  59582. private _engine;
  59583. private _isVideo;
  59584. private _generateMipMaps;
  59585. private _samplingMode;
  59586. /**
  59587. * Instantiates a HtmlElementTexture from the following parameters.
  59588. *
  59589. * @param name Defines the name of the texture
  59590. * @param element Defines the video or canvas the texture is filled with
  59591. * @param options Defines the other none mandatory texture creation options
  59592. */
  59593. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  59594. private _createInternalTexture;
  59595. /**
  59596. * Returns the texture matrix used in most of the material.
  59597. */
  59598. getTextureMatrix(): Matrix;
  59599. /**
  59600. * Updates the content of the texture.
  59601. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  59602. */
  59603. update(invertY?: Nullable<boolean>): void;
  59604. }
  59605. }
  59606. declare module "babylonjs/Materials/Textures/Packer/frame" {
  59607. import { Vector2 } from "babylonjs/Maths/math.vector";
  59608. /**
  59609. * Defines the basic options interface of a TexturePacker Frame
  59610. */
  59611. export interface ITexturePackerFrame {
  59612. /**
  59613. * The frame ID
  59614. */
  59615. id: number;
  59616. /**
  59617. * The frames Scale
  59618. */
  59619. scale: Vector2;
  59620. /**
  59621. * The Frames offset
  59622. */
  59623. offset: Vector2;
  59624. }
  59625. /**
  59626. * This is a support class for frame Data on texture packer sets.
  59627. */
  59628. export class TexturePackerFrame implements ITexturePackerFrame {
  59629. /**
  59630. * The frame ID
  59631. */
  59632. id: number;
  59633. /**
  59634. * The frames Scale
  59635. */
  59636. scale: Vector2;
  59637. /**
  59638. * The Frames offset
  59639. */
  59640. offset: Vector2;
  59641. /**
  59642. * Initializes a texture package frame.
  59643. * @param id The numerical frame identifier
  59644. * @param scale Scalar Vector2 for UV frame
  59645. * @param offset Vector2 for the frame position in UV units.
  59646. * @returns TexturePackerFrame
  59647. */
  59648. constructor(id: number, scale: Vector2, offset: Vector2);
  59649. }
  59650. }
  59651. declare module "babylonjs/Materials/Textures/Packer/packer" {
  59652. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59653. import { Scene } from "babylonjs/scene";
  59654. import { Nullable } from "babylonjs/types";
  59655. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  59656. import { TexturePackerFrame } from "babylonjs/Materials/Textures/Packer/frame";
  59657. /**
  59658. * Defines the basic options interface of a TexturePacker
  59659. */
  59660. export interface ITexturePackerOptions {
  59661. /**
  59662. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  59663. */
  59664. map?: string[];
  59665. /**
  59666. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  59667. */
  59668. uvsIn?: string;
  59669. /**
  59670. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  59671. */
  59672. uvsOut?: string;
  59673. /**
  59674. * number representing the layout style. Defaults to LAYOUT_STRIP
  59675. */
  59676. layout?: number;
  59677. /**
  59678. * number of columns if using custom column count layout(2). This defaults to 4.
  59679. */
  59680. colnum?: number;
  59681. /**
  59682. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  59683. */
  59684. updateInputMeshes?: boolean;
  59685. /**
  59686. * boolean flag to dispose all the source textures. Defaults to true.
  59687. */
  59688. disposeSources?: boolean;
  59689. /**
  59690. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  59691. */
  59692. fillBlanks?: boolean;
  59693. /**
  59694. * string value representing the context fill style color. Defaults to 'black'.
  59695. */
  59696. customFillColor?: string;
  59697. /**
  59698. * Width and Height Value of each Frame in the TexturePacker Sets
  59699. */
  59700. frameSize?: number;
  59701. /**
  59702. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  59703. */
  59704. paddingRatio?: number;
  59705. /**
  59706. * Number that declares the fill method for the padding gutter.
  59707. */
  59708. paddingMode?: number;
  59709. /**
  59710. * If in SUBUV_COLOR padding mode what color to use.
  59711. */
  59712. paddingColor?: Color3 | Color4;
  59713. }
  59714. /**
  59715. * Defines the basic interface of a TexturePacker JSON File
  59716. */
  59717. export interface ITexturePackerJSON {
  59718. /**
  59719. * The frame ID
  59720. */
  59721. name: string;
  59722. /**
  59723. * The base64 channel data
  59724. */
  59725. sets: any;
  59726. /**
  59727. * The options of the Packer
  59728. */
  59729. options: ITexturePackerOptions;
  59730. /**
  59731. * The frame data of the Packer
  59732. */
  59733. frames: Array<number>;
  59734. }
  59735. /**
  59736. * This is a support class that generates a series of packed texture sets.
  59737. * @see https://doc.babylonjs.com/babylon101/materials
  59738. */
  59739. export class TexturePacker {
  59740. /** Packer Layout Constant 0 */
  59741. static readonly LAYOUT_STRIP: number;
  59742. /** Packer Layout Constant 1 */
  59743. static readonly LAYOUT_POWER2: number;
  59744. /** Packer Layout Constant 2 */
  59745. static readonly LAYOUT_COLNUM: number;
  59746. /** Packer Layout Constant 0 */
  59747. static readonly SUBUV_WRAP: number;
  59748. /** Packer Layout Constant 1 */
  59749. static readonly SUBUV_EXTEND: number;
  59750. /** Packer Layout Constant 2 */
  59751. static readonly SUBUV_COLOR: number;
  59752. /** The Name of the Texture Package */
  59753. name: string;
  59754. /** The scene scope of the TexturePacker */
  59755. scene: Scene;
  59756. /** The Meshes to target */
  59757. meshes: AbstractMesh[];
  59758. /** Arguments passed with the Constructor */
  59759. options: ITexturePackerOptions;
  59760. /** The promise that is started upon initialization */
  59761. promise: Nullable<Promise<TexturePacker | string>>;
  59762. /** The Container object for the channel sets that are generated */
  59763. sets: object;
  59764. /** The Container array for the frames that are generated */
  59765. frames: TexturePackerFrame[];
  59766. /** The expected number of textures the system is parsing. */
  59767. private _expecting;
  59768. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  59769. private _paddingValue;
  59770. /**
  59771. * Initializes a texture package series from an array of meshes or a single mesh.
  59772. * @param name The name of the package
  59773. * @param meshes The target meshes to compose the package from
  59774. * @param options The arguments that texture packer should follow while building.
  59775. * @param scene The scene which the textures are scoped to.
  59776. * @returns TexturePacker
  59777. */
  59778. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  59779. /**
  59780. * Starts the package process
  59781. * @param resolve The promises resolution function
  59782. * @returns TexturePacker
  59783. */
  59784. private _createFrames;
  59785. /**
  59786. * Calculates the Size of the Channel Sets
  59787. * @returns Vector2
  59788. */
  59789. private _calculateSize;
  59790. /**
  59791. * Calculates the UV data for the frames.
  59792. * @param baseSize the base frameSize
  59793. * @param padding the base frame padding
  59794. * @param dtSize size of the Dynamic Texture for that channel
  59795. * @param dtUnits is 1/dtSize
  59796. * @param update flag to update the input meshes
  59797. */
  59798. private _calculateMeshUVFrames;
  59799. /**
  59800. * Calculates the frames Offset.
  59801. * @param index of the frame
  59802. * @returns Vector2
  59803. */
  59804. private _getFrameOffset;
  59805. /**
  59806. * Updates a Mesh to the frame data
  59807. * @param mesh that is the target
  59808. * @param frameID or the frame index
  59809. */
  59810. private _updateMeshUV;
  59811. /**
  59812. * Updates a Meshes materials to use the texture packer channels
  59813. * @param m is the mesh to target
  59814. * @param force all channels on the packer to be set.
  59815. */
  59816. private _updateTextureReferences;
  59817. /**
  59818. * Public method to set a Mesh to a frame
  59819. * @param m that is the target
  59820. * @param frameID or the frame index
  59821. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  59822. */
  59823. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  59824. /**
  59825. * Starts the async promise to compile the texture packer.
  59826. * @returns Promise<void>
  59827. */
  59828. processAsync(): Promise<void>;
  59829. /**
  59830. * Disposes all textures associated with this packer
  59831. */
  59832. dispose(): void;
  59833. /**
  59834. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  59835. * @param imageType is the image type to use.
  59836. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  59837. */
  59838. download(imageType?: string, quality?: number): void;
  59839. /**
  59840. * Public method to load a texturePacker JSON file.
  59841. * @param data of the JSON file in string format.
  59842. */
  59843. updateFromJSON(data: string): void;
  59844. }
  59845. }
  59846. declare module "babylonjs/Materials/Textures/Packer/index" {
  59847. export * from "babylonjs/Materials/Textures/Packer/packer";
  59848. export * from "babylonjs/Materials/Textures/Packer/frame";
  59849. }
  59850. declare module "babylonjs/Materials/Textures/index" {
  59851. export * from "babylonjs/Materials/Textures/baseTexture";
  59852. export * from "babylonjs/Materials/Textures/baseTexture.polynomial";
  59853. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  59854. export * from "babylonjs/Materials/Textures/cubeTexture";
  59855. export * from "babylonjs/Materials/Textures/dynamicTexture";
  59856. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  59857. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  59858. export * from "babylonjs/Materials/Textures/internalTexture";
  59859. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  59860. export * from "babylonjs/Materials/Textures/Loaders/index";
  59861. export * from "babylonjs/Materials/Textures/mirrorTexture";
  59862. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  59863. export * from "babylonjs/Materials/Textures/Procedurals/index";
  59864. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  59865. export * from "babylonjs/Materials/Textures/rawTexture";
  59866. export * from "babylonjs/Materials/Textures/rawTexture3D";
  59867. export * from "babylonjs/Materials/Textures/rawTexture2DArray";
  59868. export * from "babylonjs/Materials/Textures/refractionTexture";
  59869. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  59870. export * from "babylonjs/Materials/Textures/texture";
  59871. export * from "babylonjs/Materials/Textures/videoTexture";
  59872. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  59873. export * from "babylonjs/Materials/Textures/Packer/index";
  59874. }
  59875. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets" {
  59876. /**
  59877. * Enum used to define the target of a block
  59878. */
  59879. export enum NodeMaterialBlockTargets {
  59880. /** Vertex shader */
  59881. Vertex = 1,
  59882. /** Fragment shader */
  59883. Fragment = 2,
  59884. /** Neutral */
  59885. Neutral = 4,
  59886. /** Vertex and Fragment */
  59887. VertexAndFragment = 3
  59888. }
  59889. }
  59890. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes" {
  59891. /**
  59892. * Defines the kind of connection point for node based material
  59893. */
  59894. export enum NodeMaterialBlockConnectionPointTypes {
  59895. /** Float */
  59896. Float = 1,
  59897. /** Int */
  59898. Int = 2,
  59899. /** Vector2 */
  59900. Vector2 = 4,
  59901. /** Vector3 */
  59902. Vector3 = 8,
  59903. /** Vector4 */
  59904. Vector4 = 16,
  59905. /** Color3 */
  59906. Color3 = 32,
  59907. /** Color4 */
  59908. Color4 = 64,
  59909. /** Matrix */
  59910. Matrix = 128,
  59911. /** Detect type based on connection */
  59912. AutoDetect = 1024,
  59913. /** Output type that will be defined by input type */
  59914. BasedOnInput = 2048
  59915. }
  59916. }
  59917. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode" {
  59918. /**
  59919. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  59920. */
  59921. export enum NodeMaterialBlockConnectionPointMode {
  59922. /** Value is an uniform */
  59923. Uniform = 0,
  59924. /** Value is a mesh attribute */
  59925. Attribute = 1,
  59926. /** Value is a varying between vertex and fragment shaders */
  59927. Varying = 2,
  59928. /** Mode is undefined */
  59929. Undefined = 3
  59930. }
  59931. }
  59932. declare module "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues" {
  59933. /**
  59934. * Enum used to define system values e.g. values automatically provided by the system
  59935. */
  59936. export enum NodeMaterialSystemValues {
  59937. /** World */
  59938. World = 1,
  59939. /** View */
  59940. View = 2,
  59941. /** Projection */
  59942. Projection = 3,
  59943. /** ViewProjection */
  59944. ViewProjection = 4,
  59945. /** WorldView */
  59946. WorldView = 5,
  59947. /** WorldViewProjection */
  59948. WorldViewProjection = 6,
  59949. /** CameraPosition */
  59950. CameraPosition = 7,
  59951. /** Fog Color */
  59952. FogColor = 8,
  59953. /** Delta time */
  59954. DeltaTime = 9
  59955. }
  59956. }
  59957. declare module "babylonjs/Materials/Node/Enums/index" {
  59958. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  59959. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  59960. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode";
  59961. export * from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  59962. }
  59963. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  59964. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59965. /**
  59966. * Root class for all node material optimizers
  59967. */
  59968. export class NodeMaterialOptimizer {
  59969. /**
  59970. * Function used to optimize a NodeMaterial graph
  59971. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  59972. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  59973. */
  59974. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  59975. }
  59976. }
  59977. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  59978. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59979. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59980. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59981. import { Scene } from "babylonjs/scene";
  59982. /**
  59983. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  59984. */
  59985. export class TransformBlock extends NodeMaterialBlock {
  59986. /**
  59987. * Defines the value to use to complement W value to transform it to a Vector4
  59988. */
  59989. complementW: number;
  59990. /**
  59991. * Defines the value to use to complement z value to transform it to a Vector4
  59992. */
  59993. complementZ: number;
  59994. /**
  59995. * Creates a new TransformBlock
  59996. * @param name defines the block name
  59997. */
  59998. constructor(name: string);
  59999. /**
  60000. * Gets the current class name
  60001. * @returns the class name
  60002. */
  60003. getClassName(): string;
  60004. /**
  60005. * Gets the vector input
  60006. */
  60007. get vector(): NodeMaterialConnectionPoint;
  60008. /**
  60009. * Gets the output component
  60010. */
  60011. get output(): NodeMaterialConnectionPoint;
  60012. /**
  60013. * Gets the xyz output component
  60014. */
  60015. get xyz(): NodeMaterialConnectionPoint;
  60016. /**
  60017. * Gets the matrix transform input
  60018. */
  60019. get transform(): NodeMaterialConnectionPoint;
  60020. protected _buildBlock(state: NodeMaterialBuildState): this;
  60021. serialize(): any;
  60022. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60023. protected _dumpPropertiesCode(): string;
  60024. }
  60025. }
  60026. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  60027. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60028. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60029. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60030. /**
  60031. * Block used to output the vertex position
  60032. */
  60033. export class VertexOutputBlock extends NodeMaterialBlock {
  60034. /**
  60035. * Creates a new VertexOutputBlock
  60036. * @param name defines the block name
  60037. */
  60038. constructor(name: string);
  60039. /**
  60040. * Gets the current class name
  60041. * @returns the class name
  60042. */
  60043. getClassName(): string;
  60044. /**
  60045. * Gets the vector input component
  60046. */
  60047. get vector(): NodeMaterialConnectionPoint;
  60048. protected _buildBlock(state: NodeMaterialBuildState): this;
  60049. }
  60050. }
  60051. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  60052. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60053. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60054. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60055. /**
  60056. * Block used to output the final color
  60057. */
  60058. export class FragmentOutputBlock extends NodeMaterialBlock {
  60059. /**
  60060. * Create a new FragmentOutputBlock
  60061. * @param name defines the block name
  60062. */
  60063. constructor(name: string);
  60064. /**
  60065. * Gets the current class name
  60066. * @returns the class name
  60067. */
  60068. getClassName(): string;
  60069. /**
  60070. * Gets the rgba input component
  60071. */
  60072. get rgba(): NodeMaterialConnectionPoint;
  60073. /**
  60074. * Gets the rgb input component
  60075. */
  60076. get rgb(): NodeMaterialConnectionPoint;
  60077. /**
  60078. * Gets the a input component
  60079. */
  60080. get a(): NodeMaterialConnectionPoint;
  60081. protected _buildBlock(state: NodeMaterialBuildState): this;
  60082. }
  60083. }
  60084. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  60085. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60086. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60087. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60088. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  60089. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60090. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  60091. import { Effect } from "babylonjs/Materials/effect";
  60092. import { Mesh } from "babylonjs/Meshes/mesh";
  60093. import { Nullable } from "babylonjs/types";
  60094. import { Scene } from "babylonjs/scene";
  60095. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  60096. /**
  60097. * Block used to read a reflection texture from a sampler
  60098. */
  60099. export class ReflectionTextureBlock extends NodeMaterialBlock {
  60100. private _define3DName;
  60101. private _defineCubicName;
  60102. private _defineExplicitName;
  60103. private _defineProjectionName;
  60104. private _defineLocalCubicName;
  60105. private _defineSphericalName;
  60106. private _definePlanarName;
  60107. private _defineEquirectangularName;
  60108. private _defineMirroredEquirectangularFixedName;
  60109. private _defineEquirectangularFixedName;
  60110. private _defineSkyboxName;
  60111. private _cubeSamplerName;
  60112. private _2DSamplerName;
  60113. private _positionUVWName;
  60114. private _directionWName;
  60115. private _reflectionCoordsName;
  60116. private _reflection2DCoordsName;
  60117. private _reflectionColorName;
  60118. private _reflectionMatrixName;
  60119. /**
  60120. * Gets or sets the texture associated with the node
  60121. */
  60122. texture: Nullable<BaseTexture>;
  60123. /**
  60124. * Create a new TextureBlock
  60125. * @param name defines the block name
  60126. */
  60127. constructor(name: string);
  60128. /**
  60129. * Gets the current class name
  60130. * @returns the class name
  60131. */
  60132. getClassName(): string;
  60133. /**
  60134. * Gets the world position input component
  60135. */
  60136. get position(): NodeMaterialConnectionPoint;
  60137. /**
  60138. * Gets the world position input component
  60139. */
  60140. get worldPosition(): NodeMaterialConnectionPoint;
  60141. /**
  60142. * Gets the world normal input component
  60143. */
  60144. get worldNormal(): NodeMaterialConnectionPoint;
  60145. /**
  60146. * Gets the world input component
  60147. */
  60148. get world(): NodeMaterialConnectionPoint;
  60149. /**
  60150. * Gets the camera (or eye) position component
  60151. */
  60152. get cameraPosition(): NodeMaterialConnectionPoint;
  60153. /**
  60154. * Gets the view input component
  60155. */
  60156. get view(): NodeMaterialConnectionPoint;
  60157. /**
  60158. * Gets the rgb output component
  60159. */
  60160. get rgb(): NodeMaterialConnectionPoint;
  60161. /**
  60162. * Gets the r output component
  60163. */
  60164. get r(): NodeMaterialConnectionPoint;
  60165. /**
  60166. * Gets the g output component
  60167. */
  60168. get g(): NodeMaterialConnectionPoint;
  60169. /**
  60170. * Gets the b output component
  60171. */
  60172. get b(): NodeMaterialConnectionPoint;
  60173. autoConfigure(material: NodeMaterial): void;
  60174. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  60175. isReady(): boolean;
  60176. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60177. private _injectVertexCode;
  60178. private _writeOutput;
  60179. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  60180. protected _dumpPropertiesCode(): string;
  60181. serialize(): any;
  60182. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60183. }
  60184. }
  60185. declare module "babylonjs/Materials/Node/nodeMaterial" {
  60186. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60187. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  60188. import { Scene } from "babylonjs/scene";
  60189. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60190. import { Matrix } from "babylonjs/Maths/math.vector";
  60191. import { Mesh } from "babylonjs/Meshes/mesh";
  60192. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  60193. import { Observable } from "babylonjs/Misc/observable";
  60194. import { SubMesh } from "babylonjs/Meshes/subMesh";
  60195. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  60196. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  60197. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  60198. import { Nullable } from "babylonjs/types";
  60199. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  60200. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  60201. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  60202. /**
  60203. * Interface used to configure the node material editor
  60204. */
  60205. export interface INodeMaterialEditorOptions {
  60206. /** Define the URl to load node editor script */
  60207. editorURL?: string;
  60208. }
  60209. /** @hidden */
  60210. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  60211. NORMAL: boolean;
  60212. TANGENT: boolean;
  60213. UV1: boolean;
  60214. /** BONES */
  60215. NUM_BONE_INFLUENCERS: number;
  60216. BonesPerMesh: number;
  60217. BONETEXTURE: boolean;
  60218. /** MORPH TARGETS */
  60219. MORPHTARGETS: boolean;
  60220. MORPHTARGETS_NORMAL: boolean;
  60221. MORPHTARGETS_TANGENT: boolean;
  60222. MORPHTARGETS_UV: boolean;
  60223. NUM_MORPH_INFLUENCERS: number;
  60224. /** IMAGE PROCESSING */
  60225. IMAGEPROCESSING: boolean;
  60226. VIGNETTE: boolean;
  60227. VIGNETTEBLENDMODEMULTIPLY: boolean;
  60228. VIGNETTEBLENDMODEOPAQUE: boolean;
  60229. TONEMAPPING: boolean;
  60230. TONEMAPPING_ACES: boolean;
  60231. CONTRAST: boolean;
  60232. EXPOSURE: boolean;
  60233. COLORCURVES: boolean;
  60234. COLORGRADING: boolean;
  60235. COLORGRADING3D: boolean;
  60236. SAMPLER3DGREENDEPTH: boolean;
  60237. SAMPLER3DBGRMAP: boolean;
  60238. IMAGEPROCESSINGPOSTPROCESS: boolean;
  60239. /** MISC. */
  60240. BUMPDIRECTUV: number;
  60241. constructor();
  60242. setValue(name: string, value: boolean): void;
  60243. }
  60244. /**
  60245. * Class used to configure NodeMaterial
  60246. */
  60247. export interface INodeMaterialOptions {
  60248. /**
  60249. * Defines if blocks should emit comments
  60250. */
  60251. emitComments: boolean;
  60252. }
  60253. /**
  60254. * Class used to create a node based material built by assembling shader blocks
  60255. */
  60256. export class NodeMaterial extends PushMaterial {
  60257. private static _BuildIdGenerator;
  60258. private _options;
  60259. private _vertexCompilationState;
  60260. private _fragmentCompilationState;
  60261. private _sharedData;
  60262. private _buildId;
  60263. private _buildWasSuccessful;
  60264. private _cachedWorldViewMatrix;
  60265. private _cachedWorldViewProjectionMatrix;
  60266. private _optimizers;
  60267. private _animationFrame;
  60268. /** Define the Url to load node editor script */
  60269. static EditorURL: string;
  60270. /** Define the Url to load snippets */
  60271. static SnippetUrl: string;
  60272. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  60273. static IgnoreTexturesAtLoadTime: boolean;
  60274. private BJSNODEMATERIALEDITOR;
  60275. /** Get the inspector from bundle or global */
  60276. private _getGlobalNodeMaterialEditor;
  60277. /**
  60278. * Snippet ID if the material was created from the snippet server
  60279. */
  60280. snippetId: string;
  60281. /**
  60282. * Gets or sets data used by visual editor
  60283. * @see https://nme.babylonjs.com
  60284. */
  60285. editorData: any;
  60286. /**
  60287. * 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)
  60288. */
  60289. ignoreAlpha: boolean;
  60290. /**
  60291. * Defines the maximum number of lights that can be used in the material
  60292. */
  60293. maxSimultaneousLights: number;
  60294. /**
  60295. * Observable raised when the material is built
  60296. */
  60297. onBuildObservable: Observable<NodeMaterial>;
  60298. /**
  60299. * Gets or sets the root nodes of the material vertex shader
  60300. */
  60301. _vertexOutputNodes: NodeMaterialBlock[];
  60302. /**
  60303. * Gets or sets the root nodes of the material fragment (pixel) shader
  60304. */
  60305. _fragmentOutputNodes: NodeMaterialBlock[];
  60306. /** Gets or sets options to control the node material overall behavior */
  60307. get options(): INodeMaterialOptions;
  60308. set options(options: INodeMaterialOptions);
  60309. /**
  60310. * Default configuration related to image processing available in the standard Material.
  60311. */
  60312. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  60313. /**
  60314. * Gets the image processing configuration used either in this material.
  60315. */
  60316. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  60317. /**
  60318. * Sets the Default image processing configuration used either in the this material.
  60319. *
  60320. * If sets to null, the scene one is in use.
  60321. */
  60322. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  60323. /**
  60324. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  60325. */
  60326. attachedBlocks: NodeMaterialBlock[];
  60327. /**
  60328. * Create a new node based material
  60329. * @param name defines the material name
  60330. * @param scene defines the hosting scene
  60331. * @param options defines creation option
  60332. */
  60333. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  60334. /**
  60335. * Gets the current class name of the material e.g. "NodeMaterial"
  60336. * @returns the class name
  60337. */
  60338. getClassName(): string;
  60339. /**
  60340. * Keep track of the image processing observer to allow dispose and replace.
  60341. */
  60342. private _imageProcessingObserver;
  60343. /**
  60344. * Attaches a new image processing configuration to the Standard Material.
  60345. * @param configuration
  60346. */
  60347. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  60348. /**
  60349. * Get a block by its name
  60350. * @param name defines the name of the block to retrieve
  60351. * @returns the required block or null if not found
  60352. */
  60353. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  60354. /**
  60355. * Get a block by its name
  60356. * @param predicate defines the predicate used to find the good candidate
  60357. * @returns the required block or null if not found
  60358. */
  60359. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  60360. /**
  60361. * Get an input block by its name
  60362. * @param predicate defines the predicate used to find the good candidate
  60363. * @returns the required input block or null if not found
  60364. */
  60365. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  60366. /**
  60367. * Gets the list of input blocks attached to this material
  60368. * @returns an array of InputBlocks
  60369. */
  60370. getInputBlocks(): InputBlock[];
  60371. /**
  60372. * Adds a new optimizer to the list of optimizers
  60373. * @param optimizer defines the optimizers to add
  60374. * @returns the current material
  60375. */
  60376. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  60377. /**
  60378. * Remove an optimizer from the list of optimizers
  60379. * @param optimizer defines the optimizers to remove
  60380. * @returns the current material
  60381. */
  60382. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  60383. /**
  60384. * Add a new block to the list of output nodes
  60385. * @param node defines the node to add
  60386. * @returns the current material
  60387. */
  60388. addOutputNode(node: NodeMaterialBlock): this;
  60389. /**
  60390. * Remove a block from the list of root nodes
  60391. * @param node defines the node to remove
  60392. * @returns the current material
  60393. */
  60394. removeOutputNode(node: NodeMaterialBlock): this;
  60395. private _addVertexOutputNode;
  60396. private _removeVertexOutputNode;
  60397. private _addFragmentOutputNode;
  60398. private _removeFragmentOutputNode;
  60399. /**
  60400. * Specifies if the material will require alpha blending
  60401. * @returns a boolean specifying if alpha blending is needed
  60402. */
  60403. needAlphaBlending(): boolean;
  60404. /**
  60405. * Specifies if this material should be rendered in alpha test mode
  60406. * @returns a boolean specifying if an alpha test is needed.
  60407. */
  60408. needAlphaTesting(): boolean;
  60409. private _initializeBlock;
  60410. private _resetDualBlocks;
  60411. /**
  60412. * Remove a block from the current node material
  60413. * @param block defines the block to remove
  60414. */
  60415. removeBlock(block: NodeMaterialBlock): void;
  60416. /**
  60417. * Build the material and generates the inner effect
  60418. * @param verbose defines if the build should log activity
  60419. */
  60420. build(verbose?: boolean): void;
  60421. /**
  60422. * Runs an otpimization phase to try to improve the shader code
  60423. */
  60424. optimize(): void;
  60425. private _prepareDefinesForAttributes;
  60426. /**
  60427. * Get if the submesh is ready to be used and all its information available.
  60428. * Child classes can use it to update shaders
  60429. * @param mesh defines the mesh to check
  60430. * @param subMesh defines which submesh to check
  60431. * @param useInstances specifies that instances should be used
  60432. * @returns a boolean indicating that the submesh is ready or not
  60433. */
  60434. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  60435. /**
  60436. * Get a string representing the shaders built by the current node graph
  60437. */
  60438. get compiledShaders(): string;
  60439. /**
  60440. * Binds the world matrix to the material
  60441. * @param world defines the world transformation matrix
  60442. */
  60443. bindOnlyWorldMatrix(world: Matrix): void;
  60444. /**
  60445. * Binds the submesh to this material by preparing the effect and shader to draw
  60446. * @param world defines the world transformation matrix
  60447. * @param mesh defines the mesh containing the submesh
  60448. * @param subMesh defines the submesh to bind the material to
  60449. */
  60450. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  60451. /**
  60452. * Gets the active textures from the material
  60453. * @returns an array of textures
  60454. */
  60455. getActiveTextures(): BaseTexture[];
  60456. /**
  60457. * Gets the list of texture blocks
  60458. * @returns an array of texture blocks
  60459. */
  60460. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  60461. /**
  60462. * Specifies if the material uses a texture
  60463. * @param texture defines the texture to check against the material
  60464. * @returns a boolean specifying if the material uses the texture
  60465. */
  60466. hasTexture(texture: BaseTexture): boolean;
  60467. /**
  60468. * Disposes the material
  60469. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  60470. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  60471. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  60472. */
  60473. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  60474. /** Creates the node editor window. */
  60475. private _createNodeEditor;
  60476. /**
  60477. * Launch the node material editor
  60478. * @param config Define the configuration of the editor
  60479. * @return a promise fulfilled when the node editor is visible
  60480. */
  60481. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  60482. /**
  60483. * Clear the current material
  60484. */
  60485. clear(): void;
  60486. /**
  60487. * Clear the current material and set it to a default state
  60488. */
  60489. setToDefault(): void;
  60490. /**
  60491. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  60492. * @param url defines the url to load from
  60493. * @returns a promise that will fullfil when the material is fully loaded
  60494. */
  60495. loadAsync(url: string): Promise<void>;
  60496. private _gatherBlocks;
  60497. /**
  60498. * Generate a string containing the code declaration required to create an equivalent of this material
  60499. * @returns a string
  60500. */
  60501. generateCode(): string;
  60502. /**
  60503. * Serializes this material in a JSON representation
  60504. * @returns the serialized material object
  60505. */
  60506. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  60507. private _restoreConnections;
  60508. /**
  60509. * Clear the current graph and load a new one from a serialization object
  60510. * @param source defines the JSON representation of the material
  60511. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  60512. */
  60513. loadFromSerialization(source: any, rootUrl?: string): void;
  60514. /**
  60515. * Makes a duplicate of the current material.
  60516. * @param name - name to use for the new material.
  60517. */
  60518. clone(name: string): NodeMaterial;
  60519. /**
  60520. * Creates a node material from parsed material data
  60521. * @param source defines the JSON representation of the material
  60522. * @param scene defines the hosting scene
  60523. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  60524. * @returns a new node material
  60525. */
  60526. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  60527. /**
  60528. * Creates a node material from a snippet saved in a remote file
  60529. * @param name defines the name of the material to create
  60530. * @param url defines the url to load from
  60531. * @param scene defines the hosting scene
  60532. * @returns a promise that will resolve to the new node material
  60533. */
  60534. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  60535. /**
  60536. * Creates a node material from a snippet saved by the node material editor
  60537. * @param snippetId defines the snippet to load
  60538. * @param scene defines the hosting scene
  60539. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  60540. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  60541. * @returns a promise that will resolve to the new node material
  60542. */
  60543. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  60544. /**
  60545. * Creates a new node material set to default basic configuration
  60546. * @param name defines the name of the material
  60547. * @param scene defines the hosting scene
  60548. * @returns a new NodeMaterial
  60549. */
  60550. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  60551. }
  60552. }
  60553. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  60554. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60555. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60556. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  60557. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60558. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60559. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  60560. import { Effect } from "babylonjs/Materials/effect";
  60561. import { Mesh } from "babylonjs/Meshes/mesh";
  60562. import { Nullable } from "babylonjs/types";
  60563. import { Texture } from "babylonjs/Materials/Textures/texture";
  60564. import { Scene } from "babylonjs/scene";
  60565. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  60566. /**
  60567. * Block used to read a texture from a sampler
  60568. */
  60569. export class TextureBlock extends NodeMaterialBlock {
  60570. private _defineName;
  60571. private _linearDefineName;
  60572. private _tempTextureRead;
  60573. private _samplerName;
  60574. private _transformedUVName;
  60575. private _textureTransformName;
  60576. private _textureInfoName;
  60577. private _mainUVName;
  60578. private _mainUVDefineName;
  60579. /**
  60580. * Gets or sets the texture associated with the node
  60581. */
  60582. texture: Nullable<Texture>;
  60583. /**
  60584. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  60585. */
  60586. convertToGammaSpace: boolean;
  60587. /**
  60588. * Create a new TextureBlock
  60589. * @param name defines the block name
  60590. */
  60591. constructor(name: string);
  60592. /**
  60593. * Gets the current class name
  60594. * @returns the class name
  60595. */
  60596. getClassName(): string;
  60597. /**
  60598. * Gets the uv input component
  60599. */
  60600. get uv(): NodeMaterialConnectionPoint;
  60601. /**
  60602. * Gets the rgba output component
  60603. */
  60604. get rgba(): NodeMaterialConnectionPoint;
  60605. /**
  60606. * Gets the rgb output component
  60607. */
  60608. get rgb(): NodeMaterialConnectionPoint;
  60609. /**
  60610. * Gets the r output component
  60611. */
  60612. get r(): NodeMaterialConnectionPoint;
  60613. /**
  60614. * Gets the g output component
  60615. */
  60616. get g(): NodeMaterialConnectionPoint;
  60617. /**
  60618. * Gets the b output component
  60619. */
  60620. get b(): NodeMaterialConnectionPoint;
  60621. /**
  60622. * Gets the a output component
  60623. */
  60624. get a(): NodeMaterialConnectionPoint;
  60625. get target(): NodeMaterialBlockTargets;
  60626. autoConfigure(material: NodeMaterial): void;
  60627. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  60628. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  60629. isReady(): boolean;
  60630. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60631. private get _isMixed();
  60632. private _injectVertexCode;
  60633. private _writeTextureRead;
  60634. private _writeOutput;
  60635. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  60636. protected _dumpPropertiesCode(): string;
  60637. serialize(): any;
  60638. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60639. }
  60640. }
  60641. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  60642. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60643. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60644. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  60645. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  60646. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  60647. import { Scene } from "babylonjs/scene";
  60648. /**
  60649. * Class used to store shared data between 2 NodeMaterialBuildState
  60650. */
  60651. export class NodeMaterialBuildStateSharedData {
  60652. /**
  60653. * Gets the list of emitted varyings
  60654. */
  60655. temps: string[];
  60656. /**
  60657. * Gets the list of emitted varyings
  60658. */
  60659. varyings: string[];
  60660. /**
  60661. * Gets the varying declaration string
  60662. */
  60663. varyingDeclaration: string;
  60664. /**
  60665. * Input blocks
  60666. */
  60667. inputBlocks: InputBlock[];
  60668. /**
  60669. * Input blocks
  60670. */
  60671. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  60672. /**
  60673. * Bindable blocks (Blocks that need to set data to the effect)
  60674. */
  60675. bindableBlocks: NodeMaterialBlock[];
  60676. /**
  60677. * List of blocks that can provide a compilation fallback
  60678. */
  60679. blocksWithFallbacks: NodeMaterialBlock[];
  60680. /**
  60681. * List of blocks that can provide a define update
  60682. */
  60683. blocksWithDefines: NodeMaterialBlock[];
  60684. /**
  60685. * List of blocks that can provide a repeatable content
  60686. */
  60687. repeatableContentBlocks: NodeMaterialBlock[];
  60688. /**
  60689. * List of blocks that can provide a dynamic list of uniforms
  60690. */
  60691. dynamicUniformBlocks: NodeMaterialBlock[];
  60692. /**
  60693. * List of blocks that can block the isReady function for the material
  60694. */
  60695. blockingBlocks: NodeMaterialBlock[];
  60696. /**
  60697. * Gets the list of animated inputs
  60698. */
  60699. animatedInputs: InputBlock[];
  60700. /**
  60701. * Build Id used to avoid multiple recompilations
  60702. */
  60703. buildId: number;
  60704. /** List of emitted variables */
  60705. variableNames: {
  60706. [key: string]: number;
  60707. };
  60708. /** List of emitted defines */
  60709. defineNames: {
  60710. [key: string]: number;
  60711. };
  60712. /** Should emit comments? */
  60713. emitComments: boolean;
  60714. /** Emit build activity */
  60715. verbose: boolean;
  60716. /** Gets or sets the hosting scene */
  60717. scene: Scene;
  60718. /**
  60719. * Gets the compilation hints emitted at compilation time
  60720. */
  60721. hints: {
  60722. needWorldViewMatrix: boolean;
  60723. needWorldViewProjectionMatrix: boolean;
  60724. needAlphaBlending: boolean;
  60725. needAlphaTesting: boolean;
  60726. };
  60727. /**
  60728. * List of compilation checks
  60729. */
  60730. checks: {
  60731. emitVertex: boolean;
  60732. emitFragment: boolean;
  60733. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  60734. };
  60735. /** Creates a new shared data */
  60736. constructor();
  60737. /**
  60738. * Emits console errors and exceptions if there is a failing check
  60739. */
  60740. emitErrors(): void;
  60741. }
  60742. }
  60743. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  60744. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  60745. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  60746. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  60747. /**
  60748. * Class used to store node based material build state
  60749. */
  60750. export class NodeMaterialBuildState {
  60751. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  60752. supportUniformBuffers: boolean;
  60753. /**
  60754. * Gets the list of emitted attributes
  60755. */
  60756. attributes: string[];
  60757. /**
  60758. * Gets the list of emitted uniforms
  60759. */
  60760. uniforms: string[];
  60761. /**
  60762. * Gets the list of emitted constants
  60763. */
  60764. constants: string[];
  60765. /**
  60766. * Gets the list of emitted samplers
  60767. */
  60768. samplers: string[];
  60769. /**
  60770. * Gets the list of emitted functions
  60771. */
  60772. functions: {
  60773. [key: string]: string;
  60774. };
  60775. /**
  60776. * Gets the list of emitted extensions
  60777. */
  60778. extensions: {
  60779. [key: string]: string;
  60780. };
  60781. /**
  60782. * Gets the target of the compilation state
  60783. */
  60784. target: NodeMaterialBlockTargets;
  60785. /**
  60786. * Gets the list of emitted counters
  60787. */
  60788. counters: {
  60789. [key: string]: number;
  60790. };
  60791. /**
  60792. * Shared data between multiple NodeMaterialBuildState instances
  60793. */
  60794. sharedData: NodeMaterialBuildStateSharedData;
  60795. /** @hidden */
  60796. _vertexState: NodeMaterialBuildState;
  60797. /** @hidden */
  60798. _attributeDeclaration: string;
  60799. /** @hidden */
  60800. _uniformDeclaration: string;
  60801. /** @hidden */
  60802. _constantDeclaration: string;
  60803. /** @hidden */
  60804. _samplerDeclaration: string;
  60805. /** @hidden */
  60806. _varyingTransfer: string;
  60807. private _repeatableContentAnchorIndex;
  60808. /** @hidden */
  60809. _builtCompilationString: string;
  60810. /**
  60811. * Gets the emitted compilation strings
  60812. */
  60813. compilationString: string;
  60814. /**
  60815. * Finalize the compilation strings
  60816. * @param state defines the current compilation state
  60817. */
  60818. finalize(state: NodeMaterialBuildState): void;
  60819. /** @hidden */
  60820. get _repeatableContentAnchor(): string;
  60821. /** @hidden */
  60822. _getFreeVariableName(prefix: string): string;
  60823. /** @hidden */
  60824. _getFreeDefineName(prefix: string): string;
  60825. /** @hidden */
  60826. _excludeVariableName(name: string): void;
  60827. /** @hidden */
  60828. _emit2DSampler(name: string): void;
  60829. /** @hidden */
  60830. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  60831. /** @hidden */
  60832. _emitExtension(name: string, extension: string): void;
  60833. /** @hidden */
  60834. _emitFunction(name: string, code: string, comments: string): void;
  60835. /** @hidden */
  60836. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  60837. replaceStrings?: {
  60838. search: RegExp;
  60839. replace: string;
  60840. }[];
  60841. repeatKey?: string;
  60842. }): string;
  60843. /** @hidden */
  60844. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  60845. repeatKey?: string;
  60846. removeAttributes?: boolean;
  60847. removeUniforms?: boolean;
  60848. removeVaryings?: boolean;
  60849. removeIfDef?: boolean;
  60850. replaceStrings?: {
  60851. search: RegExp;
  60852. replace: string;
  60853. }[];
  60854. }, storeKey?: string): void;
  60855. /** @hidden */
  60856. _registerTempVariable(name: string): boolean;
  60857. /** @hidden */
  60858. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  60859. /** @hidden */
  60860. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  60861. /** @hidden */
  60862. _emitFloat(value: number): string;
  60863. }
  60864. }
  60865. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  60866. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  60867. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60868. import { Nullable } from "babylonjs/types";
  60869. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60870. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  60871. import { Effect } from "babylonjs/Materials/effect";
  60872. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60873. import { Mesh } from "babylonjs/Meshes/mesh";
  60874. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  60875. import { Scene } from "babylonjs/scene";
  60876. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  60877. /**
  60878. * Defines a block that can be used inside a node based material
  60879. */
  60880. export class NodeMaterialBlock {
  60881. private _buildId;
  60882. private _buildTarget;
  60883. private _target;
  60884. private _isFinalMerger;
  60885. private _isInput;
  60886. protected _isUnique: boolean;
  60887. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  60888. inputsAreExclusive: boolean;
  60889. /** @hidden */
  60890. _codeVariableName: string;
  60891. /** @hidden */
  60892. _inputs: NodeMaterialConnectionPoint[];
  60893. /** @hidden */
  60894. _outputs: NodeMaterialConnectionPoint[];
  60895. /** @hidden */
  60896. _preparationId: number;
  60897. /**
  60898. * Gets or sets the name of the block
  60899. */
  60900. name: string;
  60901. /**
  60902. * Gets or sets the unique id of the node
  60903. */
  60904. uniqueId: number;
  60905. /**
  60906. * Gets or sets the comments associated with this block
  60907. */
  60908. comments: string;
  60909. /**
  60910. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  60911. */
  60912. get isUnique(): boolean;
  60913. /**
  60914. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  60915. */
  60916. get isFinalMerger(): boolean;
  60917. /**
  60918. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  60919. */
  60920. get isInput(): boolean;
  60921. /**
  60922. * Gets or sets the build Id
  60923. */
  60924. get buildId(): number;
  60925. set buildId(value: number);
  60926. /**
  60927. * Gets or sets the target of the block
  60928. */
  60929. get target(): NodeMaterialBlockTargets;
  60930. set target(value: NodeMaterialBlockTargets);
  60931. /**
  60932. * Gets the list of input points
  60933. */
  60934. get inputs(): NodeMaterialConnectionPoint[];
  60935. /** Gets the list of output points */
  60936. get outputs(): NodeMaterialConnectionPoint[];
  60937. /**
  60938. * Find an input by its name
  60939. * @param name defines the name of the input to look for
  60940. * @returns the input or null if not found
  60941. */
  60942. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  60943. /**
  60944. * Find an output by its name
  60945. * @param name defines the name of the outputto look for
  60946. * @returns the output or null if not found
  60947. */
  60948. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  60949. /**
  60950. * Creates a new NodeMaterialBlock
  60951. * @param name defines the block name
  60952. * @param target defines the target of that block (Vertex by default)
  60953. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  60954. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  60955. */
  60956. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  60957. /**
  60958. * Initialize the block and prepare the context for build
  60959. * @param state defines the state that will be used for the build
  60960. */
  60961. initialize(state: NodeMaterialBuildState): void;
  60962. /**
  60963. * Bind data to effect. Will only be called for blocks with isBindable === true
  60964. * @param effect defines the effect to bind data to
  60965. * @param nodeMaterial defines the hosting NodeMaterial
  60966. * @param mesh defines the mesh that will be rendered
  60967. */
  60968. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60969. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  60970. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  60971. protected _writeFloat(value: number): string;
  60972. /**
  60973. * Gets the current class name e.g. "NodeMaterialBlock"
  60974. * @returns the class name
  60975. */
  60976. getClassName(): string;
  60977. /**
  60978. * Register a new input. Must be called inside a block constructor
  60979. * @param name defines the connection point name
  60980. * @param type defines the connection point type
  60981. * @param isOptional defines a boolean indicating that this input can be omitted
  60982. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  60983. * @returns the current block
  60984. */
  60985. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  60986. /**
  60987. * Register a new output. 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 target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  60991. * @returns the current block
  60992. */
  60993. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  60994. /**
  60995. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  60996. * @param forOutput defines an optional connection point to check compatibility with
  60997. * @returns the first available input or null
  60998. */
  60999. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  61000. /**
  61001. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  61002. * @param forBlock defines an optional block to check compatibility with
  61003. * @returns the first available input or null
  61004. */
  61005. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  61006. /**
  61007. * Gets the sibling of the given output
  61008. * @param current defines the current output
  61009. * @returns the next output in the list or null
  61010. */
  61011. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  61012. /**
  61013. * Connect current block with another block
  61014. * @param other defines the block to connect with
  61015. * @param options define the various options to help pick the right connections
  61016. * @returns the current block
  61017. */
  61018. connectTo(other: NodeMaterialBlock, options?: {
  61019. input?: string;
  61020. output?: string;
  61021. outputSwizzle?: string;
  61022. }): this | undefined;
  61023. protected _buildBlock(state: NodeMaterialBuildState): void;
  61024. /**
  61025. * Add uniforms, samplers and uniform buffers at compilation time
  61026. * @param state defines the state to update
  61027. * @param nodeMaterial defines the node material requesting the update
  61028. * @param defines defines the material defines to update
  61029. * @param uniformBuffers defines the list of uniform buffer names
  61030. */
  61031. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  61032. /**
  61033. * Add potential fallbacks if shader compilation fails
  61034. * @param mesh defines the mesh to be rendered
  61035. * @param fallbacks defines the current prioritized list of fallbacks
  61036. */
  61037. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  61038. /**
  61039. * Initialize defines for shader compilation
  61040. * @param mesh defines the mesh to be rendered
  61041. * @param nodeMaterial defines the node material requesting the update
  61042. * @param defines defines the material defines to update
  61043. * @param useInstances specifies that instances should be used
  61044. */
  61045. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  61046. /**
  61047. * Update defines for shader compilation
  61048. * @param mesh defines the mesh to be rendered
  61049. * @param nodeMaterial defines the node material requesting the update
  61050. * @param defines defines the material defines to update
  61051. * @param useInstances specifies that instances should be used
  61052. */
  61053. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  61054. /**
  61055. * Lets the block try to connect some inputs automatically
  61056. * @param material defines the hosting NodeMaterial
  61057. */
  61058. autoConfigure(material: NodeMaterial): void;
  61059. /**
  61060. * Function called when a block is declared as repeatable content generator
  61061. * @param vertexShaderState defines the current compilation state for the vertex shader
  61062. * @param fragmentShaderState defines the current compilation state for the fragment shader
  61063. * @param mesh defines the mesh to be rendered
  61064. * @param defines defines the material defines to update
  61065. */
  61066. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  61067. /**
  61068. * Checks if the block is ready
  61069. * @param mesh defines the mesh to be rendered
  61070. * @param nodeMaterial defines the node material requesting the update
  61071. * @param defines defines the material defines to update
  61072. * @param useInstances specifies that instances should be used
  61073. * @returns true if the block is ready
  61074. */
  61075. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  61076. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  61077. private _processBuild;
  61078. /**
  61079. * Compile the current node and generate the shader code
  61080. * @param state defines the current compilation state (uniforms, samplers, current string)
  61081. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  61082. * @returns true if already built
  61083. */
  61084. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  61085. protected _inputRename(name: string): string;
  61086. protected _outputRename(name: string): string;
  61087. protected _dumpPropertiesCode(): string;
  61088. /** @hidden */
  61089. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  61090. /** @hidden */
  61091. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  61092. /**
  61093. * Clone the current block to a new identical block
  61094. * @param scene defines the hosting scene
  61095. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  61096. * @returns a copy of the current block
  61097. */
  61098. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  61099. /**
  61100. * Serializes this block in a JSON representation
  61101. * @returns the serialized block object
  61102. */
  61103. serialize(): any;
  61104. /** @hidden */
  61105. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61106. /**
  61107. * Release resources
  61108. */
  61109. dispose(): void;
  61110. }
  61111. }
  61112. declare module "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes" {
  61113. /**
  61114. * Enum defining the type of animations supported by InputBlock
  61115. */
  61116. export enum AnimatedInputBlockTypes {
  61117. /** No animation */
  61118. None = 0,
  61119. /** Time based animation. Will only work for floats */
  61120. Time = 1
  61121. }
  61122. }
  61123. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  61124. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61125. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  61126. import { NodeMaterialSystemValues } from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  61127. import { Nullable } from "babylonjs/types";
  61128. import { Effect } from "babylonjs/Materials/effect";
  61129. import { Matrix } from "babylonjs/Maths/math.vector";
  61130. import { Scene } from "babylonjs/scene";
  61131. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61132. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61133. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  61134. import { AnimatedInputBlockTypes } from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  61135. import { Observable } from "babylonjs/Misc/observable";
  61136. /**
  61137. * Block used to expose an input value
  61138. */
  61139. export class InputBlock extends NodeMaterialBlock {
  61140. private _mode;
  61141. private _associatedVariableName;
  61142. private _storedValue;
  61143. private _valueCallback;
  61144. private _type;
  61145. private _animationType;
  61146. /** Gets or set a value used to limit the range of float values */
  61147. min: number;
  61148. /** Gets or set a value used to limit the range of float values */
  61149. max: number;
  61150. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  61151. isBoolean: boolean;
  61152. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  61153. matrixMode: number;
  61154. /** @hidden */
  61155. _systemValue: Nullable<NodeMaterialSystemValues>;
  61156. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  61157. visibleInInspector: boolean;
  61158. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  61159. isConstant: boolean;
  61160. /** Gets or sets the group to use to display this block in the Inspector */
  61161. groupInInspector: string;
  61162. /** Gets an observable raised when the value is changed */
  61163. onValueChangedObservable: Observable<InputBlock>;
  61164. /**
  61165. * Gets or sets the connection point type (default is float)
  61166. */
  61167. get type(): NodeMaterialBlockConnectionPointTypes;
  61168. /**
  61169. * Creates a new InputBlock
  61170. * @param name defines the block name
  61171. * @param target defines the target of that block (Vertex by default)
  61172. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  61173. */
  61174. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  61175. /**
  61176. * Gets the output component
  61177. */
  61178. get output(): NodeMaterialConnectionPoint;
  61179. /**
  61180. * Set the source of this connection point to a vertex attribute
  61181. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  61182. * @returns the current connection point
  61183. */
  61184. setAsAttribute(attributeName?: string): InputBlock;
  61185. /**
  61186. * Set the source of this connection point to a system value
  61187. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  61188. * @returns the current connection point
  61189. */
  61190. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  61191. /**
  61192. * Gets or sets the value of that point.
  61193. * Please note that this value will be ignored if valueCallback is defined
  61194. */
  61195. get value(): any;
  61196. set value(value: any);
  61197. /**
  61198. * Gets or sets a callback used to get the value of that point.
  61199. * Please note that setting this value will force the connection point to ignore the value property
  61200. */
  61201. get valueCallback(): () => any;
  61202. set valueCallback(value: () => any);
  61203. /**
  61204. * Gets or sets the associated variable name in the shader
  61205. */
  61206. get associatedVariableName(): string;
  61207. set associatedVariableName(value: string);
  61208. /** Gets or sets the type of animation applied to the input */
  61209. get animationType(): AnimatedInputBlockTypes;
  61210. set animationType(value: AnimatedInputBlockTypes);
  61211. /**
  61212. * Gets a boolean indicating that this connection point not defined yet
  61213. */
  61214. get isUndefined(): boolean;
  61215. /**
  61216. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  61217. * In this case the connection point name must be the name of the uniform to use.
  61218. * Can only be set on inputs
  61219. */
  61220. get isUniform(): boolean;
  61221. set isUniform(value: boolean);
  61222. /**
  61223. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  61224. * In this case the connection point name must be the name of the attribute to use
  61225. * Can only be set on inputs
  61226. */
  61227. get isAttribute(): boolean;
  61228. set isAttribute(value: boolean);
  61229. /**
  61230. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  61231. * Can only be set on exit points
  61232. */
  61233. get isVarying(): boolean;
  61234. set isVarying(value: boolean);
  61235. /**
  61236. * Gets a boolean indicating that the current connection point is a system value
  61237. */
  61238. get isSystemValue(): boolean;
  61239. /**
  61240. * Gets or sets the current well known value or null if not defined as a system value
  61241. */
  61242. get systemValue(): Nullable<NodeMaterialSystemValues>;
  61243. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  61244. /**
  61245. * Gets the current class name
  61246. * @returns the class name
  61247. */
  61248. getClassName(): string;
  61249. /**
  61250. * Animate the input if animationType !== None
  61251. * @param scene defines the rendering scene
  61252. */
  61253. animate(scene: Scene): void;
  61254. private _emitDefine;
  61255. initialize(state: NodeMaterialBuildState): void;
  61256. /**
  61257. * Set the input block to its default value (based on its type)
  61258. */
  61259. setDefaultValue(): void;
  61260. private _emitConstant;
  61261. private _emit;
  61262. /** @hidden */
  61263. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  61264. /** @hidden */
  61265. _transmit(effect: Effect, scene: Scene): void;
  61266. protected _buildBlock(state: NodeMaterialBuildState): void;
  61267. protected _dumpPropertiesCode(): string;
  61268. dispose(): void;
  61269. serialize(): any;
  61270. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61271. }
  61272. }
  61273. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  61274. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  61275. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  61276. import { Nullable } from "babylonjs/types";
  61277. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  61278. import { Observable } from "babylonjs/Misc/observable";
  61279. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61280. /**
  61281. * Enum used to define the compatibility state between two connection points
  61282. */
  61283. export enum NodeMaterialConnectionPointCompatibilityStates {
  61284. /** Points are compatibles */
  61285. Compatible = 0,
  61286. /** Points are incompatible because of their types */
  61287. TypeIncompatible = 1,
  61288. /** Points are incompatible because of their targets (vertex vs fragment) */
  61289. TargetIncompatible = 2
  61290. }
  61291. /**
  61292. * Defines the direction of a connection point
  61293. */
  61294. export enum NodeMaterialConnectionPointDirection {
  61295. /** Input */
  61296. Input = 0,
  61297. /** Output */
  61298. Output = 1
  61299. }
  61300. /**
  61301. * Defines a connection point for a block
  61302. */
  61303. export class NodeMaterialConnectionPoint {
  61304. /** @hidden */
  61305. _ownerBlock: NodeMaterialBlock;
  61306. /** @hidden */
  61307. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  61308. private _endpoints;
  61309. private _associatedVariableName;
  61310. private _direction;
  61311. /** @hidden */
  61312. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  61313. /** @hidden */
  61314. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  61315. private _type;
  61316. /** @hidden */
  61317. _enforceAssociatedVariableName: boolean;
  61318. /** Gets the direction of the point */
  61319. get direction(): NodeMaterialConnectionPointDirection;
  61320. /**
  61321. * Gets or sets the additional types supported by this connection point
  61322. */
  61323. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  61324. /**
  61325. * Gets or sets the additional types excluded by this connection point
  61326. */
  61327. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  61328. /**
  61329. * Observable triggered when this point is connected
  61330. */
  61331. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  61332. /**
  61333. * Gets or sets the associated variable name in the shader
  61334. */
  61335. get associatedVariableName(): string;
  61336. set associatedVariableName(value: string);
  61337. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  61338. get innerType(): NodeMaterialBlockConnectionPointTypes;
  61339. /**
  61340. * Gets or sets the connection point type (default is float)
  61341. */
  61342. get type(): NodeMaterialBlockConnectionPointTypes;
  61343. set type(value: NodeMaterialBlockConnectionPointTypes);
  61344. /**
  61345. * Gets or sets the connection point name
  61346. */
  61347. name: string;
  61348. /**
  61349. * Gets or sets a boolean indicating that this connection point can be omitted
  61350. */
  61351. isOptional: boolean;
  61352. /**
  61353. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  61354. */
  61355. define: string;
  61356. /** @hidden */
  61357. _prioritizeVertex: boolean;
  61358. private _target;
  61359. /** Gets or sets the target of that connection point */
  61360. get target(): NodeMaterialBlockTargets;
  61361. set target(value: NodeMaterialBlockTargets);
  61362. /**
  61363. * Gets a boolean indicating that the current point is connected
  61364. */
  61365. get isConnected(): boolean;
  61366. /**
  61367. * Gets a boolean indicating that the current point is connected to an input block
  61368. */
  61369. get isConnectedToInputBlock(): boolean;
  61370. /**
  61371. * Gets a the connected input block (if any)
  61372. */
  61373. get connectInputBlock(): Nullable<InputBlock>;
  61374. /** Get the other side of the connection (if any) */
  61375. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  61376. /** Get the block that owns this connection point */
  61377. get ownerBlock(): NodeMaterialBlock;
  61378. /** Get the block connected on the other side of this connection (if any) */
  61379. get sourceBlock(): Nullable<NodeMaterialBlock>;
  61380. /** Get the block connected on the endpoints of this connection (if any) */
  61381. get connectedBlocks(): Array<NodeMaterialBlock>;
  61382. /** Gets the list of connected endpoints */
  61383. get endpoints(): NodeMaterialConnectionPoint[];
  61384. /** Gets a boolean indicating if that output point is connected to at least one input */
  61385. get hasEndpoints(): boolean;
  61386. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  61387. get isConnectedInVertexShader(): boolean;
  61388. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  61389. get isConnectedInFragmentShader(): boolean;
  61390. /**
  61391. * Creates a new connection point
  61392. * @param name defines the connection point name
  61393. * @param ownerBlock defines the block hosting this connection point
  61394. * @param direction defines the direction of the connection point
  61395. */
  61396. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  61397. /**
  61398. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  61399. * @returns the class name
  61400. */
  61401. getClassName(): string;
  61402. /**
  61403. * Gets a boolean indicating if the current point can be connected to another point
  61404. * @param connectionPoint defines the other connection point
  61405. * @returns a boolean
  61406. */
  61407. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  61408. /**
  61409. * Gets a number indicating if the current point can be connected to another point
  61410. * @param connectionPoint defines the other connection point
  61411. * @returns a number defining the compatibility state
  61412. */
  61413. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  61414. /**
  61415. * Connect this point to another connection point
  61416. * @param connectionPoint defines the other connection point
  61417. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  61418. * @returns the current connection point
  61419. */
  61420. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  61421. /**
  61422. * Disconnect this point from one of his endpoint
  61423. * @param endpoint defines the other connection point
  61424. * @returns the current connection point
  61425. */
  61426. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  61427. /**
  61428. * Serializes this point in a JSON representation
  61429. * @returns the serialized point object
  61430. */
  61431. serialize(): any;
  61432. /**
  61433. * Release resources
  61434. */
  61435. dispose(): void;
  61436. }
  61437. }
  61438. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  61439. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61440. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61441. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61442. import { Mesh } from "babylonjs/Meshes/mesh";
  61443. import { Effect } from "babylonjs/Materials/effect";
  61444. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61445. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61446. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  61447. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  61448. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  61449. /**
  61450. * Block used to add support for vertex skinning (bones)
  61451. */
  61452. export class BonesBlock extends NodeMaterialBlock {
  61453. /**
  61454. * Creates a new BonesBlock
  61455. * @param name defines the block name
  61456. */
  61457. constructor(name: string);
  61458. /**
  61459. * Initialize the block and prepare the context for build
  61460. * @param state defines the state that will be used for the build
  61461. */
  61462. initialize(state: NodeMaterialBuildState): void;
  61463. /**
  61464. * Gets the current class name
  61465. * @returns the class name
  61466. */
  61467. getClassName(): string;
  61468. /**
  61469. * Gets the matrix indices input component
  61470. */
  61471. get matricesIndices(): NodeMaterialConnectionPoint;
  61472. /**
  61473. * Gets the matrix weights input component
  61474. */
  61475. get matricesWeights(): NodeMaterialConnectionPoint;
  61476. /**
  61477. * Gets the extra matrix indices input component
  61478. */
  61479. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  61480. /**
  61481. * Gets the extra matrix weights input component
  61482. */
  61483. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  61484. /**
  61485. * Gets the world input component
  61486. */
  61487. get world(): NodeMaterialConnectionPoint;
  61488. /**
  61489. * Gets the output component
  61490. */
  61491. get output(): NodeMaterialConnectionPoint;
  61492. autoConfigure(material: NodeMaterial): void;
  61493. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  61494. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61495. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61496. protected _buildBlock(state: NodeMaterialBuildState): this;
  61497. }
  61498. }
  61499. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  61500. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61501. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61502. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61503. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61504. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61505. /**
  61506. * Block used to add support for instances
  61507. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  61508. */
  61509. export class InstancesBlock extends NodeMaterialBlock {
  61510. /**
  61511. * Creates a new InstancesBlock
  61512. * @param name defines the block name
  61513. */
  61514. constructor(name: string);
  61515. /**
  61516. * Gets the current class name
  61517. * @returns the class name
  61518. */
  61519. getClassName(): string;
  61520. /**
  61521. * Gets the first world row input component
  61522. */
  61523. get world0(): NodeMaterialConnectionPoint;
  61524. /**
  61525. * Gets the second world row input component
  61526. */
  61527. get world1(): NodeMaterialConnectionPoint;
  61528. /**
  61529. * Gets the third world row input component
  61530. */
  61531. get world2(): NodeMaterialConnectionPoint;
  61532. /**
  61533. * Gets the forth world row input component
  61534. */
  61535. get world3(): NodeMaterialConnectionPoint;
  61536. /**
  61537. * Gets the world input component
  61538. */
  61539. get world(): NodeMaterialConnectionPoint;
  61540. /**
  61541. * Gets the output component
  61542. */
  61543. get output(): NodeMaterialConnectionPoint;
  61544. /**
  61545. * Gets the isntanceID component
  61546. */
  61547. get instanceID(): NodeMaterialConnectionPoint;
  61548. autoConfigure(material: NodeMaterial): void;
  61549. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  61550. protected _buildBlock(state: NodeMaterialBuildState): this;
  61551. }
  61552. }
  61553. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  61554. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61555. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61556. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61557. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61558. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61559. import { Effect } from "babylonjs/Materials/effect";
  61560. import { Mesh } from "babylonjs/Meshes/mesh";
  61561. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  61562. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  61563. /**
  61564. * Block used to add morph targets support to vertex shader
  61565. */
  61566. export class MorphTargetsBlock extends NodeMaterialBlock {
  61567. private _repeatableContentAnchor;
  61568. /**
  61569. * Create a new MorphTargetsBlock
  61570. * @param name defines the block name
  61571. */
  61572. constructor(name: string);
  61573. /**
  61574. * Gets the current class name
  61575. * @returns the class name
  61576. */
  61577. getClassName(): string;
  61578. /**
  61579. * Gets the position input component
  61580. */
  61581. get position(): NodeMaterialConnectionPoint;
  61582. /**
  61583. * Gets the normal input component
  61584. */
  61585. get normal(): NodeMaterialConnectionPoint;
  61586. /**
  61587. * Gets the tangent input component
  61588. */
  61589. get tangent(): NodeMaterialConnectionPoint;
  61590. /**
  61591. * Gets the tangent input component
  61592. */
  61593. get uv(): NodeMaterialConnectionPoint;
  61594. /**
  61595. * Gets the position output component
  61596. */
  61597. get positionOutput(): NodeMaterialConnectionPoint;
  61598. /**
  61599. * Gets the normal output component
  61600. */
  61601. get normalOutput(): NodeMaterialConnectionPoint;
  61602. /**
  61603. * Gets the tangent output component
  61604. */
  61605. get tangentOutput(): NodeMaterialConnectionPoint;
  61606. /**
  61607. * Gets the tangent output component
  61608. */
  61609. get uvOutput(): NodeMaterialConnectionPoint;
  61610. initialize(state: NodeMaterialBuildState): void;
  61611. autoConfigure(material: NodeMaterial): void;
  61612. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61613. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61614. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  61615. protected _buildBlock(state: NodeMaterialBuildState): this;
  61616. }
  61617. }
  61618. declare module "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock" {
  61619. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61620. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61621. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61622. import { Nullable } from "babylonjs/types";
  61623. import { Scene } from "babylonjs/scene";
  61624. import { Effect } from "babylonjs/Materials/effect";
  61625. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61626. import { Mesh } from "babylonjs/Meshes/mesh";
  61627. import { Light } from "babylonjs/Lights/light";
  61628. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61629. /**
  61630. * Block used to get data information from a light
  61631. */
  61632. export class LightInformationBlock extends NodeMaterialBlock {
  61633. private _lightDataUniformName;
  61634. private _lightColorUniformName;
  61635. private _lightTypeDefineName;
  61636. /**
  61637. * Gets or sets the light associated with this block
  61638. */
  61639. light: Nullable<Light>;
  61640. /**
  61641. * Creates a new LightInformationBlock
  61642. * @param name defines the block name
  61643. */
  61644. constructor(name: string);
  61645. /**
  61646. * Gets the current class name
  61647. * @returns the class name
  61648. */
  61649. getClassName(): string;
  61650. /**
  61651. * Gets the world position input component
  61652. */
  61653. get worldPosition(): NodeMaterialConnectionPoint;
  61654. /**
  61655. * Gets the direction output component
  61656. */
  61657. get direction(): NodeMaterialConnectionPoint;
  61658. /**
  61659. * Gets the direction output component
  61660. */
  61661. get color(): NodeMaterialConnectionPoint;
  61662. /**
  61663. * Gets the direction output component
  61664. */
  61665. get intensity(): NodeMaterialConnectionPoint;
  61666. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61667. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61668. protected _buildBlock(state: NodeMaterialBuildState): this;
  61669. serialize(): any;
  61670. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61671. }
  61672. }
  61673. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  61674. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  61675. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  61676. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  61677. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  61678. export * from "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock";
  61679. }
  61680. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  61681. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61682. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61683. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61684. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61685. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61686. import { Effect } from "babylonjs/Materials/effect";
  61687. import { Mesh } from "babylonjs/Meshes/mesh";
  61688. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  61689. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  61690. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  61691. /**
  61692. * Block used to add image processing support to fragment shader
  61693. */
  61694. export class ImageProcessingBlock extends NodeMaterialBlock {
  61695. /**
  61696. * Create a new ImageProcessingBlock
  61697. * @param name defines the block name
  61698. */
  61699. constructor(name: string);
  61700. /**
  61701. * Gets the current class name
  61702. * @returns the class name
  61703. */
  61704. getClassName(): string;
  61705. /**
  61706. * Gets the color input component
  61707. */
  61708. get color(): NodeMaterialConnectionPoint;
  61709. /**
  61710. * Gets the output component
  61711. */
  61712. get output(): NodeMaterialConnectionPoint;
  61713. /**
  61714. * Initialize the block and prepare the context for build
  61715. * @param state defines the state that will be used for the build
  61716. */
  61717. initialize(state: NodeMaterialBuildState): void;
  61718. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  61719. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61720. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61721. protected _buildBlock(state: NodeMaterialBuildState): this;
  61722. }
  61723. }
  61724. declare module "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock" {
  61725. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61726. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61727. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61728. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61729. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61730. import { Effect } from "babylonjs/Materials/effect";
  61731. import { Mesh } from "babylonjs/Meshes/mesh";
  61732. import { Scene } from "babylonjs/scene";
  61733. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  61734. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  61735. /**
  61736. * Block used to pertub normals based on a normal map
  61737. */
  61738. export class PerturbNormalBlock extends NodeMaterialBlock {
  61739. private _tangentSpaceParameterName;
  61740. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  61741. invertX: boolean;
  61742. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  61743. invertY: boolean;
  61744. /**
  61745. * Create a new PerturbNormalBlock
  61746. * @param name defines the block name
  61747. */
  61748. constructor(name: string);
  61749. /**
  61750. * Gets the current class name
  61751. * @returns the class name
  61752. */
  61753. getClassName(): string;
  61754. /**
  61755. * Gets the world position input component
  61756. */
  61757. get worldPosition(): NodeMaterialConnectionPoint;
  61758. /**
  61759. * Gets the world normal input component
  61760. */
  61761. get worldNormal(): NodeMaterialConnectionPoint;
  61762. /**
  61763. * Gets the world tangent input component
  61764. */
  61765. get worldTangent(): NodeMaterialConnectionPoint;
  61766. /**
  61767. * Gets the uv input component
  61768. */
  61769. get uv(): NodeMaterialConnectionPoint;
  61770. /**
  61771. * Gets the normal map color input component
  61772. */
  61773. get normalMapColor(): NodeMaterialConnectionPoint;
  61774. /**
  61775. * Gets the strength input component
  61776. */
  61777. get strength(): NodeMaterialConnectionPoint;
  61778. /**
  61779. * Gets the output component
  61780. */
  61781. get output(): NodeMaterialConnectionPoint;
  61782. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61783. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61784. autoConfigure(material: NodeMaterial): void;
  61785. protected _buildBlock(state: NodeMaterialBuildState): this;
  61786. protected _dumpPropertiesCode(): string;
  61787. serialize(): any;
  61788. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61789. }
  61790. }
  61791. declare module "babylonjs/Materials/Node/Blocks/Fragment/discardBlock" {
  61792. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61793. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61794. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61795. /**
  61796. * Block used to discard a pixel if a value is smaller than a cutoff
  61797. */
  61798. export class DiscardBlock extends NodeMaterialBlock {
  61799. /**
  61800. * Create a new DiscardBlock
  61801. * @param name defines the block name
  61802. */
  61803. constructor(name: string);
  61804. /**
  61805. * Gets the current class name
  61806. * @returns the class name
  61807. */
  61808. getClassName(): string;
  61809. /**
  61810. * Gets the color input component
  61811. */
  61812. get value(): NodeMaterialConnectionPoint;
  61813. /**
  61814. * Gets the cutoff input component
  61815. */
  61816. get cutoff(): NodeMaterialConnectionPoint;
  61817. protected _buildBlock(state: NodeMaterialBuildState): this;
  61818. }
  61819. }
  61820. declare module "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock" {
  61821. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61822. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61823. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61824. /**
  61825. * Block used to test if the fragment shader is front facing
  61826. */
  61827. export class FrontFacingBlock extends NodeMaterialBlock {
  61828. /**
  61829. * Creates a new FrontFacingBlock
  61830. * @param name defines the block name
  61831. */
  61832. constructor(name: string);
  61833. /**
  61834. * Gets the current class name
  61835. * @returns the class name
  61836. */
  61837. getClassName(): string;
  61838. /**
  61839. * Gets the output component
  61840. */
  61841. get output(): NodeMaterialConnectionPoint;
  61842. protected _buildBlock(state: NodeMaterialBuildState): this;
  61843. }
  61844. }
  61845. declare module "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock" {
  61846. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61847. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61848. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61849. /**
  61850. * Block used to get the derivative value on x and y of a given input
  61851. */
  61852. export class DerivativeBlock extends NodeMaterialBlock {
  61853. /**
  61854. * Create a new DerivativeBlock
  61855. * @param name defines the block name
  61856. */
  61857. constructor(name: string);
  61858. /**
  61859. * Gets the current class name
  61860. * @returns the class name
  61861. */
  61862. getClassName(): string;
  61863. /**
  61864. * Gets the input component
  61865. */
  61866. get input(): NodeMaterialConnectionPoint;
  61867. /**
  61868. * Gets the derivative output on x
  61869. */
  61870. get dx(): NodeMaterialConnectionPoint;
  61871. /**
  61872. * Gets the derivative output on y
  61873. */
  61874. get dy(): NodeMaterialConnectionPoint;
  61875. protected _buildBlock(state: NodeMaterialBuildState): this;
  61876. }
  61877. }
  61878. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  61879. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  61880. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  61881. export * from "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock";
  61882. export * from "babylonjs/Materials/Node/Blocks/Fragment/discardBlock";
  61883. export * from "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock";
  61884. export * from "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock";
  61885. }
  61886. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  61887. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61888. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61889. import { Mesh } from "babylonjs/Meshes/mesh";
  61890. import { Effect } from "babylonjs/Materials/effect";
  61891. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61892. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61893. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61894. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  61895. /**
  61896. * Block used to add support for scene fog
  61897. */
  61898. export class FogBlock extends NodeMaterialBlock {
  61899. private _fogDistanceName;
  61900. private _fogParameters;
  61901. /**
  61902. * Create a new FogBlock
  61903. * @param name defines the block name
  61904. */
  61905. constructor(name: string);
  61906. /**
  61907. * Gets the current class name
  61908. * @returns the class name
  61909. */
  61910. getClassName(): string;
  61911. /**
  61912. * Gets the world position input component
  61913. */
  61914. get worldPosition(): NodeMaterialConnectionPoint;
  61915. /**
  61916. * Gets the view input component
  61917. */
  61918. get view(): NodeMaterialConnectionPoint;
  61919. /**
  61920. * Gets the color input component
  61921. */
  61922. get input(): NodeMaterialConnectionPoint;
  61923. /**
  61924. * Gets the fog color input component
  61925. */
  61926. get fogColor(): NodeMaterialConnectionPoint;
  61927. /**
  61928. * Gets the output component
  61929. */
  61930. get output(): NodeMaterialConnectionPoint;
  61931. autoConfigure(material: NodeMaterial): void;
  61932. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61933. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61934. protected _buildBlock(state: NodeMaterialBuildState): this;
  61935. }
  61936. }
  61937. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  61938. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61939. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61940. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61941. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61942. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61943. import { Effect } from "babylonjs/Materials/effect";
  61944. import { Mesh } from "babylonjs/Meshes/mesh";
  61945. import { Light } from "babylonjs/Lights/light";
  61946. import { Nullable } from "babylonjs/types";
  61947. import { Scene } from "babylonjs/scene";
  61948. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  61949. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  61950. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  61951. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  61952. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  61953. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  61954. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  61955. /**
  61956. * Block used to add light in the fragment shader
  61957. */
  61958. export class LightBlock extends NodeMaterialBlock {
  61959. private _lightId;
  61960. /**
  61961. * Gets or sets the light associated with this block
  61962. */
  61963. light: Nullable<Light>;
  61964. /**
  61965. * Create a new LightBlock
  61966. * @param name defines the block name
  61967. */
  61968. constructor(name: string);
  61969. /**
  61970. * Gets the current class name
  61971. * @returns the class name
  61972. */
  61973. getClassName(): string;
  61974. /**
  61975. * Gets the world position input component
  61976. */
  61977. get worldPosition(): NodeMaterialConnectionPoint;
  61978. /**
  61979. * Gets the world normal input component
  61980. */
  61981. get worldNormal(): NodeMaterialConnectionPoint;
  61982. /**
  61983. * Gets the camera (or eye) position component
  61984. */
  61985. get cameraPosition(): NodeMaterialConnectionPoint;
  61986. /**
  61987. * Gets the glossiness component
  61988. */
  61989. get glossiness(): NodeMaterialConnectionPoint;
  61990. /**
  61991. * Gets the glossinness power component
  61992. */
  61993. get glossPower(): NodeMaterialConnectionPoint;
  61994. /**
  61995. * Gets the diffuse color component
  61996. */
  61997. get diffuseColor(): NodeMaterialConnectionPoint;
  61998. /**
  61999. * Gets the specular color component
  62000. */
  62001. get specularColor(): NodeMaterialConnectionPoint;
  62002. /**
  62003. * Gets the diffuse output component
  62004. */
  62005. get diffuseOutput(): NodeMaterialConnectionPoint;
  62006. /**
  62007. * Gets the specular output component
  62008. */
  62009. get specularOutput(): NodeMaterialConnectionPoint;
  62010. /**
  62011. * Gets the shadow output component
  62012. */
  62013. get shadow(): NodeMaterialConnectionPoint;
  62014. autoConfigure(material: NodeMaterial): void;
  62015. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62016. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  62017. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62018. private _injectVertexCode;
  62019. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62020. serialize(): any;
  62021. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62022. }
  62023. }
  62024. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  62025. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  62026. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  62027. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  62028. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  62029. }
  62030. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  62031. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  62032. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  62033. }
  62034. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  62035. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62036. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62037. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62038. /**
  62039. * Block used to multiply 2 values
  62040. */
  62041. export class MultiplyBlock extends NodeMaterialBlock {
  62042. /**
  62043. * Creates a new MultiplyBlock
  62044. * @param name defines the block name
  62045. */
  62046. constructor(name: string);
  62047. /**
  62048. * Gets the current class name
  62049. * @returns the class name
  62050. */
  62051. getClassName(): string;
  62052. /**
  62053. * Gets the left operand input component
  62054. */
  62055. get left(): NodeMaterialConnectionPoint;
  62056. /**
  62057. * Gets the right operand input component
  62058. */
  62059. get right(): NodeMaterialConnectionPoint;
  62060. /**
  62061. * Gets the output component
  62062. */
  62063. get output(): NodeMaterialConnectionPoint;
  62064. protected _buildBlock(state: NodeMaterialBuildState): this;
  62065. }
  62066. }
  62067. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  62068. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62069. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62070. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62071. /**
  62072. * Block used to add 2 vectors
  62073. */
  62074. export class AddBlock extends NodeMaterialBlock {
  62075. /**
  62076. * Creates a new AddBlock
  62077. * @param name defines the block name
  62078. */
  62079. constructor(name: string);
  62080. /**
  62081. * Gets the current class name
  62082. * @returns the class name
  62083. */
  62084. getClassName(): string;
  62085. /**
  62086. * Gets the left operand input component
  62087. */
  62088. get left(): NodeMaterialConnectionPoint;
  62089. /**
  62090. * Gets the right operand input component
  62091. */
  62092. get right(): NodeMaterialConnectionPoint;
  62093. /**
  62094. * Gets the output component
  62095. */
  62096. get output(): NodeMaterialConnectionPoint;
  62097. protected _buildBlock(state: NodeMaterialBuildState): this;
  62098. }
  62099. }
  62100. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  62101. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62102. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62103. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62104. /**
  62105. * Block used to scale a vector by a float
  62106. */
  62107. export class ScaleBlock extends NodeMaterialBlock {
  62108. /**
  62109. * Creates a new ScaleBlock
  62110. * @param name defines the block name
  62111. */
  62112. constructor(name: string);
  62113. /**
  62114. * Gets the current class name
  62115. * @returns the class name
  62116. */
  62117. getClassName(): string;
  62118. /**
  62119. * Gets the input component
  62120. */
  62121. get input(): NodeMaterialConnectionPoint;
  62122. /**
  62123. * Gets the factor input component
  62124. */
  62125. get factor(): NodeMaterialConnectionPoint;
  62126. /**
  62127. * Gets the output component
  62128. */
  62129. get output(): NodeMaterialConnectionPoint;
  62130. protected _buildBlock(state: NodeMaterialBuildState): this;
  62131. }
  62132. }
  62133. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  62134. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62135. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62136. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62137. import { Scene } from "babylonjs/scene";
  62138. /**
  62139. * Block used to clamp a float
  62140. */
  62141. export class ClampBlock extends NodeMaterialBlock {
  62142. /** Gets or sets the minimum range */
  62143. minimum: number;
  62144. /** Gets or sets the maximum range */
  62145. maximum: number;
  62146. /**
  62147. * Creates a new ClampBlock
  62148. * @param name defines the block name
  62149. */
  62150. constructor(name: string);
  62151. /**
  62152. * Gets the current class name
  62153. * @returns the class name
  62154. */
  62155. getClassName(): string;
  62156. /**
  62157. * Gets the value input component
  62158. */
  62159. get value(): NodeMaterialConnectionPoint;
  62160. /**
  62161. * Gets the output component
  62162. */
  62163. get output(): NodeMaterialConnectionPoint;
  62164. protected _buildBlock(state: NodeMaterialBuildState): this;
  62165. protected _dumpPropertiesCode(): string;
  62166. serialize(): any;
  62167. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62168. }
  62169. }
  62170. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  62171. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62172. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62173. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62174. /**
  62175. * Block used to apply a cross product between 2 vectors
  62176. */
  62177. export class CrossBlock extends NodeMaterialBlock {
  62178. /**
  62179. * Creates a new CrossBlock
  62180. * @param name defines the block name
  62181. */
  62182. constructor(name: string);
  62183. /**
  62184. * Gets the current class name
  62185. * @returns the class name
  62186. */
  62187. getClassName(): string;
  62188. /**
  62189. * Gets the left operand input component
  62190. */
  62191. get left(): NodeMaterialConnectionPoint;
  62192. /**
  62193. * Gets the right operand input component
  62194. */
  62195. get right(): NodeMaterialConnectionPoint;
  62196. /**
  62197. * Gets the output component
  62198. */
  62199. get output(): NodeMaterialConnectionPoint;
  62200. protected _buildBlock(state: NodeMaterialBuildState): this;
  62201. }
  62202. }
  62203. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  62204. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62205. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62206. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62207. /**
  62208. * Block used to apply a dot product between 2 vectors
  62209. */
  62210. export class DotBlock extends NodeMaterialBlock {
  62211. /**
  62212. * Creates a new DotBlock
  62213. * @param name defines the block name
  62214. */
  62215. constructor(name: string);
  62216. /**
  62217. * Gets the current class name
  62218. * @returns the class name
  62219. */
  62220. getClassName(): string;
  62221. /**
  62222. * Gets the left operand input component
  62223. */
  62224. get left(): NodeMaterialConnectionPoint;
  62225. /**
  62226. * Gets the right operand input component
  62227. */
  62228. get right(): NodeMaterialConnectionPoint;
  62229. /**
  62230. * Gets the output component
  62231. */
  62232. get output(): NodeMaterialConnectionPoint;
  62233. protected _buildBlock(state: NodeMaterialBuildState): this;
  62234. }
  62235. }
  62236. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  62237. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62238. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62239. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62240. import { Vector2 } from "babylonjs/Maths/math.vector";
  62241. import { Scene } from "babylonjs/scene";
  62242. /**
  62243. * Block used to remap a float from a range to a new one
  62244. */
  62245. export class RemapBlock extends NodeMaterialBlock {
  62246. /**
  62247. * Gets or sets the source range
  62248. */
  62249. sourceRange: Vector2;
  62250. /**
  62251. * Gets or sets the target range
  62252. */
  62253. targetRange: Vector2;
  62254. /**
  62255. * Creates a new RemapBlock
  62256. * @param name defines the block name
  62257. */
  62258. constructor(name: string);
  62259. /**
  62260. * Gets the current class name
  62261. * @returns the class name
  62262. */
  62263. getClassName(): string;
  62264. /**
  62265. * Gets the input component
  62266. */
  62267. get input(): NodeMaterialConnectionPoint;
  62268. /**
  62269. * Gets the source min input component
  62270. */
  62271. get sourceMin(): NodeMaterialConnectionPoint;
  62272. /**
  62273. * Gets the source max input component
  62274. */
  62275. get sourceMax(): NodeMaterialConnectionPoint;
  62276. /**
  62277. * Gets the target min input component
  62278. */
  62279. get targetMin(): NodeMaterialConnectionPoint;
  62280. /**
  62281. * Gets the target max input component
  62282. */
  62283. get targetMax(): NodeMaterialConnectionPoint;
  62284. /**
  62285. * Gets the output component
  62286. */
  62287. get output(): NodeMaterialConnectionPoint;
  62288. protected _buildBlock(state: NodeMaterialBuildState): this;
  62289. protected _dumpPropertiesCode(): string;
  62290. serialize(): any;
  62291. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62292. }
  62293. }
  62294. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  62295. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62296. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62297. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62298. /**
  62299. * Block used to normalize a vector
  62300. */
  62301. export class NormalizeBlock extends NodeMaterialBlock {
  62302. /**
  62303. * Creates a new NormalizeBlock
  62304. * @param name defines the block name
  62305. */
  62306. constructor(name: string);
  62307. /**
  62308. * Gets the current class name
  62309. * @returns the class name
  62310. */
  62311. getClassName(): string;
  62312. /**
  62313. * Gets the input component
  62314. */
  62315. get input(): NodeMaterialConnectionPoint;
  62316. /**
  62317. * Gets the output component
  62318. */
  62319. get output(): NodeMaterialConnectionPoint;
  62320. protected _buildBlock(state: NodeMaterialBuildState): this;
  62321. }
  62322. }
  62323. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  62324. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62325. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62326. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62327. import { Scene } from "babylonjs/scene";
  62328. /**
  62329. * Operations supported by the Trigonometry block
  62330. */
  62331. export enum TrigonometryBlockOperations {
  62332. /** Cos */
  62333. Cos = 0,
  62334. /** Sin */
  62335. Sin = 1,
  62336. /** Abs */
  62337. Abs = 2,
  62338. /** Exp */
  62339. Exp = 3,
  62340. /** Exp2 */
  62341. Exp2 = 4,
  62342. /** Round */
  62343. Round = 5,
  62344. /** Floor */
  62345. Floor = 6,
  62346. /** Ceiling */
  62347. Ceiling = 7,
  62348. /** Square root */
  62349. Sqrt = 8,
  62350. /** Log */
  62351. Log = 9,
  62352. /** Tangent */
  62353. Tan = 10,
  62354. /** Arc tangent */
  62355. ArcTan = 11,
  62356. /** Arc cosinus */
  62357. ArcCos = 12,
  62358. /** Arc sinus */
  62359. ArcSin = 13,
  62360. /** Fraction */
  62361. Fract = 14,
  62362. /** Sign */
  62363. Sign = 15,
  62364. /** To radians (from degrees) */
  62365. Radians = 16,
  62366. /** To degrees (from radians) */
  62367. Degrees = 17
  62368. }
  62369. /**
  62370. * Block used to apply trigonometry operation to floats
  62371. */
  62372. export class TrigonometryBlock extends NodeMaterialBlock {
  62373. /**
  62374. * Gets or sets the operation applied by the block
  62375. */
  62376. operation: TrigonometryBlockOperations;
  62377. /**
  62378. * Creates a new TrigonometryBlock
  62379. * @param name defines the block name
  62380. */
  62381. constructor(name: string);
  62382. /**
  62383. * Gets the current class name
  62384. * @returns the class name
  62385. */
  62386. getClassName(): string;
  62387. /**
  62388. * Gets the input component
  62389. */
  62390. get input(): NodeMaterialConnectionPoint;
  62391. /**
  62392. * Gets the output component
  62393. */
  62394. get output(): NodeMaterialConnectionPoint;
  62395. protected _buildBlock(state: NodeMaterialBuildState): this;
  62396. serialize(): any;
  62397. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62398. protected _dumpPropertiesCode(): string;
  62399. }
  62400. }
  62401. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  62402. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62403. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62404. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62405. /**
  62406. * Block used to create a Color3/4 out of individual inputs (one for each component)
  62407. */
  62408. export class ColorMergerBlock extends NodeMaterialBlock {
  62409. /**
  62410. * Create a new ColorMergerBlock
  62411. * @param name defines the block name
  62412. */
  62413. constructor(name: string);
  62414. /**
  62415. * Gets the current class name
  62416. * @returns the class name
  62417. */
  62418. getClassName(): string;
  62419. /**
  62420. * Gets the rgb component (input)
  62421. */
  62422. get rgbIn(): NodeMaterialConnectionPoint;
  62423. /**
  62424. * Gets the r component (input)
  62425. */
  62426. get r(): NodeMaterialConnectionPoint;
  62427. /**
  62428. * Gets the g component (input)
  62429. */
  62430. get g(): NodeMaterialConnectionPoint;
  62431. /**
  62432. * Gets the b component (input)
  62433. */
  62434. get b(): NodeMaterialConnectionPoint;
  62435. /**
  62436. * Gets the a component (input)
  62437. */
  62438. get a(): NodeMaterialConnectionPoint;
  62439. /**
  62440. * Gets the rgba component (output)
  62441. */
  62442. get rgba(): NodeMaterialConnectionPoint;
  62443. /**
  62444. * Gets the rgb component (output)
  62445. */
  62446. get rgbOut(): NodeMaterialConnectionPoint;
  62447. /**
  62448. * Gets the rgb component (output)
  62449. * @deprecated Please use rgbOut instead.
  62450. */
  62451. get rgb(): NodeMaterialConnectionPoint;
  62452. protected _buildBlock(state: NodeMaterialBuildState): this;
  62453. }
  62454. }
  62455. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  62456. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62457. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62458. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62459. /**
  62460. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  62461. */
  62462. export class VectorMergerBlock extends NodeMaterialBlock {
  62463. /**
  62464. * Create a new VectorMergerBlock
  62465. * @param name defines the block name
  62466. */
  62467. constructor(name: string);
  62468. /**
  62469. * Gets the current class name
  62470. * @returns the class name
  62471. */
  62472. getClassName(): string;
  62473. /**
  62474. * Gets the xyz component (input)
  62475. */
  62476. get xyzIn(): NodeMaterialConnectionPoint;
  62477. /**
  62478. * Gets the xy component (input)
  62479. */
  62480. get xyIn(): NodeMaterialConnectionPoint;
  62481. /**
  62482. * Gets the x component (input)
  62483. */
  62484. get x(): NodeMaterialConnectionPoint;
  62485. /**
  62486. * Gets the y component (input)
  62487. */
  62488. get y(): NodeMaterialConnectionPoint;
  62489. /**
  62490. * Gets the z component (input)
  62491. */
  62492. get z(): NodeMaterialConnectionPoint;
  62493. /**
  62494. * Gets the w component (input)
  62495. */
  62496. get w(): NodeMaterialConnectionPoint;
  62497. /**
  62498. * Gets the xyzw component (output)
  62499. */
  62500. get xyzw(): NodeMaterialConnectionPoint;
  62501. /**
  62502. * Gets the xyz component (output)
  62503. */
  62504. get xyzOut(): NodeMaterialConnectionPoint;
  62505. /**
  62506. * Gets the xy component (output)
  62507. */
  62508. get xyOut(): NodeMaterialConnectionPoint;
  62509. /**
  62510. * Gets the xy component (output)
  62511. * @deprecated Please use xyOut instead.
  62512. */
  62513. get xy(): NodeMaterialConnectionPoint;
  62514. /**
  62515. * Gets the xyz component (output)
  62516. * @deprecated Please use xyzOut instead.
  62517. */
  62518. get xyz(): NodeMaterialConnectionPoint;
  62519. protected _buildBlock(state: NodeMaterialBuildState): this;
  62520. }
  62521. }
  62522. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  62523. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62524. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62525. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62526. /**
  62527. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  62528. */
  62529. export class ColorSplitterBlock extends NodeMaterialBlock {
  62530. /**
  62531. * Create a new ColorSplitterBlock
  62532. * @param name defines the block name
  62533. */
  62534. constructor(name: string);
  62535. /**
  62536. * Gets the current class name
  62537. * @returns the class name
  62538. */
  62539. getClassName(): string;
  62540. /**
  62541. * Gets the rgba component (input)
  62542. */
  62543. get rgba(): NodeMaterialConnectionPoint;
  62544. /**
  62545. * Gets the rgb component (input)
  62546. */
  62547. get rgbIn(): NodeMaterialConnectionPoint;
  62548. /**
  62549. * Gets the rgb component (output)
  62550. */
  62551. get rgbOut(): NodeMaterialConnectionPoint;
  62552. /**
  62553. * Gets the r component (output)
  62554. */
  62555. get r(): NodeMaterialConnectionPoint;
  62556. /**
  62557. * Gets the g component (output)
  62558. */
  62559. get g(): NodeMaterialConnectionPoint;
  62560. /**
  62561. * Gets the b component (output)
  62562. */
  62563. get b(): NodeMaterialConnectionPoint;
  62564. /**
  62565. * Gets the a component (output)
  62566. */
  62567. get a(): NodeMaterialConnectionPoint;
  62568. protected _inputRename(name: string): string;
  62569. protected _outputRename(name: string): string;
  62570. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62571. }
  62572. }
  62573. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  62574. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62575. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62576. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62577. /**
  62578. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  62579. */
  62580. export class VectorSplitterBlock extends NodeMaterialBlock {
  62581. /**
  62582. * Create a new VectorSplitterBlock
  62583. * @param name defines the block name
  62584. */
  62585. constructor(name: string);
  62586. /**
  62587. * Gets the current class name
  62588. * @returns the class name
  62589. */
  62590. getClassName(): string;
  62591. /**
  62592. * Gets the xyzw component (input)
  62593. */
  62594. get xyzw(): NodeMaterialConnectionPoint;
  62595. /**
  62596. * Gets the xyz component (input)
  62597. */
  62598. get xyzIn(): NodeMaterialConnectionPoint;
  62599. /**
  62600. * Gets the xy component (input)
  62601. */
  62602. get xyIn(): NodeMaterialConnectionPoint;
  62603. /**
  62604. * Gets the xyz component (output)
  62605. */
  62606. get xyzOut(): NodeMaterialConnectionPoint;
  62607. /**
  62608. * Gets the xy component (output)
  62609. */
  62610. get xyOut(): NodeMaterialConnectionPoint;
  62611. /**
  62612. * Gets the x component (output)
  62613. */
  62614. get x(): NodeMaterialConnectionPoint;
  62615. /**
  62616. * Gets the y component (output)
  62617. */
  62618. get y(): NodeMaterialConnectionPoint;
  62619. /**
  62620. * Gets the z component (output)
  62621. */
  62622. get z(): NodeMaterialConnectionPoint;
  62623. /**
  62624. * Gets the w component (output)
  62625. */
  62626. get w(): NodeMaterialConnectionPoint;
  62627. protected _inputRename(name: string): string;
  62628. protected _outputRename(name: string): string;
  62629. protected _buildBlock(state: NodeMaterialBuildState): this;
  62630. }
  62631. }
  62632. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  62633. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62634. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62635. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62636. /**
  62637. * Block used to lerp between 2 values
  62638. */
  62639. export class LerpBlock extends NodeMaterialBlock {
  62640. /**
  62641. * Creates a new LerpBlock
  62642. * @param name defines the block name
  62643. */
  62644. constructor(name: string);
  62645. /**
  62646. * Gets the current class name
  62647. * @returns the class name
  62648. */
  62649. getClassName(): string;
  62650. /**
  62651. * Gets the left operand input component
  62652. */
  62653. get left(): NodeMaterialConnectionPoint;
  62654. /**
  62655. * Gets the right operand input component
  62656. */
  62657. get right(): NodeMaterialConnectionPoint;
  62658. /**
  62659. * Gets the gradient operand input component
  62660. */
  62661. get gradient(): NodeMaterialConnectionPoint;
  62662. /**
  62663. * Gets the output component
  62664. */
  62665. get output(): NodeMaterialConnectionPoint;
  62666. protected _buildBlock(state: NodeMaterialBuildState): this;
  62667. }
  62668. }
  62669. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  62670. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62671. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62672. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62673. /**
  62674. * Block used to divide 2 vectors
  62675. */
  62676. export class DivideBlock extends NodeMaterialBlock {
  62677. /**
  62678. * Creates a new DivideBlock
  62679. * @param name defines the block name
  62680. */
  62681. constructor(name: string);
  62682. /**
  62683. * Gets the current class name
  62684. * @returns the class name
  62685. */
  62686. getClassName(): string;
  62687. /**
  62688. * Gets the left operand input component
  62689. */
  62690. get left(): NodeMaterialConnectionPoint;
  62691. /**
  62692. * Gets the right operand input component
  62693. */
  62694. get right(): NodeMaterialConnectionPoint;
  62695. /**
  62696. * Gets the output component
  62697. */
  62698. get output(): NodeMaterialConnectionPoint;
  62699. protected _buildBlock(state: NodeMaterialBuildState): this;
  62700. }
  62701. }
  62702. declare module "babylonjs/Materials/Node/Blocks/subtractBlock" {
  62703. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62704. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62705. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62706. /**
  62707. * Block used to subtract 2 vectors
  62708. */
  62709. export class SubtractBlock extends NodeMaterialBlock {
  62710. /**
  62711. * Creates a new SubtractBlock
  62712. * @param name defines the block name
  62713. */
  62714. constructor(name: string);
  62715. /**
  62716. * Gets the current class name
  62717. * @returns the class name
  62718. */
  62719. getClassName(): string;
  62720. /**
  62721. * Gets the left operand input component
  62722. */
  62723. get left(): NodeMaterialConnectionPoint;
  62724. /**
  62725. * Gets the right operand input component
  62726. */
  62727. get right(): NodeMaterialConnectionPoint;
  62728. /**
  62729. * Gets the output component
  62730. */
  62731. get output(): NodeMaterialConnectionPoint;
  62732. protected _buildBlock(state: NodeMaterialBuildState): this;
  62733. }
  62734. }
  62735. declare module "babylonjs/Materials/Node/Blocks/stepBlock" {
  62736. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62737. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62738. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62739. /**
  62740. * Block used to step a value
  62741. */
  62742. export class StepBlock extends NodeMaterialBlock {
  62743. /**
  62744. * Creates a new StepBlock
  62745. * @param name defines the block name
  62746. */
  62747. constructor(name: string);
  62748. /**
  62749. * Gets the current class name
  62750. * @returns the class name
  62751. */
  62752. getClassName(): string;
  62753. /**
  62754. * Gets the value operand input component
  62755. */
  62756. get value(): NodeMaterialConnectionPoint;
  62757. /**
  62758. * Gets the edge operand input component
  62759. */
  62760. get edge(): NodeMaterialConnectionPoint;
  62761. /**
  62762. * Gets the output component
  62763. */
  62764. get output(): NodeMaterialConnectionPoint;
  62765. protected _buildBlock(state: NodeMaterialBuildState): this;
  62766. }
  62767. }
  62768. declare module "babylonjs/Materials/Node/Blocks/oneMinusBlock" {
  62769. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62770. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62771. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62772. /**
  62773. * Block used to get the opposite (1 - x) of a value
  62774. */
  62775. export class OneMinusBlock extends NodeMaterialBlock {
  62776. /**
  62777. * Creates a new OneMinusBlock
  62778. * @param name defines the block name
  62779. */
  62780. constructor(name: string);
  62781. /**
  62782. * Gets the current class name
  62783. * @returns the class name
  62784. */
  62785. getClassName(): string;
  62786. /**
  62787. * Gets the input component
  62788. */
  62789. get input(): NodeMaterialConnectionPoint;
  62790. /**
  62791. * Gets the output component
  62792. */
  62793. get output(): NodeMaterialConnectionPoint;
  62794. protected _buildBlock(state: NodeMaterialBuildState): this;
  62795. }
  62796. }
  62797. declare module "babylonjs/Materials/Node/Blocks/viewDirectionBlock" {
  62798. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62799. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62800. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62801. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  62802. /**
  62803. * Block used to get the view direction
  62804. */
  62805. export class ViewDirectionBlock extends NodeMaterialBlock {
  62806. /**
  62807. * Creates a new ViewDirectionBlock
  62808. * @param name defines the block name
  62809. */
  62810. constructor(name: string);
  62811. /**
  62812. * Gets the current class name
  62813. * @returns the class name
  62814. */
  62815. getClassName(): string;
  62816. /**
  62817. * Gets the world position component
  62818. */
  62819. get worldPosition(): NodeMaterialConnectionPoint;
  62820. /**
  62821. * Gets the camera position component
  62822. */
  62823. get cameraPosition(): NodeMaterialConnectionPoint;
  62824. /**
  62825. * Gets the output component
  62826. */
  62827. get output(): NodeMaterialConnectionPoint;
  62828. autoConfigure(material: NodeMaterial): void;
  62829. protected _buildBlock(state: NodeMaterialBuildState): this;
  62830. }
  62831. }
  62832. declare module "babylonjs/Materials/Node/Blocks/fresnelBlock" {
  62833. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62834. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62835. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62836. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  62837. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  62838. /**
  62839. * Block used to compute fresnel value
  62840. */
  62841. export class FresnelBlock extends NodeMaterialBlock {
  62842. /**
  62843. * Create a new FresnelBlock
  62844. * @param name defines the block name
  62845. */
  62846. constructor(name: string);
  62847. /**
  62848. * Gets the current class name
  62849. * @returns the class name
  62850. */
  62851. getClassName(): string;
  62852. /**
  62853. * Gets the world normal input component
  62854. */
  62855. get worldNormal(): NodeMaterialConnectionPoint;
  62856. /**
  62857. * Gets the view direction input component
  62858. */
  62859. get viewDirection(): NodeMaterialConnectionPoint;
  62860. /**
  62861. * Gets the bias input component
  62862. */
  62863. get bias(): NodeMaterialConnectionPoint;
  62864. /**
  62865. * Gets the camera (or eye) position component
  62866. */
  62867. get power(): NodeMaterialConnectionPoint;
  62868. /**
  62869. * Gets the fresnel output component
  62870. */
  62871. get fresnel(): NodeMaterialConnectionPoint;
  62872. autoConfigure(material: NodeMaterial): void;
  62873. protected _buildBlock(state: NodeMaterialBuildState): this;
  62874. }
  62875. }
  62876. declare module "babylonjs/Materials/Node/Blocks/maxBlock" {
  62877. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62878. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62879. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62880. /**
  62881. * Block used to get the max of 2 values
  62882. */
  62883. export class MaxBlock extends NodeMaterialBlock {
  62884. /**
  62885. * Creates a new MaxBlock
  62886. * @param name defines the block name
  62887. */
  62888. constructor(name: string);
  62889. /**
  62890. * Gets the current class name
  62891. * @returns the class name
  62892. */
  62893. getClassName(): string;
  62894. /**
  62895. * Gets the left operand input component
  62896. */
  62897. get left(): NodeMaterialConnectionPoint;
  62898. /**
  62899. * Gets the right operand input component
  62900. */
  62901. get right(): NodeMaterialConnectionPoint;
  62902. /**
  62903. * Gets the output component
  62904. */
  62905. get output(): NodeMaterialConnectionPoint;
  62906. protected _buildBlock(state: NodeMaterialBuildState): this;
  62907. }
  62908. }
  62909. declare module "babylonjs/Materials/Node/Blocks/minBlock" {
  62910. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62911. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62912. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62913. /**
  62914. * Block used to get the min of 2 values
  62915. */
  62916. export class MinBlock extends NodeMaterialBlock {
  62917. /**
  62918. * Creates a new MinBlock
  62919. * @param name defines the block name
  62920. */
  62921. constructor(name: string);
  62922. /**
  62923. * Gets the current class name
  62924. * @returns the class name
  62925. */
  62926. getClassName(): string;
  62927. /**
  62928. * Gets the left operand input component
  62929. */
  62930. get left(): NodeMaterialConnectionPoint;
  62931. /**
  62932. * Gets the right operand input component
  62933. */
  62934. get right(): NodeMaterialConnectionPoint;
  62935. /**
  62936. * Gets the output component
  62937. */
  62938. get output(): NodeMaterialConnectionPoint;
  62939. protected _buildBlock(state: NodeMaterialBuildState): this;
  62940. }
  62941. }
  62942. declare module "babylonjs/Materials/Node/Blocks/distanceBlock" {
  62943. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62944. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62945. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62946. /**
  62947. * Block used to get the distance between 2 values
  62948. */
  62949. export class DistanceBlock extends NodeMaterialBlock {
  62950. /**
  62951. * Creates a new DistanceBlock
  62952. * @param name defines the block name
  62953. */
  62954. constructor(name: string);
  62955. /**
  62956. * Gets the current class name
  62957. * @returns the class name
  62958. */
  62959. getClassName(): string;
  62960. /**
  62961. * Gets the left operand input component
  62962. */
  62963. get left(): NodeMaterialConnectionPoint;
  62964. /**
  62965. * Gets the right operand input component
  62966. */
  62967. get right(): NodeMaterialConnectionPoint;
  62968. /**
  62969. * Gets the output component
  62970. */
  62971. get output(): NodeMaterialConnectionPoint;
  62972. protected _buildBlock(state: NodeMaterialBuildState): this;
  62973. }
  62974. }
  62975. declare module "babylonjs/Materials/Node/Blocks/lengthBlock" {
  62976. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62977. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62978. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62979. /**
  62980. * Block used to get the length of a vector
  62981. */
  62982. export class LengthBlock extends NodeMaterialBlock {
  62983. /**
  62984. * Creates a new LengthBlock
  62985. * @param name defines the block name
  62986. */
  62987. constructor(name: string);
  62988. /**
  62989. * Gets the current class name
  62990. * @returns the class name
  62991. */
  62992. getClassName(): string;
  62993. /**
  62994. * Gets the value input component
  62995. */
  62996. get value(): NodeMaterialConnectionPoint;
  62997. /**
  62998. * Gets the output component
  62999. */
  63000. get output(): NodeMaterialConnectionPoint;
  63001. protected _buildBlock(state: NodeMaterialBuildState): this;
  63002. }
  63003. }
  63004. declare module "babylonjs/Materials/Node/Blocks/negateBlock" {
  63005. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63006. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63007. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63008. /**
  63009. * Block used to get negative version of a value (i.e. x * -1)
  63010. */
  63011. export class NegateBlock extends NodeMaterialBlock {
  63012. /**
  63013. * Creates a new NegateBlock
  63014. * @param name defines the block name
  63015. */
  63016. constructor(name: string);
  63017. /**
  63018. * Gets the current class name
  63019. * @returns the class name
  63020. */
  63021. getClassName(): string;
  63022. /**
  63023. * Gets the value input component
  63024. */
  63025. get value(): NodeMaterialConnectionPoint;
  63026. /**
  63027. * Gets the output component
  63028. */
  63029. get output(): NodeMaterialConnectionPoint;
  63030. protected _buildBlock(state: NodeMaterialBuildState): this;
  63031. }
  63032. }
  63033. declare module "babylonjs/Materials/Node/Blocks/powBlock" {
  63034. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63035. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63036. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63037. /**
  63038. * Block used to get the value of the first parameter raised to the power of the second
  63039. */
  63040. export class PowBlock extends NodeMaterialBlock {
  63041. /**
  63042. * Creates a new PowBlock
  63043. * @param name defines the block name
  63044. */
  63045. constructor(name: string);
  63046. /**
  63047. * Gets the current class name
  63048. * @returns the class name
  63049. */
  63050. getClassName(): string;
  63051. /**
  63052. * Gets the value operand input component
  63053. */
  63054. get value(): NodeMaterialConnectionPoint;
  63055. /**
  63056. * Gets the power operand input component
  63057. */
  63058. get power(): NodeMaterialConnectionPoint;
  63059. /**
  63060. * Gets the output component
  63061. */
  63062. get output(): NodeMaterialConnectionPoint;
  63063. protected _buildBlock(state: NodeMaterialBuildState): this;
  63064. }
  63065. }
  63066. declare module "babylonjs/Materials/Node/Blocks/randomNumberBlock" {
  63067. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63068. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63069. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63070. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  63071. /**
  63072. * Block used to get a random number
  63073. */
  63074. export class RandomNumberBlock extends NodeMaterialBlock {
  63075. /**
  63076. * Creates a new RandomNumberBlock
  63077. * @param name defines the block name
  63078. */
  63079. constructor(name: string);
  63080. /**
  63081. * Gets the current class name
  63082. * @returns the class name
  63083. */
  63084. getClassName(): string;
  63085. /**
  63086. * Gets the seed input component
  63087. */
  63088. get seed(): NodeMaterialConnectionPoint;
  63089. /**
  63090. * Gets the output component
  63091. */
  63092. get output(): NodeMaterialConnectionPoint;
  63093. protected _buildBlock(state: NodeMaterialBuildState): this;
  63094. }
  63095. }
  63096. declare module "babylonjs/Materials/Node/Blocks/arcTan2Block" {
  63097. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63098. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63099. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63100. /**
  63101. * Block used to compute arc tangent of 2 values
  63102. */
  63103. export class ArcTan2Block extends NodeMaterialBlock {
  63104. /**
  63105. * Creates a new ArcTan2Block
  63106. * @param name defines the block name
  63107. */
  63108. constructor(name: string);
  63109. /**
  63110. * Gets the current class name
  63111. * @returns the class name
  63112. */
  63113. getClassName(): string;
  63114. /**
  63115. * Gets the x operand input component
  63116. */
  63117. get x(): NodeMaterialConnectionPoint;
  63118. /**
  63119. * Gets the y operand input component
  63120. */
  63121. get y(): NodeMaterialConnectionPoint;
  63122. /**
  63123. * Gets the output component
  63124. */
  63125. get output(): NodeMaterialConnectionPoint;
  63126. protected _buildBlock(state: NodeMaterialBuildState): this;
  63127. }
  63128. }
  63129. declare module "babylonjs/Materials/Node/Blocks/smoothStepBlock" {
  63130. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63131. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63132. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63133. /**
  63134. * Block used to smooth step a value
  63135. */
  63136. export class SmoothStepBlock extends NodeMaterialBlock {
  63137. /**
  63138. * Creates a new SmoothStepBlock
  63139. * @param name defines the block name
  63140. */
  63141. constructor(name: string);
  63142. /**
  63143. * Gets the current class name
  63144. * @returns the class name
  63145. */
  63146. getClassName(): string;
  63147. /**
  63148. * Gets the value operand input component
  63149. */
  63150. get value(): NodeMaterialConnectionPoint;
  63151. /**
  63152. * Gets the first edge operand input component
  63153. */
  63154. get edge0(): NodeMaterialConnectionPoint;
  63155. /**
  63156. * Gets the second edge operand input component
  63157. */
  63158. get edge1(): NodeMaterialConnectionPoint;
  63159. /**
  63160. * Gets the output component
  63161. */
  63162. get output(): NodeMaterialConnectionPoint;
  63163. protected _buildBlock(state: NodeMaterialBuildState): this;
  63164. }
  63165. }
  63166. declare module "babylonjs/Materials/Node/Blocks/reciprocalBlock" {
  63167. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63168. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63169. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63170. /**
  63171. * Block used to get the reciprocal (1 / x) of a value
  63172. */
  63173. export class ReciprocalBlock extends NodeMaterialBlock {
  63174. /**
  63175. * Creates a new ReciprocalBlock
  63176. * @param name defines the block name
  63177. */
  63178. constructor(name: string);
  63179. /**
  63180. * Gets the current class name
  63181. * @returns the class name
  63182. */
  63183. getClassName(): string;
  63184. /**
  63185. * Gets the input component
  63186. */
  63187. get input(): NodeMaterialConnectionPoint;
  63188. /**
  63189. * Gets the output component
  63190. */
  63191. get output(): NodeMaterialConnectionPoint;
  63192. protected _buildBlock(state: NodeMaterialBuildState): this;
  63193. }
  63194. }
  63195. declare module "babylonjs/Materials/Node/Blocks/replaceColorBlock" {
  63196. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63197. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63198. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63199. /**
  63200. * Block used to replace a color by another one
  63201. */
  63202. export class ReplaceColorBlock extends NodeMaterialBlock {
  63203. /**
  63204. * Creates a new ReplaceColorBlock
  63205. * @param name defines the block name
  63206. */
  63207. constructor(name: string);
  63208. /**
  63209. * Gets the current class name
  63210. * @returns the class name
  63211. */
  63212. getClassName(): string;
  63213. /**
  63214. * Gets the value input component
  63215. */
  63216. get value(): NodeMaterialConnectionPoint;
  63217. /**
  63218. * Gets the reference input component
  63219. */
  63220. get reference(): NodeMaterialConnectionPoint;
  63221. /**
  63222. * Gets the distance input component
  63223. */
  63224. get distance(): NodeMaterialConnectionPoint;
  63225. /**
  63226. * Gets the replacement input component
  63227. */
  63228. get replacement(): NodeMaterialConnectionPoint;
  63229. /**
  63230. * Gets the output component
  63231. */
  63232. get output(): NodeMaterialConnectionPoint;
  63233. protected _buildBlock(state: NodeMaterialBuildState): this;
  63234. }
  63235. }
  63236. declare module "babylonjs/Materials/Node/Blocks/posterizeBlock" {
  63237. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63238. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63239. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63240. /**
  63241. * Block used to posterize a value
  63242. * @see https://en.wikipedia.org/wiki/Posterization
  63243. */
  63244. export class PosterizeBlock extends NodeMaterialBlock {
  63245. /**
  63246. * Creates a new PosterizeBlock
  63247. * @param name defines the block name
  63248. */
  63249. constructor(name: string);
  63250. /**
  63251. * Gets the current class name
  63252. * @returns the class name
  63253. */
  63254. getClassName(): string;
  63255. /**
  63256. * Gets the value input component
  63257. */
  63258. get value(): NodeMaterialConnectionPoint;
  63259. /**
  63260. * Gets the steps input component
  63261. */
  63262. get steps(): NodeMaterialConnectionPoint;
  63263. /**
  63264. * Gets the output component
  63265. */
  63266. get output(): NodeMaterialConnectionPoint;
  63267. protected _buildBlock(state: NodeMaterialBuildState): this;
  63268. }
  63269. }
  63270. declare module "babylonjs/Materials/Node/Blocks/waveBlock" {
  63271. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63272. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63273. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63274. import { Scene } from "babylonjs/scene";
  63275. /**
  63276. * Operations supported by the Wave block
  63277. */
  63278. export enum WaveBlockKind {
  63279. /** SawTooth */
  63280. SawTooth = 0,
  63281. /** Square */
  63282. Square = 1,
  63283. /** Triangle */
  63284. Triangle = 2
  63285. }
  63286. /**
  63287. * Block used to apply wave operation to floats
  63288. */
  63289. export class WaveBlock extends NodeMaterialBlock {
  63290. /**
  63291. * Gets or sets the kibnd of wave to be applied by the block
  63292. */
  63293. kind: WaveBlockKind;
  63294. /**
  63295. * Creates a new WaveBlock
  63296. * @param name defines the block name
  63297. */
  63298. constructor(name: string);
  63299. /**
  63300. * Gets the current class name
  63301. * @returns the class name
  63302. */
  63303. getClassName(): string;
  63304. /**
  63305. * Gets the input component
  63306. */
  63307. get input(): NodeMaterialConnectionPoint;
  63308. /**
  63309. * Gets the output component
  63310. */
  63311. get output(): NodeMaterialConnectionPoint;
  63312. protected _buildBlock(state: NodeMaterialBuildState): this;
  63313. serialize(): any;
  63314. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63315. }
  63316. }
  63317. declare module "babylonjs/Materials/Node/Blocks/gradientBlock" {
  63318. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63319. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63320. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63321. import { Color3 } from "babylonjs/Maths/math.color";
  63322. import { Scene } from "babylonjs/scene";
  63323. /**
  63324. * Class used to store a color step for the GradientBlock
  63325. */
  63326. export class GradientBlockColorStep {
  63327. /**
  63328. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  63329. */
  63330. step: number;
  63331. /**
  63332. * Gets or sets the color associated with this step
  63333. */
  63334. color: Color3;
  63335. /**
  63336. * Creates a new GradientBlockColorStep
  63337. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  63338. * @param color defines the color associated with this step
  63339. */
  63340. constructor(
  63341. /**
  63342. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  63343. */
  63344. step: number,
  63345. /**
  63346. * Gets or sets the color associated with this step
  63347. */
  63348. color: Color3);
  63349. }
  63350. /**
  63351. * Block used to return a color from a gradient based on an input value between 0 and 1
  63352. */
  63353. export class GradientBlock extends NodeMaterialBlock {
  63354. /**
  63355. * Gets or sets the list of color steps
  63356. */
  63357. colorSteps: GradientBlockColorStep[];
  63358. /**
  63359. * Creates a new GradientBlock
  63360. * @param name defines the block name
  63361. */
  63362. constructor(name: string);
  63363. /**
  63364. * Gets the current class name
  63365. * @returns the class name
  63366. */
  63367. getClassName(): string;
  63368. /**
  63369. * Gets the gradient input component
  63370. */
  63371. get gradient(): NodeMaterialConnectionPoint;
  63372. /**
  63373. * Gets the output component
  63374. */
  63375. get output(): NodeMaterialConnectionPoint;
  63376. private _writeColorConstant;
  63377. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  63378. serialize(): any;
  63379. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63380. protected _dumpPropertiesCode(): string;
  63381. }
  63382. }
  63383. declare module "babylonjs/Materials/Node/Blocks/nLerpBlock" {
  63384. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63385. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63386. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63387. /**
  63388. * Block used to normalize lerp between 2 values
  63389. */
  63390. export class NLerpBlock extends NodeMaterialBlock {
  63391. /**
  63392. * Creates a new NLerpBlock
  63393. * @param name defines the block name
  63394. */
  63395. constructor(name: string);
  63396. /**
  63397. * Gets the current class name
  63398. * @returns the class name
  63399. */
  63400. getClassName(): string;
  63401. /**
  63402. * Gets the left operand input component
  63403. */
  63404. get left(): NodeMaterialConnectionPoint;
  63405. /**
  63406. * Gets the right operand input component
  63407. */
  63408. get right(): NodeMaterialConnectionPoint;
  63409. /**
  63410. * Gets the gradient operand input component
  63411. */
  63412. get gradient(): NodeMaterialConnectionPoint;
  63413. /**
  63414. * Gets the output component
  63415. */
  63416. get output(): NodeMaterialConnectionPoint;
  63417. protected _buildBlock(state: NodeMaterialBuildState): this;
  63418. }
  63419. }
  63420. declare module "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock" {
  63421. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63422. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63423. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63424. import { Scene } from "babylonjs/scene";
  63425. /**
  63426. * block used to Generate a Worley Noise 3D Noise Pattern
  63427. */
  63428. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  63429. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  63430. manhattanDistance: boolean;
  63431. /**
  63432. * Creates a new WorleyNoise3DBlock
  63433. * @param name defines the block name
  63434. */
  63435. constructor(name: string);
  63436. /**
  63437. * Gets the current class name
  63438. * @returns the class name
  63439. */
  63440. getClassName(): string;
  63441. /**
  63442. * Gets the seed input component
  63443. */
  63444. get seed(): NodeMaterialConnectionPoint;
  63445. /**
  63446. * Gets the jitter input component
  63447. */
  63448. get jitter(): NodeMaterialConnectionPoint;
  63449. /**
  63450. * Gets the output component
  63451. */
  63452. get output(): NodeMaterialConnectionPoint;
  63453. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  63454. /**
  63455. * Exposes the properties to the UI?
  63456. */
  63457. protected _dumpPropertiesCode(): string;
  63458. /**
  63459. * Exposes the properties to the Seralize?
  63460. */
  63461. serialize(): any;
  63462. /**
  63463. * Exposes the properties to the deseralize?
  63464. */
  63465. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63466. }
  63467. }
  63468. declare module "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock" {
  63469. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63470. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63471. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63472. /**
  63473. * block used to Generate a Simplex Perlin 3d Noise Pattern
  63474. */
  63475. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  63476. /**
  63477. * Creates a new SimplexPerlin3DBlock
  63478. * @param name defines the block name
  63479. */
  63480. constructor(name: string);
  63481. /**
  63482. * Gets the current class name
  63483. * @returns the class name
  63484. */
  63485. getClassName(): string;
  63486. /**
  63487. * Gets the seed operand input component
  63488. */
  63489. get seed(): NodeMaterialConnectionPoint;
  63490. /**
  63491. * Gets the output component
  63492. */
  63493. get output(): NodeMaterialConnectionPoint;
  63494. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  63495. }
  63496. }
  63497. declare module "babylonjs/Materials/Node/Blocks/normalBlendBlock" {
  63498. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63499. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63500. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63501. /**
  63502. * Block used to blend normals
  63503. */
  63504. export class NormalBlendBlock extends NodeMaterialBlock {
  63505. /**
  63506. * Creates a new NormalBlendBlock
  63507. * @param name defines the block name
  63508. */
  63509. constructor(name: string);
  63510. /**
  63511. * Gets the current class name
  63512. * @returns the class name
  63513. */
  63514. getClassName(): string;
  63515. /**
  63516. * Gets the first input component
  63517. */
  63518. get normalMap0(): NodeMaterialConnectionPoint;
  63519. /**
  63520. * Gets the second input component
  63521. */
  63522. get normalMap1(): NodeMaterialConnectionPoint;
  63523. /**
  63524. * Gets the output component
  63525. */
  63526. get output(): NodeMaterialConnectionPoint;
  63527. protected _buildBlock(state: NodeMaterialBuildState): this;
  63528. }
  63529. }
  63530. declare module "babylonjs/Materials/Node/Blocks/rotate2dBlock" {
  63531. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63532. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63533. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63534. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  63535. /**
  63536. * Block used to rotate a 2d vector by a given angle
  63537. */
  63538. export class Rotate2dBlock extends NodeMaterialBlock {
  63539. /**
  63540. * Creates a new Rotate2dBlock
  63541. * @param name defines the block name
  63542. */
  63543. constructor(name: string);
  63544. /**
  63545. * Gets the current class name
  63546. * @returns the class name
  63547. */
  63548. getClassName(): string;
  63549. /**
  63550. * Gets the input vector
  63551. */
  63552. get input(): NodeMaterialConnectionPoint;
  63553. /**
  63554. * Gets the input angle
  63555. */
  63556. get angle(): NodeMaterialConnectionPoint;
  63557. /**
  63558. * Gets the output component
  63559. */
  63560. get output(): NodeMaterialConnectionPoint;
  63561. autoConfigure(material: NodeMaterial): void;
  63562. protected _buildBlock(state: NodeMaterialBuildState): this;
  63563. }
  63564. }
  63565. declare module "babylonjs/Materials/Node/Blocks/reflectBlock" {
  63566. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63567. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63568. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63569. /**
  63570. * Block used to get the reflected vector from a direction and a normal
  63571. */
  63572. export class ReflectBlock extends NodeMaterialBlock {
  63573. /**
  63574. * Creates a new ReflectBlock
  63575. * @param name defines the block name
  63576. */
  63577. constructor(name: string);
  63578. /**
  63579. * Gets the current class name
  63580. * @returns the class name
  63581. */
  63582. getClassName(): string;
  63583. /**
  63584. * Gets the incident component
  63585. */
  63586. get incident(): NodeMaterialConnectionPoint;
  63587. /**
  63588. * Gets the normal component
  63589. */
  63590. get normal(): NodeMaterialConnectionPoint;
  63591. /**
  63592. * Gets the output component
  63593. */
  63594. get output(): NodeMaterialConnectionPoint;
  63595. protected _buildBlock(state: NodeMaterialBuildState): this;
  63596. }
  63597. }
  63598. declare module "babylonjs/Materials/Node/Blocks/refractBlock" {
  63599. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63600. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63601. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63602. /**
  63603. * Block used to get the refracted vector from a direction and a normal
  63604. */
  63605. export class RefractBlock extends NodeMaterialBlock {
  63606. /**
  63607. * Creates a new RefractBlock
  63608. * @param name defines the block name
  63609. */
  63610. constructor(name: string);
  63611. /**
  63612. * Gets the current class name
  63613. * @returns the class name
  63614. */
  63615. getClassName(): string;
  63616. /**
  63617. * Gets the incident component
  63618. */
  63619. get incident(): NodeMaterialConnectionPoint;
  63620. /**
  63621. * Gets the normal component
  63622. */
  63623. get normal(): NodeMaterialConnectionPoint;
  63624. /**
  63625. * Gets the index of refraction component
  63626. */
  63627. get ior(): NodeMaterialConnectionPoint;
  63628. /**
  63629. * Gets the output component
  63630. */
  63631. get output(): NodeMaterialConnectionPoint;
  63632. protected _buildBlock(state: NodeMaterialBuildState): this;
  63633. }
  63634. }
  63635. declare module "babylonjs/Materials/Node/Blocks/desaturateBlock" {
  63636. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63637. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63638. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63639. /**
  63640. * Block used to desaturate a color
  63641. */
  63642. export class DesaturateBlock extends NodeMaterialBlock {
  63643. /**
  63644. * Creates a new DesaturateBlock
  63645. * @param name defines the block name
  63646. */
  63647. constructor(name: string);
  63648. /**
  63649. * Gets the current class name
  63650. * @returns the class name
  63651. */
  63652. getClassName(): string;
  63653. /**
  63654. * Gets the color operand input component
  63655. */
  63656. get color(): NodeMaterialConnectionPoint;
  63657. /**
  63658. * Gets the level operand input component
  63659. */
  63660. get level(): NodeMaterialConnectionPoint;
  63661. /**
  63662. * Gets the output component
  63663. */
  63664. get output(): NodeMaterialConnectionPoint;
  63665. protected _buildBlock(state: NodeMaterialBuildState): this;
  63666. }
  63667. }
  63668. declare module "babylonjs/Materials/Node/Blocks/index" {
  63669. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  63670. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  63671. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  63672. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  63673. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  63674. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  63675. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  63676. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  63677. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  63678. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  63679. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  63680. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  63681. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  63682. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  63683. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  63684. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  63685. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  63686. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  63687. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  63688. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  63689. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  63690. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  63691. export * from "babylonjs/Materials/Node/Blocks/oneMinusBlock";
  63692. export * from "babylonjs/Materials/Node/Blocks/viewDirectionBlock";
  63693. export * from "babylonjs/Materials/Node/Blocks/fresnelBlock";
  63694. export * from "babylonjs/Materials/Node/Blocks/maxBlock";
  63695. export * from "babylonjs/Materials/Node/Blocks/minBlock";
  63696. export * from "babylonjs/Materials/Node/Blocks/distanceBlock";
  63697. export * from "babylonjs/Materials/Node/Blocks/lengthBlock";
  63698. export * from "babylonjs/Materials/Node/Blocks/negateBlock";
  63699. export * from "babylonjs/Materials/Node/Blocks/powBlock";
  63700. export * from "babylonjs/Materials/Node/Blocks/randomNumberBlock";
  63701. export * from "babylonjs/Materials/Node/Blocks/arcTan2Block";
  63702. export * from "babylonjs/Materials/Node/Blocks/smoothStepBlock";
  63703. export * from "babylonjs/Materials/Node/Blocks/reciprocalBlock";
  63704. export * from "babylonjs/Materials/Node/Blocks/replaceColorBlock";
  63705. export * from "babylonjs/Materials/Node/Blocks/posterizeBlock";
  63706. export * from "babylonjs/Materials/Node/Blocks/waveBlock";
  63707. export * from "babylonjs/Materials/Node/Blocks/gradientBlock";
  63708. export * from "babylonjs/Materials/Node/Blocks/nLerpBlock";
  63709. export * from "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock";
  63710. export * from "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock";
  63711. export * from "babylonjs/Materials/Node/Blocks/normalBlendBlock";
  63712. export * from "babylonjs/Materials/Node/Blocks/rotate2dBlock";
  63713. export * from "babylonjs/Materials/Node/Blocks/reflectBlock";
  63714. export * from "babylonjs/Materials/Node/Blocks/refractBlock";
  63715. export * from "babylonjs/Materials/Node/Blocks/desaturateBlock";
  63716. }
  63717. declare module "babylonjs/Materials/Node/Optimizers/index" {
  63718. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  63719. }
  63720. declare module "babylonjs/Materials/Node/index" {
  63721. export * from "babylonjs/Materials/Node/Enums/index";
  63722. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63723. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  63724. export * from "babylonjs/Materials/Node/nodeMaterial";
  63725. export * from "babylonjs/Materials/Node/Blocks/index";
  63726. export * from "babylonjs/Materials/Node/Optimizers/index";
  63727. }
  63728. declare module "babylonjs/Materials/effectRenderer" {
  63729. import { Nullable } from "babylonjs/types";
  63730. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  63731. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  63732. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  63733. import { Viewport } from "babylonjs/Maths/math.viewport";
  63734. import { Observable } from "babylonjs/Misc/observable";
  63735. import { Effect } from "babylonjs/Materials/effect";
  63736. import "babylonjs/Shaders/postprocess.vertex";
  63737. /**
  63738. * Effect Render Options
  63739. */
  63740. export interface IEffectRendererOptions {
  63741. /**
  63742. * Defines the vertices positions.
  63743. */
  63744. positions?: number[];
  63745. /**
  63746. * Defines the indices.
  63747. */
  63748. indices?: number[];
  63749. }
  63750. /**
  63751. * Helper class to render one or more effects.
  63752. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  63753. */
  63754. export class EffectRenderer {
  63755. private engine;
  63756. private static _DefaultOptions;
  63757. private _vertexBuffers;
  63758. private _indexBuffer;
  63759. private _fullscreenViewport;
  63760. /**
  63761. * Creates an effect renderer
  63762. * @param engine the engine to use for rendering
  63763. * @param options defines the options of the effect renderer
  63764. */
  63765. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  63766. /**
  63767. * Sets the current viewport in normalized coordinates 0-1
  63768. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  63769. */
  63770. setViewport(viewport?: Viewport): void;
  63771. /**
  63772. * Binds the embedded attributes buffer to the effect.
  63773. * @param effect Defines the effect to bind the attributes for
  63774. */
  63775. bindBuffers(effect: Effect): void;
  63776. /**
  63777. * Sets the current effect wrapper to use during draw.
  63778. * The effect needs to be ready before calling this api.
  63779. * This also sets the default full screen position attribute.
  63780. * @param effectWrapper Defines the effect to draw with
  63781. */
  63782. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  63783. /**
  63784. * Draws a full screen quad.
  63785. */
  63786. draw(): void;
  63787. private isRenderTargetTexture;
  63788. /**
  63789. * renders one or more effects to a specified texture
  63790. * @param effectWrapper the effect to renderer
  63791. * @param outputTexture texture to draw to, if null it will render to the screen.
  63792. */
  63793. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  63794. /**
  63795. * Disposes of the effect renderer
  63796. */
  63797. dispose(): void;
  63798. }
  63799. /**
  63800. * Options to create an EffectWrapper
  63801. */
  63802. interface EffectWrapperCreationOptions {
  63803. /**
  63804. * Engine to use to create the effect
  63805. */
  63806. engine: ThinEngine;
  63807. /**
  63808. * Fragment shader for the effect
  63809. */
  63810. fragmentShader: string;
  63811. /**
  63812. * Vertex shader for the effect
  63813. */
  63814. vertexShader?: string;
  63815. /**
  63816. * Attributes to use in the shader
  63817. */
  63818. attributeNames?: Array<string>;
  63819. /**
  63820. * Uniforms to use in the shader
  63821. */
  63822. uniformNames?: Array<string>;
  63823. /**
  63824. * Texture sampler names to use in the shader
  63825. */
  63826. samplerNames?: Array<string>;
  63827. /**
  63828. * The friendly name of the effect displayed in Spector.
  63829. */
  63830. name?: string;
  63831. }
  63832. /**
  63833. * Wraps an effect to be used for rendering
  63834. */
  63835. export class EffectWrapper {
  63836. /**
  63837. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  63838. */
  63839. onApplyObservable: Observable<{}>;
  63840. /**
  63841. * The underlying effect
  63842. */
  63843. effect: Effect;
  63844. /**
  63845. * Creates an effect to be renderer
  63846. * @param creationOptions options to create the effect
  63847. */
  63848. constructor(creationOptions: EffectWrapperCreationOptions);
  63849. /**
  63850. * Disposes of the effect wrapper
  63851. */
  63852. dispose(): void;
  63853. }
  63854. }
  63855. declare module "babylonjs/Materials/index" {
  63856. export * from "babylonjs/Materials/Background/index";
  63857. export * from "babylonjs/Materials/colorCurves";
  63858. export * from "babylonjs/Materials/iEffectFallbacks";
  63859. export * from "babylonjs/Materials/effectFallbacks";
  63860. export * from "babylonjs/Materials/effect";
  63861. export * from "babylonjs/Materials/fresnelParameters";
  63862. export * from "babylonjs/Materials/imageProcessingConfiguration";
  63863. export * from "babylonjs/Materials/material";
  63864. export * from "babylonjs/Materials/materialDefines";
  63865. export * from "babylonjs/Materials/materialHelper";
  63866. export * from "babylonjs/Materials/multiMaterial";
  63867. export * from "babylonjs/Materials/PBR/index";
  63868. export * from "babylonjs/Materials/pushMaterial";
  63869. export * from "babylonjs/Materials/shaderMaterial";
  63870. export * from "babylonjs/Materials/standardMaterial";
  63871. export * from "babylonjs/Materials/Textures/index";
  63872. export * from "babylonjs/Materials/uniformBuffer";
  63873. export * from "babylonjs/Materials/materialFlags";
  63874. export * from "babylonjs/Materials/Node/index";
  63875. export * from "babylonjs/Materials/effectRenderer";
  63876. }
  63877. declare module "babylonjs/Maths/index" {
  63878. export * from "babylonjs/Maths/math.scalar";
  63879. export * from "babylonjs/Maths/math";
  63880. export * from "babylonjs/Maths/sphericalPolynomial";
  63881. }
  63882. declare module "babylonjs/Misc/workerPool" {
  63883. import { IDisposable } from "babylonjs/scene";
  63884. /**
  63885. * Helper class to push actions to a pool of workers.
  63886. */
  63887. export class WorkerPool implements IDisposable {
  63888. private _workerInfos;
  63889. private _pendingActions;
  63890. /**
  63891. * Constructor
  63892. * @param workers Array of workers to use for actions
  63893. */
  63894. constructor(workers: Array<Worker>);
  63895. /**
  63896. * Terminates all workers and clears any pending actions.
  63897. */
  63898. dispose(): void;
  63899. /**
  63900. * Pushes an action to the worker pool. If all the workers are active, the action will be
  63901. * pended until a worker has completed its action.
  63902. * @param action The action to perform. Call onComplete when the action is complete.
  63903. */
  63904. push(action: (worker: Worker, onComplete: () => void) => void): void;
  63905. private _execute;
  63906. }
  63907. }
  63908. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  63909. import { IDisposable } from "babylonjs/scene";
  63910. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  63911. /**
  63912. * Configuration for Draco compression
  63913. */
  63914. export interface IDracoCompressionConfiguration {
  63915. /**
  63916. * Configuration for the decoder.
  63917. */
  63918. decoder: {
  63919. /**
  63920. * The url to the WebAssembly module.
  63921. */
  63922. wasmUrl?: string;
  63923. /**
  63924. * The url to the WebAssembly binary.
  63925. */
  63926. wasmBinaryUrl?: string;
  63927. /**
  63928. * The url to the fallback JavaScript module.
  63929. */
  63930. fallbackUrl?: string;
  63931. };
  63932. }
  63933. /**
  63934. * Draco compression (https://google.github.io/draco/)
  63935. *
  63936. * This class wraps the Draco module.
  63937. *
  63938. * **Encoder**
  63939. *
  63940. * The encoder is not currently implemented.
  63941. *
  63942. * **Decoder**
  63943. *
  63944. * 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.
  63945. *
  63946. * To update the configuration, use the following code:
  63947. * ```javascript
  63948. * DracoCompression.Configuration = {
  63949. * decoder: {
  63950. * wasmUrl: "<url to the WebAssembly library>",
  63951. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  63952. * fallbackUrl: "<url to the fallback JavaScript library>",
  63953. * }
  63954. * };
  63955. * ```
  63956. *
  63957. * 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.
  63958. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  63959. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  63960. *
  63961. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  63962. * ```javascript
  63963. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  63964. * ```
  63965. *
  63966. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  63967. */
  63968. export class DracoCompression implements IDisposable {
  63969. private _workerPoolPromise?;
  63970. private _decoderModulePromise?;
  63971. /**
  63972. * The configuration. Defaults to the following urls:
  63973. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  63974. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  63975. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  63976. */
  63977. static Configuration: IDracoCompressionConfiguration;
  63978. /**
  63979. * Returns true if the decoder configuration is available.
  63980. */
  63981. static get DecoderAvailable(): boolean;
  63982. /**
  63983. * Default number of workers to create when creating the draco compression object.
  63984. */
  63985. static DefaultNumWorkers: number;
  63986. private static GetDefaultNumWorkers;
  63987. private static _Default;
  63988. /**
  63989. * Default instance for the draco compression object.
  63990. */
  63991. static get Default(): DracoCompression;
  63992. /**
  63993. * Constructor
  63994. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  63995. */
  63996. constructor(numWorkers?: number);
  63997. /**
  63998. * Stop all async operations and release resources.
  63999. */
  64000. dispose(): void;
  64001. /**
  64002. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  64003. * @returns a promise that resolves when ready
  64004. */
  64005. whenReadyAsync(): Promise<void>;
  64006. /**
  64007. * Decode Draco compressed mesh data to vertex data.
  64008. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  64009. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  64010. * @returns A promise that resolves with the decoded vertex data
  64011. */
  64012. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  64013. [kind: string]: number;
  64014. }): Promise<VertexData>;
  64015. }
  64016. }
  64017. declare module "babylonjs/Meshes/Compression/index" {
  64018. export * from "babylonjs/Meshes/Compression/dracoCompression";
  64019. }
  64020. declare module "babylonjs/Meshes/csg" {
  64021. import { Nullable } from "babylonjs/types";
  64022. import { Scene } from "babylonjs/scene";
  64023. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  64024. import { Mesh } from "babylonjs/Meshes/mesh";
  64025. import { Material } from "babylonjs/Materials/material";
  64026. /**
  64027. * Class for building Constructive Solid Geometry
  64028. */
  64029. export class CSG {
  64030. private polygons;
  64031. /**
  64032. * The world matrix
  64033. */
  64034. matrix: Matrix;
  64035. /**
  64036. * Stores the position
  64037. */
  64038. position: Vector3;
  64039. /**
  64040. * Stores the rotation
  64041. */
  64042. rotation: Vector3;
  64043. /**
  64044. * Stores the rotation quaternion
  64045. */
  64046. rotationQuaternion: Nullable<Quaternion>;
  64047. /**
  64048. * Stores the scaling vector
  64049. */
  64050. scaling: Vector3;
  64051. /**
  64052. * Convert the Mesh to CSG
  64053. * @param mesh The Mesh to convert to CSG
  64054. * @returns A new CSG from the Mesh
  64055. */
  64056. static FromMesh(mesh: Mesh): CSG;
  64057. /**
  64058. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  64059. * @param polygons Polygons used to construct a CSG solid
  64060. */
  64061. private static FromPolygons;
  64062. /**
  64063. * Clones, or makes a deep copy, of the CSG
  64064. * @returns A new CSG
  64065. */
  64066. clone(): CSG;
  64067. /**
  64068. * Unions this CSG with another CSG
  64069. * @param csg The CSG to union against this CSG
  64070. * @returns The unioned CSG
  64071. */
  64072. union(csg: CSG): CSG;
  64073. /**
  64074. * Unions this CSG with another CSG in place
  64075. * @param csg The CSG to union against this CSG
  64076. */
  64077. unionInPlace(csg: CSG): void;
  64078. /**
  64079. * Subtracts this CSG with another CSG
  64080. * @param csg The CSG to subtract against this CSG
  64081. * @returns A new CSG
  64082. */
  64083. subtract(csg: CSG): CSG;
  64084. /**
  64085. * Subtracts this CSG with another CSG in place
  64086. * @param csg The CSG to subtact against this CSG
  64087. */
  64088. subtractInPlace(csg: CSG): void;
  64089. /**
  64090. * Intersect this CSG with another CSG
  64091. * @param csg The CSG to intersect against this CSG
  64092. * @returns A new CSG
  64093. */
  64094. intersect(csg: CSG): CSG;
  64095. /**
  64096. * Intersects this CSG with another CSG in place
  64097. * @param csg The CSG to intersect against this CSG
  64098. */
  64099. intersectInPlace(csg: CSG): void;
  64100. /**
  64101. * Return a new CSG solid with solid and empty space switched. This solid is
  64102. * not modified.
  64103. * @returns A new CSG solid with solid and empty space switched
  64104. */
  64105. inverse(): CSG;
  64106. /**
  64107. * Inverses the CSG in place
  64108. */
  64109. inverseInPlace(): void;
  64110. /**
  64111. * This is used to keep meshes transformations so they can be restored
  64112. * when we build back a Babylon Mesh
  64113. * NB : All CSG operations are performed in world coordinates
  64114. * @param csg The CSG to copy the transform attributes from
  64115. * @returns This CSG
  64116. */
  64117. copyTransformAttributes(csg: CSG): CSG;
  64118. /**
  64119. * Build Raw mesh from CSG
  64120. * Coordinates here are in world space
  64121. * @param name The name of the mesh geometry
  64122. * @param scene The Scene
  64123. * @param keepSubMeshes Specifies if the submeshes should be kept
  64124. * @returns A new Mesh
  64125. */
  64126. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  64127. /**
  64128. * Build Mesh from CSG taking material and transforms into account
  64129. * @param name The name of the Mesh
  64130. * @param material The material of the Mesh
  64131. * @param scene The Scene
  64132. * @param keepSubMeshes Specifies if submeshes should be kept
  64133. * @returns The new Mesh
  64134. */
  64135. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  64136. }
  64137. }
  64138. declare module "babylonjs/Meshes/trailMesh" {
  64139. import { Mesh } from "babylonjs/Meshes/mesh";
  64140. import { Scene } from "babylonjs/scene";
  64141. import { TransformNode } from "babylonjs/Meshes/transformNode";
  64142. /**
  64143. * Class used to create a trail following a mesh
  64144. */
  64145. export class TrailMesh extends Mesh {
  64146. private _generator;
  64147. private _autoStart;
  64148. private _running;
  64149. private _diameter;
  64150. private _length;
  64151. private _sectionPolygonPointsCount;
  64152. private _sectionVectors;
  64153. private _sectionNormalVectors;
  64154. private _beforeRenderObserver;
  64155. /**
  64156. * @constructor
  64157. * @param name The value used by scene.getMeshByName() to do a lookup.
  64158. * @param generator The mesh or transform node to generate a trail.
  64159. * @param scene The scene to add this mesh to.
  64160. * @param diameter Diameter of trailing mesh. Default is 1.
  64161. * @param length Length of trailing mesh. Default is 60.
  64162. * @param autoStart Automatically start trailing mesh. Default true.
  64163. */
  64164. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  64165. /**
  64166. * "TrailMesh"
  64167. * @returns "TrailMesh"
  64168. */
  64169. getClassName(): string;
  64170. private _createMesh;
  64171. /**
  64172. * Start trailing mesh.
  64173. */
  64174. start(): void;
  64175. /**
  64176. * Stop trailing mesh.
  64177. */
  64178. stop(): void;
  64179. /**
  64180. * Update trailing mesh geometry.
  64181. */
  64182. update(): void;
  64183. /**
  64184. * Returns a new TrailMesh object.
  64185. * @param name is a string, the name given to the new mesh
  64186. * @param newGenerator use new generator object for cloned trail mesh
  64187. * @returns a new mesh
  64188. */
  64189. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  64190. /**
  64191. * Serializes this trail mesh
  64192. * @param serializationObject object to write serialization to
  64193. */
  64194. serialize(serializationObject: any): void;
  64195. /**
  64196. * Parses a serialized trail mesh
  64197. * @param parsedMesh the serialized mesh
  64198. * @param scene the scene to create the trail mesh in
  64199. * @returns the created trail mesh
  64200. */
  64201. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  64202. }
  64203. }
  64204. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  64205. import { Nullable } from "babylonjs/types";
  64206. import { Scene } from "babylonjs/scene";
  64207. import { Vector4 } from "babylonjs/Maths/math.vector";
  64208. import { Color4 } from "babylonjs/Maths/math.color";
  64209. import { Mesh } from "babylonjs/Meshes/mesh";
  64210. /**
  64211. * Class containing static functions to help procedurally build meshes
  64212. */
  64213. export class TiledBoxBuilder {
  64214. /**
  64215. * Creates a box mesh
  64216. * 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)
  64217. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  64218. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64219. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64220. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64221. * @param name defines the name of the mesh
  64222. * @param options defines the options used to create the mesh
  64223. * @param scene defines the hosting scene
  64224. * @returns the box mesh
  64225. */
  64226. static CreateTiledBox(name: string, options: {
  64227. pattern?: number;
  64228. width?: number;
  64229. height?: number;
  64230. depth?: number;
  64231. tileSize?: number;
  64232. tileWidth?: number;
  64233. tileHeight?: number;
  64234. alignHorizontal?: number;
  64235. alignVertical?: number;
  64236. faceUV?: Vector4[];
  64237. faceColors?: Color4[];
  64238. sideOrientation?: number;
  64239. updatable?: boolean;
  64240. }, scene?: Nullable<Scene>): Mesh;
  64241. }
  64242. }
  64243. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  64244. import { Vector4 } from "babylonjs/Maths/math.vector";
  64245. import { Mesh } from "babylonjs/Meshes/mesh";
  64246. /**
  64247. * Class containing static functions to help procedurally build meshes
  64248. */
  64249. export class TorusKnotBuilder {
  64250. /**
  64251. * Creates a torus knot mesh
  64252. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  64253. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  64254. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  64255. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  64256. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64257. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64258. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64259. * @param name defines the name of the mesh
  64260. * @param options defines the options used to create the mesh
  64261. * @param scene defines the hosting scene
  64262. * @returns the torus knot mesh
  64263. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  64264. */
  64265. static CreateTorusKnot(name: string, options: {
  64266. radius?: number;
  64267. tube?: number;
  64268. radialSegments?: number;
  64269. tubularSegments?: number;
  64270. p?: number;
  64271. q?: number;
  64272. updatable?: boolean;
  64273. sideOrientation?: number;
  64274. frontUVs?: Vector4;
  64275. backUVs?: Vector4;
  64276. }, scene: any): Mesh;
  64277. }
  64278. }
  64279. declare module "babylonjs/Meshes/polygonMesh" {
  64280. import { Scene } from "babylonjs/scene";
  64281. import { Vector2 } from "babylonjs/Maths/math.vector";
  64282. import { Mesh } from "babylonjs/Meshes/mesh";
  64283. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  64284. import { Path2 } from "babylonjs/Maths/math.path";
  64285. /**
  64286. * Polygon
  64287. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  64288. */
  64289. export class Polygon {
  64290. /**
  64291. * Creates a rectangle
  64292. * @param xmin bottom X coord
  64293. * @param ymin bottom Y coord
  64294. * @param xmax top X coord
  64295. * @param ymax top Y coord
  64296. * @returns points that make the resulting rectation
  64297. */
  64298. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  64299. /**
  64300. * Creates a circle
  64301. * @param radius radius of circle
  64302. * @param cx scale in x
  64303. * @param cy scale in y
  64304. * @param numberOfSides number of sides that make up the circle
  64305. * @returns points that make the resulting circle
  64306. */
  64307. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  64308. /**
  64309. * Creates a polygon from input string
  64310. * @param input Input polygon data
  64311. * @returns the parsed points
  64312. */
  64313. static Parse(input: string): Vector2[];
  64314. /**
  64315. * Starts building a polygon from x and y coordinates
  64316. * @param x x coordinate
  64317. * @param y y coordinate
  64318. * @returns the started path2
  64319. */
  64320. static StartingAt(x: number, y: number): Path2;
  64321. }
  64322. /**
  64323. * Builds a polygon
  64324. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  64325. */
  64326. export class PolygonMeshBuilder {
  64327. private _points;
  64328. private _outlinepoints;
  64329. private _holes;
  64330. private _name;
  64331. private _scene;
  64332. private _epoints;
  64333. private _eholes;
  64334. private _addToepoint;
  64335. /**
  64336. * Babylon reference to the earcut plugin.
  64337. */
  64338. bjsEarcut: any;
  64339. /**
  64340. * Creates a PolygonMeshBuilder
  64341. * @param name name of the builder
  64342. * @param contours Path of the polygon
  64343. * @param scene scene to add to when creating the mesh
  64344. * @param earcutInjection can be used to inject your own earcut reference
  64345. */
  64346. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  64347. /**
  64348. * Adds a whole within the polygon
  64349. * @param hole Array of points defining the hole
  64350. * @returns this
  64351. */
  64352. addHole(hole: Vector2[]): PolygonMeshBuilder;
  64353. /**
  64354. * Creates the polygon
  64355. * @param updatable If the mesh should be updatable
  64356. * @param depth The depth of the mesh created
  64357. * @returns the created mesh
  64358. */
  64359. build(updatable?: boolean, depth?: number): Mesh;
  64360. /**
  64361. * Creates the polygon
  64362. * @param depth The depth of the mesh created
  64363. * @returns the created VertexData
  64364. */
  64365. buildVertexData(depth?: number): VertexData;
  64366. /**
  64367. * Adds a side to the polygon
  64368. * @param positions points that make the polygon
  64369. * @param normals normals of the polygon
  64370. * @param uvs uvs of the polygon
  64371. * @param indices indices of the polygon
  64372. * @param bounds bounds of the polygon
  64373. * @param points points of the polygon
  64374. * @param depth depth of the polygon
  64375. * @param flip flip of the polygon
  64376. */
  64377. private addSide;
  64378. }
  64379. }
  64380. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  64381. import { Scene } from "babylonjs/scene";
  64382. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  64383. import { Color4 } from "babylonjs/Maths/math.color";
  64384. import { Mesh } from "babylonjs/Meshes/mesh";
  64385. import { Nullable } from "babylonjs/types";
  64386. /**
  64387. * Class containing static functions to help procedurally build meshes
  64388. */
  64389. export class PolygonBuilder {
  64390. /**
  64391. * Creates a polygon mesh
  64392. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  64393. * * 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
  64394. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  64395. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64396. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  64397. * * Remember you can only change the shape positions, not their number when updating a polygon
  64398. * @param name defines the name of the mesh
  64399. * @param options defines the options used to create the mesh
  64400. * @param scene defines the hosting scene
  64401. * @param earcutInjection can be used to inject your own earcut reference
  64402. * @returns the polygon mesh
  64403. */
  64404. static CreatePolygon(name: string, options: {
  64405. shape: Vector3[];
  64406. holes?: Vector3[][];
  64407. depth?: number;
  64408. faceUV?: Vector4[];
  64409. faceColors?: Color4[];
  64410. updatable?: boolean;
  64411. sideOrientation?: number;
  64412. frontUVs?: Vector4;
  64413. backUVs?: Vector4;
  64414. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  64415. /**
  64416. * Creates an extruded polygon mesh, with depth in the Y direction.
  64417. * * 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)
  64418. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  64419. * @param name defines the name of the mesh
  64420. * @param options defines the options used to create the mesh
  64421. * @param scene defines the hosting scene
  64422. * @param earcutInjection can be used to inject your own earcut reference
  64423. * @returns the polygon mesh
  64424. */
  64425. static ExtrudePolygon(name: string, options: {
  64426. shape: Vector3[];
  64427. holes?: Vector3[][];
  64428. depth?: number;
  64429. faceUV?: Vector4[];
  64430. faceColors?: Color4[];
  64431. updatable?: boolean;
  64432. sideOrientation?: number;
  64433. frontUVs?: Vector4;
  64434. backUVs?: Vector4;
  64435. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  64436. }
  64437. }
  64438. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  64439. import { Scene } from "babylonjs/scene";
  64440. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  64441. import { Mesh } from "babylonjs/Meshes/mesh";
  64442. import { Nullable } from "babylonjs/types";
  64443. /**
  64444. * Class containing static functions to help procedurally build meshes
  64445. */
  64446. export class LatheBuilder {
  64447. /**
  64448. * Creates lathe mesh.
  64449. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  64450. * * 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
  64451. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  64452. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  64453. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  64454. * * 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
  64455. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  64456. * * 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
  64457. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64458. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64459. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64460. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64461. * @param name defines the name of the mesh
  64462. * @param options defines the options used to create the mesh
  64463. * @param scene defines the hosting scene
  64464. * @returns the lathe mesh
  64465. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  64466. */
  64467. static CreateLathe(name: string, options: {
  64468. shape: Vector3[];
  64469. radius?: number;
  64470. tessellation?: number;
  64471. clip?: number;
  64472. arc?: number;
  64473. closed?: boolean;
  64474. updatable?: boolean;
  64475. sideOrientation?: number;
  64476. frontUVs?: Vector4;
  64477. backUVs?: Vector4;
  64478. cap?: number;
  64479. invertUV?: boolean;
  64480. }, scene?: Nullable<Scene>): Mesh;
  64481. }
  64482. }
  64483. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  64484. import { Nullable } from "babylonjs/types";
  64485. import { Scene } from "babylonjs/scene";
  64486. import { Vector4 } from "babylonjs/Maths/math.vector";
  64487. import { Mesh } from "babylonjs/Meshes/mesh";
  64488. /**
  64489. * Class containing static functions to help procedurally build meshes
  64490. */
  64491. export class TiledPlaneBuilder {
  64492. /**
  64493. * Creates a tiled plane mesh
  64494. * * The parameter `pattern` will, depending on value, do nothing or
  64495. * * * flip (reflect about central vertical) alternate tiles across and up
  64496. * * * flip every tile on alternate rows
  64497. * * * rotate (180 degs) alternate tiles across and up
  64498. * * * rotate every tile on alternate rows
  64499. * * * flip and rotate alternate tiles across and up
  64500. * * * flip and rotate every tile on alternate rows
  64501. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  64502. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  64503. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64504. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  64505. * * 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)
  64506. * * 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)
  64507. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  64508. * @param name defines the name of the mesh
  64509. * @param options defines the options used to create the mesh
  64510. * @param scene defines the hosting scene
  64511. * @returns the box mesh
  64512. */
  64513. static CreateTiledPlane(name: string, options: {
  64514. pattern?: number;
  64515. tileSize?: number;
  64516. tileWidth?: number;
  64517. tileHeight?: number;
  64518. size?: number;
  64519. width?: number;
  64520. height?: number;
  64521. alignHorizontal?: number;
  64522. alignVertical?: number;
  64523. sideOrientation?: number;
  64524. frontUVs?: Vector4;
  64525. backUVs?: Vector4;
  64526. updatable?: boolean;
  64527. }, scene?: Nullable<Scene>): Mesh;
  64528. }
  64529. }
  64530. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  64531. import { Nullable } from "babylonjs/types";
  64532. import { Scene } from "babylonjs/scene";
  64533. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  64534. import { Mesh } from "babylonjs/Meshes/mesh";
  64535. /**
  64536. * Class containing static functions to help procedurally build meshes
  64537. */
  64538. export class TubeBuilder {
  64539. /**
  64540. * Creates a tube mesh.
  64541. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  64542. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  64543. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  64544. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  64545. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  64546. * * 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)
  64547. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  64548. * * 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
  64549. * * 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
  64550. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64551. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64552. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64553. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64554. * @param name defines the name of the mesh
  64555. * @param options defines the options used to create the mesh
  64556. * @param scene defines the hosting scene
  64557. * @returns the tube mesh
  64558. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64559. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  64560. */
  64561. static CreateTube(name: string, options: {
  64562. path: Vector3[];
  64563. radius?: number;
  64564. tessellation?: number;
  64565. radiusFunction?: {
  64566. (i: number, distance: number): number;
  64567. };
  64568. cap?: number;
  64569. arc?: number;
  64570. updatable?: boolean;
  64571. sideOrientation?: number;
  64572. frontUVs?: Vector4;
  64573. backUVs?: Vector4;
  64574. instance?: Mesh;
  64575. invertUV?: boolean;
  64576. }, scene?: Nullable<Scene>): Mesh;
  64577. }
  64578. }
  64579. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  64580. import { Scene } from "babylonjs/scene";
  64581. import { Vector4 } from "babylonjs/Maths/math.vector";
  64582. import { Mesh } from "babylonjs/Meshes/mesh";
  64583. import { Nullable } from "babylonjs/types";
  64584. /**
  64585. * Class containing static functions to help procedurally build meshes
  64586. */
  64587. export class IcoSphereBuilder {
  64588. /**
  64589. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  64590. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  64591. * * 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`)
  64592. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  64593. * * 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
  64594. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64595. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64596. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64597. * @param name defines the name of the mesh
  64598. * @param options defines the options used to create the mesh
  64599. * @param scene defines the hosting scene
  64600. * @returns the icosahedron mesh
  64601. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  64602. */
  64603. static CreateIcoSphere(name: string, options: {
  64604. radius?: number;
  64605. radiusX?: number;
  64606. radiusY?: number;
  64607. radiusZ?: number;
  64608. flat?: boolean;
  64609. subdivisions?: number;
  64610. sideOrientation?: number;
  64611. frontUVs?: Vector4;
  64612. backUVs?: Vector4;
  64613. updatable?: boolean;
  64614. }, scene?: Nullable<Scene>): Mesh;
  64615. }
  64616. }
  64617. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  64618. import { Vector3 } from "babylonjs/Maths/math.vector";
  64619. import { Mesh } from "babylonjs/Meshes/mesh";
  64620. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64621. /**
  64622. * Class containing static functions to help procedurally build meshes
  64623. */
  64624. export class DecalBuilder {
  64625. /**
  64626. * Creates a decal mesh.
  64627. * 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
  64628. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  64629. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  64630. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  64631. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  64632. * @param name defines the name of the mesh
  64633. * @param sourceMesh defines the mesh where the decal must be applied
  64634. * @param options defines the options used to create the mesh
  64635. * @param scene defines the hosting scene
  64636. * @returns the decal mesh
  64637. * @see https://doc.babylonjs.com/how_to/decals
  64638. */
  64639. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  64640. position?: Vector3;
  64641. normal?: Vector3;
  64642. size?: Vector3;
  64643. angle?: number;
  64644. }): Mesh;
  64645. }
  64646. }
  64647. declare module "babylonjs/Meshes/meshBuilder" {
  64648. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  64649. import { Nullable } from "babylonjs/types";
  64650. import { Scene } from "babylonjs/scene";
  64651. import { Mesh } from "babylonjs/Meshes/mesh";
  64652. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  64653. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  64654. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64655. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  64656. import { Plane } from "babylonjs/Maths/math.plane";
  64657. /**
  64658. * Class containing static functions to help procedurally build meshes
  64659. */
  64660. export class MeshBuilder {
  64661. /**
  64662. * Creates a box mesh
  64663. * * The parameter `size` sets the size (float) of each box side (default 1)
  64664. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  64665. * * 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)
  64666. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  64667. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64668. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64669. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64670. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  64671. * @param name defines the name of the mesh
  64672. * @param options defines the options used to create the mesh
  64673. * @param scene defines the hosting scene
  64674. * @returns the box mesh
  64675. */
  64676. static CreateBox(name: string, options: {
  64677. size?: number;
  64678. width?: number;
  64679. height?: number;
  64680. depth?: number;
  64681. faceUV?: Vector4[];
  64682. faceColors?: Color4[];
  64683. sideOrientation?: number;
  64684. frontUVs?: Vector4;
  64685. backUVs?: Vector4;
  64686. wrap?: boolean;
  64687. topBaseAt?: number;
  64688. bottomBaseAt?: number;
  64689. updatable?: boolean;
  64690. }, scene?: Nullable<Scene>): Mesh;
  64691. /**
  64692. * Creates a tiled box mesh
  64693. * * faceTiles sets the pattern, tile size and number of tiles for a face
  64694. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64695. * @param name defines the name of the mesh
  64696. * @param options defines the options used to create the mesh
  64697. * @param scene defines the hosting scene
  64698. * @returns the tiled box mesh
  64699. */
  64700. static CreateTiledBox(name: string, options: {
  64701. pattern?: number;
  64702. size?: number;
  64703. width?: number;
  64704. height?: number;
  64705. depth: number;
  64706. tileSize?: number;
  64707. tileWidth?: number;
  64708. tileHeight?: number;
  64709. faceUV?: Vector4[];
  64710. faceColors?: Color4[];
  64711. alignHorizontal?: number;
  64712. alignVertical?: number;
  64713. sideOrientation?: number;
  64714. updatable?: boolean;
  64715. }, scene?: Nullable<Scene>): Mesh;
  64716. /**
  64717. * Creates a sphere mesh
  64718. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  64719. * * 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`)
  64720. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  64721. * * 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
  64722. * * 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)
  64723. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64724. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64725. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64726. * @param name defines the name of the mesh
  64727. * @param options defines the options used to create the mesh
  64728. * @param scene defines the hosting scene
  64729. * @returns the sphere mesh
  64730. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  64731. */
  64732. static CreateSphere(name: string, options: {
  64733. segments?: number;
  64734. diameter?: number;
  64735. diameterX?: number;
  64736. diameterY?: number;
  64737. diameterZ?: number;
  64738. arc?: number;
  64739. slice?: number;
  64740. sideOrientation?: number;
  64741. frontUVs?: Vector4;
  64742. backUVs?: Vector4;
  64743. updatable?: boolean;
  64744. }, scene?: Nullable<Scene>): Mesh;
  64745. /**
  64746. * Creates a plane polygonal mesh. By default, this is a disc
  64747. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  64748. * * 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
  64749. * * 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
  64750. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64751. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64752. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64753. * @param name defines the name of the mesh
  64754. * @param options defines the options used to create the mesh
  64755. * @param scene defines the hosting scene
  64756. * @returns the plane polygonal mesh
  64757. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  64758. */
  64759. static CreateDisc(name: string, options: {
  64760. radius?: number;
  64761. tessellation?: number;
  64762. arc?: number;
  64763. updatable?: boolean;
  64764. sideOrientation?: number;
  64765. frontUVs?: Vector4;
  64766. backUVs?: Vector4;
  64767. }, scene?: Nullable<Scene>): Mesh;
  64768. /**
  64769. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  64770. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  64771. * * 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`)
  64772. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  64773. * * 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
  64774. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64775. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64776. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64777. * @param name defines the name of the mesh
  64778. * @param options defines the options used to create the mesh
  64779. * @param scene defines the hosting scene
  64780. * @returns the icosahedron mesh
  64781. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  64782. */
  64783. static CreateIcoSphere(name: string, options: {
  64784. radius?: number;
  64785. radiusX?: number;
  64786. radiusY?: number;
  64787. radiusZ?: number;
  64788. flat?: boolean;
  64789. subdivisions?: number;
  64790. sideOrientation?: number;
  64791. frontUVs?: Vector4;
  64792. backUVs?: Vector4;
  64793. updatable?: boolean;
  64794. }, scene?: Nullable<Scene>): Mesh;
  64795. /**
  64796. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  64797. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  64798. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  64799. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  64800. * * 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
  64801. * * 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
  64802. * * 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
  64803. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64804. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64805. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64806. * * 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
  64807. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  64808. * * 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
  64809. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  64810. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64811. * @param name defines the name of the mesh
  64812. * @param options defines the options used to create the mesh
  64813. * @param scene defines the hosting scene
  64814. * @returns the ribbon mesh
  64815. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  64816. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64817. */
  64818. static CreateRibbon(name: string, options: {
  64819. pathArray: Vector3[][];
  64820. closeArray?: boolean;
  64821. closePath?: boolean;
  64822. offset?: number;
  64823. updatable?: boolean;
  64824. sideOrientation?: number;
  64825. frontUVs?: Vector4;
  64826. backUVs?: Vector4;
  64827. instance?: Mesh;
  64828. invertUV?: boolean;
  64829. uvs?: Vector2[];
  64830. colors?: Color4[];
  64831. }, scene?: Nullable<Scene>): Mesh;
  64832. /**
  64833. * Creates a cylinder or a cone mesh
  64834. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  64835. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  64836. * * 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.
  64837. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  64838. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  64839. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  64840. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  64841. * * 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).
  64842. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  64843. * * 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).
  64844. * * 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
  64845. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  64846. * * 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
  64847. * * 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.
  64848. * * If `enclose` is false, a ring surface is one element.
  64849. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  64850. * * 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
  64851. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64852. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64853. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64854. * @param name defines the name of the mesh
  64855. * @param options defines the options used to create the mesh
  64856. * @param scene defines the hosting scene
  64857. * @returns the cylinder mesh
  64858. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  64859. */
  64860. static CreateCylinder(name: string, options: {
  64861. height?: number;
  64862. diameterTop?: number;
  64863. diameterBottom?: number;
  64864. diameter?: number;
  64865. tessellation?: number;
  64866. subdivisions?: number;
  64867. arc?: number;
  64868. faceColors?: Color4[];
  64869. faceUV?: Vector4[];
  64870. updatable?: boolean;
  64871. hasRings?: boolean;
  64872. enclose?: boolean;
  64873. cap?: number;
  64874. sideOrientation?: number;
  64875. frontUVs?: Vector4;
  64876. backUVs?: Vector4;
  64877. }, scene?: Nullable<Scene>): Mesh;
  64878. /**
  64879. * Creates a torus mesh
  64880. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  64881. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  64882. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  64883. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64884. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64885. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64886. * @param name defines the name of the mesh
  64887. * @param options defines the options used to create the mesh
  64888. * @param scene defines the hosting scene
  64889. * @returns the torus mesh
  64890. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  64891. */
  64892. static CreateTorus(name: string, options: {
  64893. diameter?: number;
  64894. thickness?: number;
  64895. tessellation?: number;
  64896. updatable?: boolean;
  64897. sideOrientation?: number;
  64898. frontUVs?: Vector4;
  64899. backUVs?: Vector4;
  64900. }, scene?: Nullable<Scene>): Mesh;
  64901. /**
  64902. * Creates a torus knot mesh
  64903. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  64904. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  64905. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  64906. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  64907. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64908. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64909. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64910. * @param name defines the name of the mesh
  64911. * @param options defines the options used to create the mesh
  64912. * @param scene defines the hosting scene
  64913. * @returns the torus knot mesh
  64914. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  64915. */
  64916. static CreateTorusKnot(name: string, options: {
  64917. radius?: number;
  64918. tube?: number;
  64919. radialSegments?: number;
  64920. tubularSegments?: number;
  64921. p?: number;
  64922. q?: number;
  64923. updatable?: boolean;
  64924. sideOrientation?: number;
  64925. frontUVs?: Vector4;
  64926. backUVs?: Vector4;
  64927. }, scene?: Nullable<Scene>): Mesh;
  64928. /**
  64929. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  64930. * * 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
  64931. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  64932. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  64933. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  64934. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  64935. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  64936. * * 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
  64937. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  64938. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64939. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  64940. * @param name defines the name of the new line system
  64941. * @param options defines the options used to create the line system
  64942. * @param scene defines the hosting scene
  64943. * @returns a new line system mesh
  64944. */
  64945. static CreateLineSystem(name: string, options: {
  64946. lines: Vector3[][];
  64947. updatable?: boolean;
  64948. instance?: Nullable<LinesMesh>;
  64949. colors?: Nullable<Color4[][]>;
  64950. useVertexAlpha?: boolean;
  64951. }, scene: Nullable<Scene>): LinesMesh;
  64952. /**
  64953. * Creates a line mesh
  64954. * 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
  64955. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  64956. * * The parameter `points` is an array successive Vector3
  64957. * * 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
  64958. * * The optional parameter `colors` is an array of successive Color4, one per line point
  64959. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  64960. * * When updating an instance, remember that only point positions can change, not the number of points
  64961. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64962. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  64963. * @param name defines the name of the new line system
  64964. * @param options defines the options used to create the line system
  64965. * @param scene defines the hosting scene
  64966. * @returns a new line mesh
  64967. */
  64968. static CreateLines(name: string, options: {
  64969. points: Vector3[];
  64970. updatable?: boolean;
  64971. instance?: Nullable<LinesMesh>;
  64972. colors?: Color4[];
  64973. useVertexAlpha?: boolean;
  64974. }, scene?: Nullable<Scene>): LinesMesh;
  64975. /**
  64976. * Creates a dashed line mesh
  64977. * * 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
  64978. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  64979. * * The parameter `points` is an array successive Vector3
  64980. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  64981. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  64982. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  64983. * * 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
  64984. * * When updating an instance, remember that only point positions can change, not the number of points
  64985. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64986. * @param name defines the name of the mesh
  64987. * @param options defines the options used to create the mesh
  64988. * @param scene defines the hosting scene
  64989. * @returns the dashed line mesh
  64990. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  64991. */
  64992. static CreateDashedLines(name: string, options: {
  64993. points: Vector3[];
  64994. dashSize?: number;
  64995. gapSize?: number;
  64996. dashNb?: number;
  64997. updatable?: boolean;
  64998. instance?: LinesMesh;
  64999. }, scene?: Nullable<Scene>): LinesMesh;
  65000. /**
  65001. * 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.
  65002. * * 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.
  65003. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  65004. * * 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.
  65005. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  65006. * * 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
  65007. * * 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
  65008. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  65009. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65010. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  65011. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  65012. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  65013. * @param name defines the name of the mesh
  65014. * @param options defines the options used to create the mesh
  65015. * @param scene defines the hosting scene
  65016. * @returns the extruded shape mesh
  65017. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  65018. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  65019. */
  65020. static ExtrudeShape(name: string, options: {
  65021. shape: Vector3[];
  65022. path: Vector3[];
  65023. scale?: number;
  65024. rotation?: number;
  65025. cap?: number;
  65026. updatable?: boolean;
  65027. sideOrientation?: number;
  65028. frontUVs?: Vector4;
  65029. backUVs?: Vector4;
  65030. instance?: Mesh;
  65031. invertUV?: boolean;
  65032. }, scene?: Nullable<Scene>): Mesh;
  65033. /**
  65034. * Creates an custom extruded shape mesh.
  65035. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  65036. * * 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.
  65037. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  65038. * * 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
  65039. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  65040. * * 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
  65041. * * It must returns a float value that will be the scale value applied to the shape on each path point
  65042. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  65043. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  65044. * * 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
  65045. * * 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
  65046. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  65047. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65048. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  65049. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  65050. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65051. * @param name defines the name of the mesh
  65052. * @param options defines the options used to create the mesh
  65053. * @param scene defines the hosting scene
  65054. * @returns the custom extruded shape mesh
  65055. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  65056. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  65057. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  65058. */
  65059. static ExtrudeShapeCustom(name: string, options: {
  65060. shape: Vector3[];
  65061. path: Vector3[];
  65062. scaleFunction?: any;
  65063. rotationFunction?: any;
  65064. ribbonCloseArray?: boolean;
  65065. ribbonClosePath?: boolean;
  65066. cap?: number;
  65067. updatable?: boolean;
  65068. sideOrientation?: number;
  65069. frontUVs?: Vector4;
  65070. backUVs?: Vector4;
  65071. instance?: Mesh;
  65072. invertUV?: boolean;
  65073. }, scene?: Nullable<Scene>): Mesh;
  65074. /**
  65075. * Creates lathe mesh.
  65076. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  65077. * * 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
  65078. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  65079. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  65080. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  65081. * * 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
  65082. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  65083. * * 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
  65084. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65085. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  65086. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  65087. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65088. * @param name defines the name of the mesh
  65089. * @param options defines the options used to create the mesh
  65090. * @param scene defines the hosting scene
  65091. * @returns the lathe mesh
  65092. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  65093. */
  65094. static CreateLathe(name: string, options: {
  65095. shape: Vector3[];
  65096. radius?: number;
  65097. tessellation?: number;
  65098. clip?: number;
  65099. arc?: number;
  65100. closed?: boolean;
  65101. updatable?: boolean;
  65102. sideOrientation?: number;
  65103. frontUVs?: Vector4;
  65104. backUVs?: Vector4;
  65105. cap?: number;
  65106. invertUV?: boolean;
  65107. }, scene?: Nullable<Scene>): Mesh;
  65108. /**
  65109. * Creates a tiled plane mesh
  65110. * * You can set a limited pattern arrangement with the tiles
  65111. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65112. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  65113. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65114. * @param name defines the name of the mesh
  65115. * @param options defines the options used to create the mesh
  65116. * @param scene defines the hosting scene
  65117. * @returns the plane mesh
  65118. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  65119. */
  65120. static CreateTiledPlane(name: string, options: {
  65121. pattern?: number;
  65122. tileSize?: number;
  65123. tileWidth?: number;
  65124. tileHeight?: number;
  65125. size?: number;
  65126. width?: number;
  65127. height?: number;
  65128. alignHorizontal?: number;
  65129. alignVertical?: number;
  65130. sideOrientation?: number;
  65131. frontUVs?: Vector4;
  65132. backUVs?: Vector4;
  65133. updatable?: boolean;
  65134. }, scene?: Nullable<Scene>): Mesh;
  65135. /**
  65136. * Creates a plane mesh
  65137. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  65138. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  65139. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  65140. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65141. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  65142. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65143. * @param name defines the name of the mesh
  65144. * @param options defines the options used to create the mesh
  65145. * @param scene defines the hosting scene
  65146. * @returns the plane mesh
  65147. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  65148. */
  65149. static CreatePlane(name: string, options: {
  65150. size?: number;
  65151. width?: number;
  65152. height?: number;
  65153. sideOrientation?: number;
  65154. frontUVs?: Vector4;
  65155. backUVs?: Vector4;
  65156. updatable?: boolean;
  65157. sourcePlane?: Plane;
  65158. }, scene?: Nullable<Scene>): Mesh;
  65159. /**
  65160. * Creates a ground mesh
  65161. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  65162. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  65163. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65164. * @param name defines the name of the mesh
  65165. * @param options defines the options used to create the mesh
  65166. * @param scene defines the hosting scene
  65167. * @returns the ground mesh
  65168. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  65169. */
  65170. static CreateGround(name: string, options: {
  65171. width?: number;
  65172. height?: number;
  65173. subdivisions?: number;
  65174. subdivisionsX?: number;
  65175. subdivisionsY?: number;
  65176. updatable?: boolean;
  65177. }, scene?: Nullable<Scene>): Mesh;
  65178. /**
  65179. * Creates a tiled ground mesh
  65180. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  65181. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  65182. * * 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
  65183. * * 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
  65184. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  65185. * @param name defines the name of the mesh
  65186. * @param options defines the options used to create the mesh
  65187. * @param scene defines the hosting scene
  65188. * @returns the tiled ground mesh
  65189. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  65190. */
  65191. static CreateTiledGround(name: string, options: {
  65192. xmin: number;
  65193. zmin: number;
  65194. xmax: number;
  65195. zmax: number;
  65196. subdivisions?: {
  65197. w: number;
  65198. h: number;
  65199. };
  65200. precision?: {
  65201. w: number;
  65202. h: number;
  65203. };
  65204. updatable?: boolean;
  65205. }, scene?: Nullable<Scene>): Mesh;
  65206. /**
  65207. * Creates a ground mesh from a height map
  65208. * * The parameter `url` sets the URL of the height map image resource.
  65209. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  65210. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  65211. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  65212. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  65213. * * 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.
  65214. * * 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).
  65215. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  65216. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  65217. * @param name defines the name of the mesh
  65218. * @param url defines the url to the height map
  65219. * @param options defines the options used to create the mesh
  65220. * @param scene defines the hosting scene
  65221. * @returns the ground mesh
  65222. * @see https://doc.babylonjs.com/babylon101/height_map
  65223. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  65224. */
  65225. static CreateGroundFromHeightMap(name: string, url: string, options: {
  65226. width?: number;
  65227. height?: number;
  65228. subdivisions?: number;
  65229. minHeight?: number;
  65230. maxHeight?: number;
  65231. colorFilter?: Color3;
  65232. alphaFilter?: number;
  65233. updatable?: boolean;
  65234. onReady?: (mesh: GroundMesh) => void;
  65235. }, scene?: Nullable<Scene>): GroundMesh;
  65236. /**
  65237. * Creates a polygon mesh
  65238. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  65239. * * 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
  65240. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  65241. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65242. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  65243. * * Remember you can only change the shape positions, not their number when updating a polygon
  65244. * @param name defines the name of the mesh
  65245. * @param options defines the options used to create the mesh
  65246. * @param scene defines the hosting scene
  65247. * @param earcutInjection can be used to inject your own earcut reference
  65248. * @returns the polygon mesh
  65249. */
  65250. static CreatePolygon(name: string, options: {
  65251. shape: Vector3[];
  65252. holes?: Vector3[][];
  65253. depth?: number;
  65254. faceUV?: Vector4[];
  65255. faceColors?: Color4[];
  65256. updatable?: boolean;
  65257. sideOrientation?: number;
  65258. frontUVs?: Vector4;
  65259. backUVs?: Vector4;
  65260. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  65261. /**
  65262. * Creates an extruded polygon mesh, with depth in the Y direction.
  65263. * * 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)
  65264. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  65265. * @param name defines the name of the mesh
  65266. * @param options defines the options used to create the mesh
  65267. * @param scene defines the hosting scene
  65268. * @param earcutInjection can be used to inject your own earcut reference
  65269. * @returns the polygon mesh
  65270. */
  65271. static ExtrudePolygon(name: string, options: {
  65272. shape: Vector3[];
  65273. holes?: Vector3[][];
  65274. depth?: number;
  65275. faceUV?: Vector4[];
  65276. faceColors?: Color4[];
  65277. updatable?: boolean;
  65278. sideOrientation?: number;
  65279. frontUVs?: Vector4;
  65280. backUVs?: Vector4;
  65281. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  65282. /**
  65283. * Creates a tube mesh.
  65284. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  65285. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  65286. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  65287. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  65288. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  65289. * * 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)
  65290. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  65291. * * 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
  65292. * * 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
  65293. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65294. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  65295. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  65296. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65297. * @param name defines the name of the mesh
  65298. * @param options defines the options used to create the mesh
  65299. * @param scene defines the hosting scene
  65300. * @returns the tube mesh
  65301. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  65302. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  65303. */
  65304. static CreateTube(name: string, options: {
  65305. path: Vector3[];
  65306. radius?: number;
  65307. tessellation?: number;
  65308. radiusFunction?: {
  65309. (i: number, distance: number): number;
  65310. };
  65311. cap?: number;
  65312. arc?: number;
  65313. updatable?: boolean;
  65314. sideOrientation?: number;
  65315. frontUVs?: Vector4;
  65316. backUVs?: Vector4;
  65317. instance?: Mesh;
  65318. invertUV?: boolean;
  65319. }, scene?: Nullable<Scene>): Mesh;
  65320. /**
  65321. * Creates a polyhedron mesh
  65322. * * 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
  65323. * * The parameter `size` (positive float, default 1) sets the polygon size
  65324. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  65325. * * 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`
  65326. * * 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
  65327. * * 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)`)
  65328. * * 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
  65329. * * 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
  65330. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65331. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  65332. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65333. * @param name defines the name of the mesh
  65334. * @param options defines the options used to create the mesh
  65335. * @param scene defines the hosting scene
  65336. * @returns the polyhedron mesh
  65337. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  65338. */
  65339. static CreatePolyhedron(name: string, options: {
  65340. type?: number;
  65341. size?: number;
  65342. sizeX?: number;
  65343. sizeY?: number;
  65344. sizeZ?: number;
  65345. custom?: any;
  65346. faceUV?: Vector4[];
  65347. faceColors?: Color4[];
  65348. flat?: boolean;
  65349. updatable?: boolean;
  65350. sideOrientation?: number;
  65351. frontUVs?: Vector4;
  65352. backUVs?: Vector4;
  65353. }, scene?: Nullable<Scene>): Mesh;
  65354. /**
  65355. * Creates a decal mesh.
  65356. * 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
  65357. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  65358. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  65359. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  65360. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  65361. * @param name defines the name of the mesh
  65362. * @param sourceMesh defines the mesh where the decal must be applied
  65363. * @param options defines the options used to create the mesh
  65364. * @param scene defines the hosting scene
  65365. * @returns the decal mesh
  65366. * @see https://doc.babylonjs.com/how_to/decals
  65367. */
  65368. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  65369. position?: Vector3;
  65370. normal?: Vector3;
  65371. size?: Vector3;
  65372. angle?: number;
  65373. }): Mesh;
  65374. }
  65375. }
  65376. declare module "babylonjs/Meshes/meshSimplification" {
  65377. import { Mesh } from "babylonjs/Meshes/mesh";
  65378. /**
  65379. * A simplifier interface for future simplification implementations
  65380. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65381. */
  65382. export interface ISimplifier {
  65383. /**
  65384. * Simplification of a given mesh according to the given settings.
  65385. * Since this requires computation, it is assumed that the function runs async.
  65386. * @param settings The settings of the simplification, including quality and distance
  65387. * @param successCallback A callback that will be called after the mesh was simplified.
  65388. * @param errorCallback in case of an error, this callback will be called. optional.
  65389. */
  65390. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  65391. }
  65392. /**
  65393. * Expected simplification settings.
  65394. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  65395. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65396. */
  65397. export interface ISimplificationSettings {
  65398. /**
  65399. * Gets or sets the expected quality
  65400. */
  65401. quality: number;
  65402. /**
  65403. * Gets or sets the distance when this optimized version should be used
  65404. */
  65405. distance: number;
  65406. /**
  65407. * Gets an already optimized mesh
  65408. */
  65409. optimizeMesh?: boolean;
  65410. }
  65411. /**
  65412. * Class used to specify simplification options
  65413. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65414. */
  65415. export class SimplificationSettings implements ISimplificationSettings {
  65416. /** expected quality */
  65417. quality: number;
  65418. /** distance when this optimized version should be used */
  65419. distance: number;
  65420. /** already optimized mesh */
  65421. optimizeMesh?: boolean | undefined;
  65422. /**
  65423. * Creates a SimplificationSettings
  65424. * @param quality expected quality
  65425. * @param distance distance when this optimized version should be used
  65426. * @param optimizeMesh already optimized mesh
  65427. */
  65428. constructor(
  65429. /** expected quality */
  65430. quality: number,
  65431. /** distance when this optimized version should be used */
  65432. distance: number,
  65433. /** already optimized mesh */
  65434. optimizeMesh?: boolean | undefined);
  65435. }
  65436. /**
  65437. * Interface used to define a simplification task
  65438. */
  65439. export interface ISimplificationTask {
  65440. /**
  65441. * Array of settings
  65442. */
  65443. settings: Array<ISimplificationSettings>;
  65444. /**
  65445. * Simplification type
  65446. */
  65447. simplificationType: SimplificationType;
  65448. /**
  65449. * Mesh to simplify
  65450. */
  65451. mesh: Mesh;
  65452. /**
  65453. * Callback called on success
  65454. */
  65455. successCallback?: () => void;
  65456. /**
  65457. * Defines if parallel processing can be used
  65458. */
  65459. parallelProcessing: boolean;
  65460. }
  65461. /**
  65462. * Queue used to order the simplification tasks
  65463. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65464. */
  65465. export class SimplificationQueue {
  65466. private _simplificationArray;
  65467. /**
  65468. * Gets a boolean indicating that the process is still running
  65469. */
  65470. running: boolean;
  65471. /**
  65472. * Creates a new queue
  65473. */
  65474. constructor();
  65475. /**
  65476. * Adds a new simplification task
  65477. * @param task defines a task to add
  65478. */
  65479. addTask(task: ISimplificationTask): void;
  65480. /**
  65481. * Execute next task
  65482. */
  65483. executeNext(): void;
  65484. /**
  65485. * Execute a simplification task
  65486. * @param task defines the task to run
  65487. */
  65488. runSimplification(task: ISimplificationTask): void;
  65489. private getSimplifier;
  65490. }
  65491. /**
  65492. * The implemented types of simplification
  65493. * At the moment only Quadratic Error Decimation is implemented
  65494. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65495. */
  65496. export enum SimplificationType {
  65497. /** Quadratic error decimation */
  65498. QUADRATIC = 0
  65499. }
  65500. /**
  65501. * An implementation of the Quadratic Error simplification algorithm.
  65502. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  65503. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  65504. * @author RaananW
  65505. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65506. */
  65507. export class QuadraticErrorSimplification implements ISimplifier {
  65508. private _mesh;
  65509. private triangles;
  65510. private vertices;
  65511. private references;
  65512. private _reconstructedMesh;
  65513. /** Gets or sets the number pf sync interations */
  65514. syncIterations: number;
  65515. /** Gets or sets the aggressiveness of the simplifier */
  65516. aggressiveness: number;
  65517. /** Gets or sets the number of allowed iterations for decimation */
  65518. decimationIterations: number;
  65519. /** Gets or sets the espilon to use for bounding box computation */
  65520. boundingBoxEpsilon: number;
  65521. /**
  65522. * Creates a new QuadraticErrorSimplification
  65523. * @param _mesh defines the target mesh
  65524. */
  65525. constructor(_mesh: Mesh);
  65526. /**
  65527. * Simplification of a given mesh according to the given settings.
  65528. * Since this requires computation, it is assumed that the function runs async.
  65529. * @param settings The settings of the simplification, including quality and distance
  65530. * @param successCallback A callback that will be called after the mesh was simplified.
  65531. */
  65532. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  65533. private runDecimation;
  65534. private initWithMesh;
  65535. private init;
  65536. private reconstructMesh;
  65537. private initDecimatedMesh;
  65538. private isFlipped;
  65539. private updateTriangles;
  65540. private identifyBorder;
  65541. private updateMesh;
  65542. private vertexError;
  65543. private calculateError;
  65544. }
  65545. }
  65546. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  65547. import { Scene } from "babylonjs/scene";
  65548. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  65549. import { ISceneComponent } from "babylonjs/sceneComponent";
  65550. module "babylonjs/scene" {
  65551. interface Scene {
  65552. /** @hidden (Backing field) */
  65553. _simplificationQueue: SimplificationQueue;
  65554. /**
  65555. * Gets or sets the simplification queue attached to the scene
  65556. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65557. */
  65558. simplificationQueue: SimplificationQueue;
  65559. }
  65560. }
  65561. module "babylonjs/Meshes/mesh" {
  65562. interface Mesh {
  65563. /**
  65564. * Simplify the mesh according to the given array of settings.
  65565. * Function will return immediately and will simplify async
  65566. * @param settings a collection of simplification settings
  65567. * @param parallelProcessing should all levels calculate parallel or one after the other
  65568. * @param simplificationType the type of simplification to run
  65569. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  65570. * @returns the current mesh
  65571. */
  65572. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  65573. }
  65574. }
  65575. /**
  65576. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  65577. * created in a scene
  65578. */
  65579. export class SimplicationQueueSceneComponent implements ISceneComponent {
  65580. /**
  65581. * The component name helpfull to identify the component in the list of scene components.
  65582. */
  65583. readonly name: string;
  65584. /**
  65585. * The scene the component belongs to.
  65586. */
  65587. scene: Scene;
  65588. /**
  65589. * Creates a new instance of the component for the given scene
  65590. * @param scene Defines the scene to register the component in
  65591. */
  65592. constructor(scene: Scene);
  65593. /**
  65594. * Registers the component in a given scene
  65595. */
  65596. register(): void;
  65597. /**
  65598. * Rebuilds the elements related to this component in case of
  65599. * context lost for instance.
  65600. */
  65601. rebuild(): void;
  65602. /**
  65603. * Disposes the component and the associated ressources
  65604. */
  65605. dispose(): void;
  65606. private _beforeCameraUpdate;
  65607. }
  65608. }
  65609. declare module "babylonjs/Meshes/Builders/index" {
  65610. export * from "babylonjs/Meshes/Builders/boxBuilder";
  65611. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  65612. export * from "babylonjs/Meshes/Builders/discBuilder";
  65613. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  65614. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  65615. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  65616. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  65617. export * from "babylonjs/Meshes/Builders/torusBuilder";
  65618. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  65619. export * from "babylonjs/Meshes/Builders/linesBuilder";
  65620. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  65621. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  65622. export * from "babylonjs/Meshes/Builders/latheBuilder";
  65623. export * from "babylonjs/Meshes/Builders/planeBuilder";
  65624. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  65625. export * from "babylonjs/Meshes/Builders/groundBuilder";
  65626. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  65627. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  65628. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  65629. export * from "babylonjs/Meshes/Builders/decalBuilder";
  65630. }
  65631. declare module "babylonjs/Meshes/index" {
  65632. export * from "babylonjs/Meshes/abstractMesh";
  65633. export * from "babylonjs/Meshes/buffer";
  65634. export * from "babylonjs/Meshes/Compression/index";
  65635. export * from "babylonjs/Meshes/csg";
  65636. export * from "babylonjs/Meshes/geometry";
  65637. export * from "babylonjs/Meshes/groundMesh";
  65638. export * from "babylonjs/Meshes/trailMesh";
  65639. export * from "babylonjs/Meshes/instancedMesh";
  65640. export * from "babylonjs/Meshes/linesMesh";
  65641. export * from "babylonjs/Meshes/mesh";
  65642. export * from "babylonjs/Meshes/mesh.vertexData";
  65643. export * from "babylonjs/Meshes/meshBuilder";
  65644. export * from "babylonjs/Meshes/meshSimplification";
  65645. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  65646. export * from "babylonjs/Meshes/polygonMesh";
  65647. export * from "babylonjs/Meshes/subMesh";
  65648. export * from "babylonjs/Meshes/meshLODLevel";
  65649. export * from "babylonjs/Meshes/transformNode";
  65650. export * from "babylonjs/Meshes/Builders/index";
  65651. export * from "babylonjs/Meshes/dataBuffer";
  65652. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  65653. }
  65654. declare module "babylonjs/Morph/index" {
  65655. export * from "babylonjs/Morph/morphTarget";
  65656. export * from "babylonjs/Morph/morphTargetManager";
  65657. }
  65658. declare module "babylonjs/Navigation/INavigationEngine" {
  65659. import { TransformNode } from "babylonjs/Meshes/transformNode";
  65660. import { Vector3 } from "babylonjs/Maths/math";
  65661. import { Mesh } from "babylonjs/Meshes/mesh";
  65662. import { Scene } from "babylonjs/scene";
  65663. /**
  65664. * Navigation plugin interface to add navigation constrained by a navigation mesh
  65665. */
  65666. export interface INavigationEnginePlugin {
  65667. /**
  65668. * plugin name
  65669. */
  65670. name: string;
  65671. /**
  65672. * Creates a navigation mesh
  65673. * @param meshes array of all the geometry used to compute the navigatio mesh
  65674. * @param parameters bunch of parameters used to filter geometry
  65675. */
  65676. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  65677. /**
  65678. * Create a navigation mesh debug mesh
  65679. * @param scene is where the mesh will be added
  65680. * @returns debug display mesh
  65681. */
  65682. createDebugNavMesh(scene: Scene): Mesh;
  65683. /**
  65684. * Get a navigation mesh constrained position, closest to the parameter position
  65685. * @param position world position
  65686. * @returns the closest point to position constrained by the navigation mesh
  65687. */
  65688. getClosestPoint(position: Vector3): Vector3;
  65689. /**
  65690. * Get a navigation mesh constrained position, closest to the parameter position
  65691. * @param position world position
  65692. * @param result output the closest point to position constrained by the navigation mesh
  65693. */
  65694. getClosestPointToRef(position: Vector3, result: Vector3): void;
  65695. /**
  65696. * Get a navigation mesh constrained position, within a particular radius
  65697. * @param position world position
  65698. * @param maxRadius the maximum distance to the constrained world position
  65699. * @returns the closest point to position constrained by the navigation mesh
  65700. */
  65701. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  65702. /**
  65703. * Get a navigation mesh constrained position, within a particular radius
  65704. * @param position world position
  65705. * @param maxRadius the maximum distance to the constrained world position
  65706. * @param result output the closest point to position constrained by the navigation mesh
  65707. */
  65708. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  65709. /**
  65710. * Compute the final position from a segment made of destination-position
  65711. * @param position world position
  65712. * @param destination world position
  65713. * @returns the resulting point along the navmesh
  65714. */
  65715. moveAlong(position: Vector3, destination: Vector3): Vector3;
  65716. /**
  65717. * Compute the final position from a segment made of destination-position
  65718. * @param position world position
  65719. * @param destination world position
  65720. * @param result output the resulting point along the navmesh
  65721. */
  65722. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  65723. /**
  65724. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  65725. * @param start world position
  65726. * @param end world position
  65727. * @returns array containing world position composing the path
  65728. */
  65729. computePath(start: Vector3, end: Vector3): Vector3[];
  65730. /**
  65731. * If this plugin is supported
  65732. * @returns true if plugin is supported
  65733. */
  65734. isSupported(): boolean;
  65735. /**
  65736. * Create a new Crowd so you can add agents
  65737. * @param maxAgents the maximum agent count in the crowd
  65738. * @param maxAgentRadius the maximum radius an agent can have
  65739. * @param scene to attach the crowd to
  65740. * @returns the crowd you can add agents to
  65741. */
  65742. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  65743. /**
  65744. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65745. * The queries will try to find a solution within those bounds
  65746. * default is (1,1,1)
  65747. * @param extent x,y,z value that define the extent around the queries point of reference
  65748. */
  65749. setDefaultQueryExtent(extent: Vector3): void;
  65750. /**
  65751. * Get the Bounding box extent specified by setDefaultQueryExtent
  65752. * @returns the box extent values
  65753. */
  65754. getDefaultQueryExtent(): Vector3;
  65755. /**
  65756. * build the navmesh from a previously saved state using getNavmeshData
  65757. * @param data the Uint8Array returned by getNavmeshData
  65758. */
  65759. buildFromNavmeshData(data: Uint8Array): void;
  65760. /**
  65761. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  65762. * @returns data the Uint8Array that can be saved and reused
  65763. */
  65764. getNavmeshData(): Uint8Array;
  65765. /**
  65766. * Get the Bounding box extent result specified by setDefaultQueryExtent
  65767. * @param result output the box extent values
  65768. */
  65769. getDefaultQueryExtentToRef(result: Vector3): void;
  65770. /**
  65771. * Release all resources
  65772. */
  65773. dispose(): void;
  65774. }
  65775. /**
  65776. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  65777. */
  65778. export interface ICrowd {
  65779. /**
  65780. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  65781. * You can attach anything to that node. The node position is updated in the scene update tick.
  65782. * @param pos world position that will be constrained by the navigation mesh
  65783. * @param parameters agent parameters
  65784. * @param transform hooked to the agent that will be update by the scene
  65785. * @returns agent index
  65786. */
  65787. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  65788. /**
  65789. * Returns the agent position in world space
  65790. * @param index agent index returned by addAgent
  65791. * @returns world space position
  65792. */
  65793. getAgentPosition(index: number): Vector3;
  65794. /**
  65795. * Gets the agent position result in world space
  65796. * @param index agent index returned by addAgent
  65797. * @param result output world space position
  65798. */
  65799. getAgentPositionToRef(index: number, result: Vector3): void;
  65800. /**
  65801. * Gets the agent velocity in world space
  65802. * @param index agent index returned by addAgent
  65803. * @returns world space velocity
  65804. */
  65805. getAgentVelocity(index: number): Vector3;
  65806. /**
  65807. * Gets the agent velocity result in world space
  65808. * @param index agent index returned by addAgent
  65809. * @param result output world space velocity
  65810. */
  65811. getAgentVelocityToRef(index: number, result: Vector3): void;
  65812. /**
  65813. * remove a particular agent previously created
  65814. * @param index agent index returned by addAgent
  65815. */
  65816. removeAgent(index: number): void;
  65817. /**
  65818. * get the list of all agents attached to this crowd
  65819. * @returns list of agent indices
  65820. */
  65821. getAgents(): number[];
  65822. /**
  65823. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  65824. * @param deltaTime in seconds
  65825. */
  65826. update(deltaTime: number): void;
  65827. /**
  65828. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  65829. * @param index agent index returned by addAgent
  65830. * @param destination targeted world position
  65831. */
  65832. agentGoto(index: number, destination: Vector3): void;
  65833. /**
  65834. * Teleport the agent to a new position
  65835. * @param index agent index returned by addAgent
  65836. * @param destination targeted world position
  65837. */
  65838. agentTeleport(index: number, destination: Vector3): void;
  65839. /**
  65840. * Update agent parameters
  65841. * @param index agent index returned by addAgent
  65842. * @param parameters agent parameters
  65843. */
  65844. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  65845. /**
  65846. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65847. * The queries will try to find a solution within those bounds
  65848. * default is (1,1,1)
  65849. * @param extent x,y,z value that define the extent around the queries point of reference
  65850. */
  65851. setDefaultQueryExtent(extent: Vector3): void;
  65852. /**
  65853. * Get the Bounding box extent specified by setDefaultQueryExtent
  65854. * @returns the box extent values
  65855. */
  65856. getDefaultQueryExtent(): Vector3;
  65857. /**
  65858. * Get the Bounding box extent result specified by setDefaultQueryExtent
  65859. * @param result output the box extent values
  65860. */
  65861. getDefaultQueryExtentToRef(result: Vector3): void;
  65862. /**
  65863. * Release all resources
  65864. */
  65865. dispose(): void;
  65866. }
  65867. /**
  65868. * Configures an agent
  65869. */
  65870. export interface IAgentParameters {
  65871. /**
  65872. * Agent radius. [Limit: >= 0]
  65873. */
  65874. radius: number;
  65875. /**
  65876. * Agent height. [Limit: > 0]
  65877. */
  65878. height: number;
  65879. /**
  65880. * Maximum allowed acceleration. [Limit: >= 0]
  65881. */
  65882. maxAcceleration: number;
  65883. /**
  65884. * Maximum allowed speed. [Limit: >= 0]
  65885. */
  65886. maxSpeed: number;
  65887. /**
  65888. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  65889. */
  65890. collisionQueryRange: number;
  65891. /**
  65892. * The path visibility optimization range. [Limit: > 0]
  65893. */
  65894. pathOptimizationRange: number;
  65895. /**
  65896. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  65897. */
  65898. separationWeight: number;
  65899. }
  65900. /**
  65901. * Configures the navigation mesh creation
  65902. */
  65903. export interface INavMeshParameters {
  65904. /**
  65905. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  65906. */
  65907. cs: number;
  65908. /**
  65909. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  65910. */
  65911. ch: number;
  65912. /**
  65913. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  65914. */
  65915. walkableSlopeAngle: number;
  65916. /**
  65917. * Minimum floor to 'ceiling' height that will still allow the floor area to
  65918. * be considered walkable. [Limit: >= 3] [Units: vx]
  65919. */
  65920. walkableHeight: number;
  65921. /**
  65922. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  65923. */
  65924. walkableClimb: number;
  65925. /**
  65926. * The distance to erode/shrink the walkable area of the heightfield away from
  65927. * obstructions. [Limit: >=0] [Units: vx]
  65928. */
  65929. walkableRadius: number;
  65930. /**
  65931. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  65932. */
  65933. maxEdgeLen: number;
  65934. /**
  65935. * The maximum distance a simplfied contour's border edges should deviate
  65936. * the original raw contour. [Limit: >=0] [Units: vx]
  65937. */
  65938. maxSimplificationError: number;
  65939. /**
  65940. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  65941. */
  65942. minRegionArea: number;
  65943. /**
  65944. * Any regions with a span count smaller than this value will, if possible,
  65945. * be merged with larger regions. [Limit: >=0] [Units: vx]
  65946. */
  65947. mergeRegionArea: number;
  65948. /**
  65949. * The maximum number of vertices allowed for polygons generated during the
  65950. * contour to polygon conversion process. [Limit: >= 3]
  65951. */
  65952. maxVertsPerPoly: number;
  65953. /**
  65954. * Sets the sampling distance to use when generating the detail mesh.
  65955. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  65956. */
  65957. detailSampleDist: number;
  65958. /**
  65959. * The maximum distance the detail mesh surface should deviate from heightfield
  65960. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  65961. */
  65962. detailSampleMaxError: number;
  65963. }
  65964. }
  65965. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  65966. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  65967. import { Mesh } from "babylonjs/Meshes/mesh";
  65968. import { Scene } from "babylonjs/scene";
  65969. import { Vector3 } from "babylonjs/Maths/math";
  65970. import { TransformNode } from "babylonjs/Meshes/transformNode";
  65971. /**
  65972. * RecastJS navigation plugin
  65973. */
  65974. export class RecastJSPlugin implements INavigationEnginePlugin {
  65975. /**
  65976. * Reference to the Recast library
  65977. */
  65978. bjsRECAST: any;
  65979. /**
  65980. * plugin name
  65981. */
  65982. name: string;
  65983. /**
  65984. * the first navmesh created. We might extend this to support multiple navmeshes
  65985. */
  65986. navMesh: any;
  65987. /**
  65988. * Initializes the recastJS plugin
  65989. * @param recastInjection can be used to inject your own recast reference
  65990. */
  65991. constructor(recastInjection?: any);
  65992. /**
  65993. * Creates a navigation mesh
  65994. * @param meshes array of all the geometry used to compute the navigatio mesh
  65995. * @param parameters bunch of parameters used to filter geometry
  65996. */
  65997. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  65998. /**
  65999. * Create a navigation mesh debug mesh
  66000. * @param scene is where the mesh will be added
  66001. * @returns debug display mesh
  66002. */
  66003. createDebugNavMesh(scene: Scene): Mesh;
  66004. /**
  66005. * Get a navigation mesh constrained position, closest to the parameter position
  66006. * @param position world position
  66007. * @returns the closest point to position constrained by the navigation mesh
  66008. */
  66009. getClosestPoint(position: Vector3): Vector3;
  66010. /**
  66011. * Get a navigation mesh constrained position, closest to the parameter position
  66012. * @param position world position
  66013. * @param result output the closest point to position constrained by the navigation mesh
  66014. */
  66015. getClosestPointToRef(position: Vector3, result: Vector3): void;
  66016. /**
  66017. * Get a navigation mesh constrained position, within a particular radius
  66018. * @param position world position
  66019. * @param maxRadius the maximum distance to the constrained world position
  66020. * @returns the closest point to position constrained by the navigation mesh
  66021. */
  66022. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  66023. /**
  66024. * Get a navigation mesh constrained position, within a particular radius
  66025. * @param position world position
  66026. * @param maxRadius the maximum distance to the constrained world position
  66027. * @param result output the closest point to position constrained by the navigation mesh
  66028. */
  66029. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  66030. /**
  66031. * Compute the final position from a segment made of destination-position
  66032. * @param position world position
  66033. * @param destination world position
  66034. * @returns the resulting point along the navmesh
  66035. */
  66036. moveAlong(position: Vector3, destination: Vector3): Vector3;
  66037. /**
  66038. * Compute the final position from a segment made of destination-position
  66039. * @param position world position
  66040. * @param destination world position
  66041. * @param result output the resulting point along the navmesh
  66042. */
  66043. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  66044. /**
  66045. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  66046. * @param start world position
  66047. * @param end world position
  66048. * @returns array containing world position composing the path
  66049. */
  66050. computePath(start: Vector3, end: Vector3): Vector3[];
  66051. /**
  66052. * Create a new Crowd so you can add agents
  66053. * @param maxAgents the maximum agent count in the crowd
  66054. * @param maxAgentRadius the maximum radius an agent can have
  66055. * @param scene to attach the crowd to
  66056. * @returns the crowd you can add agents to
  66057. */
  66058. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  66059. /**
  66060. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  66061. * The queries will try to find a solution within those bounds
  66062. * default is (1,1,1)
  66063. * @param extent x,y,z value that define the extent around the queries point of reference
  66064. */
  66065. setDefaultQueryExtent(extent: Vector3): void;
  66066. /**
  66067. * Get the Bounding box extent specified by setDefaultQueryExtent
  66068. * @returns the box extent values
  66069. */
  66070. getDefaultQueryExtent(): Vector3;
  66071. /**
  66072. * build the navmesh from a previously saved state using getNavmeshData
  66073. * @param data the Uint8Array returned by getNavmeshData
  66074. */
  66075. buildFromNavmeshData(data: Uint8Array): void;
  66076. /**
  66077. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  66078. * @returns data the Uint8Array that can be saved and reused
  66079. */
  66080. getNavmeshData(): Uint8Array;
  66081. /**
  66082. * Get the Bounding box extent result specified by setDefaultQueryExtent
  66083. * @param result output the box extent values
  66084. */
  66085. getDefaultQueryExtentToRef(result: Vector3): void;
  66086. /**
  66087. * Disposes
  66088. */
  66089. dispose(): void;
  66090. /**
  66091. * If this plugin is supported
  66092. * @returns true if plugin is supported
  66093. */
  66094. isSupported(): boolean;
  66095. }
  66096. /**
  66097. * Recast detour crowd implementation
  66098. */
  66099. export class RecastJSCrowd implements ICrowd {
  66100. /**
  66101. * Recast/detour plugin
  66102. */
  66103. bjsRECASTPlugin: RecastJSPlugin;
  66104. /**
  66105. * Link to the detour crowd
  66106. */
  66107. recastCrowd: any;
  66108. /**
  66109. * One transform per agent
  66110. */
  66111. transforms: TransformNode[];
  66112. /**
  66113. * All agents created
  66114. */
  66115. agents: number[];
  66116. /**
  66117. * Link to the scene is kept to unregister the crowd from the scene
  66118. */
  66119. private _scene;
  66120. /**
  66121. * Observer for crowd updates
  66122. */
  66123. private _onBeforeAnimationsObserver;
  66124. /**
  66125. * Constructor
  66126. * @param plugin recastJS plugin
  66127. * @param maxAgents the maximum agent count in the crowd
  66128. * @param maxAgentRadius the maximum radius an agent can have
  66129. * @param scene to attach the crowd to
  66130. * @returns the crowd you can add agents to
  66131. */
  66132. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  66133. /**
  66134. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  66135. * You can attach anything to that node. The node position is updated in the scene update tick.
  66136. * @param pos world position that will be constrained by the navigation mesh
  66137. * @param parameters agent parameters
  66138. * @param transform hooked to the agent that will be update by the scene
  66139. * @returns agent index
  66140. */
  66141. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  66142. /**
  66143. * Returns the agent position in world space
  66144. * @param index agent index returned by addAgent
  66145. * @returns world space position
  66146. */
  66147. getAgentPosition(index: number): Vector3;
  66148. /**
  66149. * Returns the agent position result in world space
  66150. * @param index agent index returned by addAgent
  66151. * @param result output world space position
  66152. */
  66153. getAgentPositionToRef(index: number, result: Vector3): void;
  66154. /**
  66155. * Returns the agent velocity in world space
  66156. * @param index agent index returned by addAgent
  66157. * @returns world space velocity
  66158. */
  66159. getAgentVelocity(index: number): Vector3;
  66160. /**
  66161. * Returns the agent velocity result in world space
  66162. * @param index agent index returned by addAgent
  66163. * @param result output world space velocity
  66164. */
  66165. getAgentVelocityToRef(index: number, result: Vector3): void;
  66166. /**
  66167. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  66168. * @param index agent index returned by addAgent
  66169. * @param destination targeted world position
  66170. */
  66171. agentGoto(index: number, destination: Vector3): void;
  66172. /**
  66173. * Teleport the agent to a new position
  66174. * @param index agent index returned by addAgent
  66175. * @param destination targeted world position
  66176. */
  66177. agentTeleport(index: number, destination: Vector3): void;
  66178. /**
  66179. * Update agent parameters
  66180. * @param index agent index returned by addAgent
  66181. * @param parameters agent parameters
  66182. */
  66183. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  66184. /**
  66185. * remove a particular agent previously created
  66186. * @param index agent index returned by addAgent
  66187. */
  66188. removeAgent(index: number): void;
  66189. /**
  66190. * get the list of all agents attached to this crowd
  66191. * @returns list of agent indices
  66192. */
  66193. getAgents(): number[];
  66194. /**
  66195. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  66196. * @param deltaTime in seconds
  66197. */
  66198. update(deltaTime: number): void;
  66199. /**
  66200. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  66201. * The queries will try to find a solution within those bounds
  66202. * default is (1,1,1)
  66203. * @param extent x,y,z value that define the extent around the queries point of reference
  66204. */
  66205. setDefaultQueryExtent(extent: Vector3): void;
  66206. /**
  66207. * Get the Bounding box extent specified by setDefaultQueryExtent
  66208. * @returns the box extent values
  66209. */
  66210. getDefaultQueryExtent(): Vector3;
  66211. /**
  66212. * Get the Bounding box extent result specified by setDefaultQueryExtent
  66213. * @param result output the box extent values
  66214. */
  66215. getDefaultQueryExtentToRef(result: Vector3): void;
  66216. /**
  66217. * Release all resources
  66218. */
  66219. dispose(): void;
  66220. }
  66221. }
  66222. declare module "babylonjs/Navigation/Plugins/index" {
  66223. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  66224. }
  66225. declare module "babylonjs/Navigation/index" {
  66226. export * from "babylonjs/Navigation/INavigationEngine";
  66227. export * from "babylonjs/Navigation/Plugins/index";
  66228. }
  66229. declare module "babylonjs/Offline/database" {
  66230. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  66231. /**
  66232. * Class used to enable access to IndexedDB
  66233. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  66234. */
  66235. export class Database implements IOfflineProvider {
  66236. private _callbackManifestChecked;
  66237. private _currentSceneUrl;
  66238. private _db;
  66239. private _enableSceneOffline;
  66240. private _enableTexturesOffline;
  66241. private _manifestVersionFound;
  66242. private _mustUpdateRessources;
  66243. private _hasReachedQuota;
  66244. private _isSupported;
  66245. private _idbFactory;
  66246. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  66247. private static IsUASupportingBlobStorage;
  66248. /**
  66249. * Gets a boolean indicating if Database storate is enabled (off by default)
  66250. */
  66251. static IDBStorageEnabled: boolean;
  66252. /**
  66253. * Gets a boolean indicating if scene must be saved in the database
  66254. */
  66255. get enableSceneOffline(): boolean;
  66256. /**
  66257. * Gets a boolean indicating if textures must be saved in the database
  66258. */
  66259. get enableTexturesOffline(): boolean;
  66260. /**
  66261. * Creates a new Database
  66262. * @param urlToScene defines the url to load the scene
  66263. * @param callbackManifestChecked defines the callback to use when manifest is checked
  66264. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  66265. */
  66266. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  66267. private static _ParseURL;
  66268. private static _ReturnFullUrlLocation;
  66269. private _checkManifestFile;
  66270. /**
  66271. * Open the database and make it available
  66272. * @param successCallback defines the callback to call on success
  66273. * @param errorCallback defines the callback to call on error
  66274. */
  66275. open(successCallback: () => void, errorCallback: () => void): void;
  66276. /**
  66277. * Loads an image from the database
  66278. * @param url defines the url to load from
  66279. * @param image defines the target DOM image
  66280. */
  66281. loadImage(url: string, image: HTMLImageElement): void;
  66282. private _loadImageFromDBAsync;
  66283. private _saveImageIntoDBAsync;
  66284. private _checkVersionFromDB;
  66285. private _loadVersionFromDBAsync;
  66286. private _saveVersionIntoDBAsync;
  66287. /**
  66288. * Loads a file from database
  66289. * @param url defines the URL to load from
  66290. * @param sceneLoaded defines a callback to call on success
  66291. * @param progressCallBack defines a callback to call when progress changed
  66292. * @param errorCallback defines a callback to call on error
  66293. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  66294. */
  66295. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  66296. private _loadFileAsync;
  66297. private _saveFileAsync;
  66298. /**
  66299. * Validates if xhr data is correct
  66300. * @param xhr defines the request to validate
  66301. * @param dataType defines the expected data type
  66302. * @returns true if data is correct
  66303. */
  66304. private static _ValidateXHRData;
  66305. }
  66306. }
  66307. declare module "babylonjs/Offline/index" {
  66308. export * from "babylonjs/Offline/database";
  66309. export * from "babylonjs/Offline/IOfflineProvider";
  66310. }
  66311. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  66312. /** @hidden */
  66313. export var gpuUpdateParticlesPixelShader: {
  66314. name: string;
  66315. shader: string;
  66316. };
  66317. }
  66318. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  66319. /** @hidden */
  66320. export var gpuUpdateParticlesVertexShader: {
  66321. name: string;
  66322. shader: string;
  66323. };
  66324. }
  66325. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  66326. /** @hidden */
  66327. export var clipPlaneFragmentDeclaration2: {
  66328. name: string;
  66329. shader: string;
  66330. };
  66331. }
  66332. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  66333. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  66334. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  66335. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  66336. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  66337. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  66338. /** @hidden */
  66339. export var gpuRenderParticlesPixelShader: {
  66340. name: string;
  66341. shader: string;
  66342. };
  66343. }
  66344. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  66345. /** @hidden */
  66346. export var clipPlaneVertexDeclaration2: {
  66347. name: string;
  66348. shader: string;
  66349. };
  66350. }
  66351. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  66352. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  66353. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  66354. /** @hidden */
  66355. export var gpuRenderParticlesVertexShader: {
  66356. name: string;
  66357. shader: string;
  66358. };
  66359. }
  66360. declare module "babylonjs/Particles/gpuParticleSystem" {
  66361. import { Nullable } from "babylonjs/types";
  66362. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  66363. import { Observable } from "babylonjs/Misc/observable";
  66364. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  66365. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  66366. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  66367. import { Scene, IDisposable } from "babylonjs/scene";
  66368. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  66369. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  66370. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  66371. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  66372. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  66373. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  66374. /**
  66375. * This represents a GPU particle system in Babylon
  66376. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  66377. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  66378. */
  66379. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  66380. /**
  66381. * The layer mask we are rendering the particles through.
  66382. */
  66383. layerMask: number;
  66384. private _capacity;
  66385. private _activeCount;
  66386. private _currentActiveCount;
  66387. private _accumulatedCount;
  66388. private _renderEffect;
  66389. private _updateEffect;
  66390. private _buffer0;
  66391. private _buffer1;
  66392. private _spriteBuffer;
  66393. private _updateVAO;
  66394. private _renderVAO;
  66395. private _targetIndex;
  66396. private _sourceBuffer;
  66397. private _targetBuffer;
  66398. private _engine;
  66399. private _currentRenderId;
  66400. private _started;
  66401. private _stopped;
  66402. private _timeDelta;
  66403. private _randomTexture;
  66404. private _randomTexture2;
  66405. private _attributesStrideSize;
  66406. private _updateEffectOptions;
  66407. private _randomTextureSize;
  66408. private _actualFrame;
  66409. private readonly _rawTextureWidth;
  66410. /**
  66411. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  66412. */
  66413. static get IsSupported(): boolean;
  66414. /**
  66415. * An event triggered when the system is disposed.
  66416. */
  66417. onDisposeObservable: Observable<GPUParticleSystem>;
  66418. /**
  66419. * Gets the maximum number of particles active at the same time.
  66420. * @returns The max number of active particles.
  66421. */
  66422. getCapacity(): number;
  66423. /**
  66424. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  66425. * to override the particles.
  66426. */
  66427. forceDepthWrite: boolean;
  66428. /**
  66429. * Gets or set the number of active particles
  66430. */
  66431. get activeParticleCount(): number;
  66432. set activeParticleCount(value: number);
  66433. private _preWarmDone;
  66434. /**
  66435. * Specifies if the particles are updated in emitter local space or world space.
  66436. * This is always false for GPU particles
  66437. */
  66438. get isLocal(): boolean;
  66439. set isLocal(value: boolean);
  66440. /**
  66441. * Is this system ready to be used/rendered
  66442. * @return true if the system is ready
  66443. */
  66444. isReady(): boolean;
  66445. /**
  66446. * Gets if the system has been started. (Note: this will still be true after stop is called)
  66447. * @returns True if it has been started, otherwise false.
  66448. */
  66449. isStarted(): boolean;
  66450. /**
  66451. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  66452. * @returns True if it has been stopped, otherwise false.
  66453. */
  66454. isStopped(): boolean;
  66455. /**
  66456. * Gets a boolean indicating that the system is stopping
  66457. * @returns true if the system is currently stopping
  66458. */
  66459. isStopping(): boolean;
  66460. /**
  66461. * Gets the number of particles active at the same time.
  66462. * @returns The number of active particles.
  66463. */
  66464. getActiveCount(): number;
  66465. /**
  66466. * Starts the particle system and begins to emit
  66467. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  66468. */
  66469. start(delay?: number): void;
  66470. /**
  66471. * Stops the particle system.
  66472. */
  66473. stop(): void;
  66474. /**
  66475. * Remove all active particles
  66476. */
  66477. reset(): void;
  66478. /**
  66479. * Returns the string "GPUParticleSystem"
  66480. * @returns a string containing the class name
  66481. */
  66482. getClassName(): string;
  66483. private _colorGradientsTexture;
  66484. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  66485. /**
  66486. * Adds a new color gradient
  66487. * @param gradient defines the gradient to use (between 0 and 1)
  66488. * @param color1 defines the color to affect to the specified gradient
  66489. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  66490. * @returns the current particle system
  66491. */
  66492. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  66493. private _refreshColorGradient;
  66494. /** Force the system to rebuild all gradients that need to be resync */
  66495. forceRefreshGradients(): void;
  66496. /**
  66497. * Remove a specific color gradient
  66498. * @param gradient defines the gradient to remove
  66499. * @returns the current particle system
  66500. */
  66501. removeColorGradient(gradient: number): GPUParticleSystem;
  66502. private _angularSpeedGradientsTexture;
  66503. private _sizeGradientsTexture;
  66504. private _velocityGradientsTexture;
  66505. private _limitVelocityGradientsTexture;
  66506. private _dragGradientsTexture;
  66507. private _addFactorGradient;
  66508. /**
  66509. * Adds a new size gradient
  66510. * @param gradient defines the gradient to use (between 0 and 1)
  66511. * @param factor defines the size factor to affect to the specified gradient
  66512. * @returns the current particle system
  66513. */
  66514. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  66515. /**
  66516. * Remove a specific size gradient
  66517. * @param gradient defines the gradient to remove
  66518. * @returns the current particle system
  66519. */
  66520. removeSizeGradient(gradient: number): GPUParticleSystem;
  66521. private _refreshFactorGradient;
  66522. /**
  66523. * Adds a new angular speed gradient
  66524. * @param gradient defines the gradient to use (between 0 and 1)
  66525. * @param factor defines the angular speed to affect to the specified gradient
  66526. * @returns the current particle system
  66527. */
  66528. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  66529. /**
  66530. * Remove a specific angular speed gradient
  66531. * @param gradient defines the gradient to remove
  66532. * @returns the current particle system
  66533. */
  66534. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  66535. /**
  66536. * Adds a new velocity gradient
  66537. * @param gradient defines the gradient to use (between 0 and 1)
  66538. * @param factor defines the velocity to affect to the specified gradient
  66539. * @returns the current particle system
  66540. */
  66541. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  66542. /**
  66543. * Remove a specific velocity gradient
  66544. * @param gradient defines the gradient to remove
  66545. * @returns the current particle system
  66546. */
  66547. removeVelocityGradient(gradient: number): GPUParticleSystem;
  66548. /**
  66549. * Adds a new limit velocity gradient
  66550. * @param gradient defines the gradient to use (between 0 and 1)
  66551. * @param factor defines the limit velocity value to affect to the specified gradient
  66552. * @returns the current particle system
  66553. */
  66554. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  66555. /**
  66556. * Remove a specific limit velocity gradient
  66557. * @param gradient defines the gradient to remove
  66558. * @returns the current particle system
  66559. */
  66560. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  66561. /**
  66562. * Adds a new drag gradient
  66563. * @param gradient defines the gradient to use (between 0 and 1)
  66564. * @param factor defines the drag value to affect to the specified gradient
  66565. * @returns the current particle system
  66566. */
  66567. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  66568. /**
  66569. * Remove a specific drag gradient
  66570. * @param gradient defines the gradient to remove
  66571. * @returns the current particle system
  66572. */
  66573. removeDragGradient(gradient: number): GPUParticleSystem;
  66574. /**
  66575. * Not supported by GPUParticleSystem
  66576. * @param gradient defines the gradient to use (between 0 and 1)
  66577. * @param factor defines the emit rate value to affect to the specified gradient
  66578. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  66579. * @returns the current particle system
  66580. */
  66581. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  66582. /**
  66583. * Not supported by GPUParticleSystem
  66584. * @param gradient defines the gradient to remove
  66585. * @returns the current particle system
  66586. */
  66587. removeEmitRateGradient(gradient: number): IParticleSystem;
  66588. /**
  66589. * Not supported by GPUParticleSystem
  66590. * @param gradient defines the gradient to use (between 0 and 1)
  66591. * @param factor defines the start size value to affect to the specified gradient
  66592. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  66593. * @returns the current particle system
  66594. */
  66595. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  66596. /**
  66597. * Not supported by GPUParticleSystem
  66598. * @param gradient defines the gradient to remove
  66599. * @returns the current particle system
  66600. */
  66601. removeStartSizeGradient(gradient: number): IParticleSystem;
  66602. /**
  66603. * Not supported by GPUParticleSystem
  66604. * @param gradient defines the gradient to use (between 0 and 1)
  66605. * @param min defines the color remap minimal range
  66606. * @param max defines the color remap maximal range
  66607. * @returns the current particle system
  66608. */
  66609. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  66610. /**
  66611. * Not supported by GPUParticleSystem
  66612. * @param gradient defines the gradient to remove
  66613. * @returns the current particle system
  66614. */
  66615. removeColorRemapGradient(): IParticleSystem;
  66616. /**
  66617. * Not supported by GPUParticleSystem
  66618. * @param gradient defines the gradient to use (between 0 and 1)
  66619. * @param min defines the alpha remap minimal range
  66620. * @param max defines the alpha remap maximal range
  66621. * @returns the current particle system
  66622. */
  66623. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  66624. /**
  66625. * Not supported by GPUParticleSystem
  66626. * @param gradient defines the gradient to remove
  66627. * @returns the current particle system
  66628. */
  66629. removeAlphaRemapGradient(): IParticleSystem;
  66630. /**
  66631. * Not supported by GPUParticleSystem
  66632. * @param gradient defines the gradient to use (between 0 and 1)
  66633. * @param color defines the color to affect to the specified gradient
  66634. * @returns the current particle system
  66635. */
  66636. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  66637. /**
  66638. * Not supported by GPUParticleSystem
  66639. * @param gradient defines the gradient to remove
  66640. * @returns the current particle system
  66641. */
  66642. removeRampGradient(): IParticleSystem;
  66643. /**
  66644. * Not supported by GPUParticleSystem
  66645. * @returns the list of ramp gradients
  66646. */
  66647. getRampGradients(): Nullable<Array<Color3Gradient>>;
  66648. /**
  66649. * Not supported by GPUParticleSystem
  66650. * Gets or sets a boolean indicating that ramp gradients must be used
  66651. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  66652. */
  66653. get useRampGradients(): boolean;
  66654. set useRampGradients(value: boolean);
  66655. /**
  66656. * Not supported by GPUParticleSystem
  66657. * @param gradient defines the gradient to use (between 0 and 1)
  66658. * @param factor defines the life time factor to affect to the specified gradient
  66659. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  66660. * @returns the current particle system
  66661. */
  66662. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  66663. /**
  66664. * Not supported by GPUParticleSystem
  66665. * @param gradient defines the gradient to remove
  66666. * @returns the current particle system
  66667. */
  66668. removeLifeTimeGradient(gradient: number): IParticleSystem;
  66669. /**
  66670. * Instantiates a GPU particle system.
  66671. * 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.
  66672. * @param name The name of the particle system
  66673. * @param options The options used to create the system
  66674. * @param scene The scene the particle system belongs to
  66675. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  66676. */
  66677. constructor(name: string, options: Partial<{
  66678. capacity: number;
  66679. randomTextureSize: number;
  66680. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  66681. protected _reset(): void;
  66682. private _createUpdateVAO;
  66683. private _createRenderVAO;
  66684. private _initialize;
  66685. /** @hidden */
  66686. _recreateUpdateEffect(): void;
  66687. /** @hidden */
  66688. _recreateRenderEffect(): void;
  66689. /**
  66690. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  66691. * @param preWarm defines if we are in the pre-warmimg phase
  66692. */
  66693. animate(preWarm?: boolean): void;
  66694. private _createFactorGradientTexture;
  66695. private _createSizeGradientTexture;
  66696. private _createAngularSpeedGradientTexture;
  66697. private _createVelocityGradientTexture;
  66698. private _createLimitVelocityGradientTexture;
  66699. private _createDragGradientTexture;
  66700. private _createColorGradientTexture;
  66701. /**
  66702. * Renders the particle system in its current state
  66703. * @param preWarm defines if the system should only update the particles but not render them
  66704. * @returns the current number of particles
  66705. */
  66706. render(preWarm?: boolean): number;
  66707. /**
  66708. * Rebuilds the particle system
  66709. */
  66710. rebuild(): void;
  66711. private _releaseBuffers;
  66712. private _releaseVAOs;
  66713. /**
  66714. * Disposes the particle system and free the associated resources
  66715. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  66716. */
  66717. dispose(disposeTexture?: boolean): void;
  66718. /**
  66719. * Clones the particle system.
  66720. * @param name The name of the cloned object
  66721. * @param newEmitter The new emitter to use
  66722. * @returns the cloned particle system
  66723. */
  66724. clone(name: string, newEmitter: any): GPUParticleSystem;
  66725. /**
  66726. * Serializes the particle system to a JSON object
  66727. * @param serializeTexture defines if the texture must be serialized as well
  66728. * @returns the JSON object
  66729. */
  66730. serialize(serializeTexture?: boolean): any;
  66731. /**
  66732. * Parses a JSON object to create a GPU particle system.
  66733. * @param parsedParticleSystem The JSON object to parse
  66734. * @param scene The scene to create the particle system in
  66735. * @param rootUrl The root url to use to load external dependencies like texture
  66736. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  66737. * @returns the parsed GPU particle system
  66738. */
  66739. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  66740. }
  66741. }
  66742. declare module "babylonjs/Particles/particleSystemSet" {
  66743. import { Nullable } from "babylonjs/types";
  66744. import { Color3 } from "babylonjs/Maths/math.color";
  66745. import { TransformNode } from "babylonjs/Meshes/transformNode";
  66746. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66747. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  66748. import { Scene, IDisposable } from "babylonjs/scene";
  66749. /**
  66750. * Represents a set of particle systems working together to create a specific effect
  66751. */
  66752. export class ParticleSystemSet implements IDisposable {
  66753. /**
  66754. * Gets or sets base Assets URL
  66755. */
  66756. static BaseAssetsUrl: string;
  66757. private _emitterCreationOptions;
  66758. private _emitterNode;
  66759. /**
  66760. * Gets the particle system list
  66761. */
  66762. systems: IParticleSystem[];
  66763. /**
  66764. * Gets the emitter node used with this set
  66765. */
  66766. get emitterNode(): Nullable<TransformNode>;
  66767. /**
  66768. * Creates a new emitter mesh as a sphere
  66769. * @param options defines the options used to create the sphere
  66770. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  66771. * @param scene defines the hosting scene
  66772. */
  66773. setEmitterAsSphere(options: {
  66774. diameter: number;
  66775. segments: number;
  66776. color: Color3;
  66777. }, renderingGroupId: number, scene: Scene): void;
  66778. /**
  66779. * Starts all particle systems of the set
  66780. * @param emitter defines an optional mesh to use as emitter for the particle systems
  66781. */
  66782. start(emitter?: AbstractMesh): void;
  66783. /**
  66784. * Release all associated resources
  66785. */
  66786. dispose(): void;
  66787. /**
  66788. * Serialize the set into a JSON compatible object
  66789. * @param serializeTexture defines if the texture must be serialized as well
  66790. * @returns a JSON compatible representation of the set
  66791. */
  66792. serialize(serializeTexture?: boolean): any;
  66793. /**
  66794. * Parse a new ParticleSystemSet from a serialized source
  66795. * @param data defines a JSON compatible representation of the set
  66796. * @param scene defines the hosting scene
  66797. * @param gpu defines if we want GPU particles or CPU particles
  66798. * @returns a new ParticleSystemSet
  66799. */
  66800. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  66801. }
  66802. }
  66803. declare module "babylonjs/Particles/particleHelper" {
  66804. import { Nullable } from "babylonjs/types";
  66805. import { Scene } from "babylonjs/scene";
  66806. import { Vector3 } from "babylonjs/Maths/math.vector";
  66807. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66808. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  66809. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  66810. /**
  66811. * This class is made for on one-liner static method to help creating particle system set.
  66812. */
  66813. export class ParticleHelper {
  66814. /**
  66815. * Gets or sets base Assets URL
  66816. */
  66817. static BaseAssetsUrl: string;
  66818. /** Define the Url to load snippets */
  66819. static SnippetUrl: string;
  66820. /**
  66821. * Create a default particle system that you can tweak
  66822. * @param emitter defines the emitter to use
  66823. * @param capacity defines the system capacity (default is 500 particles)
  66824. * @param scene defines the hosting scene
  66825. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  66826. * @returns the new Particle system
  66827. */
  66828. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  66829. /**
  66830. * This is the main static method (one-liner) of this helper to create different particle systems
  66831. * @param type This string represents the type to the particle system to create
  66832. * @param scene The scene where the particle system should live
  66833. * @param gpu If the system will use gpu
  66834. * @returns the ParticleSystemSet created
  66835. */
  66836. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  66837. /**
  66838. * Static function used to export a particle system to a ParticleSystemSet variable.
  66839. * Please note that the emitter shape is not exported
  66840. * @param systems defines the particle systems to export
  66841. * @returns the created particle system set
  66842. */
  66843. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  66844. /**
  66845. * Creates a particle system from a snippet saved in a remote file
  66846. * @param name defines the name of the particle system to create
  66847. * @param url defines the url to load from
  66848. * @param scene defines the hosting scene
  66849. * @param gpu If the system will use gpu
  66850. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  66851. * @returns a promise that will resolve to the new particle system
  66852. */
  66853. static ParseFromFileAsync(name: string, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  66854. /**
  66855. * Creates a particle system from a snippet saved by the particle system editor
  66856. * @param snippetId defines the snippet to load
  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 CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  66863. }
  66864. }
  66865. declare module "babylonjs/Particles/particleSystemComponent" {
  66866. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  66867. import { Effect } from "babylonjs/Materials/effect";
  66868. import "babylonjs/Shaders/particles.vertex";
  66869. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  66870. module "babylonjs/Engines/engine" {
  66871. interface Engine {
  66872. /**
  66873. * Create an effect to use with particle systems.
  66874. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  66875. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  66876. * @param uniformsNames defines a list of attribute names
  66877. * @param samplers defines an array of string used to represent textures
  66878. * @param defines defines the string containing the defines to use to compile the shaders
  66879. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  66880. * @param onCompiled defines a function to call when the effect creation is successful
  66881. * @param onError defines a function to call when the effect creation has failed
  66882. * @returns the new Effect
  66883. */
  66884. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  66885. }
  66886. }
  66887. module "babylonjs/Meshes/mesh" {
  66888. interface Mesh {
  66889. /**
  66890. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  66891. * @returns an array of IParticleSystem
  66892. */
  66893. getEmittedParticleSystems(): IParticleSystem[];
  66894. /**
  66895. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  66896. * @returns an array of IParticleSystem
  66897. */
  66898. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  66899. }
  66900. }
  66901. /**
  66902. * @hidden
  66903. */
  66904. export var _IDoNeedToBeInTheBuild: number;
  66905. }
  66906. declare module "babylonjs/Particles/pointsCloudSystem" {
  66907. import { Color4 } from "babylonjs/Maths/math";
  66908. import { Mesh } from "babylonjs/Meshes/mesh";
  66909. import { Scene, IDisposable } from "babylonjs/scene";
  66910. import { CloudPoint } from "babylonjs/Particles/cloudPoint";
  66911. /** Defines the 4 color options */
  66912. export enum PointColor {
  66913. /** color value */
  66914. Color = 2,
  66915. /** uv value */
  66916. UV = 1,
  66917. /** random value */
  66918. Random = 0,
  66919. /** stated value */
  66920. Stated = 3
  66921. }
  66922. /**
  66923. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  66924. * 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.
  66925. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  66926. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  66927. *
  66928. * Full documentation here : TO BE ENTERED
  66929. */
  66930. export class PointsCloudSystem implements IDisposable {
  66931. /**
  66932. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  66933. * Example : var p = SPS.particles[i];
  66934. */
  66935. particles: CloudPoint[];
  66936. /**
  66937. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  66938. */
  66939. nbParticles: number;
  66940. /**
  66941. * This a counter for your own usage. It's not set by any SPS functions.
  66942. */
  66943. counter: number;
  66944. /**
  66945. * The PCS name. This name is also given to the underlying mesh.
  66946. */
  66947. name: string;
  66948. /**
  66949. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  66950. */
  66951. mesh: Mesh;
  66952. /**
  66953. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  66954. * Please read :
  66955. */
  66956. vars: any;
  66957. /**
  66958. * @hidden
  66959. */
  66960. _size: number;
  66961. private _scene;
  66962. private _promises;
  66963. private _positions;
  66964. private _indices;
  66965. private _normals;
  66966. private _colors;
  66967. private _uvs;
  66968. private _indices32;
  66969. private _positions32;
  66970. private _colors32;
  66971. private _uvs32;
  66972. private _updatable;
  66973. private _isVisibilityBoxLocked;
  66974. private _alwaysVisible;
  66975. private _groups;
  66976. private _groupCounter;
  66977. private _computeParticleColor;
  66978. private _computeParticleTexture;
  66979. private _computeParticleRotation;
  66980. private _computeBoundingBox;
  66981. private _isReady;
  66982. /**
  66983. * Creates a PCS (Points Cloud System) object
  66984. * @param name (String) is the PCS name, this will be the underlying mesh name
  66985. * @param pointSize (number) is the size for each point
  66986. * @param scene (Scene) is the scene in which the PCS is added
  66987. * @param options defines the options of the PCS e.g.
  66988. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  66989. */
  66990. constructor(name: string, pointSize: number, scene: Scene, options?: {
  66991. updatable?: boolean;
  66992. });
  66993. /**
  66994. * Builds the PCS underlying mesh. Returns a standard Mesh.
  66995. * If no points were added to the PCS, the returned mesh is just a single point.
  66996. * @returns a promise for the created mesh
  66997. */
  66998. buildMeshAsync(): Promise<Mesh>;
  66999. /**
  67000. * @hidden
  67001. */
  67002. private _buildMesh;
  67003. private _addParticle;
  67004. private _randomUnitVector;
  67005. private _getColorIndicesForCoord;
  67006. private _setPointsColorOrUV;
  67007. private _colorFromTexture;
  67008. private _calculateDensity;
  67009. /**
  67010. * Adds points to the PCS in random positions within a unit sphere
  67011. * @param nb (positive integer) the number of particles to be created from this model
  67012. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  67013. * @returns the number of groups in the system
  67014. */
  67015. addPoints(nb: number, pointFunction?: any): number;
  67016. /**
  67017. * Adds points to the PCS from the surface of the model shape
  67018. * @param mesh is any Mesh object that will be used as a surface model for the points
  67019. * @param nb (positive integer) the number of particles to be created from this model
  67020. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  67021. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  67022. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  67023. * @returns the number of groups in the system
  67024. */
  67025. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  67026. /**
  67027. * Adds points to the PCS inside the model shape
  67028. * @param mesh is any Mesh object that will be used as a surface model for the points
  67029. * @param nb (positive integer) the number of particles to be created from this model
  67030. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  67031. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  67032. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  67033. * @returns the number of groups in the system
  67034. */
  67035. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  67036. /**
  67037. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  67038. * This method calls `updateParticle()` for each particle of the SPS.
  67039. * For an animated SPS, it is usually called within the render loop.
  67040. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  67041. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  67042. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  67043. * @returns the PCS.
  67044. */
  67045. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  67046. /**
  67047. * Disposes the PCS.
  67048. */
  67049. dispose(): void;
  67050. /**
  67051. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  67052. * doc :
  67053. * @returns the PCS.
  67054. */
  67055. refreshVisibleSize(): PointsCloudSystem;
  67056. /**
  67057. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  67058. * @param size the size (float) of the visibility box
  67059. * note : this doesn't lock the PCS mesh bounding box.
  67060. * doc :
  67061. */
  67062. setVisibilityBox(size: number): void;
  67063. /**
  67064. * Gets whether the PCS is always visible or not
  67065. * doc :
  67066. */
  67067. get isAlwaysVisible(): boolean;
  67068. /**
  67069. * Sets the PCS as always visible or not
  67070. * doc :
  67071. */
  67072. set isAlwaysVisible(val: boolean);
  67073. /**
  67074. * Tells to `setParticles()` to compute the particle rotations or not
  67075. * Default value : false. The PCS is faster when it's set to false
  67076. * Note : particle rotations are only applied to parent particles
  67077. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  67078. */
  67079. set computeParticleRotation(val: boolean);
  67080. /**
  67081. * Tells to `setParticles()` to compute the particle colors or not.
  67082. * Default value : true. The PCS is faster when it's set to false.
  67083. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  67084. */
  67085. set computeParticleColor(val: boolean);
  67086. set computeParticleTexture(val: boolean);
  67087. /**
  67088. * Gets if `setParticles()` computes the particle colors or not.
  67089. * Default value : false. The PCS is faster when it's set to false.
  67090. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  67091. */
  67092. get computeParticleColor(): boolean;
  67093. /**
  67094. * Gets if `setParticles()` computes the particle textures or not.
  67095. * Default value : false. The PCS is faster when it's set to false.
  67096. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  67097. */
  67098. get computeParticleTexture(): boolean;
  67099. /**
  67100. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  67101. */
  67102. set computeBoundingBox(val: boolean);
  67103. /**
  67104. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  67105. */
  67106. get computeBoundingBox(): boolean;
  67107. /**
  67108. * This function does nothing. It may be overwritten to set all the particle first values.
  67109. * The PCS doesn't call this function, you may have to call it by your own.
  67110. * doc :
  67111. */
  67112. initParticles(): void;
  67113. /**
  67114. * This function does nothing. It may be overwritten to recycle a particle
  67115. * The PCS doesn't call this function, you can to call it
  67116. * doc :
  67117. * @param particle The particle to recycle
  67118. * @returns the recycled particle
  67119. */
  67120. recycleParticle(particle: CloudPoint): CloudPoint;
  67121. /**
  67122. * Updates a particle : this function should be overwritten by the user.
  67123. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  67124. * doc :
  67125. * @example : just set a particle position or velocity and recycle conditions
  67126. * @param particle The particle to update
  67127. * @returns the updated particle
  67128. */
  67129. updateParticle(particle: CloudPoint): CloudPoint;
  67130. /**
  67131. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  67132. * This does nothing and may be overwritten by the user.
  67133. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  67134. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  67135. * @param update the boolean update value actually passed to setParticles()
  67136. */
  67137. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  67138. /**
  67139. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  67140. * This 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. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  67147. }
  67148. }
  67149. declare module "babylonjs/Particles/cloudPoint" {
  67150. import { Nullable } from "babylonjs/types";
  67151. import { Color4, Vector2, Vector3, Matrix, Quaternion } from "babylonjs/Maths/math";
  67152. import { Mesh } from "babylonjs/Meshes/mesh";
  67153. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  67154. import { PointsCloudSystem } from "babylonjs/Particles/pointsCloudSystem";
  67155. /**
  67156. * Represents one particle of a points cloud system.
  67157. */
  67158. export class CloudPoint {
  67159. /**
  67160. * particle global index
  67161. */
  67162. idx: number;
  67163. /**
  67164. * The color of the particle
  67165. */
  67166. color: Nullable<Color4>;
  67167. /**
  67168. * The world space position of the particle.
  67169. */
  67170. position: Vector3;
  67171. /**
  67172. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  67173. */
  67174. rotation: Vector3;
  67175. /**
  67176. * The world space rotation quaternion of the particle.
  67177. */
  67178. rotationQuaternion: Nullable<Quaternion>;
  67179. /**
  67180. * The uv of the particle.
  67181. */
  67182. uv: Nullable<Vector2>;
  67183. /**
  67184. * The current speed of the particle.
  67185. */
  67186. velocity: Vector3;
  67187. /**
  67188. * The pivot point in the particle local space.
  67189. */
  67190. pivot: Vector3;
  67191. /**
  67192. * Must the particle be translated from its pivot point in its local space ?
  67193. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  67194. * Default : false
  67195. */
  67196. translateFromPivot: boolean;
  67197. /**
  67198. * Index of this particle in the global "positions" array (Internal use)
  67199. * @hidden
  67200. */
  67201. _pos: number;
  67202. /**
  67203. * @hidden Index of this particle in the global "indices" array (Internal use)
  67204. */
  67205. _ind: number;
  67206. /**
  67207. * Group this particle belongs to
  67208. */
  67209. _group: PointsGroup;
  67210. /**
  67211. * Group id of this particle
  67212. */
  67213. groupId: number;
  67214. /**
  67215. * Index of the particle in its group id (Internal use)
  67216. */
  67217. idxInGroup: number;
  67218. /**
  67219. * @hidden Particle BoundingInfo object (Internal use)
  67220. */
  67221. _boundingInfo: BoundingInfo;
  67222. /**
  67223. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  67224. */
  67225. _pcs: PointsCloudSystem;
  67226. /**
  67227. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  67228. */
  67229. _stillInvisible: boolean;
  67230. /**
  67231. * @hidden Last computed particle rotation matrix
  67232. */
  67233. _rotationMatrix: number[];
  67234. /**
  67235. * Parent particle Id, if any.
  67236. * Default null.
  67237. */
  67238. parentId: Nullable<number>;
  67239. /**
  67240. * @hidden Internal global position in the PCS.
  67241. */
  67242. _globalPosition: Vector3;
  67243. /**
  67244. * Creates a Point Cloud object.
  67245. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  67246. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  67247. * @param group (PointsGroup) is the group the particle belongs to
  67248. * @param groupId (integer) is the group identifier in the PCS.
  67249. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  67250. * @param pcs defines the PCS it is associated to
  67251. */
  67252. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  67253. /**
  67254. * get point size
  67255. */
  67256. get size(): Vector3;
  67257. /**
  67258. * Set point size
  67259. */
  67260. set size(scale: Vector3);
  67261. /**
  67262. * Legacy support, changed quaternion to rotationQuaternion
  67263. */
  67264. get quaternion(): Nullable<Quaternion>;
  67265. /**
  67266. * Legacy support, changed quaternion to rotationQuaternion
  67267. */
  67268. set quaternion(q: Nullable<Quaternion>);
  67269. /**
  67270. * Returns a boolean. True if the particle intersects a mesh, else false
  67271. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  67272. * @param target is the object (point or mesh) what the intersection is computed against
  67273. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  67274. * @returns true if it intersects
  67275. */
  67276. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  67277. /**
  67278. * get the rotation matrix of the particle
  67279. * @hidden
  67280. */
  67281. getRotationMatrix(m: Matrix): void;
  67282. }
  67283. /**
  67284. * Represents a group of points in a points cloud system
  67285. * * PCS internal tool, don't use it manually.
  67286. */
  67287. export class PointsGroup {
  67288. /**
  67289. * The group id
  67290. * @hidden
  67291. */
  67292. groupID: number;
  67293. /**
  67294. * image data for group (internal use)
  67295. * @hidden
  67296. */
  67297. _groupImageData: Nullable<ArrayBufferView>;
  67298. /**
  67299. * Image Width (internal use)
  67300. * @hidden
  67301. */
  67302. _groupImgWidth: number;
  67303. /**
  67304. * Image Height (internal use)
  67305. * @hidden
  67306. */
  67307. _groupImgHeight: number;
  67308. /**
  67309. * Custom position function (internal use)
  67310. * @hidden
  67311. */
  67312. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  67313. /**
  67314. * density per facet for surface points
  67315. * @hidden
  67316. */
  67317. _groupDensity: number[];
  67318. /**
  67319. * Only when points are colored by texture carries pointer to texture list array
  67320. * @hidden
  67321. */
  67322. _textureNb: number;
  67323. /**
  67324. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  67325. * PCS internal tool, don't use it manually.
  67326. * @hidden
  67327. */
  67328. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  67329. }
  67330. }
  67331. declare module "babylonjs/Particles/index" {
  67332. export * from "babylonjs/Particles/baseParticleSystem";
  67333. export * from "babylonjs/Particles/EmitterTypes/index";
  67334. export * from "babylonjs/Particles/gpuParticleSystem";
  67335. export * from "babylonjs/Particles/IParticleSystem";
  67336. export * from "babylonjs/Particles/particle";
  67337. export * from "babylonjs/Particles/particleHelper";
  67338. export * from "babylonjs/Particles/particleSystem";
  67339. export * from "babylonjs/Particles/particleSystemComponent";
  67340. export * from "babylonjs/Particles/particleSystemSet";
  67341. export * from "babylonjs/Particles/solidParticle";
  67342. export * from "babylonjs/Particles/solidParticleSystem";
  67343. export * from "babylonjs/Particles/cloudPoint";
  67344. export * from "babylonjs/Particles/pointsCloudSystem";
  67345. export * from "babylonjs/Particles/subEmitter";
  67346. }
  67347. declare module "babylonjs/Physics/physicsEngineComponent" {
  67348. import { Nullable } from "babylonjs/types";
  67349. import { Observable, Observer } from "babylonjs/Misc/observable";
  67350. import { Vector3 } from "babylonjs/Maths/math.vector";
  67351. import { Mesh } from "babylonjs/Meshes/mesh";
  67352. import { ISceneComponent } from "babylonjs/sceneComponent";
  67353. import { Scene } from "babylonjs/scene";
  67354. import { Node } from "babylonjs/node";
  67355. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  67356. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  67357. module "babylonjs/scene" {
  67358. interface Scene {
  67359. /** @hidden (Backing field) */
  67360. _physicsEngine: Nullable<IPhysicsEngine>;
  67361. /** @hidden */
  67362. _physicsTimeAccumulator: number;
  67363. /**
  67364. * Gets the current physics engine
  67365. * @returns a IPhysicsEngine or null if none attached
  67366. */
  67367. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  67368. /**
  67369. * Enables physics to the current scene
  67370. * @param gravity defines the scene's gravity for the physics engine
  67371. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  67372. * @return a boolean indicating if the physics engine was initialized
  67373. */
  67374. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  67375. /**
  67376. * Disables and disposes the physics engine associated with the scene
  67377. */
  67378. disablePhysicsEngine(): void;
  67379. /**
  67380. * Gets a boolean indicating if there is an active physics engine
  67381. * @returns a boolean indicating if there is an active physics engine
  67382. */
  67383. isPhysicsEnabled(): boolean;
  67384. /**
  67385. * Deletes a physics compound impostor
  67386. * @param compound defines the compound to delete
  67387. */
  67388. deleteCompoundImpostor(compound: any): void;
  67389. /**
  67390. * An event triggered when physic simulation is about to be run
  67391. */
  67392. onBeforePhysicsObservable: Observable<Scene>;
  67393. /**
  67394. * An event triggered when physic simulation has been done
  67395. */
  67396. onAfterPhysicsObservable: Observable<Scene>;
  67397. }
  67398. }
  67399. module "babylonjs/Meshes/abstractMesh" {
  67400. interface AbstractMesh {
  67401. /** @hidden */
  67402. _physicsImpostor: Nullable<PhysicsImpostor>;
  67403. /**
  67404. * Gets or sets impostor used for physic simulation
  67405. * @see http://doc.babylonjs.com/features/physics_engine
  67406. */
  67407. physicsImpostor: Nullable<PhysicsImpostor>;
  67408. /**
  67409. * Gets the current physics impostor
  67410. * @see http://doc.babylonjs.com/features/physics_engine
  67411. * @returns a physics impostor or null
  67412. */
  67413. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  67414. /** Apply a physic impulse to the mesh
  67415. * @param force defines the force to apply
  67416. * @param contactPoint defines where to apply the force
  67417. * @returns the current mesh
  67418. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  67419. */
  67420. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  67421. /**
  67422. * Creates a physic joint between two meshes
  67423. * @param otherMesh defines the other mesh to use
  67424. * @param pivot1 defines the pivot to use on this mesh
  67425. * @param pivot2 defines the pivot to use on the other mesh
  67426. * @param options defines additional options (can be plugin dependent)
  67427. * @returns the current mesh
  67428. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  67429. */
  67430. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  67431. /** @hidden */
  67432. _disposePhysicsObserver: Nullable<Observer<Node>>;
  67433. }
  67434. }
  67435. /**
  67436. * Defines the physics engine scene component responsible to manage a physics engine
  67437. */
  67438. export class PhysicsEngineSceneComponent implements ISceneComponent {
  67439. /**
  67440. * The component name helpful to identify the component in the list of scene components.
  67441. */
  67442. readonly name: string;
  67443. /**
  67444. * The scene the component belongs to.
  67445. */
  67446. scene: Scene;
  67447. /**
  67448. * Creates a new instance of the component for the given scene
  67449. * @param scene Defines the scene to register the component in
  67450. */
  67451. constructor(scene: Scene);
  67452. /**
  67453. * Registers the component in a given scene
  67454. */
  67455. register(): void;
  67456. /**
  67457. * Rebuilds the elements related to this component in case of
  67458. * context lost for instance.
  67459. */
  67460. rebuild(): void;
  67461. /**
  67462. * Disposes the component and the associated ressources
  67463. */
  67464. dispose(): void;
  67465. }
  67466. }
  67467. declare module "babylonjs/Physics/physicsHelper" {
  67468. import { Nullable } from "babylonjs/types";
  67469. import { Vector3 } from "babylonjs/Maths/math.vector";
  67470. import { Mesh } from "babylonjs/Meshes/mesh";
  67471. import { Scene } from "babylonjs/scene";
  67472. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  67473. /**
  67474. * A helper for physics simulations
  67475. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67476. */
  67477. export class PhysicsHelper {
  67478. private _scene;
  67479. private _physicsEngine;
  67480. /**
  67481. * Initializes the Physics helper
  67482. * @param scene Babylon.js scene
  67483. */
  67484. constructor(scene: Scene);
  67485. /**
  67486. * Applies a radial explosion impulse
  67487. * @param origin the origin of the explosion
  67488. * @param radiusOrEventOptions the radius or the options of radial explosion
  67489. * @param strength the explosion strength
  67490. * @param falloff possible options: Constant & Linear. Defaults to Constant
  67491. * @returns A physics radial explosion event, or null
  67492. */
  67493. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  67494. /**
  67495. * Applies a radial explosion force
  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. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  67503. /**
  67504. * Creates a gravitational field
  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 gravitational field event, or null
  67510. */
  67511. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  67512. /**
  67513. * Creates a physics updraft event
  67514. * @param origin the origin of the updraft
  67515. * @param radiusOrEventOptions the radius or the options of the updraft
  67516. * @param strength the strength of the updraft
  67517. * @param height the height of the updraft
  67518. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  67519. * @returns A physics updraft event, or null
  67520. */
  67521. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  67522. /**
  67523. * Creates a physics vortex event
  67524. * @param origin the of the vortex
  67525. * @param radiusOrEventOptions the radius or the options of the vortex
  67526. * @param strength the strength of the vortex
  67527. * @param height the height of the vortex
  67528. * @returns a Physics vortex event, or null
  67529. * A physics vortex event or null
  67530. */
  67531. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  67532. }
  67533. /**
  67534. * Represents a physics radial explosion event
  67535. */
  67536. class PhysicsRadialExplosionEvent {
  67537. private _scene;
  67538. private _options;
  67539. private _sphere;
  67540. private _dataFetched;
  67541. /**
  67542. * Initializes a radial explosioin event
  67543. * @param _scene BabylonJS scene
  67544. * @param _options The options for the vortex event
  67545. */
  67546. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  67547. /**
  67548. * Returns the data related to the radial explosion event (sphere).
  67549. * @returns The radial explosion event data
  67550. */
  67551. getData(): PhysicsRadialExplosionEventData;
  67552. /**
  67553. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  67554. * @param impostor A physics imposter
  67555. * @param origin the origin of the explosion
  67556. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  67557. */
  67558. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  67559. /**
  67560. * Triggers affecterd impostors callbacks
  67561. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  67562. */
  67563. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  67564. /**
  67565. * Disposes the sphere.
  67566. * @param force Specifies if the sphere should be disposed by force
  67567. */
  67568. dispose(force?: boolean): void;
  67569. /*** Helpers ***/
  67570. private _prepareSphere;
  67571. private _intersectsWithSphere;
  67572. }
  67573. /**
  67574. * Represents a gravitational field event
  67575. */
  67576. class PhysicsGravitationalFieldEvent {
  67577. private _physicsHelper;
  67578. private _scene;
  67579. private _origin;
  67580. private _options;
  67581. private _tickCallback;
  67582. private _sphere;
  67583. private _dataFetched;
  67584. /**
  67585. * Initializes the physics gravitational field event
  67586. * @param _physicsHelper A physics helper
  67587. * @param _scene BabylonJS scene
  67588. * @param _origin The origin position of the gravitational field event
  67589. * @param _options The options for the vortex event
  67590. */
  67591. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  67592. /**
  67593. * Returns the data related to the gravitational field event (sphere).
  67594. * @returns A gravitational field event
  67595. */
  67596. getData(): PhysicsGravitationalFieldEventData;
  67597. /**
  67598. * Enables the gravitational field.
  67599. */
  67600. enable(): void;
  67601. /**
  67602. * Disables the gravitational field.
  67603. */
  67604. disable(): void;
  67605. /**
  67606. * Disposes the sphere.
  67607. * @param force The force to dispose from the gravitational field event
  67608. */
  67609. dispose(force?: boolean): void;
  67610. private _tick;
  67611. }
  67612. /**
  67613. * Represents a physics updraft event
  67614. */
  67615. class PhysicsUpdraftEvent {
  67616. private _scene;
  67617. private _origin;
  67618. private _options;
  67619. private _physicsEngine;
  67620. private _originTop;
  67621. private _originDirection;
  67622. private _tickCallback;
  67623. private _cylinder;
  67624. private _cylinderPosition;
  67625. private _dataFetched;
  67626. /**
  67627. * Initializes the physics updraft event
  67628. * @param _scene BabylonJS scene
  67629. * @param _origin The origin position of the updraft
  67630. * @param _options The options for the updraft event
  67631. */
  67632. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  67633. /**
  67634. * Returns the data related to the updraft event (cylinder).
  67635. * @returns A physics updraft event
  67636. */
  67637. getData(): PhysicsUpdraftEventData;
  67638. /**
  67639. * Enables the updraft.
  67640. */
  67641. enable(): void;
  67642. /**
  67643. * Disables the updraft.
  67644. */
  67645. disable(): void;
  67646. /**
  67647. * Disposes the cylinder.
  67648. * @param force Specifies if the updraft should be disposed by force
  67649. */
  67650. dispose(force?: boolean): void;
  67651. private getImpostorHitData;
  67652. private _tick;
  67653. /*** Helpers ***/
  67654. private _prepareCylinder;
  67655. private _intersectsWithCylinder;
  67656. }
  67657. /**
  67658. * Represents a physics vortex event
  67659. */
  67660. class PhysicsVortexEvent {
  67661. private _scene;
  67662. private _origin;
  67663. private _options;
  67664. private _physicsEngine;
  67665. private _originTop;
  67666. private _tickCallback;
  67667. private _cylinder;
  67668. private _cylinderPosition;
  67669. private _dataFetched;
  67670. /**
  67671. * Initializes the physics vortex event
  67672. * @param _scene The BabylonJS scene
  67673. * @param _origin The origin position of the vortex
  67674. * @param _options The options for the vortex event
  67675. */
  67676. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  67677. /**
  67678. * Returns the data related to the vortex event (cylinder).
  67679. * @returns The physics vortex event data
  67680. */
  67681. getData(): PhysicsVortexEventData;
  67682. /**
  67683. * Enables the vortex.
  67684. */
  67685. enable(): void;
  67686. /**
  67687. * Disables the cortex.
  67688. */
  67689. disable(): void;
  67690. /**
  67691. * Disposes the sphere.
  67692. * @param force
  67693. */
  67694. dispose(force?: boolean): void;
  67695. private getImpostorHitData;
  67696. private _tick;
  67697. /*** Helpers ***/
  67698. private _prepareCylinder;
  67699. private _intersectsWithCylinder;
  67700. }
  67701. /**
  67702. * Options fot the radial explosion event
  67703. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67704. */
  67705. export class PhysicsRadialExplosionEventOptions {
  67706. /**
  67707. * The radius of the sphere for the radial explosion.
  67708. */
  67709. radius: number;
  67710. /**
  67711. * The strenth of the explosion.
  67712. */
  67713. strength: number;
  67714. /**
  67715. * The strenght of the force in correspondence to the distance of the affected object
  67716. */
  67717. falloff: PhysicsRadialImpulseFalloff;
  67718. /**
  67719. * Sphere options for the radial explosion.
  67720. */
  67721. sphere: {
  67722. segments: number;
  67723. diameter: number;
  67724. };
  67725. /**
  67726. * Sphere options for the radial explosion.
  67727. */
  67728. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  67729. }
  67730. /**
  67731. * Options fot the updraft event
  67732. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67733. */
  67734. export class PhysicsUpdraftEventOptions {
  67735. /**
  67736. * The radius of the cylinder for the vortex
  67737. */
  67738. radius: number;
  67739. /**
  67740. * The strenth of the updraft.
  67741. */
  67742. strength: number;
  67743. /**
  67744. * The height of the cylinder for the updraft.
  67745. */
  67746. height: number;
  67747. /**
  67748. * The mode for the the updraft.
  67749. */
  67750. updraftMode: PhysicsUpdraftMode;
  67751. }
  67752. /**
  67753. * Options fot the vortex event
  67754. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67755. */
  67756. export class PhysicsVortexEventOptions {
  67757. /**
  67758. * The radius of the cylinder for the vortex
  67759. */
  67760. radius: number;
  67761. /**
  67762. * The strenth of the vortex.
  67763. */
  67764. strength: number;
  67765. /**
  67766. * The height of the cylinder for the vortex.
  67767. */
  67768. height: number;
  67769. /**
  67770. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  67771. */
  67772. centripetalForceThreshold: number;
  67773. /**
  67774. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  67775. */
  67776. centripetalForceMultiplier: number;
  67777. /**
  67778. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  67779. */
  67780. centrifugalForceMultiplier: number;
  67781. /**
  67782. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  67783. */
  67784. updraftForceMultiplier: number;
  67785. }
  67786. /**
  67787. * The strenght of the force in correspondence to the distance of the affected object
  67788. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67789. */
  67790. export enum PhysicsRadialImpulseFalloff {
  67791. /** Defines that impulse is constant in strength across it's whole radius */
  67792. Constant = 0,
  67793. /** Defines that impulse gets weaker if it's further from the origin */
  67794. Linear = 1
  67795. }
  67796. /**
  67797. * The strength of the force in correspondence to the distance of the affected object
  67798. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67799. */
  67800. export enum PhysicsUpdraftMode {
  67801. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  67802. Center = 0,
  67803. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  67804. Perpendicular = 1
  67805. }
  67806. /**
  67807. * Interface for a physics hit data
  67808. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67809. */
  67810. export interface PhysicsHitData {
  67811. /**
  67812. * The force applied at the contact point
  67813. */
  67814. force: Vector3;
  67815. /**
  67816. * The contact point
  67817. */
  67818. contactPoint: Vector3;
  67819. /**
  67820. * The distance from the origin to the contact point
  67821. */
  67822. distanceFromOrigin: number;
  67823. }
  67824. /**
  67825. * Interface for radial explosion event data
  67826. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67827. */
  67828. export interface PhysicsRadialExplosionEventData {
  67829. /**
  67830. * A sphere used for the radial explosion event
  67831. */
  67832. sphere: Mesh;
  67833. }
  67834. /**
  67835. * Interface for gravitational field event data
  67836. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67837. */
  67838. export interface PhysicsGravitationalFieldEventData {
  67839. /**
  67840. * A sphere mesh used for the gravitational field event
  67841. */
  67842. sphere: Mesh;
  67843. }
  67844. /**
  67845. * Interface for updraft event data
  67846. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67847. */
  67848. export interface PhysicsUpdraftEventData {
  67849. /**
  67850. * A cylinder used for the updraft event
  67851. */
  67852. cylinder: Mesh;
  67853. }
  67854. /**
  67855. * Interface for vortex event data
  67856. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67857. */
  67858. export interface PhysicsVortexEventData {
  67859. /**
  67860. * A cylinder used for the vortex event
  67861. */
  67862. cylinder: Mesh;
  67863. }
  67864. /**
  67865. * Interface for an affected physics impostor
  67866. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67867. */
  67868. export interface PhysicsAffectedImpostorWithData {
  67869. /**
  67870. * The impostor affected by the effect
  67871. */
  67872. impostor: PhysicsImpostor;
  67873. /**
  67874. * The data about the hit/horce from the explosion
  67875. */
  67876. hitData: PhysicsHitData;
  67877. }
  67878. }
  67879. declare module "babylonjs/Physics/Plugins/index" {
  67880. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  67881. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  67882. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  67883. }
  67884. declare module "babylonjs/Physics/index" {
  67885. export * from "babylonjs/Physics/IPhysicsEngine";
  67886. export * from "babylonjs/Physics/physicsEngine";
  67887. export * from "babylonjs/Physics/physicsEngineComponent";
  67888. export * from "babylonjs/Physics/physicsHelper";
  67889. export * from "babylonjs/Physics/physicsImpostor";
  67890. export * from "babylonjs/Physics/physicsJoint";
  67891. export * from "babylonjs/Physics/Plugins/index";
  67892. }
  67893. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  67894. /** @hidden */
  67895. export var blackAndWhitePixelShader: {
  67896. name: string;
  67897. shader: string;
  67898. };
  67899. }
  67900. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  67901. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67902. import { Camera } from "babylonjs/Cameras/camera";
  67903. import { Engine } from "babylonjs/Engines/engine";
  67904. import "babylonjs/Shaders/blackAndWhite.fragment";
  67905. /**
  67906. * Post process used to render in black and white
  67907. */
  67908. export class BlackAndWhitePostProcess extends PostProcess {
  67909. /**
  67910. * Linear about to convert he result to black and white (default: 1)
  67911. */
  67912. degree: number;
  67913. /**
  67914. * Creates a black and white post process
  67915. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  67916. * @param name The name of the effect.
  67917. * @param options The required width/height ratio to downsize to before computing the render pass.
  67918. * @param camera The camera to apply the render pass to.
  67919. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67920. * @param engine The engine which the post process will be applied. (default: current engine)
  67921. * @param reusable If the post process can be reused on the same frame. (default: false)
  67922. */
  67923. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67924. }
  67925. }
  67926. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  67927. import { Nullable } from "babylonjs/types";
  67928. import { Camera } from "babylonjs/Cameras/camera";
  67929. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  67930. import { Engine } from "babylonjs/Engines/engine";
  67931. /**
  67932. * This represents a set of one or more post processes in Babylon.
  67933. * A post process can be used to apply a shader to a texture after it is rendered.
  67934. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  67935. */
  67936. export class PostProcessRenderEffect {
  67937. private _postProcesses;
  67938. private _getPostProcesses;
  67939. private _singleInstance;
  67940. private _cameras;
  67941. private _indicesForCamera;
  67942. /**
  67943. * Name of the effect
  67944. * @hidden
  67945. */
  67946. _name: string;
  67947. /**
  67948. * Instantiates a post process render effect.
  67949. * A post process can be used to apply a shader to a texture after it is rendered.
  67950. * @param engine The engine the effect is tied to
  67951. * @param name The name of the effect
  67952. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  67953. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  67954. */
  67955. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  67956. /**
  67957. * Checks if all the post processes in the effect are supported.
  67958. */
  67959. get isSupported(): boolean;
  67960. /**
  67961. * Updates the current state of the effect
  67962. * @hidden
  67963. */
  67964. _update(): void;
  67965. /**
  67966. * Attaches the effect on cameras
  67967. * @param cameras The camera to attach to.
  67968. * @hidden
  67969. */
  67970. _attachCameras(cameras: Camera): void;
  67971. /**
  67972. * Attaches the effect on cameras
  67973. * @param cameras The camera to attach to.
  67974. * @hidden
  67975. */
  67976. _attachCameras(cameras: Camera[]): void;
  67977. /**
  67978. * Detaches the effect on cameras
  67979. * @param cameras The camera to detatch from.
  67980. * @hidden
  67981. */
  67982. _detachCameras(cameras: Camera): void;
  67983. /**
  67984. * Detatches the effect on cameras
  67985. * @param cameras The camera to detatch from.
  67986. * @hidden
  67987. */
  67988. _detachCameras(cameras: Camera[]): void;
  67989. /**
  67990. * Enables the effect on given cameras
  67991. * @param cameras The camera to enable.
  67992. * @hidden
  67993. */
  67994. _enable(cameras: Camera): void;
  67995. /**
  67996. * Enables the effect on given cameras
  67997. * @param cameras The camera to enable.
  67998. * @hidden
  67999. */
  68000. _enable(cameras: Nullable<Camera[]>): void;
  68001. /**
  68002. * Disables the effect on the given cameras
  68003. * @param cameras The camera to disable.
  68004. * @hidden
  68005. */
  68006. _disable(cameras: Camera): void;
  68007. /**
  68008. * Disables the effect on the given cameras
  68009. * @param cameras The camera to disable.
  68010. * @hidden
  68011. */
  68012. _disable(cameras: Nullable<Camera[]>): void;
  68013. /**
  68014. * Gets a list of the post processes contained in the effect.
  68015. * @param camera The camera to get the post processes on.
  68016. * @returns The list of the post processes in the effect.
  68017. */
  68018. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  68019. }
  68020. }
  68021. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  68022. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  68023. /** @hidden */
  68024. export var extractHighlightsPixelShader: {
  68025. name: string;
  68026. shader: string;
  68027. };
  68028. }
  68029. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  68030. import { Nullable } from "babylonjs/types";
  68031. import { Camera } from "babylonjs/Cameras/camera";
  68032. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68033. import { Engine } from "babylonjs/Engines/engine";
  68034. import "babylonjs/Shaders/extractHighlights.fragment";
  68035. /**
  68036. * 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.
  68037. */
  68038. export class ExtractHighlightsPostProcess extends PostProcess {
  68039. /**
  68040. * The luminance threshold, pixels below this value will be set to black.
  68041. */
  68042. threshold: number;
  68043. /** @hidden */
  68044. _exposure: number;
  68045. /**
  68046. * Post process which has the input texture to be used when performing highlight extraction
  68047. * @hidden
  68048. */
  68049. _inputPostProcess: Nullable<PostProcess>;
  68050. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68051. }
  68052. }
  68053. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  68054. /** @hidden */
  68055. export var bloomMergePixelShader: {
  68056. name: string;
  68057. shader: string;
  68058. };
  68059. }
  68060. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  68061. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68062. import { Nullable } from "babylonjs/types";
  68063. import { Engine } from "babylonjs/Engines/engine";
  68064. import { Camera } from "babylonjs/Cameras/camera";
  68065. import "babylonjs/Shaders/bloomMerge.fragment";
  68066. /**
  68067. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  68068. */
  68069. export class BloomMergePostProcess extends PostProcess {
  68070. /** Weight of the bloom to be added to the original input. */
  68071. weight: number;
  68072. /**
  68073. * Creates a new instance of @see BloomMergePostProcess
  68074. * @param name The name of the effect.
  68075. * @param originalFromInput Post process which's input will be used for the merge.
  68076. * @param blurred Blurred highlights post process which's output will be used.
  68077. * @param weight Weight of the bloom to be added to the original input.
  68078. * @param options The required width/height ratio to downsize to before computing the render pass.
  68079. * @param camera The camera to apply the render pass to.
  68080. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68081. * @param engine The engine which the post process will be applied. (default: current engine)
  68082. * @param reusable If the post process can be reused on the same frame. (default: false)
  68083. * @param textureType Type of textures used when performing the post process. (default: 0)
  68084. * @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)
  68085. */
  68086. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  68087. /** Weight of the bloom to be added to the original input. */
  68088. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68089. }
  68090. }
  68091. declare module "babylonjs/PostProcesses/bloomEffect" {
  68092. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  68093. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  68094. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  68095. import { Camera } from "babylonjs/Cameras/camera";
  68096. import { Scene } from "babylonjs/scene";
  68097. /**
  68098. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  68099. */
  68100. export class BloomEffect extends PostProcessRenderEffect {
  68101. private bloomScale;
  68102. /**
  68103. * @hidden Internal
  68104. */
  68105. _effects: Array<PostProcess>;
  68106. /**
  68107. * @hidden Internal
  68108. */
  68109. _downscale: ExtractHighlightsPostProcess;
  68110. private _blurX;
  68111. private _blurY;
  68112. private _merge;
  68113. /**
  68114. * The luminance threshold to find bright areas of the image to bloom.
  68115. */
  68116. get threshold(): number;
  68117. set threshold(value: number);
  68118. /**
  68119. * The strength of the bloom.
  68120. */
  68121. get weight(): number;
  68122. set weight(value: number);
  68123. /**
  68124. * Specifies the size of the bloom blur kernel, relative to the final output size
  68125. */
  68126. get kernel(): number;
  68127. set kernel(value: number);
  68128. /**
  68129. * Creates a new instance of @see BloomEffect
  68130. * @param scene The scene the effect belongs to.
  68131. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  68132. * @param bloomKernel The size of the kernel to be used when applying the blur.
  68133. * @param bloomWeight The the strength of bloom.
  68134. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  68135. * @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)
  68136. */
  68137. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  68138. /**
  68139. * Disposes each of the internal effects for a given camera.
  68140. * @param camera The camera to dispose the effect on.
  68141. */
  68142. disposeEffects(camera: Camera): void;
  68143. /**
  68144. * @hidden Internal
  68145. */
  68146. _updateEffects(): void;
  68147. /**
  68148. * Internal
  68149. * @returns if all the contained post processes are ready.
  68150. * @hidden
  68151. */
  68152. _isReady(): boolean;
  68153. }
  68154. }
  68155. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  68156. /** @hidden */
  68157. export var chromaticAberrationPixelShader: {
  68158. name: string;
  68159. shader: string;
  68160. };
  68161. }
  68162. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  68163. import { Vector2 } from "babylonjs/Maths/math.vector";
  68164. import { Nullable } from "babylonjs/types";
  68165. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68166. import { Camera } from "babylonjs/Cameras/camera";
  68167. import { Engine } from "babylonjs/Engines/engine";
  68168. import "babylonjs/Shaders/chromaticAberration.fragment";
  68169. /**
  68170. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  68171. */
  68172. export class ChromaticAberrationPostProcess extends PostProcess {
  68173. /**
  68174. * The amount of seperation of rgb channels (default: 30)
  68175. */
  68176. aberrationAmount: number;
  68177. /**
  68178. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  68179. */
  68180. radialIntensity: number;
  68181. /**
  68182. * 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))
  68183. */
  68184. direction: Vector2;
  68185. /**
  68186. * 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))
  68187. */
  68188. centerPosition: Vector2;
  68189. /**
  68190. * Creates a new instance ChromaticAberrationPostProcess
  68191. * @param name The name of the effect.
  68192. * @param screenWidth The width of the screen to apply the effect on.
  68193. * @param screenHeight The height of the screen to apply the effect on.
  68194. * @param options The required width/height ratio to downsize to before computing the render pass.
  68195. * @param camera The camera to apply the render pass to.
  68196. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68197. * @param engine The engine which the post process will be applied. (default: current engine)
  68198. * @param reusable If the post process can be reused on the same frame. (default: false)
  68199. * @param textureType Type of textures used when performing the post process. (default: 0)
  68200. * @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)
  68201. */
  68202. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68203. }
  68204. }
  68205. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  68206. /** @hidden */
  68207. export var circleOfConfusionPixelShader: {
  68208. name: string;
  68209. shader: string;
  68210. };
  68211. }
  68212. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  68213. import { Nullable } from "babylonjs/types";
  68214. import { Engine } from "babylonjs/Engines/engine";
  68215. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68216. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  68217. import { Camera } from "babylonjs/Cameras/camera";
  68218. import "babylonjs/Shaders/circleOfConfusion.fragment";
  68219. /**
  68220. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  68221. */
  68222. export class CircleOfConfusionPostProcess extends PostProcess {
  68223. /**
  68224. * 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.
  68225. */
  68226. lensSize: number;
  68227. /**
  68228. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  68229. */
  68230. fStop: number;
  68231. /**
  68232. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  68233. */
  68234. focusDistance: number;
  68235. /**
  68236. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  68237. */
  68238. focalLength: number;
  68239. private _depthTexture;
  68240. /**
  68241. * Creates a new instance CircleOfConfusionPostProcess
  68242. * @param name The name of the effect.
  68243. * @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.
  68244. * @param options The required width/height ratio to downsize to before computing the render pass.
  68245. * @param camera The camera to apply the render pass to.
  68246. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68247. * @param engine The engine which the post process will be applied. (default: current engine)
  68248. * @param reusable If the post process can be reused on the same frame. (default: false)
  68249. * @param textureType Type of textures used when performing the post process. (default: 0)
  68250. * @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)
  68251. */
  68252. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68253. /**
  68254. * 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.
  68255. */
  68256. set depthTexture(value: RenderTargetTexture);
  68257. }
  68258. }
  68259. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  68260. /** @hidden */
  68261. export var colorCorrectionPixelShader: {
  68262. name: string;
  68263. shader: string;
  68264. };
  68265. }
  68266. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  68267. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68268. import { Engine } from "babylonjs/Engines/engine";
  68269. import { Camera } from "babylonjs/Cameras/camera";
  68270. import "babylonjs/Shaders/colorCorrection.fragment";
  68271. /**
  68272. *
  68273. * This post-process allows the modification of rendered colors by using
  68274. * a 'look-up table' (LUT). This effect is also called Color Grading.
  68275. *
  68276. * The object needs to be provided an url to a texture containing the color
  68277. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  68278. * Use an image editing software to tweak the LUT to match your needs.
  68279. *
  68280. * For an example of a color LUT, see here:
  68281. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  68282. * For explanations on color grading, see here:
  68283. * @see http://udn.epicgames.com/Three/ColorGrading.html
  68284. *
  68285. */
  68286. export class ColorCorrectionPostProcess extends PostProcess {
  68287. private _colorTableTexture;
  68288. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  68289. }
  68290. }
  68291. declare module "babylonjs/Shaders/convolution.fragment" {
  68292. /** @hidden */
  68293. export var convolutionPixelShader: {
  68294. name: string;
  68295. shader: string;
  68296. };
  68297. }
  68298. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  68299. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68300. import { Nullable } from "babylonjs/types";
  68301. import { Camera } from "babylonjs/Cameras/camera";
  68302. import { Engine } from "babylonjs/Engines/engine";
  68303. import "babylonjs/Shaders/convolution.fragment";
  68304. /**
  68305. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  68306. * input texture to perform effects such as edge detection or sharpening
  68307. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  68308. */
  68309. export class ConvolutionPostProcess extends PostProcess {
  68310. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  68311. kernel: number[];
  68312. /**
  68313. * Creates a new instance ConvolutionPostProcess
  68314. * @param name The name of the effect.
  68315. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  68316. * @param options The required width/height ratio to downsize to before computing the render pass.
  68317. * @param camera The camera to apply the render pass to.
  68318. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68319. * @param engine The engine which the post process will be applied. (default: current engine)
  68320. * @param reusable If the post process can be reused on the same frame. (default: false)
  68321. * @param textureType Type of textures used when performing the post process. (default: 0)
  68322. */
  68323. constructor(name: string,
  68324. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  68325. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  68326. /**
  68327. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  68328. */
  68329. static EdgeDetect0Kernel: number[];
  68330. /**
  68331. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  68332. */
  68333. static EdgeDetect1Kernel: number[];
  68334. /**
  68335. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  68336. */
  68337. static EdgeDetect2Kernel: number[];
  68338. /**
  68339. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  68340. */
  68341. static SharpenKernel: number[];
  68342. /**
  68343. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  68344. */
  68345. static EmbossKernel: number[];
  68346. /**
  68347. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  68348. */
  68349. static GaussianKernel: number[];
  68350. }
  68351. }
  68352. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  68353. import { Nullable } from "babylonjs/types";
  68354. import { Vector2 } from "babylonjs/Maths/math.vector";
  68355. import { Camera } from "babylonjs/Cameras/camera";
  68356. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68357. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  68358. import { Engine } from "babylonjs/Engines/engine";
  68359. import { Scene } from "babylonjs/scene";
  68360. /**
  68361. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  68362. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  68363. * based on samples that have a large difference in distance than the center pixel.
  68364. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  68365. */
  68366. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  68367. direction: Vector2;
  68368. /**
  68369. * Creates a new instance CircleOfConfusionPostProcess
  68370. * @param name The name of the effect.
  68371. * @param scene The scene the effect belongs to.
  68372. * @param direction The direction the blur should be applied.
  68373. * @param kernel The size of the kernel used to blur.
  68374. * @param options The required width/height ratio to downsize to before computing the render pass.
  68375. * @param camera The camera to apply the render pass to.
  68376. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  68377. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  68378. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68379. * @param engine The engine which the post process will be applied. (default: current engine)
  68380. * @param reusable If the post process can be reused on the same frame. (default: false)
  68381. * @param textureType Type of textures used when performing the post process. (default: 0)
  68382. * @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)
  68383. */
  68384. 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);
  68385. }
  68386. }
  68387. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  68388. /** @hidden */
  68389. export var depthOfFieldMergePixelShader: {
  68390. name: string;
  68391. shader: string;
  68392. };
  68393. }
  68394. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  68395. import { Nullable } from "babylonjs/types";
  68396. import { Camera } from "babylonjs/Cameras/camera";
  68397. import { Effect } from "babylonjs/Materials/effect";
  68398. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68399. import { Engine } from "babylonjs/Engines/engine";
  68400. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  68401. /**
  68402. * Options to be set when merging outputs from the default pipeline.
  68403. */
  68404. export class DepthOfFieldMergePostProcessOptions {
  68405. /**
  68406. * The original image to merge on top of
  68407. */
  68408. originalFromInput: PostProcess;
  68409. /**
  68410. * Parameters to perform the merge of the depth of field effect
  68411. */
  68412. depthOfField?: {
  68413. circleOfConfusion: PostProcess;
  68414. blurSteps: Array<PostProcess>;
  68415. };
  68416. /**
  68417. * Parameters to perform the merge of bloom effect
  68418. */
  68419. bloom?: {
  68420. blurred: PostProcess;
  68421. weight: number;
  68422. };
  68423. }
  68424. /**
  68425. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  68426. */
  68427. export class DepthOfFieldMergePostProcess extends PostProcess {
  68428. private blurSteps;
  68429. /**
  68430. * Creates a new instance of DepthOfFieldMergePostProcess
  68431. * @param name The name of the effect.
  68432. * @param originalFromInput Post process which's input will be used for the merge.
  68433. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  68434. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  68435. * @param options The required width/height ratio to downsize to before computing the render pass.
  68436. * @param camera The camera to apply the render pass to.
  68437. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68438. * @param engine The engine which the post process will be applied. (default: current engine)
  68439. * @param reusable If the post process can be reused on the same frame. (default: false)
  68440. * @param textureType Type of textures used when performing the post process. (default: 0)
  68441. * @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)
  68442. */
  68443. 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);
  68444. /**
  68445. * Updates the effect with the current post process compile time values and recompiles the shader.
  68446. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  68447. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  68448. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  68449. * @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
  68450. * @param onCompiled Called when the shader has been compiled.
  68451. * @param onError Called if there is an error when compiling a shader.
  68452. */
  68453. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  68454. }
  68455. }
  68456. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  68457. import { Nullable } from "babylonjs/types";
  68458. import { Camera } from "babylonjs/Cameras/camera";
  68459. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  68460. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  68461. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  68462. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  68463. import { Scene } from "babylonjs/scene";
  68464. /**
  68465. * Specifies the level of max blur that should be applied when using the depth of field effect
  68466. */
  68467. export enum DepthOfFieldEffectBlurLevel {
  68468. /**
  68469. * Subtle blur
  68470. */
  68471. Low = 0,
  68472. /**
  68473. * Medium blur
  68474. */
  68475. Medium = 1,
  68476. /**
  68477. * Large blur
  68478. */
  68479. High = 2
  68480. }
  68481. /**
  68482. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  68483. */
  68484. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  68485. private _circleOfConfusion;
  68486. /**
  68487. * @hidden Internal, blurs from high to low
  68488. */
  68489. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  68490. private _depthOfFieldBlurY;
  68491. private _dofMerge;
  68492. /**
  68493. * @hidden Internal post processes in depth of field effect
  68494. */
  68495. _effects: Array<PostProcess>;
  68496. /**
  68497. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  68498. */
  68499. set focalLength(value: number);
  68500. get focalLength(): number;
  68501. /**
  68502. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  68503. */
  68504. set fStop(value: number);
  68505. get fStop(): number;
  68506. /**
  68507. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  68508. */
  68509. set focusDistance(value: number);
  68510. get focusDistance(): number;
  68511. /**
  68512. * 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.
  68513. */
  68514. set lensSize(value: number);
  68515. get lensSize(): number;
  68516. /**
  68517. * Creates a new instance DepthOfFieldEffect
  68518. * @param scene The scene the effect belongs to.
  68519. * @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.
  68520. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  68521. * @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)
  68522. */
  68523. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  68524. /**
  68525. * Get the current class name of the current effet
  68526. * @returns "DepthOfFieldEffect"
  68527. */
  68528. getClassName(): string;
  68529. /**
  68530. * 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.
  68531. */
  68532. set depthTexture(value: RenderTargetTexture);
  68533. /**
  68534. * Disposes each of the internal effects for a given camera.
  68535. * @param camera The camera to dispose the effect on.
  68536. */
  68537. disposeEffects(camera: Camera): void;
  68538. /**
  68539. * @hidden Internal
  68540. */
  68541. _updateEffects(): void;
  68542. /**
  68543. * Internal
  68544. * @returns if all the contained post processes are ready.
  68545. * @hidden
  68546. */
  68547. _isReady(): boolean;
  68548. }
  68549. }
  68550. declare module "babylonjs/Shaders/displayPass.fragment" {
  68551. /** @hidden */
  68552. export var displayPassPixelShader: {
  68553. name: string;
  68554. shader: string;
  68555. };
  68556. }
  68557. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  68558. import { Nullable } from "babylonjs/types";
  68559. import { Camera } from "babylonjs/Cameras/camera";
  68560. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68561. import { Engine } from "babylonjs/Engines/engine";
  68562. import "babylonjs/Shaders/displayPass.fragment";
  68563. /**
  68564. * DisplayPassPostProcess which produces an output the same as it's input
  68565. */
  68566. export class DisplayPassPostProcess extends PostProcess {
  68567. /**
  68568. * Creates the DisplayPassPostProcess
  68569. * @param name The name of the effect.
  68570. * @param options The required width/height ratio to downsize to before computing the render pass.
  68571. * @param camera The camera to apply the render pass to.
  68572. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68573. * @param engine The engine which the post process will be applied. (default: current engine)
  68574. * @param reusable If the post process can be reused on the same frame. (default: false)
  68575. */
  68576. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  68577. }
  68578. }
  68579. declare module "babylonjs/Shaders/filter.fragment" {
  68580. /** @hidden */
  68581. export var filterPixelShader: {
  68582. name: string;
  68583. shader: string;
  68584. };
  68585. }
  68586. declare module "babylonjs/PostProcesses/filterPostProcess" {
  68587. import { Nullable } from "babylonjs/types";
  68588. import { Matrix } from "babylonjs/Maths/math.vector";
  68589. import { Camera } from "babylonjs/Cameras/camera";
  68590. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68591. import { Engine } from "babylonjs/Engines/engine";
  68592. import "babylonjs/Shaders/filter.fragment";
  68593. /**
  68594. * Applies a kernel filter to the image
  68595. */
  68596. export class FilterPostProcess extends PostProcess {
  68597. /** The matrix to be applied to the image */
  68598. kernelMatrix: Matrix;
  68599. /**
  68600. *
  68601. * @param name The name of the effect.
  68602. * @param kernelMatrix The matrix to be applied to the image
  68603. * @param options The required width/height ratio to downsize to before computing the render pass.
  68604. * @param camera The camera to apply the render pass to.
  68605. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68606. * @param engine The engine which the post process will be applied. (default: current engine)
  68607. * @param reusable If the post process can be reused on the same frame. (default: false)
  68608. */
  68609. constructor(name: string,
  68610. /** The matrix to be applied to the image */
  68611. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  68612. }
  68613. }
  68614. declare module "babylonjs/Shaders/fxaa.fragment" {
  68615. /** @hidden */
  68616. export var fxaaPixelShader: {
  68617. name: string;
  68618. shader: string;
  68619. };
  68620. }
  68621. declare module "babylonjs/Shaders/fxaa.vertex" {
  68622. /** @hidden */
  68623. export var fxaaVertexShader: {
  68624. name: string;
  68625. shader: string;
  68626. };
  68627. }
  68628. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  68629. import { Nullable } from "babylonjs/types";
  68630. import { Camera } from "babylonjs/Cameras/camera";
  68631. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68632. import { Engine } from "babylonjs/Engines/engine";
  68633. import "babylonjs/Shaders/fxaa.fragment";
  68634. import "babylonjs/Shaders/fxaa.vertex";
  68635. /**
  68636. * Fxaa post process
  68637. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  68638. */
  68639. export class FxaaPostProcess extends PostProcess {
  68640. /** @hidden */
  68641. texelWidth: number;
  68642. /** @hidden */
  68643. texelHeight: number;
  68644. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  68645. private _getDefines;
  68646. }
  68647. }
  68648. declare module "babylonjs/Shaders/grain.fragment" {
  68649. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  68650. /** @hidden */
  68651. export var grainPixelShader: {
  68652. name: string;
  68653. shader: string;
  68654. };
  68655. }
  68656. declare module "babylonjs/PostProcesses/grainPostProcess" {
  68657. import { Nullable } from "babylonjs/types";
  68658. import { Camera } from "babylonjs/Cameras/camera";
  68659. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68660. import { Engine } from "babylonjs/Engines/engine";
  68661. import "babylonjs/Shaders/grain.fragment";
  68662. /**
  68663. * The GrainPostProcess adds noise to the image at mid luminance levels
  68664. */
  68665. export class GrainPostProcess extends PostProcess {
  68666. /**
  68667. * The intensity of the grain added (default: 30)
  68668. */
  68669. intensity: number;
  68670. /**
  68671. * If the grain should be randomized on every frame
  68672. */
  68673. animated: boolean;
  68674. /**
  68675. * Creates a new instance of @see GrainPostProcess
  68676. * @param name The name of the effect.
  68677. * @param options The required width/height ratio to downsize to before computing the render pass.
  68678. * @param camera The camera to apply the render pass to.
  68679. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68680. * @param engine The engine which the post process will be applied. (default: current engine)
  68681. * @param reusable If the post process can be reused on the same frame. (default: false)
  68682. * @param textureType Type of textures used when performing the post process. (default: 0)
  68683. * @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)
  68684. */
  68685. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68686. }
  68687. }
  68688. declare module "babylonjs/Shaders/highlights.fragment" {
  68689. /** @hidden */
  68690. export var highlightsPixelShader: {
  68691. name: string;
  68692. shader: string;
  68693. };
  68694. }
  68695. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  68696. import { Nullable } from "babylonjs/types";
  68697. import { Camera } from "babylonjs/Cameras/camera";
  68698. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68699. import { Engine } from "babylonjs/Engines/engine";
  68700. import "babylonjs/Shaders/highlights.fragment";
  68701. /**
  68702. * Extracts highlights from the image
  68703. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  68704. */
  68705. export class HighlightsPostProcess extends PostProcess {
  68706. /**
  68707. * Extracts highlights from the image
  68708. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  68709. * @param name The name of the effect.
  68710. * @param options The required width/height ratio to downsize to before computing the render pass.
  68711. * @param camera The camera to apply the render pass to.
  68712. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68713. * @param engine The engine which the post process will be applied. (default: current engine)
  68714. * @param reusable If the post process can be reused on the same frame. (default: false)
  68715. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  68716. */
  68717. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  68718. }
  68719. }
  68720. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  68721. /** @hidden */
  68722. export var mrtFragmentDeclaration: {
  68723. name: string;
  68724. shader: string;
  68725. };
  68726. }
  68727. declare module "babylonjs/Shaders/geometry.fragment" {
  68728. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  68729. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  68730. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  68731. /** @hidden */
  68732. export var geometryPixelShader: {
  68733. name: string;
  68734. shader: string;
  68735. };
  68736. }
  68737. declare module "babylonjs/Shaders/geometry.vertex" {
  68738. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  68739. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  68740. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  68741. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  68742. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  68743. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  68744. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  68745. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  68746. /** @hidden */
  68747. export var geometryVertexShader: {
  68748. name: string;
  68749. shader: string;
  68750. };
  68751. }
  68752. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  68753. import { Matrix } from "babylonjs/Maths/math.vector";
  68754. import { SubMesh } from "babylonjs/Meshes/subMesh";
  68755. import { Mesh } from "babylonjs/Meshes/mesh";
  68756. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  68757. import { Effect } from "babylonjs/Materials/effect";
  68758. import { Scene } from "babylonjs/scene";
  68759. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68760. import "babylonjs/Shaders/geometry.fragment";
  68761. import "babylonjs/Shaders/geometry.vertex";
  68762. /** @hidden */
  68763. interface ISavedTransformationMatrix {
  68764. world: Matrix;
  68765. viewProjection: Matrix;
  68766. }
  68767. /**
  68768. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  68769. */
  68770. export class GeometryBufferRenderer {
  68771. /**
  68772. * Constant used to retrieve the position texture index in the G-Buffer textures array
  68773. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  68774. */
  68775. static readonly POSITION_TEXTURE_TYPE: number;
  68776. /**
  68777. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  68778. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  68779. */
  68780. static readonly VELOCITY_TEXTURE_TYPE: number;
  68781. /**
  68782. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  68783. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  68784. */
  68785. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  68786. /**
  68787. * Dictionary used to store the previous transformation matrices of each rendered mesh
  68788. * in order to compute objects velocities when enableVelocity is set to "true"
  68789. * @hidden
  68790. */
  68791. _previousTransformationMatrices: {
  68792. [index: number]: ISavedTransformationMatrix;
  68793. };
  68794. /**
  68795. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  68796. * in order to compute objects velocities when enableVelocity is set to "true"
  68797. * @hidden
  68798. */
  68799. _previousBonesTransformationMatrices: {
  68800. [index: number]: Float32Array;
  68801. };
  68802. /**
  68803. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  68804. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  68805. */
  68806. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  68807. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  68808. renderTransparentMeshes: boolean;
  68809. private _scene;
  68810. private _multiRenderTarget;
  68811. private _ratio;
  68812. private _enablePosition;
  68813. private _enableVelocity;
  68814. private _enableReflectivity;
  68815. private _positionIndex;
  68816. private _velocityIndex;
  68817. private _reflectivityIndex;
  68818. protected _effect: Effect;
  68819. protected _cachedDefines: string;
  68820. /**
  68821. * Set the render list (meshes to be rendered) used in the G buffer.
  68822. */
  68823. set renderList(meshes: Mesh[]);
  68824. /**
  68825. * Gets wether or not G buffer are supported by the running hardware.
  68826. * This requires draw buffer supports
  68827. */
  68828. get isSupported(): boolean;
  68829. /**
  68830. * Returns the index of the given texture type in the G-Buffer textures array
  68831. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  68832. * @returns the index of the given texture type in the G-Buffer textures array
  68833. */
  68834. getTextureIndex(textureType: number): number;
  68835. /**
  68836. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  68837. */
  68838. get enablePosition(): boolean;
  68839. /**
  68840. * Sets whether or not objects positions are enabled for the G buffer.
  68841. */
  68842. set enablePosition(enable: boolean);
  68843. /**
  68844. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  68845. */
  68846. get enableVelocity(): boolean;
  68847. /**
  68848. * Sets wether or not objects velocities are enabled for the G buffer.
  68849. */
  68850. set enableVelocity(enable: boolean);
  68851. /**
  68852. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  68853. */
  68854. get enableReflectivity(): boolean;
  68855. /**
  68856. * Sets wether or not objects roughness are enabled for the G buffer.
  68857. */
  68858. set enableReflectivity(enable: boolean);
  68859. /**
  68860. * Gets the scene associated with the buffer.
  68861. */
  68862. get scene(): Scene;
  68863. /**
  68864. * Gets the ratio used by the buffer during its creation.
  68865. * How big is the buffer related to the main canvas.
  68866. */
  68867. get ratio(): number;
  68868. /** @hidden */
  68869. static _SceneComponentInitialization: (scene: Scene) => void;
  68870. /**
  68871. * Creates a new G Buffer for the scene
  68872. * @param scene The scene the buffer belongs to
  68873. * @param ratio How big is the buffer related to the main canvas.
  68874. */
  68875. constructor(scene: Scene, ratio?: number);
  68876. /**
  68877. * Checks wether everything is ready to render a submesh to the G buffer.
  68878. * @param subMesh the submesh to check readiness for
  68879. * @param useInstances is the mesh drawn using instance or not
  68880. * @returns true if ready otherwise false
  68881. */
  68882. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  68883. /**
  68884. * Gets the current underlying G Buffer.
  68885. * @returns the buffer
  68886. */
  68887. getGBuffer(): MultiRenderTarget;
  68888. /**
  68889. * Gets the number of samples used to render the buffer (anti aliasing).
  68890. */
  68891. get samples(): number;
  68892. /**
  68893. * Sets the number of samples used to render the buffer (anti aliasing).
  68894. */
  68895. set samples(value: number);
  68896. /**
  68897. * Disposes the renderer and frees up associated resources.
  68898. */
  68899. dispose(): void;
  68900. protected _createRenderTargets(): void;
  68901. private _copyBonesTransformationMatrices;
  68902. }
  68903. }
  68904. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  68905. import { Nullable } from "babylonjs/types";
  68906. import { Scene } from "babylonjs/scene";
  68907. import { ISceneComponent } from "babylonjs/sceneComponent";
  68908. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  68909. module "babylonjs/scene" {
  68910. interface Scene {
  68911. /** @hidden (Backing field) */
  68912. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  68913. /**
  68914. * Gets or Sets the current geometry buffer associated to the scene.
  68915. */
  68916. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  68917. /**
  68918. * Enables a GeometryBufferRender and associates it with the scene
  68919. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  68920. * @returns the GeometryBufferRenderer
  68921. */
  68922. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  68923. /**
  68924. * Disables the GeometryBufferRender associated with the scene
  68925. */
  68926. disableGeometryBufferRenderer(): void;
  68927. }
  68928. }
  68929. /**
  68930. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  68931. * in several rendering techniques.
  68932. */
  68933. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  68934. /**
  68935. * The component name helpful to identify the component in the list of scene components.
  68936. */
  68937. readonly name: string;
  68938. /**
  68939. * The scene the component belongs to.
  68940. */
  68941. scene: Scene;
  68942. /**
  68943. * Creates a new instance of the component for the given scene
  68944. * @param scene Defines the scene to register the component in
  68945. */
  68946. constructor(scene: Scene);
  68947. /**
  68948. * Registers the component in a given scene
  68949. */
  68950. register(): void;
  68951. /**
  68952. * Rebuilds the elements related to this component in case of
  68953. * context lost for instance.
  68954. */
  68955. rebuild(): void;
  68956. /**
  68957. * Disposes the component and the associated ressources
  68958. */
  68959. dispose(): void;
  68960. private _gatherRenderTargets;
  68961. }
  68962. }
  68963. declare module "babylonjs/Shaders/motionBlur.fragment" {
  68964. /** @hidden */
  68965. export var motionBlurPixelShader: {
  68966. name: string;
  68967. shader: string;
  68968. };
  68969. }
  68970. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  68971. import { Nullable } from "babylonjs/types";
  68972. import { Camera } from "babylonjs/Cameras/camera";
  68973. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68974. import { Scene } from "babylonjs/scene";
  68975. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68976. import "babylonjs/Animations/animatable";
  68977. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  68978. import "babylonjs/Shaders/motionBlur.fragment";
  68979. import { Engine } from "babylonjs/Engines/engine";
  68980. /**
  68981. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  68982. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  68983. * As an example, all you have to do is to create the post-process:
  68984. * var mb = new BABYLON.MotionBlurPostProcess(
  68985. * 'mb', // The name of the effect.
  68986. * scene, // The scene containing the objects to blur according to their velocity.
  68987. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  68988. * camera // The camera to apply the render pass to.
  68989. * );
  68990. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  68991. */
  68992. export class MotionBlurPostProcess extends PostProcess {
  68993. /**
  68994. * Defines how much the image is blurred by the movement. Default value is equal to 1
  68995. */
  68996. motionStrength: number;
  68997. /**
  68998. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  68999. */
  69000. get motionBlurSamples(): number;
  69001. /**
  69002. * Sets the number of iterations to be used for motion blur quality
  69003. */
  69004. set motionBlurSamples(samples: number);
  69005. private _motionBlurSamples;
  69006. private _geometryBufferRenderer;
  69007. /**
  69008. * Creates a new instance MotionBlurPostProcess
  69009. * @param name The name of the effect.
  69010. * @param scene The scene containing the objects to blur according to their velocity.
  69011. * @param options The required width/height ratio to downsize to before computing the render pass.
  69012. * @param camera The camera to apply the render pass to.
  69013. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69014. * @param engine The engine which the post process will be applied. (default: current engine)
  69015. * @param reusable If the post process can be reused on the same frame. (default: false)
  69016. * @param textureType Type of textures used when performing the post process. (default: 0)
  69017. * @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)
  69018. */
  69019. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69020. /**
  69021. * Excludes the given skinned mesh from computing bones velocities.
  69022. * 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.
  69023. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  69024. */
  69025. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  69026. /**
  69027. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  69028. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  69029. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  69030. */
  69031. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  69032. /**
  69033. * Disposes the post process.
  69034. * @param camera The camera to dispose the post process on.
  69035. */
  69036. dispose(camera?: Camera): void;
  69037. }
  69038. }
  69039. declare module "babylonjs/Shaders/refraction.fragment" {
  69040. /** @hidden */
  69041. export var refractionPixelShader: {
  69042. name: string;
  69043. shader: string;
  69044. };
  69045. }
  69046. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  69047. import { Color3 } from "babylonjs/Maths/math.color";
  69048. import { Camera } from "babylonjs/Cameras/camera";
  69049. import { Texture } from "babylonjs/Materials/Textures/texture";
  69050. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  69051. import { Engine } from "babylonjs/Engines/engine";
  69052. import "babylonjs/Shaders/refraction.fragment";
  69053. /**
  69054. * Post process which applies a refractin texture
  69055. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  69056. */
  69057. export class RefractionPostProcess extends PostProcess {
  69058. /** the base color of the refraction (used to taint the rendering) */
  69059. color: Color3;
  69060. /** simulated refraction depth */
  69061. depth: number;
  69062. /** the coefficient of the base color (0 to remove base color tainting) */
  69063. colorLevel: number;
  69064. private _refTexture;
  69065. private _ownRefractionTexture;
  69066. /**
  69067. * Gets or sets the refraction texture
  69068. * Please note that you are responsible for disposing the texture if you set it manually
  69069. */
  69070. get refractionTexture(): Texture;
  69071. set refractionTexture(value: Texture);
  69072. /**
  69073. * Initializes the RefractionPostProcess
  69074. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  69075. * @param name The name of the effect.
  69076. * @param refractionTextureUrl Url of the refraction texture to use
  69077. * @param color the base color of the refraction (used to taint the rendering)
  69078. * @param depth simulated refraction depth
  69079. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  69080. * @param camera The camera to apply the render pass to.
  69081. * @param options The required width/height ratio to downsize to before computing the render pass.
  69082. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69083. * @param engine The engine which the post process will be applied. (default: current engine)
  69084. * @param reusable If the post process can be reused on the same frame. (default: false)
  69085. */
  69086. constructor(name: string, refractionTextureUrl: string,
  69087. /** the base color of the refraction (used to taint the rendering) */
  69088. color: Color3,
  69089. /** simulated refraction depth */
  69090. depth: number,
  69091. /** the coefficient of the base color (0 to remove base color tainting) */
  69092. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  69093. /**
  69094. * Disposes of the post process
  69095. * @param camera Camera to dispose post process on
  69096. */
  69097. dispose(camera: Camera): void;
  69098. }
  69099. }
  69100. declare module "babylonjs/Shaders/sharpen.fragment" {
  69101. /** @hidden */
  69102. export var sharpenPixelShader: {
  69103. name: string;
  69104. shader: string;
  69105. };
  69106. }
  69107. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  69108. import { Nullable } from "babylonjs/types";
  69109. import { Camera } from "babylonjs/Cameras/camera";
  69110. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  69111. import "babylonjs/Shaders/sharpen.fragment";
  69112. import { Engine } from "babylonjs/Engines/engine";
  69113. /**
  69114. * The SharpenPostProcess applies a sharpen kernel to every pixel
  69115. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  69116. */
  69117. export class SharpenPostProcess extends PostProcess {
  69118. /**
  69119. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  69120. */
  69121. colorAmount: number;
  69122. /**
  69123. * How much sharpness should be applied (default: 0.3)
  69124. */
  69125. edgeAmount: number;
  69126. /**
  69127. * Creates a new instance ConvolutionPostProcess
  69128. * @param name The name of the effect.
  69129. * @param options The required width/height ratio to downsize to before computing the render pass.
  69130. * @param camera The camera to apply the render pass to.
  69131. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69132. * @param engine The engine which the post process will be applied. (default: current engine)
  69133. * @param reusable If the post process can be reused on the same frame. (default: false)
  69134. * @param textureType Type of textures used when performing the post process. (default: 0)
  69135. * @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)
  69136. */
  69137. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69138. }
  69139. }
  69140. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  69141. import { Nullable } from "babylonjs/types";
  69142. import { Camera } from "babylonjs/Cameras/camera";
  69143. import { Engine } from "babylonjs/Engines/engine";
  69144. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  69145. import { IInspectable } from "babylonjs/Misc/iInspectable";
  69146. /**
  69147. * PostProcessRenderPipeline
  69148. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  69149. */
  69150. export class PostProcessRenderPipeline {
  69151. private engine;
  69152. private _renderEffects;
  69153. private _renderEffectsForIsolatedPass;
  69154. /**
  69155. * List of inspectable custom properties (used by the Inspector)
  69156. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  69157. */
  69158. inspectableCustomProperties: IInspectable[];
  69159. /**
  69160. * @hidden
  69161. */
  69162. protected _cameras: Camera[];
  69163. /** @hidden */
  69164. _name: string;
  69165. /**
  69166. * Gets pipeline name
  69167. */
  69168. get name(): string;
  69169. /** Gets the list of attached cameras */
  69170. get cameras(): Camera[];
  69171. /**
  69172. * Initializes a PostProcessRenderPipeline
  69173. * @param engine engine to add the pipeline to
  69174. * @param name name of the pipeline
  69175. */
  69176. constructor(engine: Engine, name: string);
  69177. /**
  69178. * Gets the class name
  69179. * @returns "PostProcessRenderPipeline"
  69180. */
  69181. getClassName(): string;
  69182. /**
  69183. * If all the render effects in the pipeline are supported
  69184. */
  69185. get isSupported(): boolean;
  69186. /**
  69187. * Adds an effect to the pipeline
  69188. * @param renderEffect the effect to add
  69189. */
  69190. addEffect(renderEffect: PostProcessRenderEffect): void;
  69191. /** @hidden */
  69192. _rebuild(): void;
  69193. /** @hidden */
  69194. _enableEffect(renderEffectName: string, cameras: Camera): void;
  69195. /** @hidden */
  69196. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  69197. /** @hidden */
  69198. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  69199. /** @hidden */
  69200. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  69201. /** @hidden */
  69202. _attachCameras(cameras: Camera, unique: boolean): void;
  69203. /** @hidden */
  69204. _attachCameras(cameras: Camera[], unique: boolean): void;
  69205. /** @hidden */
  69206. _detachCameras(cameras: Camera): void;
  69207. /** @hidden */
  69208. _detachCameras(cameras: Nullable<Camera[]>): void;
  69209. /** @hidden */
  69210. _update(): void;
  69211. /** @hidden */
  69212. _reset(): void;
  69213. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  69214. /**
  69215. * Disposes of the pipeline
  69216. */
  69217. dispose(): void;
  69218. }
  69219. }
  69220. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  69221. import { Camera } from "babylonjs/Cameras/camera";
  69222. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  69223. /**
  69224. * PostProcessRenderPipelineManager class
  69225. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  69226. */
  69227. export class PostProcessRenderPipelineManager {
  69228. private _renderPipelines;
  69229. /**
  69230. * Initializes a PostProcessRenderPipelineManager
  69231. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  69232. */
  69233. constructor();
  69234. /**
  69235. * Gets the list of supported render pipelines
  69236. */
  69237. get supportedPipelines(): PostProcessRenderPipeline[];
  69238. /**
  69239. * Adds a pipeline to the manager
  69240. * @param renderPipeline The pipeline to add
  69241. */
  69242. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  69243. /**
  69244. * Attaches a camera to the pipeline
  69245. * @param renderPipelineName The name of the pipeline to attach to
  69246. * @param cameras the camera to attach
  69247. * @param unique if the camera can be attached multiple times to the pipeline
  69248. */
  69249. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  69250. /**
  69251. * Detaches a camera from the pipeline
  69252. * @param renderPipelineName The name of the pipeline to detach from
  69253. * @param cameras the camera to detach
  69254. */
  69255. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  69256. /**
  69257. * Enables an effect by name on a pipeline
  69258. * @param renderPipelineName the name of the pipeline to enable the effect in
  69259. * @param renderEffectName the name of the effect to enable
  69260. * @param cameras the cameras that the effect should be enabled on
  69261. */
  69262. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  69263. /**
  69264. * Disables an effect by name on a pipeline
  69265. * @param renderPipelineName the name of the pipeline to disable the effect in
  69266. * @param renderEffectName the name of the effect to disable
  69267. * @param cameras the cameras that the effect should be disabled on
  69268. */
  69269. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  69270. /**
  69271. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  69272. */
  69273. update(): void;
  69274. /** @hidden */
  69275. _rebuild(): void;
  69276. /**
  69277. * Disposes of the manager and pipelines
  69278. */
  69279. dispose(): void;
  69280. }
  69281. }
  69282. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  69283. import { ISceneComponent } from "babylonjs/sceneComponent";
  69284. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  69285. import { Scene } from "babylonjs/scene";
  69286. module "babylonjs/scene" {
  69287. interface Scene {
  69288. /** @hidden (Backing field) */
  69289. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  69290. /**
  69291. * Gets the postprocess render pipeline manager
  69292. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  69293. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  69294. */
  69295. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  69296. }
  69297. }
  69298. /**
  69299. * Defines the Render Pipeline scene component responsible to rendering pipelines
  69300. */
  69301. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  69302. /**
  69303. * The component name helpfull to identify the component in the list of scene components.
  69304. */
  69305. readonly name: string;
  69306. /**
  69307. * The scene the component belongs to.
  69308. */
  69309. scene: Scene;
  69310. /**
  69311. * Creates a new instance of the component for the given scene
  69312. * @param scene Defines the scene to register the component in
  69313. */
  69314. constructor(scene: Scene);
  69315. /**
  69316. * Registers the component in a given scene
  69317. */
  69318. register(): void;
  69319. /**
  69320. * Rebuilds the elements related to this component in case of
  69321. * context lost for instance.
  69322. */
  69323. rebuild(): void;
  69324. /**
  69325. * Disposes the component and the associated ressources
  69326. */
  69327. dispose(): void;
  69328. private _gatherRenderTargets;
  69329. }
  69330. }
  69331. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  69332. import { Nullable } from "babylonjs/types";
  69333. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  69334. import { Camera } from "babylonjs/Cameras/camera";
  69335. import { IDisposable } from "babylonjs/scene";
  69336. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  69337. import { Scene } from "babylonjs/scene";
  69338. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  69339. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  69340. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  69341. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  69342. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  69343. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  69344. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  69345. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  69346. import { Animation } from "babylonjs/Animations/animation";
  69347. /**
  69348. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  69349. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  69350. */
  69351. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  69352. private _scene;
  69353. private _camerasToBeAttached;
  69354. /**
  69355. * ID of the sharpen post process,
  69356. */
  69357. private readonly SharpenPostProcessId;
  69358. /**
  69359. * @ignore
  69360. * ID of the image processing post process;
  69361. */
  69362. readonly ImageProcessingPostProcessId: string;
  69363. /**
  69364. * @ignore
  69365. * ID of the Fast Approximate Anti-Aliasing post process;
  69366. */
  69367. readonly FxaaPostProcessId: string;
  69368. /**
  69369. * ID of the chromatic aberration post process,
  69370. */
  69371. private readonly ChromaticAberrationPostProcessId;
  69372. /**
  69373. * ID of the grain post process
  69374. */
  69375. private readonly GrainPostProcessId;
  69376. /**
  69377. * Sharpen post process which will apply a sharpen convolution to enhance edges
  69378. */
  69379. sharpen: SharpenPostProcess;
  69380. private _sharpenEffect;
  69381. private bloom;
  69382. /**
  69383. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  69384. */
  69385. depthOfField: DepthOfFieldEffect;
  69386. /**
  69387. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  69388. */
  69389. fxaa: FxaaPostProcess;
  69390. /**
  69391. * Image post processing pass used to perform operations such as tone mapping or color grading.
  69392. */
  69393. imageProcessing: ImageProcessingPostProcess;
  69394. /**
  69395. * Chromatic aberration post process which will shift rgb colors in the image
  69396. */
  69397. chromaticAberration: ChromaticAberrationPostProcess;
  69398. private _chromaticAberrationEffect;
  69399. /**
  69400. * Grain post process which add noise to the image
  69401. */
  69402. grain: GrainPostProcess;
  69403. private _grainEffect;
  69404. /**
  69405. * Glow post process which adds a glow to emissive areas of the image
  69406. */
  69407. private _glowLayer;
  69408. /**
  69409. * Animations which can be used to tweak settings over a period of time
  69410. */
  69411. animations: Animation[];
  69412. private _imageProcessingConfigurationObserver;
  69413. private _sharpenEnabled;
  69414. private _bloomEnabled;
  69415. private _depthOfFieldEnabled;
  69416. private _depthOfFieldBlurLevel;
  69417. private _fxaaEnabled;
  69418. private _imageProcessingEnabled;
  69419. private _defaultPipelineTextureType;
  69420. private _bloomScale;
  69421. private _chromaticAberrationEnabled;
  69422. private _grainEnabled;
  69423. private _buildAllowed;
  69424. /**
  69425. * Gets active scene
  69426. */
  69427. get scene(): Scene;
  69428. /**
  69429. * Enable or disable the sharpen process from the pipeline
  69430. */
  69431. set sharpenEnabled(enabled: boolean);
  69432. get sharpenEnabled(): boolean;
  69433. private _resizeObserver;
  69434. private _hardwareScaleLevel;
  69435. private _bloomKernel;
  69436. /**
  69437. * Specifies the size of the bloom blur kernel, relative to the final output size
  69438. */
  69439. get bloomKernel(): number;
  69440. set bloomKernel(value: number);
  69441. /**
  69442. * Specifies the weight of the bloom in the final rendering
  69443. */
  69444. private _bloomWeight;
  69445. /**
  69446. * Specifies the luma threshold for the area that will be blurred by the bloom
  69447. */
  69448. private _bloomThreshold;
  69449. private _hdr;
  69450. /**
  69451. * The strength of the bloom.
  69452. */
  69453. set bloomWeight(value: number);
  69454. get bloomWeight(): number;
  69455. /**
  69456. * The strength of the bloom.
  69457. */
  69458. set bloomThreshold(value: number);
  69459. get bloomThreshold(): number;
  69460. /**
  69461. * The scale of the bloom, lower value will provide better performance.
  69462. */
  69463. set bloomScale(value: number);
  69464. get bloomScale(): number;
  69465. /**
  69466. * Enable or disable the bloom from the pipeline
  69467. */
  69468. set bloomEnabled(enabled: boolean);
  69469. get bloomEnabled(): boolean;
  69470. private _rebuildBloom;
  69471. /**
  69472. * If the depth of field is enabled.
  69473. */
  69474. get depthOfFieldEnabled(): boolean;
  69475. set depthOfFieldEnabled(enabled: boolean);
  69476. /**
  69477. * Blur level of the depth of field effect. (Higher blur will effect performance)
  69478. */
  69479. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  69480. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  69481. /**
  69482. * If the anti aliasing is enabled.
  69483. */
  69484. set fxaaEnabled(enabled: boolean);
  69485. get fxaaEnabled(): boolean;
  69486. private _samples;
  69487. /**
  69488. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  69489. */
  69490. set samples(sampleCount: number);
  69491. get samples(): number;
  69492. /**
  69493. * If image processing is enabled.
  69494. */
  69495. set imageProcessingEnabled(enabled: boolean);
  69496. get imageProcessingEnabled(): boolean;
  69497. /**
  69498. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  69499. */
  69500. set glowLayerEnabled(enabled: boolean);
  69501. get glowLayerEnabled(): boolean;
  69502. /**
  69503. * Gets the glow layer (or null if not defined)
  69504. */
  69505. get glowLayer(): Nullable<GlowLayer>;
  69506. /**
  69507. * Enable or disable the chromaticAberration process from the pipeline
  69508. */
  69509. set chromaticAberrationEnabled(enabled: boolean);
  69510. get chromaticAberrationEnabled(): boolean;
  69511. /**
  69512. * Enable or disable the grain process from the pipeline
  69513. */
  69514. set grainEnabled(enabled: boolean);
  69515. get grainEnabled(): boolean;
  69516. /**
  69517. * @constructor
  69518. * @param name - The rendering pipeline name (default: "")
  69519. * @param hdr - If high dynamic range textures should be used (default: true)
  69520. * @param scene - The scene linked to this pipeline (default: the last created scene)
  69521. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  69522. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  69523. */
  69524. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  69525. /**
  69526. * Get the class name
  69527. * @returns "DefaultRenderingPipeline"
  69528. */
  69529. getClassName(): string;
  69530. /**
  69531. * Force the compilation of the entire pipeline.
  69532. */
  69533. prepare(): void;
  69534. private _hasCleared;
  69535. private _prevPostProcess;
  69536. private _prevPrevPostProcess;
  69537. private _setAutoClearAndTextureSharing;
  69538. private _depthOfFieldSceneObserver;
  69539. private _buildPipeline;
  69540. private _disposePostProcesses;
  69541. /**
  69542. * Adds a camera to the pipeline
  69543. * @param camera the camera to be added
  69544. */
  69545. addCamera(camera: Camera): void;
  69546. /**
  69547. * Removes a camera from the pipeline
  69548. * @param camera the camera to remove
  69549. */
  69550. removeCamera(camera: Camera): void;
  69551. /**
  69552. * Dispose of the pipeline and stop all post processes
  69553. */
  69554. dispose(): void;
  69555. /**
  69556. * Serialize the rendering pipeline (Used when exporting)
  69557. * @returns the serialized object
  69558. */
  69559. serialize(): any;
  69560. /**
  69561. * Parse the serialized pipeline
  69562. * @param source Source pipeline.
  69563. * @param scene The scene to load the pipeline to.
  69564. * @param rootUrl The URL of the serialized pipeline.
  69565. * @returns An instantiated pipeline from the serialized object.
  69566. */
  69567. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  69568. }
  69569. }
  69570. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  69571. /** @hidden */
  69572. export var lensHighlightsPixelShader: {
  69573. name: string;
  69574. shader: string;
  69575. };
  69576. }
  69577. declare module "babylonjs/Shaders/depthOfField.fragment" {
  69578. /** @hidden */
  69579. export var depthOfFieldPixelShader: {
  69580. name: string;
  69581. shader: string;
  69582. };
  69583. }
  69584. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  69585. import { Camera } from "babylonjs/Cameras/camera";
  69586. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  69587. import { Scene } from "babylonjs/scene";
  69588. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  69589. import "babylonjs/Shaders/chromaticAberration.fragment";
  69590. import "babylonjs/Shaders/lensHighlights.fragment";
  69591. import "babylonjs/Shaders/depthOfField.fragment";
  69592. /**
  69593. * BABYLON.JS Chromatic Aberration GLSL Shader
  69594. * Author: Olivier Guyot
  69595. * Separates very slightly R, G and B colors on the edges of the screen
  69596. * Inspired by Francois Tarlier & Martins Upitis
  69597. */
  69598. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  69599. /**
  69600. * @ignore
  69601. * The chromatic aberration PostProcess id in the pipeline
  69602. */
  69603. LensChromaticAberrationEffect: string;
  69604. /**
  69605. * @ignore
  69606. * The highlights enhancing PostProcess id in the pipeline
  69607. */
  69608. HighlightsEnhancingEffect: string;
  69609. /**
  69610. * @ignore
  69611. * The depth-of-field PostProcess id in the pipeline
  69612. */
  69613. LensDepthOfFieldEffect: string;
  69614. private _scene;
  69615. private _depthTexture;
  69616. private _grainTexture;
  69617. private _chromaticAberrationPostProcess;
  69618. private _highlightsPostProcess;
  69619. private _depthOfFieldPostProcess;
  69620. private _edgeBlur;
  69621. private _grainAmount;
  69622. private _chromaticAberration;
  69623. private _distortion;
  69624. private _highlightsGain;
  69625. private _highlightsThreshold;
  69626. private _dofDistance;
  69627. private _dofAperture;
  69628. private _dofDarken;
  69629. private _dofPentagon;
  69630. private _blurNoise;
  69631. /**
  69632. * @constructor
  69633. *
  69634. * Effect parameters are as follow:
  69635. * {
  69636. * chromatic_aberration: number; // from 0 to x (1 for realism)
  69637. * edge_blur: number; // from 0 to x (1 for realism)
  69638. * distortion: number; // from 0 to x (1 for realism)
  69639. * grain_amount: number; // from 0 to 1
  69640. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  69641. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  69642. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  69643. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  69644. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  69645. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  69646. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  69647. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  69648. * }
  69649. * Note: if an effect parameter is unset, effect is disabled
  69650. *
  69651. * @param name The rendering pipeline name
  69652. * @param parameters - An object containing all parameters (see above)
  69653. * @param scene The scene linked to this pipeline
  69654. * @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)
  69655. * @param cameras The array of cameras that the rendering pipeline will be attached to
  69656. */
  69657. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  69658. /**
  69659. * Get the class name
  69660. * @returns "LensRenderingPipeline"
  69661. */
  69662. getClassName(): string;
  69663. /**
  69664. * Gets associated scene
  69665. */
  69666. get scene(): Scene;
  69667. /**
  69668. * Gets or sets the edge blur
  69669. */
  69670. get edgeBlur(): number;
  69671. set edgeBlur(value: number);
  69672. /**
  69673. * Gets or sets the grain amount
  69674. */
  69675. get grainAmount(): number;
  69676. set grainAmount(value: number);
  69677. /**
  69678. * Gets or sets the chromatic aberration amount
  69679. */
  69680. get chromaticAberration(): number;
  69681. set chromaticAberration(value: number);
  69682. /**
  69683. * Gets or sets the depth of field aperture
  69684. */
  69685. get dofAperture(): number;
  69686. set dofAperture(value: number);
  69687. /**
  69688. * Gets or sets the edge distortion
  69689. */
  69690. get edgeDistortion(): number;
  69691. set edgeDistortion(value: number);
  69692. /**
  69693. * Gets or sets the depth of field distortion
  69694. */
  69695. get dofDistortion(): number;
  69696. set dofDistortion(value: number);
  69697. /**
  69698. * Gets or sets the darken out of focus amount
  69699. */
  69700. get darkenOutOfFocus(): number;
  69701. set darkenOutOfFocus(value: number);
  69702. /**
  69703. * Gets or sets a boolean indicating if blur noise is enabled
  69704. */
  69705. get blurNoise(): boolean;
  69706. set blurNoise(value: boolean);
  69707. /**
  69708. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  69709. */
  69710. get pentagonBokeh(): boolean;
  69711. set pentagonBokeh(value: boolean);
  69712. /**
  69713. * Gets or sets the highlight grain amount
  69714. */
  69715. get highlightsGain(): number;
  69716. set highlightsGain(value: number);
  69717. /**
  69718. * Gets or sets the highlight threshold
  69719. */
  69720. get highlightsThreshold(): number;
  69721. set highlightsThreshold(value: number);
  69722. /**
  69723. * Sets the amount of blur at the edges
  69724. * @param amount blur amount
  69725. */
  69726. setEdgeBlur(amount: number): void;
  69727. /**
  69728. * Sets edge blur to 0
  69729. */
  69730. disableEdgeBlur(): void;
  69731. /**
  69732. * Sets the amout of grain
  69733. * @param amount Amount of grain
  69734. */
  69735. setGrainAmount(amount: number): void;
  69736. /**
  69737. * Set grain amount to 0
  69738. */
  69739. disableGrain(): void;
  69740. /**
  69741. * Sets the chromatic aberration amount
  69742. * @param amount amount of chromatic aberration
  69743. */
  69744. setChromaticAberration(amount: number): void;
  69745. /**
  69746. * Sets chromatic aberration amount to 0
  69747. */
  69748. disableChromaticAberration(): void;
  69749. /**
  69750. * Sets the EdgeDistortion amount
  69751. * @param amount amount of EdgeDistortion
  69752. */
  69753. setEdgeDistortion(amount: number): void;
  69754. /**
  69755. * Sets edge distortion to 0
  69756. */
  69757. disableEdgeDistortion(): void;
  69758. /**
  69759. * Sets the FocusDistance amount
  69760. * @param amount amount of FocusDistance
  69761. */
  69762. setFocusDistance(amount: number): void;
  69763. /**
  69764. * Disables depth of field
  69765. */
  69766. disableDepthOfField(): void;
  69767. /**
  69768. * Sets the Aperture amount
  69769. * @param amount amount of Aperture
  69770. */
  69771. setAperture(amount: number): void;
  69772. /**
  69773. * Sets the DarkenOutOfFocus amount
  69774. * @param amount amount of DarkenOutOfFocus
  69775. */
  69776. setDarkenOutOfFocus(amount: number): void;
  69777. private _pentagonBokehIsEnabled;
  69778. /**
  69779. * Creates a pentagon bokeh effect
  69780. */
  69781. enablePentagonBokeh(): void;
  69782. /**
  69783. * Disables the pentagon bokeh effect
  69784. */
  69785. disablePentagonBokeh(): void;
  69786. /**
  69787. * Enables noise blur
  69788. */
  69789. enableNoiseBlur(): void;
  69790. /**
  69791. * Disables noise blur
  69792. */
  69793. disableNoiseBlur(): void;
  69794. /**
  69795. * Sets the HighlightsGain amount
  69796. * @param amount amount of HighlightsGain
  69797. */
  69798. setHighlightsGain(amount: number): void;
  69799. /**
  69800. * Sets the HighlightsThreshold amount
  69801. * @param amount amount of HighlightsThreshold
  69802. */
  69803. setHighlightsThreshold(amount: number): void;
  69804. /**
  69805. * Disables highlights
  69806. */
  69807. disableHighlights(): void;
  69808. /**
  69809. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  69810. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  69811. */
  69812. dispose(disableDepthRender?: boolean): void;
  69813. private _createChromaticAberrationPostProcess;
  69814. private _createHighlightsPostProcess;
  69815. private _createDepthOfFieldPostProcess;
  69816. private _createGrainTexture;
  69817. }
  69818. }
  69819. declare module "babylonjs/Shaders/ssao2.fragment" {
  69820. /** @hidden */
  69821. export var ssao2PixelShader: {
  69822. name: string;
  69823. shader: string;
  69824. };
  69825. }
  69826. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  69827. /** @hidden */
  69828. export var ssaoCombinePixelShader: {
  69829. name: string;
  69830. shader: string;
  69831. };
  69832. }
  69833. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  69834. import { Camera } from "babylonjs/Cameras/camera";
  69835. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  69836. import { Scene } from "babylonjs/scene";
  69837. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  69838. import "babylonjs/Shaders/ssao2.fragment";
  69839. import "babylonjs/Shaders/ssaoCombine.fragment";
  69840. /**
  69841. * Render pipeline to produce ssao effect
  69842. */
  69843. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  69844. /**
  69845. * @ignore
  69846. * The PassPostProcess id in the pipeline that contains the original scene color
  69847. */
  69848. SSAOOriginalSceneColorEffect: string;
  69849. /**
  69850. * @ignore
  69851. * The SSAO PostProcess id in the pipeline
  69852. */
  69853. SSAORenderEffect: string;
  69854. /**
  69855. * @ignore
  69856. * The horizontal blur PostProcess id in the pipeline
  69857. */
  69858. SSAOBlurHRenderEffect: string;
  69859. /**
  69860. * @ignore
  69861. * The vertical blur PostProcess id in the pipeline
  69862. */
  69863. SSAOBlurVRenderEffect: string;
  69864. /**
  69865. * @ignore
  69866. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  69867. */
  69868. SSAOCombineRenderEffect: string;
  69869. /**
  69870. * The output strength of the SSAO post-process. Default value is 1.0.
  69871. */
  69872. totalStrength: number;
  69873. /**
  69874. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  69875. */
  69876. maxZ: number;
  69877. /**
  69878. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  69879. */
  69880. minZAspect: number;
  69881. private _samples;
  69882. /**
  69883. * Number of samples used for the SSAO calculations. Default value is 8
  69884. */
  69885. set samples(n: number);
  69886. get samples(): number;
  69887. private _textureSamples;
  69888. /**
  69889. * Number of samples to use for antialiasing
  69890. */
  69891. set textureSamples(n: number);
  69892. get textureSamples(): number;
  69893. /**
  69894. * Ratio object used for SSAO ratio and blur ratio
  69895. */
  69896. private _ratio;
  69897. /**
  69898. * Dynamically generated sphere sampler.
  69899. */
  69900. private _sampleSphere;
  69901. /**
  69902. * Blur filter offsets
  69903. */
  69904. private _samplerOffsets;
  69905. private _expensiveBlur;
  69906. /**
  69907. * If bilateral blur should be used
  69908. */
  69909. set expensiveBlur(b: boolean);
  69910. get expensiveBlur(): boolean;
  69911. /**
  69912. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  69913. */
  69914. radius: number;
  69915. /**
  69916. * The base color of the SSAO post-process
  69917. * The final result is "base + ssao" between [0, 1]
  69918. */
  69919. base: number;
  69920. /**
  69921. * Support test.
  69922. */
  69923. static get IsSupported(): boolean;
  69924. private _scene;
  69925. private _depthTexture;
  69926. private _normalTexture;
  69927. private _randomTexture;
  69928. private _originalColorPostProcess;
  69929. private _ssaoPostProcess;
  69930. private _blurHPostProcess;
  69931. private _blurVPostProcess;
  69932. private _ssaoCombinePostProcess;
  69933. /**
  69934. * Gets active scene
  69935. */
  69936. get scene(): Scene;
  69937. /**
  69938. * @constructor
  69939. * @param name The rendering pipeline name
  69940. * @param scene The scene linked to this pipeline
  69941. * @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 }
  69942. * @param cameras The array of cameras that the rendering pipeline will be attached to
  69943. */
  69944. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  69945. /**
  69946. * Get the class name
  69947. * @returns "SSAO2RenderingPipeline"
  69948. */
  69949. getClassName(): string;
  69950. /**
  69951. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  69952. */
  69953. dispose(disableGeometryBufferRenderer?: boolean): void;
  69954. private _createBlurPostProcess;
  69955. /** @hidden */
  69956. _rebuild(): void;
  69957. private _bits;
  69958. private _radicalInverse_VdC;
  69959. private _hammersley;
  69960. private _hemisphereSample_uniform;
  69961. private _generateHemisphere;
  69962. private _createSSAOPostProcess;
  69963. private _createSSAOCombinePostProcess;
  69964. private _createRandomTexture;
  69965. /**
  69966. * Serialize the rendering pipeline (Used when exporting)
  69967. * @returns the serialized object
  69968. */
  69969. serialize(): any;
  69970. /**
  69971. * Parse the serialized pipeline
  69972. * @param source Source pipeline.
  69973. * @param scene The scene to load the pipeline to.
  69974. * @param rootUrl The URL of the serialized pipeline.
  69975. * @returns An instantiated pipeline from the serialized object.
  69976. */
  69977. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  69978. }
  69979. }
  69980. declare module "babylonjs/Shaders/ssao.fragment" {
  69981. /** @hidden */
  69982. export var ssaoPixelShader: {
  69983. name: string;
  69984. shader: string;
  69985. };
  69986. }
  69987. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  69988. import { Camera } from "babylonjs/Cameras/camera";
  69989. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  69990. import { Scene } from "babylonjs/scene";
  69991. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  69992. import "babylonjs/Shaders/ssao.fragment";
  69993. import "babylonjs/Shaders/ssaoCombine.fragment";
  69994. /**
  69995. * Render pipeline to produce ssao effect
  69996. */
  69997. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  69998. /**
  69999. * @ignore
  70000. * The PassPostProcess id in the pipeline that contains the original scene color
  70001. */
  70002. SSAOOriginalSceneColorEffect: string;
  70003. /**
  70004. * @ignore
  70005. * The SSAO PostProcess id in the pipeline
  70006. */
  70007. SSAORenderEffect: string;
  70008. /**
  70009. * @ignore
  70010. * The horizontal blur PostProcess id in the pipeline
  70011. */
  70012. SSAOBlurHRenderEffect: string;
  70013. /**
  70014. * @ignore
  70015. * The vertical blur PostProcess id in the pipeline
  70016. */
  70017. SSAOBlurVRenderEffect: string;
  70018. /**
  70019. * @ignore
  70020. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  70021. */
  70022. SSAOCombineRenderEffect: string;
  70023. /**
  70024. * The output strength of the SSAO post-process. Default value is 1.0.
  70025. */
  70026. totalStrength: number;
  70027. /**
  70028. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  70029. */
  70030. radius: number;
  70031. /**
  70032. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  70033. * Must not be equal to fallOff and superior to fallOff.
  70034. * Default value is 0.0075
  70035. */
  70036. area: number;
  70037. /**
  70038. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  70039. * Must not be equal to area and inferior to area.
  70040. * Default value is 0.000001
  70041. */
  70042. fallOff: number;
  70043. /**
  70044. * The base color of the SSAO post-process
  70045. * The final result is "base + ssao" between [0, 1]
  70046. */
  70047. base: number;
  70048. private _scene;
  70049. private _depthTexture;
  70050. private _randomTexture;
  70051. private _originalColorPostProcess;
  70052. private _ssaoPostProcess;
  70053. private _blurHPostProcess;
  70054. private _blurVPostProcess;
  70055. private _ssaoCombinePostProcess;
  70056. private _firstUpdate;
  70057. /**
  70058. * Gets active scene
  70059. */
  70060. get scene(): Scene;
  70061. /**
  70062. * @constructor
  70063. * @param name - The rendering pipeline name
  70064. * @param scene - The scene linked to this pipeline
  70065. * @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 }
  70066. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  70067. */
  70068. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  70069. /**
  70070. * Get the class name
  70071. * @returns "SSAORenderingPipeline"
  70072. */
  70073. getClassName(): string;
  70074. /**
  70075. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  70076. */
  70077. dispose(disableDepthRender?: boolean): void;
  70078. private _createBlurPostProcess;
  70079. /** @hidden */
  70080. _rebuild(): void;
  70081. private _createSSAOPostProcess;
  70082. private _createSSAOCombinePostProcess;
  70083. private _createRandomTexture;
  70084. }
  70085. }
  70086. declare module "babylonjs/Shaders/screenSpaceReflection.fragment" {
  70087. /** @hidden */
  70088. export var screenSpaceReflectionPixelShader: {
  70089. name: string;
  70090. shader: string;
  70091. };
  70092. }
  70093. declare module "babylonjs/PostProcesses/screenSpaceReflectionPostProcess" {
  70094. import { Nullable } from "babylonjs/types";
  70095. import { Camera } from "babylonjs/Cameras/camera";
  70096. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  70097. import { Scene } from "babylonjs/scene";
  70098. import "babylonjs/Shaders/screenSpaceReflection.fragment";
  70099. import { Engine } from "babylonjs/Engines/engine";
  70100. /**
  70101. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  70102. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  70103. */
  70104. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  70105. /**
  70106. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  70107. */
  70108. threshold: number;
  70109. /**
  70110. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  70111. */
  70112. strength: number;
  70113. /**
  70114. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  70115. */
  70116. reflectionSpecularFalloffExponent: number;
  70117. /**
  70118. * 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]
  70119. */
  70120. step: number;
  70121. /**
  70122. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  70123. */
  70124. roughnessFactor: number;
  70125. private _geometryBufferRenderer;
  70126. private _enableSmoothReflections;
  70127. private _reflectionSamples;
  70128. private _smoothSteps;
  70129. /**
  70130. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  70131. * @param name The name of the effect.
  70132. * @param scene The scene containing the objects to calculate reflections.
  70133. * @param options The required width/height ratio to downsize to before computing the render pass.
  70134. * @param camera The camera to apply the render pass to.
  70135. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70136. * @param engine The engine which the post process will be applied. (default: current engine)
  70137. * @param reusable If the post process can be reused on the same frame. (default: false)
  70138. * @param textureType Type of textures used when performing the post process. (default: 0)
  70139. * @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)
  70140. */
  70141. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  70142. /**
  70143. * Gets wether or not smoothing reflections is enabled.
  70144. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  70145. */
  70146. get enableSmoothReflections(): boolean;
  70147. /**
  70148. * Sets wether or not smoothing reflections is enabled.
  70149. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  70150. */
  70151. set enableSmoothReflections(enabled: boolean);
  70152. /**
  70153. * Gets the number of samples taken while computing reflections. More samples count is high,
  70154. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  70155. */
  70156. get reflectionSamples(): number;
  70157. /**
  70158. * Sets the number of samples taken while computing reflections. More samples count is high,
  70159. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  70160. */
  70161. set reflectionSamples(samples: number);
  70162. /**
  70163. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  70164. * more the post-process will require GPU power and can generate a drop in FPS.
  70165. * Default value (5.0) work pretty well in all cases but can be adjusted.
  70166. */
  70167. get smoothSteps(): number;
  70168. set smoothSteps(steps: number);
  70169. private _updateEffectDefines;
  70170. }
  70171. }
  70172. declare module "babylonjs/Shaders/standard.fragment" {
  70173. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  70174. /** @hidden */
  70175. export var standardPixelShader: {
  70176. name: string;
  70177. shader: string;
  70178. };
  70179. }
  70180. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  70181. import { Nullable } from "babylonjs/types";
  70182. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  70183. import { Camera } from "babylonjs/Cameras/camera";
  70184. import { Texture } from "babylonjs/Materials/Textures/texture";
  70185. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  70186. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  70187. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  70188. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  70189. import { IDisposable } from "babylonjs/scene";
  70190. import { SpotLight } from "babylonjs/Lights/spotLight";
  70191. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  70192. import { Scene } from "babylonjs/scene";
  70193. import { ScreenSpaceReflectionPostProcess } from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  70194. import { Animation } from "babylonjs/Animations/animation";
  70195. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  70196. import "babylonjs/Shaders/standard.fragment";
  70197. /**
  70198. * Standard rendering pipeline
  70199. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  70200. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  70201. */
  70202. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  70203. /**
  70204. * Public members
  70205. */
  70206. /**
  70207. * Post-process which contains the original scene color before the pipeline applies all the effects
  70208. */
  70209. originalPostProcess: Nullable<PostProcess>;
  70210. /**
  70211. * Post-process used to down scale an image x4
  70212. */
  70213. downSampleX4PostProcess: Nullable<PostProcess>;
  70214. /**
  70215. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  70216. */
  70217. brightPassPostProcess: Nullable<PostProcess>;
  70218. /**
  70219. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  70220. */
  70221. blurHPostProcesses: PostProcess[];
  70222. /**
  70223. * Post-process array storing all the vertical blur post-processes used by the pipeline
  70224. */
  70225. blurVPostProcesses: PostProcess[];
  70226. /**
  70227. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  70228. */
  70229. textureAdderPostProcess: Nullable<PostProcess>;
  70230. /**
  70231. * Post-process used to create volumetric lighting effect
  70232. */
  70233. volumetricLightPostProcess: Nullable<PostProcess>;
  70234. /**
  70235. * Post-process used to smooth the previous volumetric light post-process on the X axis
  70236. */
  70237. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  70238. /**
  70239. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  70240. */
  70241. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  70242. /**
  70243. * Post-process used to merge the volumetric light effect and the real scene color
  70244. */
  70245. volumetricLightMergePostProces: Nullable<PostProcess>;
  70246. /**
  70247. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  70248. */
  70249. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  70250. /**
  70251. * Base post-process used to calculate the average luminance of the final image for HDR
  70252. */
  70253. luminancePostProcess: Nullable<PostProcess>;
  70254. /**
  70255. * Post-processes used to create down sample post-processes in order to get
  70256. * the average luminance of the final image for HDR
  70257. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  70258. */
  70259. luminanceDownSamplePostProcesses: PostProcess[];
  70260. /**
  70261. * Post-process used to create a HDR effect (light adaptation)
  70262. */
  70263. hdrPostProcess: Nullable<PostProcess>;
  70264. /**
  70265. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  70266. */
  70267. textureAdderFinalPostProcess: Nullable<PostProcess>;
  70268. /**
  70269. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  70270. */
  70271. lensFlareFinalPostProcess: Nullable<PostProcess>;
  70272. /**
  70273. * Post-process used to merge the final HDR post-process and the real scene color
  70274. */
  70275. hdrFinalPostProcess: Nullable<PostProcess>;
  70276. /**
  70277. * Post-process used to create a lens flare effect
  70278. */
  70279. lensFlarePostProcess: Nullable<PostProcess>;
  70280. /**
  70281. * Post-process that merges the result of the lens flare post-process and the real scene color
  70282. */
  70283. lensFlareComposePostProcess: Nullable<PostProcess>;
  70284. /**
  70285. * Post-process used to create a motion blur effect
  70286. */
  70287. motionBlurPostProcess: Nullable<PostProcess>;
  70288. /**
  70289. * Post-process used to create a depth of field effect
  70290. */
  70291. depthOfFieldPostProcess: Nullable<PostProcess>;
  70292. /**
  70293. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  70294. */
  70295. fxaaPostProcess: Nullable<FxaaPostProcess>;
  70296. /**
  70297. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  70298. */
  70299. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  70300. /**
  70301. * Represents the brightness threshold in order to configure the illuminated surfaces
  70302. */
  70303. brightThreshold: number;
  70304. /**
  70305. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  70306. */
  70307. blurWidth: number;
  70308. /**
  70309. * Sets if the blur for highlighted surfaces must be only horizontal
  70310. */
  70311. horizontalBlur: boolean;
  70312. /**
  70313. * Gets the overall exposure used by the pipeline
  70314. */
  70315. get exposure(): number;
  70316. /**
  70317. * Sets the overall exposure used by the pipeline
  70318. */
  70319. set exposure(value: number);
  70320. /**
  70321. * Texture used typically to simulate "dirty" on camera lens
  70322. */
  70323. lensTexture: Nullable<Texture>;
  70324. /**
  70325. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  70326. */
  70327. volumetricLightCoefficient: number;
  70328. /**
  70329. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  70330. */
  70331. volumetricLightPower: number;
  70332. /**
  70333. * Used the set the blur intensity to smooth the volumetric lights
  70334. */
  70335. volumetricLightBlurScale: number;
  70336. /**
  70337. * Light (spot or directional) used to generate the volumetric lights rays
  70338. * The source light must have a shadow generate so the pipeline can get its
  70339. * depth map
  70340. */
  70341. sourceLight: Nullable<SpotLight | DirectionalLight>;
  70342. /**
  70343. * For eye adaptation, represents the minimum luminance the eye can see
  70344. */
  70345. hdrMinimumLuminance: number;
  70346. /**
  70347. * For eye adaptation, represents the decrease luminance speed
  70348. */
  70349. hdrDecreaseRate: number;
  70350. /**
  70351. * For eye adaptation, represents the increase luminance speed
  70352. */
  70353. hdrIncreaseRate: number;
  70354. /**
  70355. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  70356. */
  70357. get hdrAutoExposure(): boolean;
  70358. /**
  70359. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  70360. */
  70361. set hdrAutoExposure(value: boolean);
  70362. /**
  70363. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  70364. */
  70365. lensColorTexture: Nullable<Texture>;
  70366. /**
  70367. * The overall strengh for the lens flare effect
  70368. */
  70369. lensFlareStrength: number;
  70370. /**
  70371. * Dispersion coefficient for lens flare ghosts
  70372. */
  70373. lensFlareGhostDispersal: number;
  70374. /**
  70375. * Main lens flare halo width
  70376. */
  70377. lensFlareHaloWidth: number;
  70378. /**
  70379. * Based on the lens distortion effect, defines how much the lens flare result
  70380. * is distorted
  70381. */
  70382. lensFlareDistortionStrength: number;
  70383. /**
  70384. * Configures the blur intensity used for for lens flare (halo)
  70385. */
  70386. lensFlareBlurWidth: number;
  70387. /**
  70388. * Lens star texture must be used to simulate rays on the flares and is available
  70389. * in the documentation
  70390. */
  70391. lensStarTexture: Nullable<Texture>;
  70392. /**
  70393. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  70394. * flare effect by taking account of the dirt texture
  70395. */
  70396. lensFlareDirtTexture: Nullable<Texture>;
  70397. /**
  70398. * Represents the focal length for the depth of field effect
  70399. */
  70400. depthOfFieldDistance: number;
  70401. /**
  70402. * Represents the blur intensity for the blurred part of the depth of field effect
  70403. */
  70404. depthOfFieldBlurWidth: number;
  70405. /**
  70406. * Gets how much the image is blurred by the movement while using the motion blur post-process
  70407. */
  70408. get motionStrength(): number;
  70409. /**
  70410. * Sets how much the image is blurred by the movement while using the motion blur post-process
  70411. */
  70412. set motionStrength(strength: number);
  70413. /**
  70414. * Gets wether or not the motion blur post-process is object based or screen based.
  70415. */
  70416. get objectBasedMotionBlur(): boolean;
  70417. /**
  70418. * Sets wether or not the motion blur post-process should be object based or screen based
  70419. */
  70420. set objectBasedMotionBlur(value: boolean);
  70421. /**
  70422. * List of animations for the pipeline (IAnimatable implementation)
  70423. */
  70424. animations: Animation[];
  70425. /**
  70426. * Private members
  70427. */
  70428. private _scene;
  70429. private _currentDepthOfFieldSource;
  70430. private _basePostProcess;
  70431. private _fixedExposure;
  70432. private _currentExposure;
  70433. private _hdrAutoExposure;
  70434. private _hdrCurrentLuminance;
  70435. private _motionStrength;
  70436. private _isObjectBasedMotionBlur;
  70437. private _floatTextureType;
  70438. private _camerasToBeAttached;
  70439. private _ratio;
  70440. private _bloomEnabled;
  70441. private _depthOfFieldEnabled;
  70442. private _vlsEnabled;
  70443. private _lensFlareEnabled;
  70444. private _hdrEnabled;
  70445. private _motionBlurEnabled;
  70446. private _fxaaEnabled;
  70447. private _screenSpaceReflectionsEnabled;
  70448. private _motionBlurSamples;
  70449. private _volumetricLightStepsCount;
  70450. private _samples;
  70451. /**
  70452. * @ignore
  70453. * Specifies if the bloom pipeline is enabled
  70454. */
  70455. get BloomEnabled(): boolean;
  70456. set BloomEnabled(enabled: boolean);
  70457. /**
  70458. * @ignore
  70459. * Specifies if the depth of field pipeline is enabed
  70460. */
  70461. get DepthOfFieldEnabled(): boolean;
  70462. set DepthOfFieldEnabled(enabled: boolean);
  70463. /**
  70464. * @ignore
  70465. * Specifies if the lens flare pipeline is enabed
  70466. */
  70467. get LensFlareEnabled(): boolean;
  70468. set LensFlareEnabled(enabled: boolean);
  70469. /**
  70470. * @ignore
  70471. * Specifies if the HDR pipeline is enabled
  70472. */
  70473. get HDREnabled(): boolean;
  70474. set HDREnabled(enabled: boolean);
  70475. /**
  70476. * @ignore
  70477. * Specifies if the volumetric lights scattering effect is enabled
  70478. */
  70479. get VLSEnabled(): boolean;
  70480. set VLSEnabled(enabled: boolean);
  70481. /**
  70482. * @ignore
  70483. * Specifies if the motion blur effect is enabled
  70484. */
  70485. get MotionBlurEnabled(): boolean;
  70486. set MotionBlurEnabled(enabled: boolean);
  70487. /**
  70488. * Specifies if anti-aliasing is enabled
  70489. */
  70490. get fxaaEnabled(): boolean;
  70491. set fxaaEnabled(enabled: boolean);
  70492. /**
  70493. * Specifies if screen space reflections are enabled.
  70494. */
  70495. get screenSpaceReflectionsEnabled(): boolean;
  70496. set screenSpaceReflectionsEnabled(enabled: boolean);
  70497. /**
  70498. * Specifies the number of steps used to calculate the volumetric lights
  70499. * Typically in interval [50, 200]
  70500. */
  70501. get volumetricLightStepsCount(): number;
  70502. set volumetricLightStepsCount(count: number);
  70503. /**
  70504. * Specifies the number of samples used for the motion blur effect
  70505. * Typically in interval [16, 64]
  70506. */
  70507. get motionBlurSamples(): number;
  70508. set motionBlurSamples(samples: number);
  70509. /**
  70510. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  70511. */
  70512. get samples(): number;
  70513. set samples(sampleCount: number);
  70514. /**
  70515. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  70516. * @constructor
  70517. * @param name The rendering pipeline name
  70518. * @param scene The scene linked to this pipeline
  70519. * @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)
  70520. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  70521. * @param cameras The array of cameras that the rendering pipeline will be attached to
  70522. */
  70523. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  70524. private _buildPipeline;
  70525. private _createDownSampleX4PostProcess;
  70526. private _createBrightPassPostProcess;
  70527. private _createBlurPostProcesses;
  70528. private _createTextureAdderPostProcess;
  70529. private _createVolumetricLightPostProcess;
  70530. private _createLuminancePostProcesses;
  70531. private _createHdrPostProcess;
  70532. private _createLensFlarePostProcess;
  70533. private _createDepthOfFieldPostProcess;
  70534. private _createMotionBlurPostProcess;
  70535. private _getDepthTexture;
  70536. private _disposePostProcesses;
  70537. /**
  70538. * Dispose of the pipeline and stop all post processes
  70539. */
  70540. dispose(): void;
  70541. /**
  70542. * Serialize the rendering pipeline (Used when exporting)
  70543. * @returns the serialized object
  70544. */
  70545. serialize(): any;
  70546. /**
  70547. * Parse the serialized pipeline
  70548. * @param source Source pipeline.
  70549. * @param scene The scene to load the pipeline to.
  70550. * @param rootUrl The URL of the serialized pipeline.
  70551. * @returns An instantiated pipeline from the serialized object.
  70552. */
  70553. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  70554. /**
  70555. * Luminance steps
  70556. */
  70557. static LuminanceSteps: number;
  70558. }
  70559. }
  70560. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  70561. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  70562. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  70563. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  70564. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  70565. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  70566. }
  70567. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  70568. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  70569. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  70570. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  70571. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  70572. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  70573. }
  70574. declare module "babylonjs/Shaders/tonemap.fragment" {
  70575. /** @hidden */
  70576. export var tonemapPixelShader: {
  70577. name: string;
  70578. shader: string;
  70579. };
  70580. }
  70581. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  70582. import { Camera } from "babylonjs/Cameras/camera";
  70583. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  70584. import "babylonjs/Shaders/tonemap.fragment";
  70585. import { Engine } from "babylonjs/Engines/engine";
  70586. /** Defines operator used for tonemapping */
  70587. export enum TonemappingOperator {
  70588. /** Hable */
  70589. Hable = 0,
  70590. /** Reinhard */
  70591. Reinhard = 1,
  70592. /** HejiDawson */
  70593. HejiDawson = 2,
  70594. /** Photographic */
  70595. Photographic = 3
  70596. }
  70597. /**
  70598. * Defines a post process to apply tone mapping
  70599. */
  70600. export class TonemapPostProcess extends PostProcess {
  70601. private _operator;
  70602. /** Defines the required exposure adjustement */
  70603. exposureAdjustment: number;
  70604. /**
  70605. * Creates a new TonemapPostProcess
  70606. * @param name defines the name of the postprocess
  70607. * @param _operator defines the operator to use
  70608. * @param exposureAdjustment defines the required exposure adjustement
  70609. * @param camera defines the camera to use (can be null)
  70610. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  70611. * @param engine defines the hosting engine (can be ignore if camera is set)
  70612. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  70613. */
  70614. constructor(name: string, _operator: TonemappingOperator,
  70615. /** Defines the required exposure adjustement */
  70616. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  70617. }
  70618. }
  70619. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  70620. /** @hidden */
  70621. export var volumetricLightScatteringPixelShader: {
  70622. name: string;
  70623. shader: string;
  70624. };
  70625. }
  70626. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  70627. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  70628. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  70629. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  70630. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  70631. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  70632. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  70633. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  70634. /** @hidden */
  70635. export var volumetricLightScatteringPassVertexShader: {
  70636. name: string;
  70637. shader: string;
  70638. };
  70639. }
  70640. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  70641. /** @hidden */
  70642. export var volumetricLightScatteringPassPixelShader: {
  70643. name: string;
  70644. shader: string;
  70645. };
  70646. }
  70647. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  70648. import { Vector3 } from "babylonjs/Maths/math.vector";
  70649. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  70650. import { Mesh } from "babylonjs/Meshes/mesh";
  70651. import { Camera } from "babylonjs/Cameras/camera";
  70652. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  70653. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  70654. import { Scene } from "babylonjs/scene";
  70655. import "babylonjs/Meshes/Builders/planeBuilder";
  70656. import "babylonjs/Shaders/depth.vertex";
  70657. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  70658. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  70659. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  70660. import { Engine } from "babylonjs/Engines/engine";
  70661. /**
  70662. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  70663. */
  70664. export class VolumetricLightScatteringPostProcess extends PostProcess {
  70665. private _volumetricLightScatteringPass;
  70666. private _volumetricLightScatteringRTT;
  70667. private _viewPort;
  70668. private _screenCoordinates;
  70669. private _cachedDefines;
  70670. /**
  70671. * If not undefined, the mesh position is computed from the attached node position
  70672. */
  70673. attachedNode: {
  70674. position: Vector3;
  70675. };
  70676. /**
  70677. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  70678. */
  70679. customMeshPosition: Vector3;
  70680. /**
  70681. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  70682. */
  70683. useCustomMeshPosition: boolean;
  70684. /**
  70685. * If the post-process should inverse the light scattering direction
  70686. */
  70687. invert: boolean;
  70688. /**
  70689. * The internal mesh used by the post-process
  70690. */
  70691. mesh: Mesh;
  70692. /**
  70693. * @hidden
  70694. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  70695. */
  70696. get useDiffuseColor(): boolean;
  70697. set useDiffuseColor(useDiffuseColor: boolean);
  70698. /**
  70699. * Array containing the excluded meshes not rendered in the internal pass
  70700. */
  70701. excludedMeshes: AbstractMesh[];
  70702. /**
  70703. * Controls the overall intensity of the post-process
  70704. */
  70705. exposure: number;
  70706. /**
  70707. * Dissipates each sample's contribution in range [0, 1]
  70708. */
  70709. decay: number;
  70710. /**
  70711. * Controls the overall intensity of each sample
  70712. */
  70713. weight: number;
  70714. /**
  70715. * Controls the density of each sample
  70716. */
  70717. density: number;
  70718. /**
  70719. * @constructor
  70720. * @param name The post-process name
  70721. * @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)
  70722. * @param camera The camera that the post-process will be attached to
  70723. * @param mesh The mesh used to create the light scattering
  70724. * @param samples The post-process quality, default 100
  70725. * @param samplingModeThe post-process filtering mode
  70726. * @param engine The babylon engine
  70727. * @param reusable If the post-process is reusable
  70728. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  70729. */
  70730. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  70731. /**
  70732. * Returns the string "VolumetricLightScatteringPostProcess"
  70733. * @returns "VolumetricLightScatteringPostProcess"
  70734. */
  70735. getClassName(): string;
  70736. private _isReady;
  70737. /**
  70738. * Sets the new light position for light scattering effect
  70739. * @param position The new custom light position
  70740. */
  70741. setCustomMeshPosition(position: Vector3): void;
  70742. /**
  70743. * Returns the light position for light scattering effect
  70744. * @return Vector3 The custom light position
  70745. */
  70746. getCustomMeshPosition(): Vector3;
  70747. /**
  70748. * Disposes the internal assets and detaches the post-process from the camera
  70749. */
  70750. dispose(camera: Camera): void;
  70751. /**
  70752. * Returns the render target texture used by the post-process
  70753. * @return the render target texture used by the post-process
  70754. */
  70755. getPass(): RenderTargetTexture;
  70756. private _meshExcluded;
  70757. private _createPass;
  70758. private _updateMeshScreenCoordinates;
  70759. /**
  70760. * Creates a default mesh for the Volumeric Light Scattering post-process
  70761. * @param name The mesh name
  70762. * @param scene The scene where to create the mesh
  70763. * @return the default mesh
  70764. */
  70765. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  70766. }
  70767. }
  70768. declare module "babylonjs/PostProcesses/index" {
  70769. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  70770. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  70771. export * from "babylonjs/PostProcesses/bloomEffect";
  70772. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  70773. export * from "babylonjs/PostProcesses/blurPostProcess";
  70774. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  70775. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  70776. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  70777. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  70778. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  70779. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  70780. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  70781. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  70782. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  70783. export * from "babylonjs/PostProcesses/filterPostProcess";
  70784. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  70785. export * from "babylonjs/PostProcesses/grainPostProcess";
  70786. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  70787. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  70788. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  70789. export * from "babylonjs/PostProcesses/passPostProcess";
  70790. export * from "babylonjs/PostProcesses/postProcess";
  70791. export * from "babylonjs/PostProcesses/postProcessManager";
  70792. export * from "babylonjs/PostProcesses/refractionPostProcess";
  70793. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  70794. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  70795. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  70796. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  70797. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  70798. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  70799. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  70800. export * from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  70801. }
  70802. declare module "babylonjs/Probes/index" {
  70803. export * from "babylonjs/Probes/reflectionProbe";
  70804. }
  70805. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  70806. import { Scene } from "babylonjs/scene";
  70807. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  70808. import { SmartArray } from "babylonjs/Misc/smartArray";
  70809. import { ISceneComponent } from "babylonjs/sceneComponent";
  70810. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  70811. import "babylonjs/Meshes/Builders/boxBuilder";
  70812. import "babylonjs/Shaders/color.fragment";
  70813. import "babylonjs/Shaders/color.vertex";
  70814. import { Color3 } from "babylonjs/Maths/math.color";
  70815. module "babylonjs/scene" {
  70816. interface Scene {
  70817. /** @hidden (Backing field) */
  70818. _boundingBoxRenderer: BoundingBoxRenderer;
  70819. /** @hidden (Backing field) */
  70820. _forceShowBoundingBoxes: boolean;
  70821. /**
  70822. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  70823. */
  70824. forceShowBoundingBoxes: boolean;
  70825. /**
  70826. * Gets the bounding box renderer associated with the scene
  70827. * @returns a BoundingBoxRenderer
  70828. */
  70829. getBoundingBoxRenderer(): BoundingBoxRenderer;
  70830. }
  70831. }
  70832. module "babylonjs/Meshes/abstractMesh" {
  70833. interface AbstractMesh {
  70834. /** @hidden (Backing field) */
  70835. _showBoundingBox: boolean;
  70836. /**
  70837. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  70838. */
  70839. showBoundingBox: boolean;
  70840. }
  70841. }
  70842. /**
  70843. * Component responsible of rendering the bounding box of the meshes in a scene.
  70844. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  70845. */
  70846. export class BoundingBoxRenderer implements ISceneComponent {
  70847. /**
  70848. * The component name helpfull to identify the component in the list of scene components.
  70849. */
  70850. readonly name: string;
  70851. /**
  70852. * The scene the component belongs to.
  70853. */
  70854. scene: Scene;
  70855. /**
  70856. * Color of the bounding box lines placed in front of an object
  70857. */
  70858. frontColor: Color3;
  70859. /**
  70860. * Color of the bounding box lines placed behind an object
  70861. */
  70862. backColor: Color3;
  70863. /**
  70864. * Defines if the renderer should show the back lines or not
  70865. */
  70866. showBackLines: boolean;
  70867. /**
  70868. * @hidden
  70869. */
  70870. renderList: SmartArray<BoundingBox>;
  70871. private _colorShader;
  70872. private _vertexBuffers;
  70873. private _indexBuffer;
  70874. private _fillIndexBuffer;
  70875. private _fillIndexData;
  70876. /**
  70877. * Instantiates a new bounding box renderer in a scene.
  70878. * @param scene the scene the renderer renders in
  70879. */
  70880. constructor(scene: Scene);
  70881. /**
  70882. * Registers the component in a given scene
  70883. */
  70884. register(): void;
  70885. private _evaluateSubMesh;
  70886. private _activeMesh;
  70887. private _prepareRessources;
  70888. private _createIndexBuffer;
  70889. /**
  70890. * Rebuilds the elements related to this component in case of
  70891. * context lost for instance.
  70892. */
  70893. rebuild(): void;
  70894. /**
  70895. * @hidden
  70896. */
  70897. reset(): void;
  70898. /**
  70899. * Render the bounding boxes of a specific rendering group
  70900. * @param renderingGroupId defines the rendering group to render
  70901. */
  70902. render(renderingGroupId: number): void;
  70903. /**
  70904. * In case of occlusion queries, we can render the occlusion bounding box through this method
  70905. * @param mesh Define the mesh to render the occlusion bounding box for
  70906. */
  70907. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  70908. /**
  70909. * Dispose and release the resources attached to this renderer.
  70910. */
  70911. dispose(): void;
  70912. }
  70913. }
  70914. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  70915. import { Nullable } from "babylonjs/types";
  70916. import { Scene } from "babylonjs/scene";
  70917. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  70918. import { Camera } from "babylonjs/Cameras/camera";
  70919. import { ISceneComponent } from "babylonjs/sceneComponent";
  70920. module "babylonjs/scene" {
  70921. interface Scene {
  70922. /** @hidden (Backing field) */
  70923. _depthRenderer: {
  70924. [id: string]: DepthRenderer;
  70925. };
  70926. /**
  70927. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  70928. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  70929. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  70930. * @returns the created depth renderer
  70931. */
  70932. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  70933. /**
  70934. * Disables a depth renderer for a given camera
  70935. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  70936. */
  70937. disableDepthRenderer(camera?: Nullable<Camera>): void;
  70938. }
  70939. }
  70940. /**
  70941. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  70942. * in several rendering techniques.
  70943. */
  70944. export class DepthRendererSceneComponent implements ISceneComponent {
  70945. /**
  70946. * The component name helpfull to identify the component in the list of scene components.
  70947. */
  70948. readonly name: string;
  70949. /**
  70950. * The scene the component belongs to.
  70951. */
  70952. scene: Scene;
  70953. /**
  70954. * Creates a new instance of the component for the given scene
  70955. * @param scene Defines the scene to register the component in
  70956. */
  70957. constructor(scene: Scene);
  70958. /**
  70959. * Registers the component in a given scene
  70960. */
  70961. register(): void;
  70962. /**
  70963. * Rebuilds the elements related to this component in case of
  70964. * context lost for instance.
  70965. */
  70966. rebuild(): void;
  70967. /**
  70968. * Disposes the component and the associated ressources
  70969. */
  70970. dispose(): void;
  70971. private _gatherRenderTargets;
  70972. private _gatherActiveCameraRenderTargets;
  70973. }
  70974. }
  70975. declare module "babylonjs/Shaders/outline.fragment" {
  70976. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  70977. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  70978. /** @hidden */
  70979. export var outlinePixelShader: {
  70980. name: string;
  70981. shader: string;
  70982. };
  70983. }
  70984. declare module "babylonjs/Shaders/outline.vertex" {
  70985. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  70986. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  70987. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  70988. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  70989. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  70990. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  70991. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  70992. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  70993. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  70994. /** @hidden */
  70995. export var outlineVertexShader: {
  70996. name: string;
  70997. shader: string;
  70998. };
  70999. }
  71000. declare module "babylonjs/Rendering/outlineRenderer" {
  71001. import { SubMesh } from "babylonjs/Meshes/subMesh";
  71002. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  71003. import { Scene } from "babylonjs/scene";
  71004. import { ISceneComponent } from "babylonjs/sceneComponent";
  71005. import "babylonjs/Shaders/outline.fragment";
  71006. import "babylonjs/Shaders/outline.vertex";
  71007. module "babylonjs/scene" {
  71008. interface Scene {
  71009. /** @hidden */
  71010. _outlineRenderer: OutlineRenderer;
  71011. /**
  71012. * Gets the outline renderer associated with the scene
  71013. * @returns a OutlineRenderer
  71014. */
  71015. getOutlineRenderer(): OutlineRenderer;
  71016. }
  71017. }
  71018. module "babylonjs/Meshes/abstractMesh" {
  71019. interface AbstractMesh {
  71020. /** @hidden (Backing field) */
  71021. _renderOutline: boolean;
  71022. /**
  71023. * Gets or sets a boolean indicating if the outline must be rendered as well
  71024. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  71025. */
  71026. renderOutline: boolean;
  71027. /** @hidden (Backing field) */
  71028. _renderOverlay: boolean;
  71029. /**
  71030. * Gets or sets a boolean indicating if the overlay must be rendered as well
  71031. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  71032. */
  71033. renderOverlay: boolean;
  71034. }
  71035. }
  71036. /**
  71037. * This class is responsible to draw bothe outline/overlay of meshes.
  71038. * It should not be used directly but through the available method on mesh.
  71039. */
  71040. export class OutlineRenderer implements ISceneComponent {
  71041. /**
  71042. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  71043. */
  71044. private static _StencilReference;
  71045. /**
  71046. * The name of the component. Each component must have a unique name.
  71047. */
  71048. name: string;
  71049. /**
  71050. * The scene the component belongs to.
  71051. */
  71052. scene: Scene;
  71053. /**
  71054. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  71055. */
  71056. zOffset: number;
  71057. private _engine;
  71058. private _effect;
  71059. private _cachedDefines;
  71060. private _savedDepthWrite;
  71061. /**
  71062. * Instantiates a new outline renderer. (There could be only one per scene).
  71063. * @param scene Defines the scene it belongs to
  71064. */
  71065. constructor(scene: Scene);
  71066. /**
  71067. * Register the component to one instance of a scene.
  71068. */
  71069. register(): void;
  71070. /**
  71071. * Rebuilds the elements related to this component in case of
  71072. * context lost for instance.
  71073. */
  71074. rebuild(): void;
  71075. /**
  71076. * Disposes the component and the associated ressources.
  71077. */
  71078. dispose(): void;
  71079. /**
  71080. * Renders the outline in the canvas.
  71081. * @param subMesh Defines the sumesh to render
  71082. * @param batch Defines the batch of meshes in case of instances
  71083. * @param useOverlay Defines if the rendering is for the overlay or the outline
  71084. */
  71085. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  71086. /**
  71087. * Returns whether or not the outline renderer is ready for a given submesh.
  71088. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  71089. * @param subMesh Defines the submesh to check readyness for
  71090. * @param useInstances Defines wheter wee are trying to render instances or not
  71091. * @returns true if ready otherwise false
  71092. */
  71093. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  71094. private _beforeRenderingMesh;
  71095. private _afterRenderingMesh;
  71096. }
  71097. }
  71098. declare module "babylonjs/Rendering/index" {
  71099. export * from "babylonjs/Rendering/boundingBoxRenderer";
  71100. export * from "babylonjs/Rendering/depthRenderer";
  71101. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  71102. export * from "babylonjs/Rendering/edgesRenderer";
  71103. export * from "babylonjs/Rendering/geometryBufferRenderer";
  71104. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  71105. export * from "babylonjs/Rendering/outlineRenderer";
  71106. export * from "babylonjs/Rendering/renderingGroup";
  71107. export * from "babylonjs/Rendering/renderingManager";
  71108. export * from "babylonjs/Rendering/utilityLayerRenderer";
  71109. }
  71110. declare module "babylonjs/Sprites/ISprites" {
  71111. /**
  71112. * Defines the basic options interface of a Sprite Frame Source Size.
  71113. */
  71114. export interface ISpriteJSONSpriteSourceSize {
  71115. /**
  71116. * number of the original width of the Frame
  71117. */
  71118. w: number;
  71119. /**
  71120. * number of the original height of the Frame
  71121. */
  71122. h: number;
  71123. }
  71124. /**
  71125. * Defines the basic options interface of a Sprite Frame Data.
  71126. */
  71127. export interface ISpriteJSONSpriteFrameData {
  71128. /**
  71129. * number of the x offset of the Frame
  71130. */
  71131. x: number;
  71132. /**
  71133. * number of the y offset of the Frame
  71134. */
  71135. y: number;
  71136. /**
  71137. * number of the width of the Frame
  71138. */
  71139. w: number;
  71140. /**
  71141. * number of the height of the Frame
  71142. */
  71143. h: number;
  71144. }
  71145. /**
  71146. * Defines the basic options interface of a JSON Sprite.
  71147. */
  71148. export interface ISpriteJSONSprite {
  71149. /**
  71150. * string name of the Frame
  71151. */
  71152. filename: string;
  71153. /**
  71154. * ISpriteJSONSpriteFrame basic object of the frame data
  71155. */
  71156. frame: ISpriteJSONSpriteFrameData;
  71157. /**
  71158. * boolean to flag is the frame was rotated.
  71159. */
  71160. rotated: boolean;
  71161. /**
  71162. * boolean to flag is the frame was trimmed.
  71163. */
  71164. trimmed: boolean;
  71165. /**
  71166. * ISpriteJSONSpriteFrame basic object of the source data
  71167. */
  71168. spriteSourceSize: ISpriteJSONSpriteFrameData;
  71169. /**
  71170. * ISpriteJSONSpriteFrame basic object of the source data
  71171. */
  71172. sourceSize: ISpriteJSONSpriteSourceSize;
  71173. }
  71174. /**
  71175. * Defines the basic options interface of a JSON atlas.
  71176. */
  71177. export interface ISpriteJSONAtlas {
  71178. /**
  71179. * Array of objects that contain the frame data.
  71180. */
  71181. frames: Array<ISpriteJSONSprite>;
  71182. /**
  71183. * object basic object containing the sprite meta data.
  71184. */
  71185. meta?: object;
  71186. }
  71187. }
  71188. declare module "babylonjs/Shaders/spriteMap.fragment" {
  71189. /** @hidden */
  71190. export var spriteMapPixelShader: {
  71191. name: string;
  71192. shader: string;
  71193. };
  71194. }
  71195. declare module "babylonjs/Shaders/spriteMap.vertex" {
  71196. /** @hidden */
  71197. export var spriteMapVertexShader: {
  71198. name: string;
  71199. shader: string;
  71200. };
  71201. }
  71202. declare module "babylonjs/Sprites/spriteMap" {
  71203. import { IDisposable, Scene } from "babylonjs/scene";
  71204. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  71205. import { Texture } from "babylonjs/Materials/Textures/texture";
  71206. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  71207. import { ISpriteJSONSprite, ISpriteJSONAtlas } from "babylonjs/Sprites/ISprites";
  71208. import "babylonjs/Meshes/Builders/planeBuilder";
  71209. import "babylonjs/Shaders/spriteMap.fragment";
  71210. import "babylonjs/Shaders/spriteMap.vertex";
  71211. /**
  71212. * Defines the basic options interface of a SpriteMap
  71213. */
  71214. export interface ISpriteMapOptions {
  71215. /**
  71216. * Vector2 of the number of cells in the grid.
  71217. */
  71218. stageSize?: Vector2;
  71219. /**
  71220. * Vector2 of the size of the output plane in World Units.
  71221. */
  71222. outputSize?: Vector2;
  71223. /**
  71224. * Vector3 of the position of the output plane in World Units.
  71225. */
  71226. outputPosition?: Vector3;
  71227. /**
  71228. * Vector3 of the rotation of the output plane.
  71229. */
  71230. outputRotation?: Vector3;
  71231. /**
  71232. * number of layers that the system will reserve in resources.
  71233. */
  71234. layerCount?: number;
  71235. /**
  71236. * number of max animation frames a single cell will reserve in resources.
  71237. */
  71238. maxAnimationFrames?: number;
  71239. /**
  71240. * number cell index of the base tile when the system compiles.
  71241. */
  71242. baseTile?: number;
  71243. /**
  71244. * boolean flip the sprite after its been repositioned by the framing data.
  71245. */
  71246. flipU?: boolean;
  71247. /**
  71248. * Vector3 scalar of the global RGB values of the SpriteMap.
  71249. */
  71250. colorMultiply?: Vector3;
  71251. }
  71252. /**
  71253. * Defines the IDisposable interface in order to be cleanable from resources.
  71254. */
  71255. export interface ISpriteMap extends IDisposable {
  71256. /**
  71257. * String name of the SpriteMap.
  71258. */
  71259. name: string;
  71260. /**
  71261. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  71262. */
  71263. atlasJSON: ISpriteJSONAtlas;
  71264. /**
  71265. * Texture of the SpriteMap.
  71266. */
  71267. spriteSheet: Texture;
  71268. /**
  71269. * The parameters to initialize the SpriteMap with.
  71270. */
  71271. options: ISpriteMapOptions;
  71272. }
  71273. /**
  71274. * Class used to manage a grid restricted sprite deployment on an Output plane.
  71275. */
  71276. export class SpriteMap implements ISpriteMap {
  71277. /** The Name of the spriteMap */
  71278. name: string;
  71279. /** The JSON file with the frame and meta data */
  71280. atlasJSON: ISpriteJSONAtlas;
  71281. /** The systems Sprite Sheet Texture */
  71282. spriteSheet: Texture;
  71283. /** Arguments passed with the Constructor */
  71284. options: ISpriteMapOptions;
  71285. /** Public Sprite Storage array, parsed from atlasJSON */
  71286. sprites: Array<ISpriteJSONSprite>;
  71287. /** Returns the Number of Sprites in the System */
  71288. get spriteCount(): number;
  71289. /** Returns the Position of Output Plane*/
  71290. get position(): Vector3;
  71291. /** Returns the Position of Output Plane*/
  71292. set position(v: Vector3);
  71293. /** Returns the Rotation of Output Plane*/
  71294. get rotation(): Vector3;
  71295. /** Returns the Rotation of Output Plane*/
  71296. set rotation(v: Vector3);
  71297. /** Sets the AnimationMap*/
  71298. get animationMap(): RawTexture;
  71299. /** Sets the AnimationMap*/
  71300. set animationMap(v: RawTexture);
  71301. /** Scene that the SpriteMap was created in */
  71302. private _scene;
  71303. /** Texture Buffer of Float32 that holds tile frame data*/
  71304. private _frameMap;
  71305. /** Texture Buffers of Float32 that holds tileMap data*/
  71306. private _tileMaps;
  71307. /** Texture Buffer of Float32 that holds Animation Data*/
  71308. private _animationMap;
  71309. /** Custom ShaderMaterial Central to the System*/
  71310. private _material;
  71311. /** Custom ShaderMaterial Central to the System*/
  71312. private _output;
  71313. /** Systems Time Ticker*/
  71314. private _time;
  71315. /**
  71316. * Creates a new SpriteMap
  71317. * @param name defines the SpriteMaps Name
  71318. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  71319. * @param spriteSheet is the Texture that the Sprites are on.
  71320. * @param options a basic deployment configuration
  71321. * @param scene The Scene that the map is deployed on
  71322. */
  71323. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  71324. /**
  71325. * Returns tileID location
  71326. * @returns Vector2 the cell position ID
  71327. */
  71328. getTileID(): Vector2;
  71329. /**
  71330. * Gets the UV location of the mouse over the SpriteMap.
  71331. * @returns Vector2 the UV position of the mouse interaction
  71332. */
  71333. getMousePosition(): Vector2;
  71334. /**
  71335. * Creates the "frame" texture Buffer
  71336. * -------------------------------------
  71337. * Structure of frames
  71338. * "filename": "Falling-Water-2.png",
  71339. * "frame": {"x":69,"y":103,"w":24,"h":32},
  71340. * "rotated": true,
  71341. * "trimmed": true,
  71342. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  71343. * "sourceSize": {"w":32,"h":32}
  71344. * @returns RawTexture of the frameMap
  71345. */
  71346. private _createFrameBuffer;
  71347. /**
  71348. * Creates the tileMap texture Buffer
  71349. * @param buffer normally and array of numbers, or a false to generate from scratch
  71350. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  71351. * @returns RawTexture of the tileMap
  71352. */
  71353. private _createTileBuffer;
  71354. /**
  71355. * Modifies the data of the tileMaps
  71356. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  71357. * @param pos is the iVector2 Coordinates of the Tile
  71358. * @param tile The SpriteIndex of the new Tile
  71359. */
  71360. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  71361. /**
  71362. * Creates the animationMap texture Buffer
  71363. * @param buffer normally and array of numbers, or a false to generate from scratch
  71364. * @returns RawTexture of the animationMap
  71365. */
  71366. private _createTileAnimationBuffer;
  71367. /**
  71368. * Modifies the data of the animationMap
  71369. * @param cellID is the Index of the Sprite
  71370. * @param _frame is the target Animation frame
  71371. * @param toCell is the Target Index of the next frame of the animation
  71372. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  71373. * @param speed is a global scalar of the time variable on the map.
  71374. */
  71375. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  71376. /**
  71377. * Exports the .tilemaps file
  71378. */
  71379. saveTileMaps(): void;
  71380. /**
  71381. * Imports the .tilemaps file
  71382. * @param url of the .tilemaps file
  71383. */
  71384. loadTileMaps(url: string): void;
  71385. /**
  71386. * Release associated resources
  71387. */
  71388. dispose(): void;
  71389. }
  71390. }
  71391. declare module "babylonjs/Sprites/spritePackedManager" {
  71392. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  71393. import { Scene } from "babylonjs/scene";
  71394. /**
  71395. * Class used to manage multiple sprites of different sizes on the same spritesheet
  71396. * @see http://doc.babylonjs.com/babylon101/sprites
  71397. */
  71398. export class SpritePackedManager extends SpriteManager {
  71399. /** defines the packed manager's name */
  71400. name: string;
  71401. /**
  71402. * Creates a new sprite manager from a packed sprite sheet
  71403. * @param name defines the manager's name
  71404. * @param imgUrl defines the sprite sheet url
  71405. * @param capacity defines the maximum allowed number of sprites
  71406. * @param scene defines the hosting scene
  71407. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  71408. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  71409. * @param samplingMode defines the smapling mode to use with spritesheet
  71410. * @param fromPacked set to true; do not alter
  71411. */
  71412. constructor(
  71413. /** defines the packed manager's name */
  71414. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  71415. }
  71416. }
  71417. declare module "babylonjs/Sprites/index" {
  71418. export * from "babylonjs/Sprites/sprite";
  71419. export * from "babylonjs/Sprites/ISprites";
  71420. export * from "babylonjs/Sprites/spriteManager";
  71421. export * from "babylonjs/Sprites/spriteMap";
  71422. export * from "babylonjs/Sprites/spritePackedManager";
  71423. export * from "babylonjs/Sprites/spriteSceneComponent";
  71424. }
  71425. declare module "babylonjs/States/index" {
  71426. export * from "babylonjs/States/alphaCullingState";
  71427. export * from "babylonjs/States/depthCullingState";
  71428. export * from "babylonjs/States/stencilState";
  71429. }
  71430. declare module "babylonjs/Misc/assetsManager" {
  71431. import { Scene } from "babylonjs/scene";
  71432. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  71433. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  71434. import { Skeleton } from "babylonjs/Bones/skeleton";
  71435. import { Observable } from "babylonjs/Misc/observable";
  71436. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  71437. import { Texture } from "babylonjs/Materials/Textures/texture";
  71438. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  71439. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  71440. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  71441. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  71442. /**
  71443. * Defines the list of states available for a task inside a AssetsManager
  71444. */
  71445. export enum AssetTaskState {
  71446. /**
  71447. * Initialization
  71448. */
  71449. INIT = 0,
  71450. /**
  71451. * Running
  71452. */
  71453. RUNNING = 1,
  71454. /**
  71455. * Done
  71456. */
  71457. DONE = 2,
  71458. /**
  71459. * Error
  71460. */
  71461. ERROR = 3
  71462. }
  71463. /**
  71464. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  71465. */
  71466. export abstract class AbstractAssetTask {
  71467. /**
  71468. * Task name
  71469. */ name: string;
  71470. /**
  71471. * Callback called when the task is successful
  71472. */
  71473. onSuccess: (task: any) => void;
  71474. /**
  71475. * Callback called when the task is not successful
  71476. */
  71477. onError: (task: any, message?: string, exception?: any) => void;
  71478. /**
  71479. * Creates a new AssetsManager
  71480. * @param name defines the name of the task
  71481. */
  71482. constructor(
  71483. /**
  71484. * Task name
  71485. */ name: string);
  71486. private _isCompleted;
  71487. private _taskState;
  71488. private _errorObject;
  71489. /**
  71490. * Get if the task is completed
  71491. */
  71492. get isCompleted(): boolean;
  71493. /**
  71494. * Gets the current state of the task
  71495. */
  71496. get taskState(): AssetTaskState;
  71497. /**
  71498. * Gets the current error object (if task is in error)
  71499. */
  71500. get errorObject(): {
  71501. message?: string;
  71502. exception?: any;
  71503. };
  71504. /**
  71505. * Internal only
  71506. * @hidden
  71507. */
  71508. _setErrorObject(message?: string, exception?: any): void;
  71509. /**
  71510. * Execute the current task
  71511. * @param scene defines the scene where you want your assets to be loaded
  71512. * @param onSuccess is a callback called when the task is successfully executed
  71513. * @param onError is a callback called if an error occurs
  71514. */
  71515. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71516. /**
  71517. * Execute the current task
  71518. * @param scene defines the scene where you want your assets to be loaded
  71519. * @param onSuccess is a callback called when the task is successfully executed
  71520. * @param onError is a callback called if an error occurs
  71521. */
  71522. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71523. /**
  71524. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  71525. * This can be used with failed tasks that have the reason for failure fixed.
  71526. */
  71527. reset(): void;
  71528. private onErrorCallback;
  71529. private onDoneCallback;
  71530. }
  71531. /**
  71532. * Define the interface used by progress events raised during assets loading
  71533. */
  71534. export interface IAssetsProgressEvent {
  71535. /**
  71536. * Defines the number of remaining tasks to process
  71537. */
  71538. remainingCount: number;
  71539. /**
  71540. * Defines the total number of tasks
  71541. */
  71542. totalCount: number;
  71543. /**
  71544. * Defines the task that was just processed
  71545. */
  71546. task: AbstractAssetTask;
  71547. }
  71548. /**
  71549. * Class used to share progress information about assets loading
  71550. */
  71551. export class AssetsProgressEvent implements IAssetsProgressEvent {
  71552. /**
  71553. * Defines the number of remaining tasks to process
  71554. */
  71555. remainingCount: number;
  71556. /**
  71557. * Defines the total number of tasks
  71558. */
  71559. totalCount: number;
  71560. /**
  71561. * Defines the task that was just processed
  71562. */
  71563. task: AbstractAssetTask;
  71564. /**
  71565. * Creates a AssetsProgressEvent
  71566. * @param remainingCount defines the number of remaining tasks to process
  71567. * @param totalCount defines the total number of tasks
  71568. * @param task defines the task that was just processed
  71569. */
  71570. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  71571. }
  71572. /**
  71573. * Define a task used by AssetsManager to load meshes
  71574. */
  71575. export class MeshAssetTask extends AbstractAssetTask {
  71576. /**
  71577. * Defines the name of the task
  71578. */
  71579. name: string;
  71580. /**
  71581. * Defines the list of mesh's names you want to load
  71582. */
  71583. meshesNames: any;
  71584. /**
  71585. * Defines the root url to use as a base to load your meshes and associated resources
  71586. */
  71587. rootUrl: string;
  71588. /**
  71589. * Defines the filename of the scene to load from
  71590. */
  71591. sceneFilename: string;
  71592. /**
  71593. * Gets the list of loaded meshes
  71594. */
  71595. loadedMeshes: Array<AbstractMesh>;
  71596. /**
  71597. * Gets the list of loaded particle systems
  71598. */
  71599. loadedParticleSystems: Array<IParticleSystem>;
  71600. /**
  71601. * Gets the list of loaded skeletons
  71602. */
  71603. loadedSkeletons: Array<Skeleton>;
  71604. /**
  71605. * Gets the list of loaded animation groups
  71606. */
  71607. loadedAnimationGroups: Array<AnimationGroup>;
  71608. /**
  71609. * Callback called when the task is successful
  71610. */
  71611. onSuccess: (task: MeshAssetTask) => void;
  71612. /**
  71613. * Callback called when the task is successful
  71614. */
  71615. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  71616. /**
  71617. * Creates a new MeshAssetTask
  71618. * @param name defines the name of the task
  71619. * @param meshesNames defines the list of mesh's names you want to load
  71620. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  71621. * @param sceneFilename defines the filename of the scene to load from
  71622. */
  71623. constructor(
  71624. /**
  71625. * Defines the name of the task
  71626. */
  71627. name: string,
  71628. /**
  71629. * Defines the list of mesh's names you want to load
  71630. */
  71631. meshesNames: any,
  71632. /**
  71633. * Defines the root url to use as a base to load your meshes and associated resources
  71634. */
  71635. rootUrl: string,
  71636. /**
  71637. * Defines the filename of the scene to load from
  71638. */
  71639. sceneFilename: string);
  71640. /**
  71641. * Execute the current task
  71642. * @param scene defines the scene where you want your assets to be loaded
  71643. * @param onSuccess is a callback called when the task is successfully executed
  71644. * @param onError is a callback called if an error occurs
  71645. */
  71646. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71647. }
  71648. /**
  71649. * Define a task used by AssetsManager to load text content
  71650. */
  71651. export class TextFileAssetTask extends AbstractAssetTask {
  71652. /**
  71653. * Defines the name of the task
  71654. */
  71655. name: string;
  71656. /**
  71657. * Defines the location of the file to load
  71658. */
  71659. url: string;
  71660. /**
  71661. * Gets the loaded text string
  71662. */
  71663. text: string;
  71664. /**
  71665. * Callback called when the task is successful
  71666. */
  71667. onSuccess: (task: TextFileAssetTask) => void;
  71668. /**
  71669. * Callback called when the task is successful
  71670. */
  71671. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  71672. /**
  71673. * Creates a new TextFileAssetTask object
  71674. * @param name defines the name of the task
  71675. * @param url defines the location of the file to load
  71676. */
  71677. constructor(
  71678. /**
  71679. * Defines the name of the task
  71680. */
  71681. name: string,
  71682. /**
  71683. * Defines the location of the file to load
  71684. */
  71685. url: string);
  71686. /**
  71687. * Execute the current task
  71688. * @param scene defines the scene where you want your assets to be loaded
  71689. * @param onSuccess is a callback called when the task is successfully executed
  71690. * @param onError is a callback called if an error occurs
  71691. */
  71692. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71693. }
  71694. /**
  71695. * Define a task used by AssetsManager to load binary data
  71696. */
  71697. export class BinaryFileAssetTask extends AbstractAssetTask {
  71698. /**
  71699. * Defines the name of the task
  71700. */
  71701. name: string;
  71702. /**
  71703. * Defines the location of the file to load
  71704. */
  71705. url: string;
  71706. /**
  71707. * Gets the lodaded data (as an array buffer)
  71708. */
  71709. data: ArrayBuffer;
  71710. /**
  71711. * Callback called when the task is successful
  71712. */
  71713. onSuccess: (task: BinaryFileAssetTask) => void;
  71714. /**
  71715. * Callback called when the task is successful
  71716. */
  71717. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  71718. /**
  71719. * Creates a new BinaryFileAssetTask object
  71720. * @param name defines the name of the new task
  71721. * @param url defines the location of the file to load
  71722. */
  71723. constructor(
  71724. /**
  71725. * Defines the name of the task
  71726. */
  71727. name: string,
  71728. /**
  71729. * Defines the location of the file to load
  71730. */
  71731. url: string);
  71732. /**
  71733. * Execute the current task
  71734. * @param scene defines the scene where you want your assets to be loaded
  71735. * @param onSuccess is a callback called when the task is successfully executed
  71736. * @param onError is a callback called if an error occurs
  71737. */
  71738. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71739. }
  71740. /**
  71741. * Define a task used by AssetsManager to load images
  71742. */
  71743. export class ImageAssetTask extends AbstractAssetTask {
  71744. /**
  71745. * Defines the name of the task
  71746. */
  71747. name: string;
  71748. /**
  71749. * Defines the location of the image to load
  71750. */
  71751. url: string;
  71752. /**
  71753. * Gets the loaded images
  71754. */
  71755. image: HTMLImageElement;
  71756. /**
  71757. * Callback called when the task is successful
  71758. */
  71759. onSuccess: (task: ImageAssetTask) => void;
  71760. /**
  71761. * Callback called when the task is successful
  71762. */
  71763. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  71764. /**
  71765. * Creates a new ImageAssetTask
  71766. * @param name defines the name of the task
  71767. * @param url defines the location of the image to load
  71768. */
  71769. constructor(
  71770. /**
  71771. * Defines the name of the task
  71772. */
  71773. name: string,
  71774. /**
  71775. * Defines the location of the image to load
  71776. */
  71777. url: string);
  71778. /**
  71779. * Execute the current task
  71780. * @param scene defines the scene where you want your assets to be loaded
  71781. * @param onSuccess is a callback called when the task is successfully executed
  71782. * @param onError is a callback called if an error occurs
  71783. */
  71784. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71785. }
  71786. /**
  71787. * Defines the interface used by texture loading tasks
  71788. */
  71789. export interface ITextureAssetTask<TEX extends BaseTexture> {
  71790. /**
  71791. * Gets the loaded texture
  71792. */
  71793. texture: TEX;
  71794. }
  71795. /**
  71796. * Define a task used by AssetsManager to load 2D textures
  71797. */
  71798. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  71799. /**
  71800. * Defines the name of the task
  71801. */
  71802. name: string;
  71803. /**
  71804. * Defines the location of the file to load
  71805. */
  71806. url: string;
  71807. /**
  71808. * Defines if mipmap should not be generated (default is false)
  71809. */
  71810. noMipmap?: boolean | undefined;
  71811. /**
  71812. * Defines if texture must be inverted on Y axis (default is true)
  71813. */
  71814. invertY: boolean;
  71815. /**
  71816. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  71817. */
  71818. samplingMode: number;
  71819. /**
  71820. * Gets the loaded texture
  71821. */
  71822. texture: Texture;
  71823. /**
  71824. * Callback called when the task is successful
  71825. */
  71826. onSuccess: (task: TextureAssetTask) => void;
  71827. /**
  71828. * Callback called when the task is successful
  71829. */
  71830. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  71831. /**
  71832. * Creates a new TextureAssetTask object
  71833. * @param name defines the name of the task
  71834. * @param url defines the location of the file to load
  71835. * @param noMipmap defines if mipmap should not be generated (default is false)
  71836. * @param invertY defines if texture must be inverted on Y axis (default is true)
  71837. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  71838. */
  71839. constructor(
  71840. /**
  71841. * Defines the name of the task
  71842. */
  71843. name: string,
  71844. /**
  71845. * Defines the location of the file to load
  71846. */
  71847. url: string,
  71848. /**
  71849. * Defines if mipmap should not be generated (default is false)
  71850. */
  71851. noMipmap?: boolean | undefined,
  71852. /**
  71853. * Defines if texture must be inverted on Y axis (default is true)
  71854. */
  71855. invertY?: boolean,
  71856. /**
  71857. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  71858. */
  71859. samplingMode?: number);
  71860. /**
  71861. * Execute the current task
  71862. * @param scene defines the scene where you want your assets to be loaded
  71863. * @param onSuccess is a callback called when the task is successfully executed
  71864. * @param onError is a callback called if an error occurs
  71865. */
  71866. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71867. }
  71868. /**
  71869. * Define a task used by AssetsManager to load cube textures
  71870. */
  71871. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  71872. /**
  71873. * Defines the name of the task
  71874. */
  71875. name: string;
  71876. /**
  71877. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  71878. */
  71879. url: string;
  71880. /**
  71881. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  71882. */
  71883. extensions?: string[] | undefined;
  71884. /**
  71885. * Defines if mipmaps should not be generated (default is false)
  71886. */
  71887. noMipmap?: boolean | undefined;
  71888. /**
  71889. * Defines the explicit list of files (undefined by default)
  71890. */
  71891. files?: string[] | undefined;
  71892. /**
  71893. * Gets the loaded texture
  71894. */
  71895. texture: CubeTexture;
  71896. /**
  71897. * Callback called when the task is successful
  71898. */
  71899. onSuccess: (task: CubeTextureAssetTask) => void;
  71900. /**
  71901. * Callback called when the task is successful
  71902. */
  71903. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  71904. /**
  71905. * Creates a new CubeTextureAssetTask
  71906. * @param name defines the name of the task
  71907. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  71908. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  71909. * @param noMipmap defines if mipmaps should not be generated (default is false)
  71910. * @param files defines the explicit list of files (undefined by default)
  71911. */
  71912. constructor(
  71913. /**
  71914. * Defines the name of the task
  71915. */
  71916. name: string,
  71917. /**
  71918. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  71919. */
  71920. url: string,
  71921. /**
  71922. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  71923. */
  71924. extensions?: string[] | undefined,
  71925. /**
  71926. * Defines if mipmaps should not be generated (default is false)
  71927. */
  71928. noMipmap?: boolean | undefined,
  71929. /**
  71930. * Defines the explicit list of files (undefined by default)
  71931. */
  71932. files?: string[] | undefined);
  71933. /**
  71934. * Execute the current task
  71935. * @param scene defines the scene where you want your assets to be loaded
  71936. * @param onSuccess is a callback called when the task is successfully executed
  71937. * @param onError is a callback called if an error occurs
  71938. */
  71939. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71940. }
  71941. /**
  71942. * Define a task used by AssetsManager to load HDR cube textures
  71943. */
  71944. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  71945. /**
  71946. * Defines the name of the task
  71947. */
  71948. name: string;
  71949. /**
  71950. * Defines the location of the file to load
  71951. */
  71952. url: string;
  71953. /**
  71954. * Defines the desired size (the more it increases the longer the generation will be)
  71955. */
  71956. size: number;
  71957. /**
  71958. * Defines if mipmaps should not be generated (default is false)
  71959. */
  71960. noMipmap: boolean;
  71961. /**
  71962. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  71963. */
  71964. generateHarmonics: boolean;
  71965. /**
  71966. * 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)
  71967. */
  71968. gammaSpace: boolean;
  71969. /**
  71970. * Internal Use Only
  71971. */
  71972. reserved: boolean;
  71973. /**
  71974. * Gets the loaded texture
  71975. */
  71976. texture: HDRCubeTexture;
  71977. /**
  71978. * Callback called when the task is successful
  71979. */
  71980. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  71981. /**
  71982. * Callback called when the task is successful
  71983. */
  71984. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  71985. /**
  71986. * Creates a new HDRCubeTextureAssetTask object
  71987. * @param name defines the name of the task
  71988. * @param url defines the location of the file to load
  71989. * @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.
  71990. * @param noMipmap defines if mipmaps should not be generated (default is false)
  71991. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  71992. * @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)
  71993. * @param reserved Internal use only
  71994. */
  71995. constructor(
  71996. /**
  71997. * Defines the name of the task
  71998. */
  71999. name: string,
  72000. /**
  72001. * Defines the location of the file to load
  72002. */
  72003. url: string,
  72004. /**
  72005. * Defines the desired size (the more it increases the longer the generation will be)
  72006. */
  72007. size: number,
  72008. /**
  72009. * Defines if mipmaps should not be generated (default is false)
  72010. */
  72011. noMipmap?: boolean,
  72012. /**
  72013. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  72014. */
  72015. generateHarmonics?: boolean,
  72016. /**
  72017. * 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)
  72018. */
  72019. gammaSpace?: boolean,
  72020. /**
  72021. * Internal Use Only
  72022. */
  72023. reserved?: boolean);
  72024. /**
  72025. * Execute the current task
  72026. * @param scene defines the scene where you want your assets to be loaded
  72027. * @param onSuccess is a callback called when the task is successfully executed
  72028. * @param onError is a callback called if an error occurs
  72029. */
  72030. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72031. }
  72032. /**
  72033. * Define a task used by AssetsManager to load Equirectangular cube textures
  72034. */
  72035. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  72036. /**
  72037. * Defines the name of the task
  72038. */
  72039. name: string;
  72040. /**
  72041. * Defines the location of the file to load
  72042. */
  72043. url: string;
  72044. /**
  72045. * Defines the desired size (the more it increases the longer the generation will be)
  72046. */
  72047. size: number;
  72048. /**
  72049. * Defines if mipmaps should not be generated (default is false)
  72050. */
  72051. noMipmap: boolean;
  72052. /**
  72053. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  72054. * but the standard material would require them in Gamma space) (default is true)
  72055. */
  72056. gammaSpace: boolean;
  72057. /**
  72058. * Gets the loaded texture
  72059. */
  72060. texture: EquiRectangularCubeTexture;
  72061. /**
  72062. * Callback called when the task is successful
  72063. */
  72064. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  72065. /**
  72066. * Callback called when the task is successful
  72067. */
  72068. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  72069. /**
  72070. * Creates a new EquiRectangularCubeTextureAssetTask object
  72071. * @param name defines the name of the task
  72072. * @param url defines the location of the file to load
  72073. * @param size defines the desired size (the more it increases the longer the generation will be)
  72074. * If the size is omitted this implies you are using a preprocessed cubemap.
  72075. * @param noMipmap defines if mipmaps should not be generated (default is false)
  72076. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  72077. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  72078. * (default is true)
  72079. */
  72080. constructor(
  72081. /**
  72082. * Defines the name of the task
  72083. */
  72084. name: string,
  72085. /**
  72086. * Defines the location of the file to load
  72087. */
  72088. url: string,
  72089. /**
  72090. * Defines the desired size (the more it increases the longer the generation will be)
  72091. */
  72092. size: number,
  72093. /**
  72094. * Defines if mipmaps should not be generated (default is false)
  72095. */
  72096. noMipmap?: boolean,
  72097. /**
  72098. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  72099. * but the standard material would require them in Gamma space) (default is true)
  72100. */
  72101. gammaSpace?: boolean);
  72102. /**
  72103. * Execute the current task
  72104. * @param scene defines the scene where you want your assets to be loaded
  72105. * @param onSuccess is a callback called when the task is successfully executed
  72106. * @param onError is a callback called if an error occurs
  72107. */
  72108. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72109. }
  72110. /**
  72111. * This class can be used to easily import assets into a scene
  72112. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  72113. */
  72114. export class AssetsManager {
  72115. private _scene;
  72116. private _isLoading;
  72117. protected _tasks: AbstractAssetTask[];
  72118. protected _waitingTasksCount: number;
  72119. protected _totalTasksCount: number;
  72120. /**
  72121. * Callback called when all tasks are processed
  72122. */
  72123. onFinish: (tasks: AbstractAssetTask[]) => void;
  72124. /**
  72125. * Callback called when a task is successful
  72126. */
  72127. onTaskSuccess: (task: AbstractAssetTask) => void;
  72128. /**
  72129. * Callback called when a task had an error
  72130. */
  72131. onTaskError: (task: AbstractAssetTask) => void;
  72132. /**
  72133. * Callback called when a task is done (whatever the result is)
  72134. */
  72135. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  72136. /**
  72137. * Observable called when all tasks are processed
  72138. */
  72139. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  72140. /**
  72141. * Observable called when a task had an error
  72142. */
  72143. onTaskErrorObservable: Observable<AbstractAssetTask>;
  72144. /**
  72145. * Observable called when all tasks were executed
  72146. */
  72147. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  72148. /**
  72149. * Observable called when a task is done (whatever the result is)
  72150. */
  72151. onProgressObservable: Observable<IAssetsProgressEvent>;
  72152. /**
  72153. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  72154. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  72155. */
  72156. useDefaultLoadingScreen: boolean;
  72157. /**
  72158. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  72159. * when all assets have been downloaded.
  72160. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  72161. */
  72162. autoHideLoadingUI: boolean;
  72163. /**
  72164. * Creates a new AssetsManager
  72165. * @param scene defines the scene to work on
  72166. */
  72167. constructor(scene: Scene);
  72168. /**
  72169. * Add a MeshAssetTask to the list of active tasks
  72170. * @param taskName defines the name of the new task
  72171. * @param meshesNames defines the name of meshes to load
  72172. * @param rootUrl defines the root url to use to locate files
  72173. * @param sceneFilename defines the filename of the scene file
  72174. * @returns a new MeshAssetTask object
  72175. */
  72176. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  72177. /**
  72178. * Add a TextFileAssetTask to the list of active tasks
  72179. * @param taskName defines the name of the new task
  72180. * @param url defines the url of the file to load
  72181. * @returns a new TextFileAssetTask object
  72182. */
  72183. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  72184. /**
  72185. * Add a BinaryFileAssetTask to the list of active tasks
  72186. * @param taskName defines the name of the new task
  72187. * @param url defines the url of the file to load
  72188. * @returns a new BinaryFileAssetTask object
  72189. */
  72190. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  72191. /**
  72192. * Add a ImageAssetTask to the list of active tasks
  72193. * @param taskName defines the name of the new task
  72194. * @param url defines the url of the file to load
  72195. * @returns a new ImageAssetTask object
  72196. */
  72197. addImageTask(taskName: string, url: string): ImageAssetTask;
  72198. /**
  72199. * Add a TextureAssetTask to the list of active tasks
  72200. * @param taskName defines the name of the new task
  72201. * @param url defines the url of the file to load
  72202. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  72203. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  72204. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  72205. * @returns a new TextureAssetTask object
  72206. */
  72207. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  72208. /**
  72209. * Add a CubeTextureAssetTask to the list of active tasks
  72210. * @param taskName defines the name of the new task
  72211. * @param url defines the url of the file to load
  72212. * @param extensions defines the extension to use to load the cube map (can be null)
  72213. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  72214. * @param files defines the list of files to load (can be null)
  72215. * @returns a new CubeTextureAssetTask object
  72216. */
  72217. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  72218. /**
  72219. *
  72220. * Add a HDRCubeTextureAssetTask to the list of active tasks
  72221. * @param taskName defines the name of the new task
  72222. * @param url defines the url of the file to load
  72223. * @param size defines the size you want for the cubemap (can be null)
  72224. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  72225. * @param generateHarmonics defines if you want to automatically generate (true by default)
  72226. * @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)
  72227. * @param reserved Internal use only
  72228. * @returns a new HDRCubeTextureAssetTask object
  72229. */
  72230. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  72231. /**
  72232. *
  72233. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  72234. * @param taskName defines the name of the new task
  72235. * @param url defines the url of the file to load
  72236. * @param size defines the size you want for the cubemap (can be null)
  72237. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  72238. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  72239. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  72240. * @returns a new EquiRectangularCubeTextureAssetTask object
  72241. */
  72242. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  72243. /**
  72244. * Remove a task from the assets manager.
  72245. * @param task the task to remove
  72246. */
  72247. removeTask(task: AbstractAssetTask): void;
  72248. private _decreaseWaitingTasksCount;
  72249. private _runTask;
  72250. /**
  72251. * Reset the AssetsManager and remove all tasks
  72252. * @return the current instance of the AssetsManager
  72253. */
  72254. reset(): AssetsManager;
  72255. /**
  72256. * Start the loading process
  72257. * @return the current instance of the AssetsManager
  72258. */
  72259. load(): AssetsManager;
  72260. /**
  72261. * Start the loading process as an async operation
  72262. * @return a promise returning the list of failed tasks
  72263. */
  72264. loadAsync(): Promise<void>;
  72265. }
  72266. }
  72267. declare module "babylonjs/Misc/deferred" {
  72268. /**
  72269. * Wrapper class for promise with external resolve and reject.
  72270. */
  72271. export class Deferred<T> {
  72272. /**
  72273. * The promise associated with this deferred object.
  72274. */
  72275. readonly promise: Promise<T>;
  72276. private _resolve;
  72277. private _reject;
  72278. /**
  72279. * The resolve method of the promise associated with this deferred object.
  72280. */
  72281. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  72282. /**
  72283. * The reject method of the promise associated with this deferred object.
  72284. */
  72285. get reject(): (reason?: any) => void;
  72286. /**
  72287. * Constructor for this deferred object.
  72288. */
  72289. constructor();
  72290. }
  72291. }
  72292. declare module "babylonjs/Misc/meshExploder" {
  72293. import { Mesh } from "babylonjs/Meshes/mesh";
  72294. /**
  72295. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  72296. */
  72297. export class MeshExploder {
  72298. private _centerMesh;
  72299. private _meshes;
  72300. private _meshesOrigins;
  72301. private _toCenterVectors;
  72302. private _scaledDirection;
  72303. private _newPosition;
  72304. private _centerPosition;
  72305. /**
  72306. * Explodes meshes from a center mesh.
  72307. * @param meshes The meshes to explode.
  72308. * @param centerMesh The mesh to be center of explosion.
  72309. */
  72310. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  72311. private _setCenterMesh;
  72312. /**
  72313. * Get class name
  72314. * @returns "MeshExploder"
  72315. */
  72316. getClassName(): string;
  72317. /**
  72318. * "Exploded meshes"
  72319. * @returns Array of meshes with the centerMesh at index 0.
  72320. */
  72321. getMeshes(): Array<Mesh>;
  72322. /**
  72323. * Explodes meshes giving a specific direction
  72324. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  72325. */
  72326. explode(direction?: number): void;
  72327. }
  72328. }
  72329. declare module "babylonjs/Misc/filesInput" {
  72330. import { Engine } from "babylonjs/Engines/engine";
  72331. import { Scene } from "babylonjs/scene";
  72332. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  72333. /**
  72334. * Class used to help managing file picking and drag'n'drop
  72335. */
  72336. export class FilesInput {
  72337. /**
  72338. * List of files ready to be loaded
  72339. */
  72340. static get FilesToLoad(): {
  72341. [key: string]: File;
  72342. };
  72343. /**
  72344. * Callback called when a file is processed
  72345. */
  72346. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  72347. private _engine;
  72348. private _currentScene;
  72349. private _sceneLoadedCallback;
  72350. private _progressCallback;
  72351. private _additionalRenderLoopLogicCallback;
  72352. private _textureLoadingCallback;
  72353. private _startingProcessingFilesCallback;
  72354. private _onReloadCallback;
  72355. private _errorCallback;
  72356. private _elementToMonitor;
  72357. private _sceneFileToLoad;
  72358. private _filesToLoad;
  72359. /**
  72360. * Creates a new FilesInput
  72361. * @param engine defines the rendering engine
  72362. * @param scene defines the hosting scene
  72363. * @param sceneLoadedCallback callback called when scene is loaded
  72364. * @param progressCallback callback called to track progress
  72365. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  72366. * @param textureLoadingCallback callback called when a texture is loading
  72367. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  72368. * @param onReloadCallback callback called when a reload is requested
  72369. * @param errorCallback callback call if an error occurs
  72370. */
  72371. 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);
  72372. private _dragEnterHandler;
  72373. private _dragOverHandler;
  72374. private _dropHandler;
  72375. /**
  72376. * Calls this function to listen to drag'n'drop events on a specific DOM element
  72377. * @param elementToMonitor defines the DOM element to track
  72378. */
  72379. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  72380. /**
  72381. * Release all associated resources
  72382. */
  72383. dispose(): void;
  72384. private renderFunction;
  72385. private drag;
  72386. private drop;
  72387. private _traverseFolder;
  72388. private _processFiles;
  72389. /**
  72390. * Load files from a drop event
  72391. * @param event defines the drop event to use as source
  72392. */
  72393. loadFiles(event: any): void;
  72394. private _processReload;
  72395. /**
  72396. * Reload the current scene from the loaded files
  72397. */
  72398. reload(): void;
  72399. }
  72400. }
  72401. declare module "babylonjs/Misc/HighDynamicRange/index" {
  72402. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  72403. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  72404. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  72405. }
  72406. declare module "babylonjs/Misc/sceneOptimizer" {
  72407. import { Scene, IDisposable } from "babylonjs/scene";
  72408. import { Observable } from "babylonjs/Misc/observable";
  72409. /**
  72410. * Defines the root class used to create scene optimization to use with SceneOptimizer
  72411. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72412. */
  72413. export class SceneOptimization {
  72414. /**
  72415. * Defines the priority of this optimization (0 by default which means first in the list)
  72416. */
  72417. priority: number;
  72418. /**
  72419. * Gets a string describing the action executed by the current optimization
  72420. * @returns description string
  72421. */
  72422. getDescription(): string;
  72423. /**
  72424. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72425. * @param scene defines the current scene where to apply this optimization
  72426. * @param optimizer defines the current optimizer
  72427. * @returns true if everything that can be done was applied
  72428. */
  72429. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72430. /**
  72431. * Creates the SceneOptimization object
  72432. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  72433. * @param desc defines the description associated with the optimization
  72434. */
  72435. constructor(
  72436. /**
  72437. * Defines the priority of this optimization (0 by default which means first in the list)
  72438. */
  72439. priority?: number);
  72440. }
  72441. /**
  72442. * Defines an optimization used to reduce the size of render target textures
  72443. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72444. */
  72445. export class TextureOptimization extends SceneOptimization {
  72446. /**
  72447. * Defines the priority of this optimization (0 by default which means first in the list)
  72448. */
  72449. priority: number;
  72450. /**
  72451. * 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
  72452. */
  72453. maximumSize: number;
  72454. /**
  72455. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  72456. */
  72457. step: number;
  72458. /**
  72459. * Gets a string describing the action executed by the current optimization
  72460. * @returns description string
  72461. */
  72462. getDescription(): string;
  72463. /**
  72464. * Creates the TextureOptimization object
  72465. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  72466. * @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
  72467. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  72468. */
  72469. constructor(
  72470. /**
  72471. * Defines the priority of this optimization (0 by default which means first in the list)
  72472. */
  72473. priority?: number,
  72474. /**
  72475. * 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. */
  72477. maximumSize?: number,
  72478. /**
  72479. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  72480. */
  72481. step?: number);
  72482. /**
  72483. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72484. * @param scene defines the current scene where to apply this optimization
  72485. * @param optimizer defines the current optimizer
  72486. * @returns true if everything that can be done was applied
  72487. */
  72488. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72489. }
  72490. /**
  72491. * Defines an optimization used to increase or decrease the rendering resolution
  72492. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72493. */
  72494. export class HardwareScalingOptimization extends SceneOptimization {
  72495. /**
  72496. * Defines the priority of this optimization (0 by default which means first in the list)
  72497. */
  72498. priority: number;
  72499. /**
  72500. * Defines the maximum scale to use (2 by default)
  72501. */
  72502. maximumScale: number;
  72503. /**
  72504. * Defines the step to use between two passes (0.5 by default)
  72505. */
  72506. step: number;
  72507. private _currentScale;
  72508. private _directionOffset;
  72509. /**
  72510. * Gets a string describing the action executed by the current optimization
  72511. * @return description string
  72512. */
  72513. getDescription(): string;
  72514. /**
  72515. * Creates the HardwareScalingOptimization object
  72516. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  72517. * @param maximumScale defines the maximum scale to use (2 by default)
  72518. * @param step defines the step to use between two passes (0.5 by default)
  72519. */
  72520. constructor(
  72521. /**
  72522. * Defines the priority of this optimization (0 by default which means first in the list)
  72523. */
  72524. priority?: number,
  72525. /**
  72526. * Defines the maximum scale to use (2 by default)
  72527. */
  72528. maximumScale?: number,
  72529. /**
  72530. * Defines the step to use between two passes (0.5 by default)
  72531. */
  72532. step?: number);
  72533. /**
  72534. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72535. * @param scene defines the current scene where to apply this optimization
  72536. * @param optimizer defines the current optimizer
  72537. * @returns true if everything that can be done was applied
  72538. */
  72539. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72540. }
  72541. /**
  72542. * Defines an optimization used to remove shadows
  72543. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72544. */
  72545. export class ShadowsOptimization extends SceneOptimization {
  72546. /**
  72547. * Gets a string describing the action executed by the current optimization
  72548. * @return description string
  72549. */
  72550. getDescription(): string;
  72551. /**
  72552. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72553. * @param scene defines the current scene where to apply this optimization
  72554. * @param optimizer defines the current optimizer
  72555. * @returns true if everything that can be done was applied
  72556. */
  72557. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72558. }
  72559. /**
  72560. * Defines an optimization used to turn post-processes off
  72561. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72562. */
  72563. export class PostProcessesOptimization extends SceneOptimization {
  72564. /**
  72565. * Gets a string describing the action executed by the current optimization
  72566. * @return description string
  72567. */
  72568. getDescription(): string;
  72569. /**
  72570. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72571. * @param scene defines the current scene where to apply this optimization
  72572. * @param optimizer defines the current optimizer
  72573. * @returns true if everything that can be done was applied
  72574. */
  72575. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72576. }
  72577. /**
  72578. * Defines an optimization used to turn lens flares off
  72579. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72580. */
  72581. export class LensFlaresOptimization extends SceneOptimization {
  72582. /**
  72583. * Gets a string describing the action executed by the current optimization
  72584. * @return description string
  72585. */
  72586. getDescription(): string;
  72587. /**
  72588. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72589. * @param scene defines the current scene where to apply this optimization
  72590. * @param optimizer defines the current optimizer
  72591. * @returns true if everything that can be done was applied
  72592. */
  72593. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72594. }
  72595. /**
  72596. * Defines an optimization based on user defined callback.
  72597. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72598. */
  72599. export class CustomOptimization extends SceneOptimization {
  72600. /**
  72601. * Callback called to apply the custom optimization.
  72602. */
  72603. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  72604. /**
  72605. * Callback called to get custom description
  72606. */
  72607. onGetDescription: () => string;
  72608. /**
  72609. * Gets a string describing the action executed by the current optimization
  72610. * @returns description string
  72611. */
  72612. getDescription(): string;
  72613. /**
  72614. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72615. * @param scene defines the current scene where to apply this optimization
  72616. * @param optimizer defines the current optimizer
  72617. * @returns true if everything that can be done was applied
  72618. */
  72619. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72620. }
  72621. /**
  72622. * Defines an optimization used to turn particles off
  72623. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72624. */
  72625. export class ParticlesOptimization extends SceneOptimization {
  72626. /**
  72627. * Gets a string describing the action executed by the current optimization
  72628. * @return description string
  72629. */
  72630. getDescription(): string;
  72631. /**
  72632. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72633. * @param scene defines the current scene where to apply this optimization
  72634. * @param optimizer defines the current optimizer
  72635. * @returns true if everything that can be done was applied
  72636. */
  72637. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72638. }
  72639. /**
  72640. * Defines an optimization used to turn render targets off
  72641. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72642. */
  72643. export class RenderTargetsOptimization extends SceneOptimization {
  72644. /**
  72645. * Gets a string describing the action executed by the current optimization
  72646. * @return description string
  72647. */
  72648. getDescription(): string;
  72649. /**
  72650. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72651. * @param scene defines the current scene where to apply this optimization
  72652. * @param optimizer defines the current optimizer
  72653. * @returns true if everything that can be done was applied
  72654. */
  72655. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72656. }
  72657. /**
  72658. * Defines an optimization used to merge meshes with compatible materials
  72659. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72660. */
  72661. export class MergeMeshesOptimization extends SceneOptimization {
  72662. private static _UpdateSelectionTree;
  72663. /**
  72664. * Gets or sets a boolean which defines if optimization octree has to be updated
  72665. */
  72666. static get UpdateSelectionTree(): boolean;
  72667. /**
  72668. * Gets or sets a boolean which defines if optimization octree has to be updated
  72669. */
  72670. static set UpdateSelectionTree(value: boolean);
  72671. /**
  72672. * Gets a string describing the action executed by the current optimization
  72673. * @return description string
  72674. */
  72675. getDescription(): string;
  72676. private _canBeMerged;
  72677. /**
  72678. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72679. * @param scene defines the current scene where to apply this optimization
  72680. * @param optimizer defines the current optimizer
  72681. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  72682. * @returns true if everything that can be done was applied
  72683. */
  72684. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  72685. }
  72686. /**
  72687. * Defines a list of options used by SceneOptimizer
  72688. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72689. */
  72690. export class SceneOptimizerOptions {
  72691. /**
  72692. * Defines the target frame rate to reach (60 by default)
  72693. */
  72694. targetFrameRate: number;
  72695. /**
  72696. * Defines the interval between two checkes (2000ms by default)
  72697. */
  72698. trackerDuration: number;
  72699. /**
  72700. * Gets the list of optimizations to apply
  72701. */
  72702. optimizations: SceneOptimization[];
  72703. /**
  72704. * Creates a new list of options used by SceneOptimizer
  72705. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  72706. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  72707. */
  72708. constructor(
  72709. /**
  72710. * Defines the target frame rate to reach (60 by default)
  72711. */
  72712. targetFrameRate?: number,
  72713. /**
  72714. * Defines the interval between two checkes (2000ms by default)
  72715. */
  72716. trackerDuration?: number);
  72717. /**
  72718. * Add a new optimization
  72719. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  72720. * @returns the current SceneOptimizerOptions
  72721. */
  72722. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  72723. /**
  72724. * Add a new custom optimization
  72725. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  72726. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  72727. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  72728. * @returns the current SceneOptimizerOptions
  72729. */
  72730. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  72731. /**
  72732. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  72733. * @param targetFrameRate defines the target frame rate (60 by default)
  72734. * @returns a SceneOptimizerOptions object
  72735. */
  72736. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  72737. /**
  72738. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  72739. * @param targetFrameRate defines the target frame rate (60 by default)
  72740. * @returns a SceneOptimizerOptions object
  72741. */
  72742. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  72743. /**
  72744. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  72745. * @param targetFrameRate defines the target frame rate (60 by default)
  72746. * @returns a SceneOptimizerOptions object
  72747. */
  72748. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  72749. }
  72750. /**
  72751. * Class used to run optimizations in order to reach a target frame rate
  72752. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72753. */
  72754. export class SceneOptimizer implements IDisposable {
  72755. private _isRunning;
  72756. private _options;
  72757. private _scene;
  72758. private _currentPriorityLevel;
  72759. private _targetFrameRate;
  72760. private _trackerDuration;
  72761. private _currentFrameRate;
  72762. private _sceneDisposeObserver;
  72763. private _improvementMode;
  72764. /**
  72765. * Defines an observable called when the optimizer reaches the target frame rate
  72766. */
  72767. onSuccessObservable: Observable<SceneOptimizer>;
  72768. /**
  72769. * Defines an observable called when the optimizer enables an optimization
  72770. */
  72771. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  72772. /**
  72773. * Defines an observable called when the optimizer is not able to reach the target frame rate
  72774. */
  72775. onFailureObservable: Observable<SceneOptimizer>;
  72776. /**
  72777. * Gets a boolean indicating if the optimizer is in improvement mode
  72778. */
  72779. get isInImprovementMode(): boolean;
  72780. /**
  72781. * Gets the current priority level (0 at start)
  72782. */
  72783. get currentPriorityLevel(): number;
  72784. /**
  72785. * Gets the current frame rate checked by the SceneOptimizer
  72786. */
  72787. get currentFrameRate(): number;
  72788. /**
  72789. * Gets or sets the current target frame rate (60 by default)
  72790. */
  72791. get targetFrameRate(): number;
  72792. /**
  72793. * Gets or sets the current target frame rate (60 by default)
  72794. */
  72795. set targetFrameRate(value: number);
  72796. /**
  72797. * Gets or sets the current interval between two checks (every 2000ms by default)
  72798. */
  72799. get trackerDuration(): number;
  72800. /**
  72801. * Gets or sets the current interval between two checks (every 2000ms by default)
  72802. */
  72803. set trackerDuration(value: number);
  72804. /**
  72805. * Gets the list of active optimizations
  72806. */
  72807. get optimizations(): SceneOptimization[];
  72808. /**
  72809. * Creates a new SceneOptimizer
  72810. * @param scene defines the scene to work on
  72811. * @param options defines the options to use with the SceneOptimizer
  72812. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  72813. * @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)
  72814. */
  72815. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  72816. /**
  72817. * Stops the current optimizer
  72818. */
  72819. stop(): void;
  72820. /**
  72821. * Reset the optimizer to initial step (current priority level = 0)
  72822. */
  72823. reset(): void;
  72824. /**
  72825. * Start the optimizer. By default it will try to reach a specific framerate
  72826. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  72827. */
  72828. start(): void;
  72829. private _checkCurrentState;
  72830. /**
  72831. * Release all resources
  72832. */
  72833. dispose(): void;
  72834. /**
  72835. * Helper function to create a SceneOptimizer with one single line of code
  72836. * @param scene defines the scene to work on
  72837. * @param options defines the options to use with the SceneOptimizer
  72838. * @param onSuccess defines a callback to call on success
  72839. * @param onFailure defines a callback to call on failure
  72840. * @returns the new SceneOptimizer object
  72841. */
  72842. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  72843. }
  72844. }
  72845. declare module "babylonjs/Misc/sceneSerializer" {
  72846. import { Scene } from "babylonjs/scene";
  72847. /**
  72848. * Class used to serialize a scene into a string
  72849. */
  72850. export class SceneSerializer {
  72851. /**
  72852. * Clear cache used by a previous serialization
  72853. */
  72854. static ClearCache(): void;
  72855. /**
  72856. * Serialize a scene into a JSON compatible object
  72857. * @param scene defines the scene to serialize
  72858. * @returns a JSON compatible object
  72859. */
  72860. static Serialize(scene: Scene): any;
  72861. /**
  72862. * Serialize a mesh into a JSON compatible object
  72863. * @param toSerialize defines the mesh to serialize
  72864. * @param withParents defines if parents must be serialized as well
  72865. * @param withChildren defines if children must be serialized as well
  72866. * @returns a JSON compatible object
  72867. */
  72868. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  72869. }
  72870. }
  72871. declare module "babylonjs/Misc/textureTools" {
  72872. import { Texture } from "babylonjs/Materials/Textures/texture";
  72873. /**
  72874. * Class used to host texture specific utilities
  72875. */
  72876. export class TextureTools {
  72877. /**
  72878. * Uses the GPU to create a copy texture rescaled at a given size
  72879. * @param texture Texture to copy from
  72880. * @param width defines the desired width
  72881. * @param height defines the desired height
  72882. * @param useBilinearMode defines if bilinear mode has to be used
  72883. * @return the generated texture
  72884. */
  72885. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  72886. }
  72887. }
  72888. declare module "babylonjs/Misc/videoRecorder" {
  72889. import { Nullable } from "babylonjs/types";
  72890. import { Engine } from "babylonjs/Engines/engine";
  72891. /**
  72892. * This represents the different options available for the video capture.
  72893. */
  72894. export interface VideoRecorderOptions {
  72895. /** Defines the mime type of the video. */
  72896. mimeType: string;
  72897. /** Defines the FPS the video should be recorded at. */
  72898. fps: number;
  72899. /** Defines the chunk size for the recording data. */
  72900. recordChunckSize: number;
  72901. /** The audio tracks to attach to the recording. */
  72902. audioTracks?: MediaStreamTrack[];
  72903. }
  72904. /**
  72905. * This can help with recording videos from BabylonJS.
  72906. * This is based on the available WebRTC functionalities of the browser.
  72907. *
  72908. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  72909. */
  72910. export class VideoRecorder {
  72911. private static readonly _defaultOptions;
  72912. /**
  72913. * Returns whether or not the VideoRecorder is available in your browser.
  72914. * @param engine Defines the Babylon Engine.
  72915. * @returns true if supported otherwise false.
  72916. */
  72917. static IsSupported(engine: Engine): boolean;
  72918. private readonly _options;
  72919. private _canvas;
  72920. private _mediaRecorder;
  72921. private _recordedChunks;
  72922. private _fileName;
  72923. private _resolve;
  72924. private _reject;
  72925. /**
  72926. * True when a recording is already in progress.
  72927. */
  72928. get isRecording(): boolean;
  72929. /**
  72930. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  72931. * @param engine Defines the BabylonJS Engine you wish to record.
  72932. * @param options Defines options that can be used to customize the capture.
  72933. */
  72934. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  72935. /**
  72936. * Stops the current recording before the default capture timeout passed in the startRecording function.
  72937. */
  72938. stopRecording(): void;
  72939. /**
  72940. * Starts recording the canvas for a max duration specified in parameters.
  72941. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  72942. * If null no automatic download will start and you can rely on the promise to get the data back.
  72943. * @param maxDuration Defines the maximum recording time in seconds.
  72944. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  72945. * @return A promise callback at the end of the recording with the video data in Blob.
  72946. */
  72947. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  72948. /**
  72949. * Releases internal resources used during the recording.
  72950. */
  72951. dispose(): void;
  72952. private _handleDataAvailable;
  72953. private _handleError;
  72954. private _handleStop;
  72955. }
  72956. }
  72957. declare module "babylonjs/Misc/screenshotTools" {
  72958. import { Camera } from "babylonjs/Cameras/camera";
  72959. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  72960. import { Engine } from "babylonjs/Engines/engine";
  72961. /**
  72962. * Class containing a set of static utilities functions for screenshots
  72963. */
  72964. export class ScreenshotTools {
  72965. /**
  72966. * Captures a screenshot of the current rendering
  72967. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  72968. * @param engine defines the rendering engine
  72969. * @param camera defines the source camera
  72970. * @param size This parameter can be set to a single number or to an object with the
  72971. * following (optional) properties: precision, width, height. If a single number is passed,
  72972. * it will be used for both width and height. If an object is passed, the screenshot size
  72973. * will be derived from the parameters. The precision property is a multiplier allowing
  72974. * rendering at a higher or lower resolution
  72975. * @param successCallback defines the callback receives a single parameter which contains the
  72976. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  72977. * src parameter of an <img> to display it
  72978. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  72979. * Check your browser for supported MIME types
  72980. */
  72981. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  72982. /**
  72983. * Captures a screenshot of the current rendering
  72984. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  72985. * @param engine defines the rendering engine
  72986. * @param camera defines the source camera
  72987. * @param size This parameter can be set to a single number or to an object with the
  72988. * following (optional) properties: precision, width, height. If a single number is passed,
  72989. * it will be used for both width and height. If an object is passed, the screenshot size
  72990. * will be derived from the parameters. The precision property is a multiplier allowing
  72991. * rendering at a higher or lower resolution
  72992. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  72993. * Check your browser for supported MIME types
  72994. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  72995. * to the src parameter of an <img> to display it
  72996. */
  72997. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  72998. /**
  72999. * Generates an image screenshot from the specified camera.
  73000. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  73001. * @param engine The engine to use for rendering
  73002. * @param camera The camera to use for rendering
  73003. * @param size This parameter can be set to a single number or to an object with the
  73004. * following (optional) properties: precision, width, height. If a single number is passed,
  73005. * it will be used for both width and height. If an object is passed, the screenshot size
  73006. * will be derived from the parameters. The precision property is a multiplier allowing
  73007. * rendering at a higher or lower resolution
  73008. * @param successCallback The callback receives a single parameter which contains the
  73009. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  73010. * src parameter of an <img> to display it
  73011. * @param mimeType The MIME type of the screenshot image (default: image/png).
  73012. * Check your browser for supported MIME types
  73013. * @param samples Texture samples (default: 1)
  73014. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  73015. * @param fileName A name for for the downloaded file.
  73016. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  73017. */
  73018. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  73019. /**
  73020. * Generates an image screenshot from the specified camera.
  73021. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  73022. * @param engine The engine to use for rendering
  73023. * @param camera The camera to use for rendering
  73024. * @param size This parameter can be set to a single number or to an object with the
  73025. * following (optional) properties: precision, width, height. If a single number is passed,
  73026. * it will be used for both width and height. If an object is passed, the screenshot size
  73027. * will be derived from the parameters. The precision property is a multiplier allowing
  73028. * rendering at a higher or lower resolution
  73029. * @param mimeType The MIME type of the screenshot image (default: image/png).
  73030. * Check your browser for supported MIME types
  73031. * @param samples Texture samples (default: 1)
  73032. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  73033. * @param fileName A name for for the downloaded file.
  73034. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  73035. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  73036. * to the src parameter of an <img> to display it
  73037. */
  73038. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  73039. /**
  73040. * Gets height and width for screenshot size
  73041. * @private
  73042. */
  73043. private static _getScreenshotSize;
  73044. }
  73045. }
  73046. declare module "babylonjs/Misc/dataReader" {
  73047. /**
  73048. * Interface for a data buffer
  73049. */
  73050. export interface IDataBuffer {
  73051. /**
  73052. * Reads bytes from the data buffer.
  73053. * @param byteOffset The byte offset to read
  73054. * @param byteLength The byte length to read
  73055. * @returns A promise that resolves when the bytes are read
  73056. */
  73057. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  73058. /**
  73059. * The byte length of the buffer.
  73060. */
  73061. readonly byteLength: number;
  73062. }
  73063. /**
  73064. * Utility class for reading from a data buffer
  73065. */
  73066. export class DataReader {
  73067. /**
  73068. * The data buffer associated with this data reader.
  73069. */
  73070. readonly buffer: IDataBuffer;
  73071. /**
  73072. * The current byte offset from the beginning of the data buffer.
  73073. */
  73074. byteOffset: number;
  73075. private _dataView;
  73076. private _dataByteOffset;
  73077. /**
  73078. * Constructor
  73079. * @param buffer The buffer to read
  73080. */
  73081. constructor(buffer: IDataBuffer);
  73082. /**
  73083. * Loads the given byte length.
  73084. * @param byteLength The byte length to load
  73085. * @returns A promise that resolves when the load is complete
  73086. */
  73087. loadAsync(byteLength: number): Promise<void>;
  73088. /**
  73089. * Read a unsigned 32-bit integer from the currently loaded data range.
  73090. * @returns The 32-bit integer read
  73091. */
  73092. readUint32(): number;
  73093. /**
  73094. * Read a byte array from the currently loaded data range.
  73095. * @param byteLength The byte length to read
  73096. * @returns The byte array read
  73097. */
  73098. readUint8Array(byteLength: number): Uint8Array;
  73099. /**
  73100. * Read a string from the currently loaded data range.
  73101. * @param byteLength The byte length to read
  73102. * @returns The string read
  73103. */
  73104. readString(byteLength: number): string;
  73105. /**
  73106. * Skips the given byte length the currently loaded data range.
  73107. * @param byteLength The byte length to skip
  73108. */
  73109. skipBytes(byteLength: number): void;
  73110. }
  73111. }
  73112. declare module "babylonjs/Misc/dataStorage" {
  73113. /**
  73114. * Class for storing data to local storage if available or in-memory storage otherwise
  73115. */
  73116. export class DataStorage {
  73117. private static _Storage;
  73118. private static _GetStorage;
  73119. /**
  73120. * Reads a string from the data storage
  73121. * @param key The key to read
  73122. * @param defaultValue The value if the key doesn't exist
  73123. * @returns The string value
  73124. */
  73125. static ReadString(key: string, defaultValue: string): string;
  73126. /**
  73127. * Writes a string to the data storage
  73128. * @param key The key to write
  73129. * @param value The value to write
  73130. */
  73131. static WriteString(key: string, value: string): void;
  73132. /**
  73133. * Reads a boolean from the data storage
  73134. * @param key The key to read
  73135. * @param defaultValue The value if the key doesn't exist
  73136. * @returns The boolean value
  73137. */
  73138. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  73139. /**
  73140. * Writes a boolean to the data storage
  73141. * @param key The key to write
  73142. * @param value The value to write
  73143. */
  73144. static WriteBoolean(key: string, value: boolean): void;
  73145. /**
  73146. * Reads a number from the data storage
  73147. * @param key The key to read
  73148. * @param defaultValue The value if the key doesn't exist
  73149. * @returns The number value
  73150. */
  73151. static ReadNumber(key: string, defaultValue: number): number;
  73152. /**
  73153. * Writes a number to the data storage
  73154. * @param key The key to write
  73155. * @param value The value to write
  73156. */
  73157. static WriteNumber(key: string, value: number): void;
  73158. }
  73159. }
  73160. declare module "babylonjs/Misc/index" {
  73161. export * from "babylonjs/Misc/andOrNotEvaluator";
  73162. export * from "babylonjs/Misc/assetsManager";
  73163. export * from "babylonjs/Misc/basis";
  73164. export * from "babylonjs/Misc/dds";
  73165. export * from "babylonjs/Misc/decorators";
  73166. export * from "babylonjs/Misc/deferred";
  73167. export * from "babylonjs/Misc/environmentTextureTools";
  73168. export * from "babylonjs/Misc/meshExploder";
  73169. export * from "babylonjs/Misc/filesInput";
  73170. export * from "babylonjs/Misc/HighDynamicRange/index";
  73171. export * from "babylonjs/Misc/khronosTextureContainer";
  73172. export * from "babylonjs/Misc/observable";
  73173. export * from "babylonjs/Misc/performanceMonitor";
  73174. export * from "babylonjs/Misc/promise";
  73175. export * from "babylonjs/Misc/sceneOptimizer";
  73176. export * from "babylonjs/Misc/sceneSerializer";
  73177. export * from "babylonjs/Misc/smartArray";
  73178. export * from "babylonjs/Misc/stringDictionary";
  73179. export * from "babylonjs/Misc/tags";
  73180. export * from "babylonjs/Misc/textureTools";
  73181. export * from "babylonjs/Misc/tga";
  73182. export * from "babylonjs/Misc/tools";
  73183. export * from "babylonjs/Misc/videoRecorder";
  73184. export * from "babylonjs/Misc/virtualJoystick";
  73185. export * from "babylonjs/Misc/workerPool";
  73186. export * from "babylonjs/Misc/logger";
  73187. export * from "babylonjs/Misc/typeStore";
  73188. export * from "babylonjs/Misc/filesInputStore";
  73189. export * from "babylonjs/Misc/deepCopier";
  73190. export * from "babylonjs/Misc/pivotTools";
  73191. export * from "babylonjs/Misc/precisionDate";
  73192. export * from "babylonjs/Misc/screenshotTools";
  73193. export * from "babylonjs/Misc/typeStore";
  73194. export * from "babylonjs/Misc/webRequest";
  73195. export * from "babylonjs/Misc/iInspectable";
  73196. export * from "babylonjs/Misc/brdfTextureTools";
  73197. export * from "babylonjs/Misc/rgbdTextureTools";
  73198. export * from "babylonjs/Misc/gradients";
  73199. export * from "babylonjs/Misc/perfCounter";
  73200. export * from "babylonjs/Misc/fileRequest";
  73201. export * from "babylonjs/Misc/customAnimationFrameRequester";
  73202. export * from "babylonjs/Misc/retryStrategy";
  73203. export * from "babylonjs/Misc/interfaces/screenshotSize";
  73204. export * from "babylonjs/Misc/canvasGenerator";
  73205. export * from "babylonjs/Misc/fileTools";
  73206. export * from "babylonjs/Misc/stringTools";
  73207. export * from "babylonjs/Misc/dataReader";
  73208. export * from "babylonjs/Misc/minMaxReducer";
  73209. export * from "babylonjs/Misc/depthReducer";
  73210. export * from "babylonjs/Misc/dataStorage";
  73211. }
  73212. declare module "babylonjs/XR/features/WebXRHitTestLegacy" {
  73213. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  73214. import { Observable } from "babylonjs/Misc/observable";
  73215. import { Matrix } from "babylonjs/Maths/math.vector";
  73216. import { TransformNode } from "babylonjs/Meshes/transformNode";
  73217. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  73218. /**
  73219. * Options used for hit testing
  73220. */
  73221. export interface IWebXRLegacyHitTestOptions {
  73222. /**
  73223. * Only test when user interacted with the scene. Default - hit test every frame
  73224. */
  73225. testOnPointerDownOnly?: boolean;
  73226. /**
  73227. * The node to use to transform the local results to world coordinates
  73228. */
  73229. worldParentNode?: TransformNode;
  73230. }
  73231. /**
  73232. * Interface defining the babylon result of raycasting/hit-test
  73233. */
  73234. export interface IWebXRLegacyHitResult {
  73235. /**
  73236. * Transformation matrix that can be applied to a node that will put it in the hit point location
  73237. */
  73238. transformationMatrix: Matrix;
  73239. /**
  73240. * The native hit test result
  73241. */
  73242. xrHitResult: XRHitResult | XRHitTestResult;
  73243. }
  73244. /**
  73245. * The currently-working hit-test module.
  73246. * Hit test (or Ray-casting) is used to interact with the real world.
  73247. * For further information read here - https://github.com/immersive-web/hit-test
  73248. */
  73249. export class WebXRHitTestLegacy extends WebXRAbstractFeature {
  73250. /**
  73251. * options to use when constructing this feature
  73252. */
  73253. readonly options: IWebXRLegacyHitTestOptions;
  73254. private _direction;
  73255. private _mat;
  73256. private _onSelectEnabled;
  73257. private _origin;
  73258. /**
  73259. * The module's name
  73260. */
  73261. static readonly Name: string;
  73262. /**
  73263. * The (Babylon) version of this module.
  73264. * This is an integer representing the implementation version.
  73265. * This number does not correspond to the WebXR specs version
  73266. */
  73267. static readonly Version: number;
  73268. /**
  73269. * Populated with the last native XR Hit Results
  73270. */
  73271. lastNativeXRHitResults: XRHitResult[];
  73272. /**
  73273. * Triggered when new babylon (transformed) hit test results are available
  73274. */
  73275. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  73276. /**
  73277. * Creates a new instance of the (legacy version) hit test feature
  73278. * @param _xrSessionManager an instance of WebXRSessionManager
  73279. * @param options options to use when constructing this feature
  73280. */
  73281. constructor(_xrSessionManager: WebXRSessionManager,
  73282. /**
  73283. * options to use when constructing this feature
  73284. */
  73285. options?: IWebXRLegacyHitTestOptions);
  73286. /**
  73287. * execute a hit test with an XR Ray
  73288. *
  73289. * @param xrSession a native xrSession that will execute this hit test
  73290. * @param xrRay the ray (position and direction) to use for ray-casting
  73291. * @param referenceSpace native XR reference space to use for the hit-test
  73292. * @param filter filter function that will filter the results
  73293. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  73294. */
  73295. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  73296. /**
  73297. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  73298. * @param event the (select) event to use to select with
  73299. * @param referenceSpace the reference space to use for this hit test
  73300. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  73301. */
  73302. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  73303. /**
  73304. * attach this feature
  73305. * Will usually be called by the features manager
  73306. *
  73307. * @returns true if successful.
  73308. */
  73309. attach(): boolean;
  73310. /**
  73311. * detach this feature.
  73312. * Will usually be called by the features manager
  73313. *
  73314. * @returns true if successful.
  73315. */
  73316. detach(): boolean;
  73317. /**
  73318. * Dispose this feature and all of the resources attached
  73319. */
  73320. dispose(): void;
  73321. protected _onXRFrame(frame: XRFrame): void;
  73322. private _onHitTestResults;
  73323. private _onSelect;
  73324. }
  73325. }
  73326. declare module "babylonjs/XR/features/WebXRPlaneDetector" {
  73327. import { TransformNode } from "babylonjs/Meshes/transformNode";
  73328. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  73329. import { Observable } from "babylonjs/Misc/observable";
  73330. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  73331. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  73332. /**
  73333. * Options used in the plane detector module
  73334. */
  73335. export interface IWebXRPlaneDetectorOptions {
  73336. /**
  73337. * The node to use to transform the local results to world coordinates
  73338. */
  73339. worldParentNode?: TransformNode;
  73340. }
  73341. /**
  73342. * A babylon interface for a WebXR plane.
  73343. * A Plane is actually a polygon, built from N points in space
  73344. *
  73345. * Supported in chrome 79, not supported in canary 81 ATM
  73346. */
  73347. export interface IWebXRPlane {
  73348. /**
  73349. * a babylon-assigned ID for this polygon
  73350. */
  73351. id: number;
  73352. /**
  73353. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  73354. */
  73355. polygonDefinition: Array<Vector3>;
  73356. /**
  73357. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  73358. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  73359. */
  73360. transformationMatrix: Matrix;
  73361. /**
  73362. * the native xr-plane object
  73363. */
  73364. xrPlane: XRPlane;
  73365. }
  73366. /**
  73367. * The plane detector is used to detect planes in the real world when in AR
  73368. * For more information see https://github.com/immersive-web/real-world-geometry/
  73369. */
  73370. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  73371. private _options;
  73372. private _detectedPlanes;
  73373. private _enabled;
  73374. private _lastFrameDetected;
  73375. /**
  73376. * The module's name
  73377. */
  73378. static readonly Name: string;
  73379. /**
  73380. * The (Babylon) version of this module.
  73381. * This is an integer representing the implementation version.
  73382. * This number does not correspond to the WebXR specs version
  73383. */
  73384. static readonly Version: number;
  73385. /**
  73386. * Observers registered here will be executed when a new plane was added to the session
  73387. */
  73388. onPlaneAddedObservable: Observable<IWebXRPlane>;
  73389. /**
  73390. * Observers registered here will be executed when a plane is no longer detected in the session
  73391. */
  73392. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  73393. /**
  73394. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  73395. * This can execute N times every frame
  73396. */
  73397. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  73398. /**
  73399. * construct a new Plane Detector
  73400. * @param _xrSessionManager an instance of xr Session manager
  73401. * @param _options configuration to use when constructing this feature
  73402. */
  73403. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  73404. /**
  73405. * Dispose this feature and all of the resources attached
  73406. */
  73407. dispose(): void;
  73408. protected _onXRFrame(frame: XRFrame): void;
  73409. private _init;
  73410. private _updatePlaneWithXRPlane;
  73411. /**
  73412. * avoiding using Array.find for global support.
  73413. * @param xrPlane the plane to find in the array
  73414. */
  73415. private findIndexInPlaneArray;
  73416. }
  73417. }
  73418. declare module "babylonjs/XR/features/WebXRAnchorSystem" {
  73419. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  73420. import { Observable } from "babylonjs/Misc/observable";
  73421. import { Matrix } from "babylonjs/Maths/math.vector";
  73422. import { TransformNode } from "babylonjs/Meshes/transformNode";
  73423. import { WebXRPlaneDetector } from "babylonjs/XR/features/WebXRPlaneDetector";
  73424. import { WebXRHitTestLegacy } from "babylonjs/XR/features/WebXRHitTestLegacy";
  73425. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  73426. /**
  73427. * Configuration options of the anchor system
  73428. */
  73429. export interface IWebXRAnchorSystemOptions {
  73430. /**
  73431. * Should a new anchor be added every time a select event is triggered
  73432. */
  73433. addAnchorOnSelect?: boolean;
  73434. /**
  73435. * should the anchor system use plane detection.
  73436. * If set to true, the plane-detection feature should be set using setPlaneDetector
  73437. */
  73438. usePlaneDetection?: boolean;
  73439. /**
  73440. * a node that will be used to convert local to world coordinates
  73441. */
  73442. worldParentNode?: TransformNode;
  73443. }
  73444. /**
  73445. * A babylon container for an XR Anchor
  73446. */
  73447. export interface IWebXRAnchor {
  73448. /**
  73449. * A babylon-assigned ID for this anchor
  73450. */
  73451. id: number;
  73452. /**
  73453. * Transformation matrix to apply to an object attached to this anchor
  73454. */
  73455. transformationMatrix: Matrix;
  73456. /**
  73457. * The native anchor object
  73458. */
  73459. xrAnchor: XRAnchor;
  73460. }
  73461. /**
  73462. * An implementation of the anchor system of WebXR.
  73463. * Note that the current documented implementation is not available in any browser. Future implementations
  73464. * will use the frame to create an anchor and not the session or a detected plane
  73465. * For further information see https://github.com/immersive-web/anchors/
  73466. */
  73467. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  73468. private _options;
  73469. private _enabled;
  73470. private _hitTestModule;
  73471. private _lastFrameDetected;
  73472. private _onSelect;
  73473. private _planeDetector;
  73474. private _trackedAnchors;
  73475. /**
  73476. * The module's name
  73477. */
  73478. static readonly Name: string;
  73479. /**
  73480. * The (Babylon) version of this module.
  73481. * This is an integer representing the implementation version.
  73482. * This number does not correspond to the WebXR specs version
  73483. */
  73484. static readonly Version: number;
  73485. /**
  73486. * Observers registered here will be executed when a new anchor was added to the session
  73487. */
  73488. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  73489. /**
  73490. * Observers registered here will be executed when an anchor was removed from the session
  73491. */
  73492. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  73493. /**
  73494. * Observers registered here will be executed when an existing anchor updates
  73495. * This can execute N times every frame
  73496. */
  73497. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  73498. /**
  73499. * constructs a new anchor system
  73500. * @param _xrSessionManager an instance of WebXRSessionManager
  73501. * @param _options configuration object for this feature
  73502. */
  73503. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  73504. /**
  73505. * Add anchor at a specific XR point.
  73506. *
  73507. * @param xrRigidTransformation xr-coordinates where a new anchor should be added
  73508. * @param anchorCreator the object o use to create an anchor with. either a session or a plane
  73509. * @returns a promise the fulfills when the anchor was created
  73510. */
  73511. addAnchorAtRigidTransformation(xrRigidTransformation: XRRigidTransform, anchorCreator?: XRAnchorCreator): Promise<XRAnchor>;
  73512. /**
  73513. * attach this feature
  73514. * Will usually be called by the features manager
  73515. *
  73516. * @returns true if successful.
  73517. */
  73518. attach(): boolean;
  73519. /**
  73520. * detach this feature.
  73521. * Will usually be called by the features manager
  73522. *
  73523. * @returns true if successful.
  73524. */
  73525. detach(): boolean;
  73526. /**
  73527. * Dispose this feature and all of the resources attached
  73528. */
  73529. dispose(): void;
  73530. /**
  73531. * If set, it will improve performance by using the current hit-test results instead of executing a new hit-test
  73532. * @param hitTestModule the hit-test module to use.
  73533. */
  73534. setHitTestModule(hitTestModule: WebXRHitTestLegacy): void;
  73535. /**
  73536. * set the plane detector to use in order to create anchors from frames
  73537. * @param planeDetector the plane-detector module to use
  73538. * @param enable enable plane-anchors. default is true
  73539. */
  73540. setPlaneDetector(planeDetector: WebXRPlaneDetector, enable?: boolean): void;
  73541. protected _onXRFrame(frame: XRFrame): void;
  73542. /**
  73543. * avoiding using Array.find for global support.
  73544. * @param xrAnchor the plane to find in the array
  73545. */
  73546. private _findIndexInAnchorArray;
  73547. private _updateAnchorWithXRFrame;
  73548. }
  73549. }
  73550. declare module "babylonjs/XR/features/WebXRBackgroundRemover" {
  73551. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  73552. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  73553. import { Observable } from "babylonjs/Misc/observable";
  73554. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  73555. /**
  73556. * Options interface for the background remover plugin
  73557. */
  73558. export interface IWebXRBackgroundRemoverOptions {
  73559. /**
  73560. * Further background meshes to disable when entering AR
  73561. */
  73562. backgroundMeshes?: AbstractMesh[];
  73563. /**
  73564. * flags to configure the removal of the environment helper.
  73565. * If not set, the entire background will be removed. If set, flags should be set as well.
  73566. */
  73567. environmentHelperRemovalFlags?: {
  73568. /**
  73569. * Should the skybox be removed (default false)
  73570. */
  73571. skyBox?: boolean;
  73572. /**
  73573. * Should the ground be removed (default false)
  73574. */
  73575. ground?: boolean;
  73576. };
  73577. /**
  73578. * don't disable the environment helper
  73579. */
  73580. ignoreEnvironmentHelper?: boolean;
  73581. }
  73582. /**
  73583. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  73584. */
  73585. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  73586. /**
  73587. * read-only options to be used in this module
  73588. */
  73589. readonly options: IWebXRBackgroundRemoverOptions;
  73590. /**
  73591. * The module's name
  73592. */
  73593. static readonly Name: string;
  73594. /**
  73595. * The (Babylon) version of this module.
  73596. * This is an integer representing the implementation version.
  73597. * This number does not correspond to the WebXR specs version
  73598. */
  73599. static readonly Version: number;
  73600. /**
  73601. * registered observers will be triggered when the background state changes
  73602. */
  73603. onBackgroundStateChangedObservable: Observable<boolean>;
  73604. /**
  73605. * constructs a new background remover module
  73606. * @param _xrSessionManager the session manager for this module
  73607. * @param options read-only options to be used in this module
  73608. */
  73609. constructor(_xrSessionManager: WebXRSessionManager,
  73610. /**
  73611. * read-only options to be used in this module
  73612. */
  73613. options?: IWebXRBackgroundRemoverOptions);
  73614. /**
  73615. * attach this feature
  73616. * Will usually be called by the features manager
  73617. *
  73618. * @returns true if successful.
  73619. */
  73620. attach(): boolean;
  73621. /**
  73622. * detach this feature.
  73623. * Will usually be called by the features manager
  73624. *
  73625. * @returns true if successful.
  73626. */
  73627. detach(): boolean;
  73628. /**
  73629. * Dispose this feature and all of the resources attached
  73630. */
  73631. dispose(): void;
  73632. protected _onXRFrame(_xrFrame: XRFrame): void;
  73633. private _setBackgroundState;
  73634. }
  73635. }
  73636. declare module "babylonjs/XR/features/WebXRControllerPhysics" {
  73637. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  73638. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  73639. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  73640. import { WebXRInput } from "babylonjs/XR/webXRInput";
  73641. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  73642. import { Nullable } from "babylonjs/types";
  73643. /**
  73644. * Options for the controller physics feature
  73645. */
  73646. export class IWebXRControllerPhysicsOptions {
  73647. /**
  73648. * Should the headset get its own impostor
  73649. */
  73650. enableHeadsetImpostor?: boolean;
  73651. /**
  73652. * Optional parameters for the headset impostor
  73653. */
  73654. headsetImpostorParams?: {
  73655. /**
  73656. * The type of impostor to create. Default is sphere
  73657. */
  73658. impostorType: number;
  73659. /**
  73660. * the size of the impostor. Defaults to 10cm
  73661. */
  73662. impostorSize?: number | {
  73663. width: number;
  73664. height: number;
  73665. depth: number;
  73666. };
  73667. /**
  73668. * Friction definitions
  73669. */
  73670. friction?: number;
  73671. /**
  73672. * Restitution
  73673. */
  73674. restitution?: number;
  73675. };
  73676. /**
  73677. * The physics properties of the future impostors
  73678. */
  73679. physicsProperties?: {
  73680. /**
  73681. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  73682. * Note that this requires a physics engine that supports mesh impostors!
  73683. */
  73684. useControllerMesh?: boolean;
  73685. /**
  73686. * The type of impostor to create. Default is sphere
  73687. */
  73688. impostorType?: number;
  73689. /**
  73690. * the size of the impostor. Defaults to 10cm
  73691. */
  73692. impostorSize?: number | {
  73693. width: number;
  73694. height: number;
  73695. depth: number;
  73696. };
  73697. /**
  73698. * Friction definitions
  73699. */
  73700. friction?: number;
  73701. /**
  73702. * Restitution
  73703. */
  73704. restitution?: number;
  73705. };
  73706. /**
  73707. * the xr input to use with this pointer selection
  73708. */
  73709. xrInput: WebXRInput;
  73710. }
  73711. /**
  73712. * Add physics impostor to your webxr controllers,
  73713. * including naive calculation of their linear and angular velocity
  73714. */
  73715. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  73716. private readonly _options;
  73717. private _attachController;
  73718. private _controllers;
  73719. private _debugMode;
  73720. private _delta;
  73721. private _headsetImpostor?;
  73722. private _headsetMesh?;
  73723. private _lastTimestamp;
  73724. private _tmpQuaternion;
  73725. private _tmpVector;
  73726. /**
  73727. * The module's name
  73728. */
  73729. static readonly Name: string;
  73730. /**
  73731. * The (Babylon) version of this module.
  73732. * This is an integer representing the implementation version.
  73733. * This number does not correspond to the webxr specs version
  73734. */
  73735. static readonly Version: number;
  73736. /**
  73737. * Construct a new Controller Physics Feature
  73738. * @param _xrSessionManager the corresponding xr session manager
  73739. * @param _options options to create this feature with
  73740. */
  73741. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  73742. /**
  73743. * @hidden
  73744. * enable debugging - will show console outputs and the impostor mesh
  73745. */
  73746. _enablePhysicsDebug(): void;
  73747. /**
  73748. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  73749. * @param xrController the controller to add
  73750. */
  73751. addController(xrController: WebXRInputSource): void;
  73752. /**
  73753. * attach this feature
  73754. * Will usually be called by the features manager
  73755. *
  73756. * @returns true if successful.
  73757. */
  73758. attach(): boolean;
  73759. /**
  73760. * detach this feature.
  73761. * Will usually be called by the features manager
  73762. *
  73763. * @returns true if successful.
  73764. */
  73765. detach(): boolean;
  73766. /**
  73767. * Get the headset impostor, if enabled
  73768. * @returns the impostor
  73769. */
  73770. getHeadsetImpostor(): PhysicsImpostor | undefined;
  73771. /**
  73772. * Get the physics impostor of a specific controller.
  73773. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  73774. * @param controller the controller or the controller id of which to get the impostor
  73775. * @returns the impostor or null
  73776. */
  73777. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  73778. /**
  73779. * Update the physics properties provided in the constructor
  73780. * @param newProperties the new properties object
  73781. */
  73782. setPhysicsProperties(newProperties: {
  73783. impostorType?: number;
  73784. impostorSize?: number | {
  73785. width: number;
  73786. height: number;
  73787. depth: number;
  73788. };
  73789. friction?: number;
  73790. restitution?: number;
  73791. }): void;
  73792. protected _onXRFrame(_xrFrame: any): void;
  73793. private _detachController;
  73794. }
  73795. }
  73796. declare module "babylonjs/XR/features/WebXRHitTest" {
  73797. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  73798. import { Observable } from "babylonjs/Misc/observable";
  73799. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  73800. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  73801. import { IWebXRLegacyHitTestOptions, IWebXRLegacyHitResult } from "babylonjs/XR/features/WebXRHitTestLegacy";
  73802. /**
  73803. * Options used for hit testing (version 2)
  73804. */
  73805. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  73806. /**
  73807. * Do not create a permanent hit test. Will usually be used when only
  73808. * transient inputs are needed.
  73809. */
  73810. disablePermanentHitTest?: boolean;
  73811. /**
  73812. * Enable transient (for example touch-based) hit test inspections
  73813. */
  73814. enableTransientHitTest?: boolean;
  73815. /**
  73816. * Offset ray for the permanent hit test
  73817. */
  73818. offsetRay?: Vector3;
  73819. /**
  73820. * Offset ray for the transient hit test
  73821. */
  73822. transientOffsetRay?: Vector3;
  73823. /**
  73824. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  73825. */
  73826. useReferenceSpace?: boolean;
  73827. }
  73828. /**
  73829. * Interface defining the babylon result of hit-test
  73830. */
  73831. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  73832. /**
  73833. * The input source that generated this hit test (if transient)
  73834. */
  73835. inputSource?: XRInputSource;
  73836. /**
  73837. * Is this a transient hit test
  73838. */
  73839. isTransient?: boolean;
  73840. /**
  73841. * Position of the hit test result
  73842. */
  73843. position: Vector3;
  73844. /**
  73845. * Rotation of the hit test result
  73846. */
  73847. rotationQuaternion: Quaternion;
  73848. }
  73849. /**
  73850. * The currently-working hit-test module.
  73851. * Hit test (or Ray-casting) is used to interact with the real world.
  73852. * For further information read here - https://github.com/immersive-web/hit-test
  73853. *
  73854. * Tested on chrome (mobile) 80.
  73855. */
  73856. export class WebXRHitTest extends WebXRAbstractFeature {
  73857. /**
  73858. * options to use when constructing this feature
  73859. */
  73860. readonly options: IWebXRHitTestOptions;
  73861. private _tmpMat;
  73862. private _tmpPos;
  73863. private _tmpQuat;
  73864. private _transientXrHitTestSource;
  73865. private _xrHitTestSource;
  73866. private initHitTestSource;
  73867. /**
  73868. * The module's name
  73869. */
  73870. static readonly Name: string;
  73871. /**
  73872. * The (Babylon) version of this module.
  73873. * This is an integer representing the implementation version.
  73874. * This number does not correspond to the WebXR specs version
  73875. */
  73876. static readonly Version: number;
  73877. /**
  73878. * When set to true, each hit test will have its own position/rotation objects
  73879. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  73880. * the developers will clone them or copy them as they see fit.
  73881. */
  73882. autoCloneTransformation: boolean;
  73883. /**
  73884. * Populated with the last native XR Hit Results
  73885. */
  73886. lastNativeXRHitResults: XRHitResult[];
  73887. /**
  73888. * Triggered when new babylon (transformed) hit test results are available
  73889. */
  73890. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  73891. /**
  73892. * Use this to temporarily pause hit test checks.
  73893. */
  73894. paused: boolean;
  73895. /**
  73896. * Creates a new instance of the hit test feature
  73897. * @param _xrSessionManager an instance of WebXRSessionManager
  73898. * @param options options to use when constructing this feature
  73899. */
  73900. constructor(_xrSessionManager: WebXRSessionManager,
  73901. /**
  73902. * options to use when constructing this feature
  73903. */
  73904. options?: IWebXRHitTestOptions);
  73905. /**
  73906. * attach this feature
  73907. * Will usually be called by the features manager
  73908. *
  73909. * @returns true if successful.
  73910. */
  73911. attach(): boolean;
  73912. /**
  73913. * detach this feature.
  73914. * Will usually be called by the features manager
  73915. *
  73916. * @returns true if successful.
  73917. */
  73918. detach(): boolean;
  73919. /**
  73920. * Dispose this feature and all of the resources attached
  73921. */
  73922. dispose(): void;
  73923. protected _onXRFrame(frame: XRFrame): void;
  73924. private _processWebXRHitTestResult;
  73925. }
  73926. }
  73927. declare module "babylonjs/XR/features/index" {
  73928. export * from "babylonjs/XR/features/WebXRHitTestLegacy";
  73929. export * from "babylonjs/XR/features/WebXRAnchorSystem";
  73930. export * from "babylonjs/XR/features/WebXRPlaneDetector";
  73931. export * from "babylonjs/XR/features/WebXRBackgroundRemover";
  73932. export * from "babylonjs/XR/features/WebXRControllerTeleportation";
  73933. export * from "babylonjs/XR/features/WebXRControllerPointerSelection";
  73934. export * from "babylonjs/XR/features/WebXRControllerPhysics";
  73935. export * from "babylonjs/XR/features/WebXRHitTest";
  73936. }
  73937. declare module "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController" {
  73938. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  73939. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  73940. import { Scene } from "babylonjs/scene";
  73941. /**
  73942. * The motion controller class for all microsoft mixed reality controllers
  73943. */
  73944. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  73945. protected readonly _mapping: {
  73946. defaultButton: {
  73947. valueNodeName: string;
  73948. unpressedNodeName: string;
  73949. pressedNodeName: string;
  73950. };
  73951. defaultAxis: {
  73952. valueNodeName: string;
  73953. minNodeName: string;
  73954. maxNodeName: string;
  73955. };
  73956. buttons: {
  73957. "xr-standard-trigger": {
  73958. rootNodeName: string;
  73959. componentProperty: string;
  73960. states: string[];
  73961. };
  73962. "xr-standard-squeeze": {
  73963. rootNodeName: string;
  73964. componentProperty: string;
  73965. states: string[];
  73966. };
  73967. "xr-standard-touchpad": {
  73968. rootNodeName: string;
  73969. labelAnchorNodeName: string;
  73970. touchPointNodeName: string;
  73971. };
  73972. "xr-standard-thumbstick": {
  73973. rootNodeName: string;
  73974. componentProperty: string;
  73975. states: string[];
  73976. };
  73977. };
  73978. axes: {
  73979. "xr-standard-touchpad": {
  73980. "x-axis": {
  73981. rootNodeName: string;
  73982. };
  73983. "y-axis": {
  73984. rootNodeName: string;
  73985. };
  73986. };
  73987. "xr-standard-thumbstick": {
  73988. "x-axis": {
  73989. rootNodeName: string;
  73990. };
  73991. "y-axis": {
  73992. rootNodeName: string;
  73993. };
  73994. };
  73995. };
  73996. };
  73997. /**
  73998. * The base url used to load the left and right controller models
  73999. */
  74000. static MODEL_BASE_URL: string;
  74001. /**
  74002. * The name of the left controller model file
  74003. */
  74004. static MODEL_LEFT_FILENAME: string;
  74005. /**
  74006. * The name of the right controller model file
  74007. */
  74008. static MODEL_RIGHT_FILENAME: string;
  74009. profileId: string;
  74010. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  74011. protected _getFilenameAndPath(): {
  74012. filename: string;
  74013. path: string;
  74014. };
  74015. protected _getModelLoadingConstraints(): boolean;
  74016. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  74017. protected _setRootMesh(meshes: AbstractMesh[]): void;
  74018. protected _updateModel(): void;
  74019. }
  74020. }
  74021. declare module "babylonjs/XR/motionController/webXROculusTouchMotionController" {
  74022. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  74023. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  74024. import { Scene } from "babylonjs/scene";
  74025. /**
  74026. * The motion controller class for oculus touch (quest, rift).
  74027. * This class supports legacy mapping as well the standard xr mapping
  74028. */
  74029. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  74030. private _forceLegacyControllers;
  74031. private _modelRootNode;
  74032. /**
  74033. * The base url used to load the left and right controller models
  74034. */
  74035. static MODEL_BASE_URL: string;
  74036. /**
  74037. * The name of the left controller model file
  74038. */
  74039. static MODEL_LEFT_FILENAME: string;
  74040. /**
  74041. * The name of the right controller model file
  74042. */
  74043. static MODEL_RIGHT_FILENAME: string;
  74044. /**
  74045. * Base Url for the Quest controller model.
  74046. */
  74047. static QUEST_MODEL_BASE_URL: string;
  74048. profileId: string;
  74049. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  74050. protected _getFilenameAndPath(): {
  74051. filename: string;
  74052. path: string;
  74053. };
  74054. protected _getModelLoadingConstraints(): boolean;
  74055. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  74056. protected _setRootMesh(meshes: AbstractMesh[]): void;
  74057. protected _updateModel(): void;
  74058. /**
  74059. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  74060. * between the touch and touch 2.
  74061. */
  74062. private _isQuest;
  74063. }
  74064. }
  74065. declare module "babylonjs/XR/motionController/webXRHTCViveMotionController" {
  74066. import { IMinimalMotionControllerObject, MotionControllerHandness, WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  74067. import { Scene } from "babylonjs/scene";
  74068. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  74069. /**
  74070. * The motion controller class for the standard HTC-Vive controllers
  74071. */
  74072. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  74073. private _modelRootNode;
  74074. /**
  74075. * The base url used to load the left and right controller models
  74076. */
  74077. static MODEL_BASE_URL: string;
  74078. /**
  74079. * File name for the controller model.
  74080. */
  74081. static MODEL_FILENAME: string;
  74082. profileId: string;
  74083. /**
  74084. * Create a new Vive motion controller object
  74085. * @param scene the scene to use to create this controller
  74086. * @param gamepadObject the corresponding gamepad object
  74087. * @param handness the handness of the controller
  74088. */
  74089. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  74090. protected _getFilenameAndPath(): {
  74091. filename: string;
  74092. path: string;
  74093. };
  74094. protected _getModelLoadingConstraints(): boolean;
  74095. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  74096. protected _setRootMesh(meshes: AbstractMesh[]): void;
  74097. protected _updateModel(): void;
  74098. }
  74099. }
  74100. declare module "babylonjs/XR/motionController/index" {
  74101. export * from "babylonjs/XR/motionController/webXRAbstractMotionController";
  74102. export * from "babylonjs/XR/motionController/webXRControllerComponent";
  74103. export * from "babylonjs/XR/motionController/webXRGenericMotionController";
  74104. export * from "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController";
  74105. export * from "babylonjs/XR/motionController/webXRMotionControllerManager";
  74106. export * from "babylonjs/XR/motionController/webXROculusTouchMotionController";
  74107. export * from "babylonjs/XR/motionController/webXRHTCViveMotionController";
  74108. export * from "babylonjs/XR/motionController/webXRProfiledMotionController";
  74109. }
  74110. declare module "babylonjs/XR/index" {
  74111. export * from "babylonjs/XR/webXRCamera";
  74112. export * from "babylonjs/XR/webXREnterExitUI";
  74113. export * from "babylonjs/XR/webXRExperienceHelper";
  74114. export * from "babylonjs/XR/webXRInput";
  74115. export * from "babylonjs/XR/webXRInputSource";
  74116. export * from "babylonjs/XR/webXRManagedOutputCanvas";
  74117. export * from "babylonjs/XR/webXRTypes";
  74118. export * from "babylonjs/XR/webXRSessionManager";
  74119. export * from "babylonjs/XR/webXRDefaultExperience";
  74120. export * from "babylonjs/XR/webXRFeaturesManager";
  74121. export * from "babylonjs/XR/features/index";
  74122. export * from "babylonjs/XR/motionController/index";
  74123. }
  74124. declare module "babylonjs/index" {
  74125. export * from "babylonjs/abstractScene";
  74126. export * from "babylonjs/Actions/index";
  74127. export * from "babylonjs/Animations/index";
  74128. export * from "babylonjs/assetContainer";
  74129. export * from "babylonjs/Audio/index";
  74130. export * from "babylonjs/Behaviors/index";
  74131. export * from "babylonjs/Bones/index";
  74132. export * from "babylonjs/Cameras/index";
  74133. export * from "babylonjs/Collisions/index";
  74134. export * from "babylonjs/Culling/index";
  74135. export * from "babylonjs/Debug/index";
  74136. export * from "babylonjs/Engines/index";
  74137. export * from "babylonjs/Events/index";
  74138. export * from "babylonjs/Gamepads/index";
  74139. export * from "babylonjs/Gizmos/index";
  74140. export * from "babylonjs/Helpers/index";
  74141. export * from "babylonjs/Instrumentation/index";
  74142. export * from "babylonjs/Layers/index";
  74143. export * from "babylonjs/LensFlares/index";
  74144. export * from "babylonjs/Lights/index";
  74145. export * from "babylonjs/Loading/index";
  74146. export * from "babylonjs/Materials/index";
  74147. export * from "babylonjs/Maths/index";
  74148. export * from "babylonjs/Meshes/index";
  74149. export * from "babylonjs/Morph/index";
  74150. export * from "babylonjs/Navigation/index";
  74151. export * from "babylonjs/node";
  74152. export * from "babylonjs/Offline/index";
  74153. export * from "babylonjs/Particles/index";
  74154. export * from "babylonjs/Physics/index";
  74155. export * from "babylonjs/PostProcesses/index";
  74156. export * from "babylonjs/Probes/index";
  74157. export * from "babylonjs/Rendering/index";
  74158. export * from "babylonjs/scene";
  74159. export * from "babylonjs/sceneComponent";
  74160. export * from "babylonjs/Sprites/index";
  74161. export * from "babylonjs/States/index";
  74162. export * from "babylonjs/Misc/index";
  74163. export * from "babylonjs/XR/index";
  74164. export * from "babylonjs/types";
  74165. }
  74166. declare module "babylonjs/Animations/pathCursor" {
  74167. import { Vector3 } from "babylonjs/Maths/math.vector";
  74168. import { Path2 } from "babylonjs/Maths/math.path";
  74169. /**
  74170. * A cursor which tracks a point on a path
  74171. */
  74172. export class PathCursor {
  74173. private path;
  74174. /**
  74175. * Stores path cursor callbacks for when an onchange event is triggered
  74176. */
  74177. private _onchange;
  74178. /**
  74179. * The value of the path cursor
  74180. */
  74181. value: number;
  74182. /**
  74183. * The animation array of the path cursor
  74184. */
  74185. animations: Animation[];
  74186. /**
  74187. * Initializes the path cursor
  74188. * @param path The path to track
  74189. */
  74190. constructor(path: Path2);
  74191. /**
  74192. * Gets the cursor point on the path
  74193. * @returns A point on the path cursor at the cursor location
  74194. */
  74195. getPoint(): Vector3;
  74196. /**
  74197. * Moves the cursor ahead by the step amount
  74198. * @param step The amount to move the cursor forward
  74199. * @returns This path cursor
  74200. */
  74201. moveAhead(step?: number): PathCursor;
  74202. /**
  74203. * Moves the cursor behind by the step amount
  74204. * @param step The amount to move the cursor back
  74205. * @returns This path cursor
  74206. */
  74207. moveBack(step?: number): PathCursor;
  74208. /**
  74209. * Moves the cursor by the step amount
  74210. * If the step amount is greater than one, an exception is thrown
  74211. * @param step The amount to move the cursor
  74212. * @returns This path cursor
  74213. */
  74214. move(step: number): PathCursor;
  74215. /**
  74216. * Ensures that the value is limited between zero and one
  74217. * @returns This path cursor
  74218. */
  74219. private ensureLimits;
  74220. /**
  74221. * Runs onchange callbacks on change (used by the animation engine)
  74222. * @returns This path cursor
  74223. */
  74224. private raiseOnChange;
  74225. /**
  74226. * Executes a function on change
  74227. * @param f A path cursor onchange callback
  74228. * @returns This path cursor
  74229. */
  74230. onchange(f: (cursor: PathCursor) => void): PathCursor;
  74231. }
  74232. }
  74233. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  74234. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  74235. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  74236. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  74237. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  74238. }
  74239. declare module "babylonjs/Engines/Processors/Expressions/index" {
  74240. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  74241. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  74242. }
  74243. declare module "babylonjs/Engines/Processors/index" {
  74244. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  74245. export * from "babylonjs/Engines/Processors/Expressions/index";
  74246. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  74247. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  74248. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  74249. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  74250. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  74251. export * from "babylonjs/Engines/Processors/shaderProcessor";
  74252. }
  74253. declare module "babylonjs/Legacy/legacy" {
  74254. import * as Babylon from "babylonjs/index";
  74255. export * from "babylonjs/index";
  74256. }
  74257. declare module "babylonjs/Shaders/blur.fragment" {
  74258. /** @hidden */
  74259. export var blurPixelShader: {
  74260. name: string;
  74261. shader: string;
  74262. };
  74263. }
  74264. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  74265. /** @hidden */
  74266. export var pointCloudVertexDeclaration: {
  74267. name: string;
  74268. shader: string;
  74269. };
  74270. }
  74271. declare module "babylonjs" {
  74272. export * from "babylonjs/Legacy/legacy";
  74273. }
  74274. declare module BABYLON {
  74275. /** Alias type for value that can be null */
  74276. export type Nullable<T> = T | null;
  74277. /**
  74278. * Alias type for number that are floats
  74279. * @ignorenaming
  74280. */
  74281. export type float = number;
  74282. /**
  74283. * Alias type for number that are doubles.
  74284. * @ignorenaming
  74285. */
  74286. export type double = number;
  74287. /**
  74288. * Alias type for number that are integer
  74289. * @ignorenaming
  74290. */
  74291. export type int = number;
  74292. /** Alias type for number array or Float32Array */
  74293. export type FloatArray = number[] | Float32Array;
  74294. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  74295. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  74296. /**
  74297. * Alias for types that can be used by a Buffer or VertexBuffer.
  74298. */
  74299. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  74300. /**
  74301. * Alias type for primitive types
  74302. * @ignorenaming
  74303. */
  74304. type Primitive = undefined | null | boolean | string | number | Function;
  74305. /**
  74306. * Type modifier to make all the properties of an object Readonly
  74307. */
  74308. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  74309. /**
  74310. * Type modifier to make all the properties of an object Readonly recursively
  74311. */
  74312. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  74313. /**
  74314. * Type modifier to make object properties readonly.
  74315. */
  74316. export type DeepImmutableObject<T> = {
  74317. readonly [K in keyof T]: DeepImmutable<T[K]>;
  74318. };
  74319. /** @hidden */
  74320. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  74321. }
  74322. }
  74323. declare module BABYLON {
  74324. /**
  74325. * A class serves as a medium between the observable and its observers
  74326. */
  74327. export class EventState {
  74328. /**
  74329. * Create a new EventState
  74330. * @param mask defines the mask associated with this state
  74331. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  74332. * @param target defines the original target of the state
  74333. * @param currentTarget defines the current target of the state
  74334. */
  74335. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  74336. /**
  74337. * Initialize the current event state
  74338. * @param mask defines the mask associated with this state
  74339. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  74340. * @param target defines the original target of the state
  74341. * @param currentTarget defines the current target of the state
  74342. * @returns the current event state
  74343. */
  74344. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  74345. /**
  74346. * An Observer can set this property to true to prevent subsequent observers of being notified
  74347. */
  74348. skipNextObservers: boolean;
  74349. /**
  74350. * Get the mask value that were used to trigger the event corresponding to this EventState object
  74351. */
  74352. mask: number;
  74353. /**
  74354. * The object that originally notified the event
  74355. */
  74356. target?: any;
  74357. /**
  74358. * The current object in the bubbling phase
  74359. */
  74360. currentTarget?: any;
  74361. /**
  74362. * This will be populated with the return value of the last function that was executed.
  74363. * If it is the first function in the callback chain it will be the event data.
  74364. */
  74365. lastReturnValue?: any;
  74366. }
  74367. /**
  74368. * Represent an Observer registered to a given Observable object.
  74369. */
  74370. export class Observer<T> {
  74371. /**
  74372. * Defines the callback to call when the observer is notified
  74373. */
  74374. callback: (eventData: T, eventState: EventState) => void;
  74375. /**
  74376. * Defines the mask of the observer (used to filter notifications)
  74377. */
  74378. mask: number;
  74379. /**
  74380. * Defines the current scope used to restore the JS context
  74381. */
  74382. scope: any;
  74383. /** @hidden */
  74384. _willBeUnregistered: boolean;
  74385. /**
  74386. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  74387. */
  74388. unregisterOnNextCall: boolean;
  74389. /**
  74390. * Creates a new observer
  74391. * @param callback defines the callback to call when the observer is notified
  74392. * @param mask defines the mask of the observer (used to filter notifications)
  74393. * @param scope defines the current scope used to restore the JS context
  74394. */
  74395. constructor(
  74396. /**
  74397. * Defines the callback to call when the observer is notified
  74398. */
  74399. callback: (eventData: T, eventState: EventState) => void,
  74400. /**
  74401. * Defines the mask of the observer (used to filter notifications)
  74402. */
  74403. mask: number,
  74404. /**
  74405. * Defines the current scope used to restore the JS context
  74406. */
  74407. scope?: any);
  74408. }
  74409. /**
  74410. * Represent a list of observers registered to multiple Observables object.
  74411. */
  74412. export class MultiObserver<T> {
  74413. private _observers;
  74414. private _observables;
  74415. /**
  74416. * Release associated resources
  74417. */
  74418. dispose(): void;
  74419. /**
  74420. * Raise a callback when one of the observable will notify
  74421. * @param observables defines a list of observables to watch
  74422. * @param callback defines the callback to call on notification
  74423. * @param mask defines the mask used to filter notifications
  74424. * @param scope defines the current scope used to restore the JS context
  74425. * @returns the new MultiObserver
  74426. */
  74427. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  74428. }
  74429. /**
  74430. * The Observable class is a simple implementation of the Observable pattern.
  74431. *
  74432. * 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.
  74433. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  74434. * 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).
  74435. * 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.
  74436. */
  74437. export class Observable<T> {
  74438. private _observers;
  74439. private _eventState;
  74440. private _onObserverAdded;
  74441. /**
  74442. * Gets the list of observers
  74443. */
  74444. get observers(): Array<Observer<T>>;
  74445. /**
  74446. * Creates a new observable
  74447. * @param onObserverAdded defines a callback to call when a new observer is added
  74448. */
  74449. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  74450. /**
  74451. * Create a new Observer with the specified callback
  74452. * @param callback the callback that will be executed for that Observer
  74453. * @param mask the mask used to filter observers
  74454. * @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.
  74455. * @param scope optional scope for the callback to be called from
  74456. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  74457. * @returns the new observer created for the callback
  74458. */
  74459. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  74460. /**
  74461. * Create a new Observer with the specified callback and unregisters after the next notification
  74462. * @param callback the callback that will be executed for that Observer
  74463. * @returns the new observer created for the callback
  74464. */
  74465. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  74466. /**
  74467. * Remove an Observer from the Observable object
  74468. * @param observer the instance of the Observer to remove
  74469. * @returns false if it doesn't belong to this Observable
  74470. */
  74471. remove(observer: Nullable<Observer<T>>): boolean;
  74472. /**
  74473. * Remove a callback from the Observable object
  74474. * @param callback the callback to remove
  74475. * @param scope optional scope. If used only the callbacks with this scope will be removed
  74476. * @returns false if it doesn't belong to this Observable
  74477. */
  74478. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  74479. private _deferUnregister;
  74480. private _remove;
  74481. /**
  74482. * Moves the observable to the top of the observer list making it get called first when notified
  74483. * @param observer the observer to move
  74484. */
  74485. makeObserverTopPriority(observer: Observer<T>): void;
  74486. /**
  74487. * Moves the observable to the bottom of the observer list making it get called last when notified
  74488. * @param observer the observer to move
  74489. */
  74490. makeObserverBottomPriority(observer: Observer<T>): void;
  74491. /**
  74492. * Notify all Observers by calling their respective callback with the given data
  74493. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  74494. * @param eventData defines the data to send to all observers
  74495. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  74496. * @param target defines the original target of the state
  74497. * @param currentTarget defines the current target of the state
  74498. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  74499. */
  74500. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  74501. /**
  74502. * Calling this will execute each callback, expecting it to be a promise or return a value.
  74503. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  74504. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  74505. * and it is crucial that all callbacks will be executed.
  74506. * The order of the callbacks is kept, callbacks are not executed parallel.
  74507. *
  74508. * @param eventData The data to be sent to each callback
  74509. * @param mask is used to filter observers defaults to -1
  74510. * @param target defines the callback target (see EventState)
  74511. * @param currentTarget defines he current object in the bubbling phase
  74512. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  74513. */
  74514. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  74515. /**
  74516. * Notify a specific observer
  74517. * @param observer defines the observer to notify
  74518. * @param eventData defines the data to be sent to each callback
  74519. * @param mask is used to filter observers defaults to -1
  74520. */
  74521. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  74522. /**
  74523. * Gets a boolean indicating if the observable has at least one observer
  74524. * @returns true is the Observable has at least one Observer registered
  74525. */
  74526. hasObservers(): boolean;
  74527. /**
  74528. * Clear the list of observers
  74529. */
  74530. clear(): void;
  74531. /**
  74532. * Clone the current observable
  74533. * @returns a new observable
  74534. */
  74535. clone(): Observable<T>;
  74536. /**
  74537. * Does this observable handles observer registered with a given mask
  74538. * @param mask defines the mask to be tested
  74539. * @return whether or not one observer registered with the given mask is handeled
  74540. **/
  74541. hasSpecificMask(mask?: number): boolean;
  74542. }
  74543. }
  74544. declare module BABYLON {
  74545. /**
  74546. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  74547. * Babylon.js
  74548. */
  74549. export class DomManagement {
  74550. /**
  74551. * Checks if the window object exists
  74552. * @returns true if the window object exists
  74553. */
  74554. static IsWindowObjectExist(): boolean;
  74555. /**
  74556. * Checks if the navigator object exists
  74557. * @returns true if the navigator object exists
  74558. */
  74559. static IsNavigatorAvailable(): boolean;
  74560. /**
  74561. * Extracts text content from a DOM element hierarchy
  74562. * @param element defines the root element
  74563. * @returns a string
  74564. */
  74565. static GetDOMTextContent(element: HTMLElement): string;
  74566. }
  74567. }
  74568. declare module BABYLON {
  74569. /**
  74570. * Logger used througouht the application to allow configuration of
  74571. * the log level required for the messages.
  74572. */
  74573. export class Logger {
  74574. /**
  74575. * No log
  74576. */
  74577. static readonly NoneLogLevel: number;
  74578. /**
  74579. * Only message logs
  74580. */
  74581. static readonly MessageLogLevel: number;
  74582. /**
  74583. * Only warning logs
  74584. */
  74585. static readonly WarningLogLevel: number;
  74586. /**
  74587. * Only error logs
  74588. */
  74589. static readonly ErrorLogLevel: number;
  74590. /**
  74591. * All logs
  74592. */
  74593. static readonly AllLogLevel: number;
  74594. private static _LogCache;
  74595. /**
  74596. * Gets a value indicating the number of loading errors
  74597. * @ignorenaming
  74598. */
  74599. static errorsCount: number;
  74600. /**
  74601. * Callback called when a new log is added
  74602. */
  74603. static OnNewCacheEntry: (entry: string) => void;
  74604. private static _AddLogEntry;
  74605. private static _FormatMessage;
  74606. private static _LogDisabled;
  74607. private static _LogEnabled;
  74608. private static _WarnDisabled;
  74609. private static _WarnEnabled;
  74610. private static _ErrorDisabled;
  74611. private static _ErrorEnabled;
  74612. /**
  74613. * Log a message to the console
  74614. */
  74615. static Log: (message: string) => void;
  74616. /**
  74617. * Write a warning message to the console
  74618. */
  74619. static Warn: (message: string) => void;
  74620. /**
  74621. * Write an error message to the console
  74622. */
  74623. static Error: (message: string) => void;
  74624. /**
  74625. * Gets current log cache (list of logs)
  74626. */
  74627. static get LogCache(): string;
  74628. /**
  74629. * Clears the log cache
  74630. */
  74631. static ClearLogCache(): void;
  74632. /**
  74633. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  74634. */
  74635. static set LogLevels(level: number);
  74636. }
  74637. }
  74638. declare module BABYLON {
  74639. /** @hidden */
  74640. export class _TypeStore {
  74641. /** @hidden */
  74642. static RegisteredTypes: {
  74643. [key: string]: Object;
  74644. };
  74645. /** @hidden */
  74646. static GetClass(fqdn: string): any;
  74647. }
  74648. }
  74649. declare module BABYLON {
  74650. /**
  74651. * Helper to manipulate strings
  74652. */
  74653. export class StringTools {
  74654. /**
  74655. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  74656. * @param str Source string
  74657. * @param suffix Suffix to search for in the source string
  74658. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  74659. */
  74660. static EndsWith(str: string, suffix: string): boolean;
  74661. /**
  74662. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  74663. * @param str Source string
  74664. * @param suffix Suffix to search for in the source string
  74665. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  74666. */
  74667. static StartsWith(str: string, suffix: string): boolean;
  74668. /**
  74669. * Decodes a buffer into a string
  74670. * @param buffer The buffer to decode
  74671. * @returns The decoded string
  74672. */
  74673. static Decode(buffer: Uint8Array | Uint16Array): string;
  74674. /**
  74675. * Encode a buffer to a base64 string
  74676. * @param buffer defines the buffer to encode
  74677. * @returns the encoded string
  74678. */
  74679. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  74680. /**
  74681. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  74682. * @param num the number to convert and pad
  74683. * @param length the expected length of the string
  74684. * @returns the padded string
  74685. */
  74686. static PadNumber(num: number, length: number): string;
  74687. }
  74688. }
  74689. declare module BABYLON {
  74690. /**
  74691. * Class containing a set of static utilities functions for deep copy.
  74692. */
  74693. export class DeepCopier {
  74694. /**
  74695. * Tries to copy an object by duplicating every property
  74696. * @param source defines the source object
  74697. * @param destination defines the target object
  74698. * @param doNotCopyList defines a list of properties to avoid
  74699. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  74700. */
  74701. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  74702. }
  74703. }
  74704. declare module BABYLON {
  74705. /**
  74706. * Class containing a set of static utilities functions for precision date
  74707. */
  74708. export class PrecisionDate {
  74709. /**
  74710. * Gets either window.performance.now() if supported or Date.now() else
  74711. */
  74712. static get Now(): number;
  74713. }
  74714. }
  74715. declare module BABYLON {
  74716. /** @hidden */
  74717. export class _DevTools {
  74718. static WarnImport(name: string): string;
  74719. }
  74720. }
  74721. declare module BABYLON {
  74722. /**
  74723. * Interface used to define the mechanism to get data from the network
  74724. */
  74725. export interface IWebRequest {
  74726. /**
  74727. * Returns client's response url
  74728. */
  74729. responseURL: string;
  74730. /**
  74731. * Returns client's status
  74732. */
  74733. status: number;
  74734. /**
  74735. * Returns client's status as a text
  74736. */
  74737. statusText: string;
  74738. }
  74739. }
  74740. declare module BABYLON {
  74741. /**
  74742. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  74743. */
  74744. export class WebRequest implements IWebRequest {
  74745. private _xhr;
  74746. /**
  74747. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  74748. * i.e. when loading files, where the server/service expects an Authorization header
  74749. */
  74750. static CustomRequestHeaders: {
  74751. [key: string]: string;
  74752. };
  74753. /**
  74754. * Add callback functions in this array to update all the requests before they get sent to the network
  74755. */
  74756. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  74757. private _injectCustomRequestHeaders;
  74758. /**
  74759. * Gets or sets a function to be called when loading progress changes
  74760. */
  74761. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  74762. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  74763. /**
  74764. * Returns client's state
  74765. */
  74766. get readyState(): number;
  74767. /**
  74768. * Returns client's status
  74769. */
  74770. get status(): number;
  74771. /**
  74772. * Returns client's status as a text
  74773. */
  74774. get statusText(): string;
  74775. /**
  74776. * Returns client's response
  74777. */
  74778. get response(): any;
  74779. /**
  74780. * Returns client's response url
  74781. */
  74782. get responseURL(): string;
  74783. /**
  74784. * Returns client's response as text
  74785. */
  74786. get responseText(): string;
  74787. /**
  74788. * Gets or sets the expected response type
  74789. */
  74790. get responseType(): XMLHttpRequestResponseType;
  74791. set responseType(value: XMLHttpRequestResponseType);
  74792. /** @hidden */
  74793. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  74794. /** @hidden */
  74795. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  74796. /**
  74797. * Cancels any network activity
  74798. */
  74799. abort(): void;
  74800. /**
  74801. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  74802. * @param body defines an optional request body
  74803. */
  74804. send(body?: Document | BodyInit | null): void;
  74805. /**
  74806. * Sets the request method, request URL
  74807. * @param method defines the method to use (GET, POST, etc..)
  74808. * @param url defines the url to connect with
  74809. */
  74810. open(method: string, url: string): void;
  74811. /**
  74812. * Sets the value of a request header.
  74813. * @param name The name of the header whose value is to be set
  74814. * @param value The value to set as the body of the header
  74815. */
  74816. setRequestHeader(name: string, value: string): void;
  74817. /**
  74818. * Get the string containing the text of a particular header's value.
  74819. * @param name The name of the header
  74820. * @returns The string containing the text of the given header name
  74821. */
  74822. getResponseHeader(name: string): Nullable<string>;
  74823. }
  74824. }
  74825. declare module BABYLON {
  74826. /**
  74827. * File request interface
  74828. */
  74829. export interface IFileRequest {
  74830. /**
  74831. * Raised when the request is complete (success or error).
  74832. */
  74833. onCompleteObservable: Observable<IFileRequest>;
  74834. /**
  74835. * Aborts the request for a file.
  74836. */
  74837. abort: () => void;
  74838. }
  74839. }
  74840. declare module BABYLON {
  74841. /**
  74842. * Define options used to create a render target texture
  74843. */
  74844. export class RenderTargetCreationOptions {
  74845. /**
  74846. * Specifies is mipmaps must be generated
  74847. */
  74848. generateMipMaps?: boolean;
  74849. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  74850. generateDepthBuffer?: boolean;
  74851. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  74852. generateStencilBuffer?: boolean;
  74853. /** Defines texture type (int by default) */
  74854. type?: number;
  74855. /** Defines sampling mode (trilinear by default) */
  74856. samplingMode?: number;
  74857. /** Defines format (RGBA by default) */
  74858. format?: number;
  74859. }
  74860. }
  74861. declare module BABYLON {
  74862. /** Defines the cross module used constants to avoid circular dependncies */
  74863. export class Constants {
  74864. /** Defines that alpha blending is disabled */
  74865. static readonly ALPHA_DISABLE: number;
  74866. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  74867. static readonly ALPHA_ADD: number;
  74868. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  74869. static readonly ALPHA_COMBINE: number;
  74870. /** Defines that alpha blending is DEST - SRC * DEST */
  74871. static readonly ALPHA_SUBTRACT: number;
  74872. /** Defines that alpha blending is SRC * DEST */
  74873. static readonly ALPHA_MULTIPLY: number;
  74874. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  74875. static readonly ALPHA_MAXIMIZED: number;
  74876. /** Defines that alpha blending is SRC + DEST */
  74877. static readonly ALPHA_ONEONE: number;
  74878. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  74879. static readonly ALPHA_PREMULTIPLIED: number;
  74880. /**
  74881. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  74882. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  74883. */
  74884. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  74885. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  74886. static readonly ALPHA_INTERPOLATE: number;
  74887. /**
  74888. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  74889. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  74890. */
  74891. static readonly ALPHA_SCREENMODE: number;
  74892. /**
  74893. * Defines that alpha blending is SRC + DST
  74894. * Alpha will be set to SRC ALPHA + DST ALPHA
  74895. */
  74896. static readonly ALPHA_ONEONE_ONEONE: number;
  74897. /**
  74898. * Defines that alpha blending is SRC * DST ALPHA + DST
  74899. * Alpha will be set to 0
  74900. */
  74901. static readonly ALPHA_ALPHATOCOLOR: number;
  74902. /**
  74903. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  74904. */
  74905. static readonly ALPHA_REVERSEONEMINUS: number;
  74906. /**
  74907. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  74908. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  74909. */
  74910. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  74911. /**
  74912. * Defines that alpha blending is SRC + DST
  74913. * Alpha will be set to SRC ALPHA
  74914. */
  74915. static readonly ALPHA_ONEONE_ONEZERO: number;
  74916. /**
  74917. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  74918. * Alpha will be set to DST ALPHA
  74919. */
  74920. static readonly ALPHA_EXCLUSION: number;
  74921. /** Defines that alpha blending equation a SUM */
  74922. static readonly ALPHA_EQUATION_ADD: number;
  74923. /** Defines that alpha blending equation a SUBSTRACTION */
  74924. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  74925. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  74926. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  74927. /** Defines that alpha blending equation a MAX operation */
  74928. static readonly ALPHA_EQUATION_MAX: number;
  74929. /** Defines that alpha blending equation a MIN operation */
  74930. static readonly ALPHA_EQUATION_MIN: number;
  74931. /**
  74932. * Defines that alpha blending equation a DARKEN operation:
  74933. * It takes the min of the src and sums the alpha channels.
  74934. */
  74935. static readonly ALPHA_EQUATION_DARKEN: number;
  74936. /** Defines that the ressource is not delayed*/
  74937. static readonly DELAYLOADSTATE_NONE: number;
  74938. /** Defines that the ressource was successfully delay loaded */
  74939. static readonly DELAYLOADSTATE_LOADED: number;
  74940. /** Defines that the ressource is currently delay loading */
  74941. static readonly DELAYLOADSTATE_LOADING: number;
  74942. /** Defines that the ressource is delayed and has not started loading */
  74943. static readonly DELAYLOADSTATE_NOTLOADED: number;
  74944. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  74945. static readonly NEVER: number;
  74946. /** 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 */
  74947. static readonly ALWAYS: number;
  74948. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  74949. static readonly LESS: number;
  74950. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  74951. static readonly EQUAL: number;
  74952. /** 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 */
  74953. static readonly LEQUAL: number;
  74954. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  74955. static readonly GREATER: number;
  74956. /** 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 */
  74957. static readonly GEQUAL: number;
  74958. /** 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 */
  74959. static readonly NOTEQUAL: number;
  74960. /** Passed to stencilOperation to specify that stencil value must be kept */
  74961. static readonly KEEP: number;
  74962. /** Passed to stencilOperation to specify that stencil value must be replaced */
  74963. static readonly REPLACE: number;
  74964. /** Passed to stencilOperation to specify that stencil value must be incremented */
  74965. static readonly INCR: number;
  74966. /** Passed to stencilOperation to specify that stencil value must be decremented */
  74967. static readonly DECR: number;
  74968. /** Passed to stencilOperation to specify that stencil value must be inverted */
  74969. static readonly INVERT: number;
  74970. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  74971. static readonly INCR_WRAP: number;
  74972. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  74973. static readonly DECR_WRAP: number;
  74974. /** Texture is not repeating outside of 0..1 UVs */
  74975. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  74976. /** Texture is repeating outside of 0..1 UVs */
  74977. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  74978. /** Texture is repeating and mirrored */
  74979. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  74980. /** ALPHA */
  74981. static readonly TEXTUREFORMAT_ALPHA: number;
  74982. /** LUMINANCE */
  74983. static readonly TEXTUREFORMAT_LUMINANCE: number;
  74984. /** LUMINANCE_ALPHA */
  74985. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  74986. /** RGB */
  74987. static readonly TEXTUREFORMAT_RGB: number;
  74988. /** RGBA */
  74989. static readonly TEXTUREFORMAT_RGBA: number;
  74990. /** RED */
  74991. static readonly TEXTUREFORMAT_RED: number;
  74992. /** RED (2nd reference) */
  74993. static readonly TEXTUREFORMAT_R: number;
  74994. /** RG */
  74995. static readonly TEXTUREFORMAT_RG: number;
  74996. /** RED_INTEGER */
  74997. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  74998. /** RED_INTEGER (2nd reference) */
  74999. static readonly TEXTUREFORMAT_R_INTEGER: number;
  75000. /** RG_INTEGER */
  75001. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  75002. /** RGB_INTEGER */
  75003. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  75004. /** RGBA_INTEGER */
  75005. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  75006. /** UNSIGNED_BYTE */
  75007. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  75008. /** UNSIGNED_BYTE (2nd reference) */
  75009. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  75010. /** FLOAT */
  75011. static readonly TEXTURETYPE_FLOAT: number;
  75012. /** HALF_FLOAT */
  75013. static readonly TEXTURETYPE_HALF_FLOAT: number;
  75014. /** BYTE */
  75015. static readonly TEXTURETYPE_BYTE: number;
  75016. /** SHORT */
  75017. static readonly TEXTURETYPE_SHORT: number;
  75018. /** UNSIGNED_SHORT */
  75019. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  75020. /** INT */
  75021. static readonly TEXTURETYPE_INT: number;
  75022. /** UNSIGNED_INT */
  75023. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  75024. /** UNSIGNED_SHORT_4_4_4_4 */
  75025. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  75026. /** UNSIGNED_SHORT_5_5_5_1 */
  75027. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  75028. /** UNSIGNED_SHORT_5_6_5 */
  75029. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  75030. /** UNSIGNED_INT_2_10_10_10_REV */
  75031. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  75032. /** UNSIGNED_INT_24_8 */
  75033. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  75034. /** UNSIGNED_INT_10F_11F_11F_REV */
  75035. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  75036. /** UNSIGNED_INT_5_9_9_9_REV */
  75037. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  75038. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  75039. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  75040. /** nearest is mag = nearest and min = nearest and no mip */
  75041. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  75042. /** mag = nearest and min = nearest and mip = none */
  75043. static readonly TEXTURE_NEAREST_NEAREST: number;
  75044. /** Bilinear is mag = linear and min = linear and no mip */
  75045. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  75046. /** mag = linear and min = linear and mip = none */
  75047. static readonly TEXTURE_LINEAR_LINEAR: number;
  75048. /** Trilinear is mag = linear and min = linear and mip = linear */
  75049. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  75050. /** Trilinear is mag = linear and min = linear and mip = linear */
  75051. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  75052. /** mag = nearest and min = nearest and mip = nearest */
  75053. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  75054. /** mag = nearest and min = linear and mip = nearest */
  75055. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  75056. /** mag = nearest and min = linear and mip = linear */
  75057. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  75058. /** mag = nearest and min = linear and mip = none */
  75059. static readonly TEXTURE_NEAREST_LINEAR: number;
  75060. /** nearest is mag = nearest and min = nearest and mip = linear */
  75061. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  75062. /** mag = linear and min = nearest and mip = nearest */
  75063. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  75064. /** mag = linear and min = nearest and mip = linear */
  75065. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  75066. /** Bilinear is mag = linear and min = linear and mip = nearest */
  75067. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  75068. /** mag = linear and min = nearest and mip = none */
  75069. static readonly TEXTURE_LINEAR_NEAREST: number;
  75070. /** Explicit coordinates mode */
  75071. static readonly TEXTURE_EXPLICIT_MODE: number;
  75072. /** Spherical coordinates mode */
  75073. static readonly TEXTURE_SPHERICAL_MODE: number;
  75074. /** Planar coordinates mode */
  75075. static readonly TEXTURE_PLANAR_MODE: number;
  75076. /** Cubic coordinates mode */
  75077. static readonly TEXTURE_CUBIC_MODE: number;
  75078. /** Projection coordinates mode */
  75079. static readonly TEXTURE_PROJECTION_MODE: number;
  75080. /** Skybox coordinates mode */
  75081. static readonly TEXTURE_SKYBOX_MODE: number;
  75082. /** Inverse Cubic coordinates mode */
  75083. static readonly TEXTURE_INVCUBIC_MODE: number;
  75084. /** Equirectangular coordinates mode */
  75085. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  75086. /** Equirectangular Fixed coordinates mode */
  75087. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  75088. /** Equirectangular Fixed Mirrored coordinates mode */
  75089. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  75090. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  75091. static readonly SCALEMODE_FLOOR: number;
  75092. /** Defines that texture rescaling will look for the nearest power of 2 size */
  75093. static readonly SCALEMODE_NEAREST: number;
  75094. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  75095. static readonly SCALEMODE_CEILING: number;
  75096. /**
  75097. * The dirty texture flag value
  75098. */
  75099. static readonly MATERIAL_TextureDirtyFlag: number;
  75100. /**
  75101. * The dirty light flag value
  75102. */
  75103. static readonly MATERIAL_LightDirtyFlag: number;
  75104. /**
  75105. * The dirty fresnel flag value
  75106. */
  75107. static readonly MATERIAL_FresnelDirtyFlag: number;
  75108. /**
  75109. * The dirty attribute flag value
  75110. */
  75111. static readonly MATERIAL_AttributesDirtyFlag: number;
  75112. /**
  75113. * The dirty misc flag value
  75114. */
  75115. static readonly MATERIAL_MiscDirtyFlag: number;
  75116. /**
  75117. * The all dirty flag value
  75118. */
  75119. static readonly MATERIAL_AllDirtyFlag: number;
  75120. /**
  75121. * Returns the triangle fill mode
  75122. */
  75123. static readonly MATERIAL_TriangleFillMode: number;
  75124. /**
  75125. * Returns the wireframe mode
  75126. */
  75127. static readonly MATERIAL_WireFrameFillMode: number;
  75128. /**
  75129. * Returns the point fill mode
  75130. */
  75131. static readonly MATERIAL_PointFillMode: number;
  75132. /**
  75133. * Returns the point list draw mode
  75134. */
  75135. static readonly MATERIAL_PointListDrawMode: number;
  75136. /**
  75137. * Returns the line list draw mode
  75138. */
  75139. static readonly MATERIAL_LineListDrawMode: number;
  75140. /**
  75141. * Returns the line loop draw mode
  75142. */
  75143. static readonly MATERIAL_LineLoopDrawMode: number;
  75144. /**
  75145. * Returns the line strip draw mode
  75146. */
  75147. static readonly MATERIAL_LineStripDrawMode: number;
  75148. /**
  75149. * Returns the triangle strip draw mode
  75150. */
  75151. static readonly MATERIAL_TriangleStripDrawMode: number;
  75152. /**
  75153. * Returns the triangle fan draw mode
  75154. */
  75155. static readonly MATERIAL_TriangleFanDrawMode: number;
  75156. /**
  75157. * Stores the clock-wise side orientation
  75158. */
  75159. static readonly MATERIAL_ClockWiseSideOrientation: number;
  75160. /**
  75161. * Stores the counter clock-wise side orientation
  75162. */
  75163. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  75164. /**
  75165. * Nothing
  75166. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75167. */
  75168. static readonly ACTION_NothingTrigger: number;
  75169. /**
  75170. * On pick
  75171. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75172. */
  75173. static readonly ACTION_OnPickTrigger: number;
  75174. /**
  75175. * On left pick
  75176. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75177. */
  75178. static readonly ACTION_OnLeftPickTrigger: number;
  75179. /**
  75180. * On right pick
  75181. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75182. */
  75183. static readonly ACTION_OnRightPickTrigger: number;
  75184. /**
  75185. * On center pick
  75186. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75187. */
  75188. static readonly ACTION_OnCenterPickTrigger: number;
  75189. /**
  75190. * On pick down
  75191. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75192. */
  75193. static readonly ACTION_OnPickDownTrigger: number;
  75194. /**
  75195. * On double pick
  75196. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75197. */
  75198. static readonly ACTION_OnDoublePickTrigger: number;
  75199. /**
  75200. * On pick up
  75201. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75202. */
  75203. static readonly ACTION_OnPickUpTrigger: number;
  75204. /**
  75205. * On pick out.
  75206. * This trigger will only be raised if you also declared a OnPickDown
  75207. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75208. */
  75209. static readonly ACTION_OnPickOutTrigger: number;
  75210. /**
  75211. * On long press
  75212. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75213. */
  75214. static readonly ACTION_OnLongPressTrigger: number;
  75215. /**
  75216. * On pointer over
  75217. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75218. */
  75219. static readonly ACTION_OnPointerOverTrigger: number;
  75220. /**
  75221. * On pointer out
  75222. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75223. */
  75224. static readonly ACTION_OnPointerOutTrigger: number;
  75225. /**
  75226. * On every frame
  75227. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75228. */
  75229. static readonly ACTION_OnEveryFrameTrigger: number;
  75230. /**
  75231. * On intersection enter
  75232. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75233. */
  75234. static readonly ACTION_OnIntersectionEnterTrigger: number;
  75235. /**
  75236. * On intersection exit
  75237. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75238. */
  75239. static readonly ACTION_OnIntersectionExitTrigger: number;
  75240. /**
  75241. * On key down
  75242. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75243. */
  75244. static readonly ACTION_OnKeyDownTrigger: number;
  75245. /**
  75246. * On key up
  75247. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75248. */
  75249. static readonly ACTION_OnKeyUpTrigger: number;
  75250. /**
  75251. * Billboard mode will only apply to Y axis
  75252. */
  75253. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  75254. /**
  75255. * Billboard mode will apply to all axes
  75256. */
  75257. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  75258. /**
  75259. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  75260. */
  75261. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  75262. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  75263. * Test order :
  75264. * Is the bounding sphere outside the frustum ?
  75265. * If not, are the bounding box vertices outside the frustum ?
  75266. * It not, then the cullable object is in the frustum.
  75267. */
  75268. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  75269. /** Culling strategy : Bounding Sphere Only.
  75270. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  75271. * It's also less accurate than the standard because some not visible objects can still be selected.
  75272. * Test : is the bounding sphere outside the frustum ?
  75273. * If not, then the cullable object is in the frustum.
  75274. */
  75275. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  75276. /** Culling strategy : Optimistic Inclusion.
  75277. * This in an inclusion test first, then the standard exclusion test.
  75278. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  75279. * 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.
  75280. * Anyway, it's as accurate as the standard strategy.
  75281. * Test :
  75282. * Is the cullable object bounding sphere center in the frustum ?
  75283. * If not, apply the default culling strategy.
  75284. */
  75285. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  75286. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  75287. * This in an inclusion test first, then the bounding sphere only exclusion test.
  75288. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  75289. * 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.
  75290. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  75291. * Test :
  75292. * Is the cullable object bounding sphere center in the frustum ?
  75293. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  75294. */
  75295. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  75296. /**
  75297. * No logging while loading
  75298. */
  75299. static readonly SCENELOADER_NO_LOGGING: number;
  75300. /**
  75301. * Minimal logging while loading
  75302. */
  75303. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  75304. /**
  75305. * Summary logging while loading
  75306. */
  75307. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  75308. /**
  75309. * Detailled logging while loading
  75310. */
  75311. static readonly SCENELOADER_DETAILED_LOGGING: number;
  75312. }
  75313. }
  75314. declare module BABYLON {
  75315. /**
  75316. * This represents the required contract to create a new type of texture loader.
  75317. */
  75318. export interface IInternalTextureLoader {
  75319. /**
  75320. * Defines wether the loader supports cascade loading the different faces.
  75321. */
  75322. supportCascades: boolean;
  75323. /**
  75324. * This returns if the loader support the current file information.
  75325. * @param extension defines the file extension of the file being loaded
  75326. * @returns true if the loader can load the specified file
  75327. */
  75328. canLoad(extension: string): boolean;
  75329. /**
  75330. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  75331. * @param data contains the texture data
  75332. * @param texture defines the BabylonJS internal texture
  75333. * @param createPolynomials will be true if polynomials have been requested
  75334. * @param onLoad defines the callback to trigger once the texture is ready
  75335. * @param onError defines the callback to trigger in case of error
  75336. */
  75337. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  75338. /**
  75339. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  75340. * @param data contains the texture data
  75341. * @param texture defines the BabylonJS internal texture
  75342. * @param callback defines the method to call once ready to upload
  75343. */
  75344. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  75345. }
  75346. }
  75347. declare module BABYLON {
  75348. /**
  75349. * Class used to store and describe the pipeline context associated with an effect
  75350. */
  75351. export interface IPipelineContext {
  75352. /**
  75353. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  75354. */
  75355. isAsync: boolean;
  75356. /**
  75357. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  75358. */
  75359. isReady: boolean;
  75360. /** @hidden */
  75361. _getVertexShaderCode(): string | null;
  75362. /** @hidden */
  75363. _getFragmentShaderCode(): string | null;
  75364. /** @hidden */
  75365. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  75366. }
  75367. }
  75368. declare module BABYLON {
  75369. /**
  75370. * Class used to store gfx data (like WebGLBuffer)
  75371. */
  75372. export class DataBuffer {
  75373. /**
  75374. * Gets or sets the number of objects referencing this buffer
  75375. */
  75376. references: number;
  75377. /** Gets or sets the size of the underlying buffer */
  75378. capacity: number;
  75379. /**
  75380. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  75381. */
  75382. is32Bits: boolean;
  75383. /**
  75384. * Gets the underlying buffer
  75385. */
  75386. get underlyingResource(): any;
  75387. }
  75388. }
  75389. declare module BABYLON {
  75390. /** @hidden */
  75391. export interface IShaderProcessor {
  75392. attributeProcessor?: (attribute: string) => string;
  75393. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  75394. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  75395. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  75396. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  75397. lineProcessor?: (line: string, isFragment: boolean) => string;
  75398. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  75399. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  75400. }
  75401. }
  75402. declare module BABYLON {
  75403. /** @hidden */
  75404. export interface ProcessingOptions {
  75405. defines: string[];
  75406. indexParameters: any;
  75407. isFragment: boolean;
  75408. shouldUseHighPrecisionShader: boolean;
  75409. supportsUniformBuffers: boolean;
  75410. shadersRepository: string;
  75411. includesShadersStore: {
  75412. [key: string]: string;
  75413. };
  75414. processor?: IShaderProcessor;
  75415. version: string;
  75416. platformName: string;
  75417. lookForClosingBracketForUniformBuffer?: boolean;
  75418. }
  75419. }
  75420. declare module BABYLON {
  75421. /** @hidden */
  75422. export class ShaderCodeNode {
  75423. line: string;
  75424. children: ShaderCodeNode[];
  75425. additionalDefineKey?: string;
  75426. additionalDefineValue?: string;
  75427. isValid(preprocessors: {
  75428. [key: string]: string;
  75429. }): boolean;
  75430. process(preprocessors: {
  75431. [key: string]: string;
  75432. }, options: ProcessingOptions): string;
  75433. }
  75434. }
  75435. declare module BABYLON {
  75436. /** @hidden */
  75437. export class ShaderCodeCursor {
  75438. private _lines;
  75439. lineIndex: number;
  75440. get currentLine(): string;
  75441. get canRead(): boolean;
  75442. set lines(value: string[]);
  75443. }
  75444. }
  75445. declare module BABYLON {
  75446. /** @hidden */
  75447. export class ShaderCodeConditionNode extends ShaderCodeNode {
  75448. process(preprocessors: {
  75449. [key: string]: string;
  75450. }, options: ProcessingOptions): string;
  75451. }
  75452. }
  75453. declare module BABYLON {
  75454. /** @hidden */
  75455. export class ShaderDefineExpression {
  75456. isTrue(preprocessors: {
  75457. [key: string]: string;
  75458. }): boolean;
  75459. private static _OperatorPriority;
  75460. private static _Stack;
  75461. static postfixToInfix(postfix: string[]): string;
  75462. static infixToPostfix(infix: string): string[];
  75463. }
  75464. }
  75465. declare module BABYLON {
  75466. /** @hidden */
  75467. export class ShaderCodeTestNode extends ShaderCodeNode {
  75468. testExpression: ShaderDefineExpression;
  75469. isValid(preprocessors: {
  75470. [key: string]: string;
  75471. }): boolean;
  75472. }
  75473. }
  75474. declare module BABYLON {
  75475. /** @hidden */
  75476. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  75477. define: string;
  75478. not: boolean;
  75479. constructor(define: string, not?: boolean);
  75480. isTrue(preprocessors: {
  75481. [key: string]: string;
  75482. }): boolean;
  75483. }
  75484. }
  75485. declare module BABYLON {
  75486. /** @hidden */
  75487. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  75488. leftOperand: ShaderDefineExpression;
  75489. rightOperand: ShaderDefineExpression;
  75490. isTrue(preprocessors: {
  75491. [key: string]: string;
  75492. }): boolean;
  75493. }
  75494. }
  75495. declare module BABYLON {
  75496. /** @hidden */
  75497. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  75498. leftOperand: ShaderDefineExpression;
  75499. rightOperand: ShaderDefineExpression;
  75500. isTrue(preprocessors: {
  75501. [key: string]: string;
  75502. }): boolean;
  75503. }
  75504. }
  75505. declare module BABYLON {
  75506. /** @hidden */
  75507. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  75508. define: string;
  75509. operand: string;
  75510. testValue: string;
  75511. constructor(define: string, operand: string, testValue: string);
  75512. isTrue(preprocessors: {
  75513. [key: string]: string;
  75514. }): boolean;
  75515. }
  75516. }
  75517. declare module BABYLON {
  75518. /**
  75519. * Class used to enable access to offline support
  75520. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  75521. */
  75522. export interface IOfflineProvider {
  75523. /**
  75524. * Gets a boolean indicating if scene must be saved in the database
  75525. */
  75526. enableSceneOffline: boolean;
  75527. /**
  75528. * Gets a boolean indicating if textures must be saved in the database
  75529. */
  75530. enableTexturesOffline: boolean;
  75531. /**
  75532. * Open the offline support and make it available
  75533. * @param successCallback defines the callback to call on success
  75534. * @param errorCallback defines the callback to call on error
  75535. */
  75536. open(successCallback: () => void, errorCallback: () => void): void;
  75537. /**
  75538. * Loads an image from the offline support
  75539. * @param url defines the url to load from
  75540. * @param image defines the target DOM image
  75541. */
  75542. loadImage(url: string, image: HTMLImageElement): void;
  75543. /**
  75544. * Loads a file from offline support
  75545. * @param url defines the URL to load from
  75546. * @param sceneLoaded defines a callback to call on success
  75547. * @param progressCallBack defines a callback to call when progress changed
  75548. * @param errorCallback defines a callback to call on error
  75549. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  75550. */
  75551. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  75552. }
  75553. }
  75554. declare module BABYLON {
  75555. /**
  75556. * Class used to help managing file picking and drag'n'drop
  75557. * File Storage
  75558. */
  75559. export class FilesInputStore {
  75560. /**
  75561. * List of files ready to be loaded
  75562. */
  75563. static FilesToLoad: {
  75564. [key: string]: File;
  75565. };
  75566. }
  75567. }
  75568. declare module BABYLON {
  75569. /**
  75570. * Class used to define a retry strategy when error happens while loading assets
  75571. */
  75572. export class RetryStrategy {
  75573. /**
  75574. * Function used to defines an exponential back off strategy
  75575. * @param maxRetries defines the maximum number of retries (3 by default)
  75576. * @param baseInterval defines the interval between retries
  75577. * @returns the strategy function to use
  75578. */
  75579. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  75580. }
  75581. }
  75582. declare module BABYLON {
  75583. /**
  75584. * @ignore
  75585. * Application error to support additional information when loading a file
  75586. */
  75587. export abstract class BaseError extends Error {
  75588. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  75589. }
  75590. }
  75591. declare module BABYLON {
  75592. /** @ignore */
  75593. export class LoadFileError extends BaseError {
  75594. request?: WebRequest;
  75595. file?: File;
  75596. /**
  75597. * Creates a new LoadFileError
  75598. * @param message defines the message of the error
  75599. * @param request defines the optional web request
  75600. * @param file defines the optional file
  75601. */
  75602. constructor(message: string, object?: WebRequest | File);
  75603. }
  75604. /** @ignore */
  75605. export class RequestFileError extends BaseError {
  75606. request: WebRequest;
  75607. /**
  75608. * Creates a new LoadFileError
  75609. * @param message defines the message of the error
  75610. * @param request defines the optional web request
  75611. */
  75612. constructor(message: string, request: WebRequest);
  75613. }
  75614. /** @ignore */
  75615. export class ReadFileError extends BaseError {
  75616. file: File;
  75617. /**
  75618. * Creates a new ReadFileError
  75619. * @param message defines the message of the error
  75620. * @param file defines the optional file
  75621. */
  75622. constructor(message: string, file: File);
  75623. }
  75624. /**
  75625. * @hidden
  75626. */
  75627. export class FileTools {
  75628. /**
  75629. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  75630. */
  75631. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  75632. /**
  75633. * Gets or sets the base URL to use to load assets
  75634. */
  75635. static BaseUrl: string;
  75636. /**
  75637. * Default behaviour for cors in the application.
  75638. * It can be a string if the expected behavior is identical in the entire app.
  75639. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  75640. */
  75641. static CorsBehavior: string | ((url: string | string[]) => string);
  75642. /**
  75643. * Gets or sets a function used to pre-process url before using them to load assets
  75644. */
  75645. static PreprocessUrl: (url: string) => string;
  75646. /**
  75647. * Removes unwanted characters from an url
  75648. * @param url defines the url to clean
  75649. * @returns the cleaned url
  75650. */
  75651. private static _CleanUrl;
  75652. /**
  75653. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  75654. * @param url define the url we are trying
  75655. * @param element define the dom element where to configure the cors policy
  75656. */
  75657. static SetCorsBehavior(url: string | string[], element: {
  75658. crossOrigin: string | null;
  75659. }): void;
  75660. /**
  75661. * Loads an image as an HTMLImageElement.
  75662. * @param input url string, ArrayBuffer, or Blob to load
  75663. * @param onLoad callback called when the image successfully loads
  75664. * @param onError callback called when the image fails to load
  75665. * @param offlineProvider offline provider for caching
  75666. * @param mimeType optional mime type
  75667. * @returns the HTMLImageElement of the loaded image
  75668. */
  75669. 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>;
  75670. /**
  75671. * Reads a file from a File object
  75672. * @param file defines the file to load
  75673. * @param onSuccess defines the callback to call when data is loaded
  75674. * @param onProgress defines the callback to call during loading process
  75675. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  75676. * @param onError defines the callback to call when an error occurs
  75677. * @returns a file request object
  75678. */
  75679. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  75680. /**
  75681. * Loads a file from a url
  75682. * @param url url to load
  75683. * @param onSuccess callback called when the file successfully loads
  75684. * @param onProgress callback called while file is loading (if the server supports this mode)
  75685. * @param offlineProvider defines the offline provider for caching
  75686. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  75687. * @param onError callback called when the file fails to load
  75688. * @returns a file request object
  75689. */
  75690. 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;
  75691. /**
  75692. * Loads a file
  75693. * @param url url to load
  75694. * @param onSuccess callback called when the file successfully loads
  75695. * @param onProgress callback called while file is loading (if the server supports this mode)
  75696. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  75697. * @param onError callback called when the file fails to load
  75698. * @param onOpened callback called when the web request is opened
  75699. * @returns a file request object
  75700. */
  75701. 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;
  75702. /**
  75703. * Checks if the loaded document was accessed via `file:`-Protocol.
  75704. * @returns boolean
  75705. */
  75706. static IsFileURL(): boolean;
  75707. }
  75708. }
  75709. declare module BABYLON {
  75710. /** @hidden */
  75711. export class ShaderProcessor {
  75712. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  75713. private static _ProcessPrecision;
  75714. private static _ExtractOperation;
  75715. private static _BuildSubExpression;
  75716. private static _BuildExpression;
  75717. private static _MoveCursorWithinIf;
  75718. private static _MoveCursor;
  75719. private static _EvaluatePreProcessors;
  75720. private static _PreparePreProcessors;
  75721. private static _ProcessShaderConversion;
  75722. private static _ProcessIncludes;
  75723. /**
  75724. * Loads a file from a url
  75725. * @param url url to load
  75726. * @param onSuccess callback called when the file successfully loads
  75727. * @param onProgress callback called while file is loading (if the server supports this mode)
  75728. * @param offlineProvider defines the offline provider for caching
  75729. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  75730. * @param onError callback called when the file fails to load
  75731. * @returns a file request object
  75732. * @hidden
  75733. */
  75734. 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;
  75735. }
  75736. }
  75737. declare module BABYLON {
  75738. /**
  75739. * @hidden
  75740. */
  75741. export interface IColor4Like {
  75742. r: float;
  75743. g: float;
  75744. b: float;
  75745. a: float;
  75746. }
  75747. /**
  75748. * @hidden
  75749. */
  75750. export interface IColor3Like {
  75751. r: float;
  75752. g: float;
  75753. b: float;
  75754. }
  75755. /**
  75756. * @hidden
  75757. */
  75758. export interface IVector4Like {
  75759. x: float;
  75760. y: float;
  75761. z: float;
  75762. w: float;
  75763. }
  75764. /**
  75765. * @hidden
  75766. */
  75767. export interface IVector3Like {
  75768. x: float;
  75769. y: float;
  75770. z: float;
  75771. }
  75772. /**
  75773. * @hidden
  75774. */
  75775. export interface IVector2Like {
  75776. x: float;
  75777. y: float;
  75778. }
  75779. /**
  75780. * @hidden
  75781. */
  75782. export interface IMatrixLike {
  75783. toArray(): DeepImmutable<Float32Array>;
  75784. updateFlag: int;
  75785. }
  75786. /**
  75787. * @hidden
  75788. */
  75789. export interface IViewportLike {
  75790. x: float;
  75791. y: float;
  75792. width: float;
  75793. height: float;
  75794. }
  75795. /**
  75796. * @hidden
  75797. */
  75798. export interface IPlaneLike {
  75799. normal: IVector3Like;
  75800. d: float;
  75801. normalize(): void;
  75802. }
  75803. }
  75804. declare module BABYLON {
  75805. /**
  75806. * Interface used to define common properties for effect fallbacks
  75807. */
  75808. export interface IEffectFallbacks {
  75809. /**
  75810. * Removes the defines that should be removed when falling back.
  75811. * @param currentDefines defines the current define statements for the shader.
  75812. * @param effect defines the current effect we try to compile
  75813. * @returns The resulting defines with defines of the current rank removed.
  75814. */
  75815. reduce(currentDefines: string, effect: Effect): string;
  75816. /**
  75817. * Removes the fallback from the bound mesh.
  75818. */
  75819. unBindMesh(): void;
  75820. /**
  75821. * Checks to see if more fallbacks are still availible.
  75822. */
  75823. hasMoreFallbacks: boolean;
  75824. }
  75825. }
  75826. declare module BABYLON {
  75827. /**
  75828. * Class used to evalaute queries containing `and` and `or` operators
  75829. */
  75830. export class AndOrNotEvaluator {
  75831. /**
  75832. * Evaluate a query
  75833. * @param query defines the query to evaluate
  75834. * @param evaluateCallback defines the callback used to filter result
  75835. * @returns true if the query matches
  75836. */
  75837. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  75838. private static _HandleParenthesisContent;
  75839. private static _SimplifyNegation;
  75840. }
  75841. }
  75842. declare module BABYLON {
  75843. /**
  75844. * Class used to store custom tags
  75845. */
  75846. export class Tags {
  75847. /**
  75848. * Adds support for tags on the given object
  75849. * @param obj defines the object to use
  75850. */
  75851. static EnableFor(obj: any): void;
  75852. /**
  75853. * Removes tags support
  75854. * @param obj defines the object to use
  75855. */
  75856. static DisableFor(obj: any): void;
  75857. /**
  75858. * Gets a boolean indicating if the given object has tags
  75859. * @param obj defines the object to use
  75860. * @returns a boolean
  75861. */
  75862. static HasTags(obj: any): boolean;
  75863. /**
  75864. * Gets the tags available on a given object
  75865. * @param obj defines the object to use
  75866. * @param asString defines if the tags must be returned as a string instead of an array of strings
  75867. * @returns the tags
  75868. */
  75869. static GetTags(obj: any, asString?: boolean): any;
  75870. /**
  75871. * Adds tags to an object
  75872. * @param obj defines the object to use
  75873. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  75874. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  75875. */
  75876. static AddTagsTo(obj: any, tagsString: string): void;
  75877. /**
  75878. * @hidden
  75879. */
  75880. static _AddTagTo(obj: any, tag: string): void;
  75881. /**
  75882. * Removes specific tags from a specific object
  75883. * @param obj defines the object to use
  75884. * @param tagsString defines the tags to remove
  75885. */
  75886. static RemoveTagsFrom(obj: any, tagsString: string): void;
  75887. /**
  75888. * @hidden
  75889. */
  75890. static _RemoveTagFrom(obj: any, tag: string): void;
  75891. /**
  75892. * Defines if tags hosted on an object match a given query
  75893. * @param obj defines the object to use
  75894. * @param tagsQuery defines the tag query
  75895. * @returns a boolean
  75896. */
  75897. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  75898. }
  75899. }
  75900. declare module BABYLON {
  75901. /**
  75902. * Scalar computation library
  75903. */
  75904. export class Scalar {
  75905. /**
  75906. * Two pi constants convenient for computation.
  75907. */
  75908. static TwoPi: number;
  75909. /**
  75910. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  75911. * @param a number
  75912. * @param b number
  75913. * @param epsilon (default = 1.401298E-45)
  75914. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  75915. */
  75916. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  75917. /**
  75918. * Returns a string : the upper case translation of the number i to hexadecimal.
  75919. * @param i number
  75920. * @returns the upper case translation of the number i to hexadecimal.
  75921. */
  75922. static ToHex(i: number): string;
  75923. /**
  75924. * Returns -1 if value is negative and +1 is value is positive.
  75925. * @param value the value
  75926. * @returns the value itself if it's equal to zero.
  75927. */
  75928. static Sign(value: number): number;
  75929. /**
  75930. * Returns the value itself if it's between min and max.
  75931. * Returns min if the value is lower than min.
  75932. * Returns max if the value is greater than max.
  75933. * @param value the value to clmap
  75934. * @param min the min value to clamp to (default: 0)
  75935. * @param max the max value to clamp to (default: 1)
  75936. * @returns the clamped value
  75937. */
  75938. static Clamp(value: number, min?: number, max?: number): number;
  75939. /**
  75940. * the log2 of value.
  75941. * @param value the value to compute log2 of
  75942. * @returns the log2 of value.
  75943. */
  75944. static Log2(value: number): number;
  75945. /**
  75946. * Loops the value, so that it is never larger than length and never smaller than 0.
  75947. *
  75948. * This is similar to the modulo operator but it works with floating point numbers.
  75949. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  75950. * With t = 5 and length = 2.5, the result would be 0.0.
  75951. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  75952. * @param value the value
  75953. * @param length the length
  75954. * @returns the looped value
  75955. */
  75956. static Repeat(value: number, length: number): number;
  75957. /**
  75958. * Normalize the value between 0.0 and 1.0 using min and max values
  75959. * @param value value to normalize
  75960. * @param min max to normalize between
  75961. * @param max min to normalize between
  75962. * @returns the normalized value
  75963. */
  75964. static Normalize(value: number, min: number, max: number): number;
  75965. /**
  75966. * Denormalize the value from 0.0 and 1.0 using min and max values
  75967. * @param normalized value to denormalize
  75968. * @param min max to denormalize between
  75969. * @param max min to denormalize between
  75970. * @returns the denormalized value
  75971. */
  75972. static Denormalize(normalized: number, min: number, max: number): number;
  75973. /**
  75974. * Calculates the shortest difference between two given angles given in degrees.
  75975. * @param current current angle in degrees
  75976. * @param target target angle in degrees
  75977. * @returns the delta
  75978. */
  75979. static DeltaAngle(current: number, target: number): number;
  75980. /**
  75981. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  75982. * @param tx value
  75983. * @param length length
  75984. * @returns The returned value will move back and forth between 0 and length
  75985. */
  75986. static PingPong(tx: number, length: number): number;
  75987. /**
  75988. * Interpolates between min and max with smoothing at the limits.
  75989. *
  75990. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  75991. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  75992. * @param from from
  75993. * @param to to
  75994. * @param tx value
  75995. * @returns the smooth stepped value
  75996. */
  75997. static SmoothStep(from: number, to: number, tx: number): number;
  75998. /**
  75999. * Moves a value current towards target.
  76000. *
  76001. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  76002. * Negative values of maxDelta pushes the value away from target.
  76003. * @param current current value
  76004. * @param target target value
  76005. * @param maxDelta max distance to move
  76006. * @returns resulting value
  76007. */
  76008. static MoveTowards(current: number, target: number, maxDelta: number): number;
  76009. /**
  76010. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  76011. *
  76012. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  76013. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  76014. * @param current current value
  76015. * @param target target value
  76016. * @param maxDelta max distance to move
  76017. * @returns resulting angle
  76018. */
  76019. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  76020. /**
  76021. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  76022. * @param start start value
  76023. * @param end target value
  76024. * @param amount amount to lerp between
  76025. * @returns the lerped value
  76026. */
  76027. static Lerp(start: number, end: number, amount: number): number;
  76028. /**
  76029. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  76030. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  76031. * @param start start value
  76032. * @param end target value
  76033. * @param amount amount to lerp between
  76034. * @returns the lerped value
  76035. */
  76036. static LerpAngle(start: number, end: number, amount: number): number;
  76037. /**
  76038. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  76039. * @param a start value
  76040. * @param b target value
  76041. * @param value value between a and b
  76042. * @returns the inverseLerp value
  76043. */
  76044. static InverseLerp(a: number, b: number, value: number): number;
  76045. /**
  76046. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  76047. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  76048. * @param value1 spline value
  76049. * @param tangent1 spline value
  76050. * @param value2 spline value
  76051. * @param tangent2 spline value
  76052. * @param amount input value
  76053. * @returns hermite result
  76054. */
  76055. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  76056. /**
  76057. * Returns a random float number between and min and max values
  76058. * @param min min value of random
  76059. * @param max max value of random
  76060. * @returns random value
  76061. */
  76062. static RandomRange(min: number, max: number): number;
  76063. /**
  76064. * This function returns percentage of a number in a given range.
  76065. *
  76066. * RangeToPercent(40,20,60) will return 0.5 (50%)
  76067. * RangeToPercent(34,0,100) will return 0.34 (34%)
  76068. * @param number to convert to percentage
  76069. * @param min min range
  76070. * @param max max range
  76071. * @returns the percentage
  76072. */
  76073. static RangeToPercent(number: number, min: number, max: number): number;
  76074. /**
  76075. * This function returns number that corresponds to the percentage in a given range.
  76076. *
  76077. * PercentToRange(0.34,0,100) will return 34.
  76078. * @param percent to convert to number
  76079. * @param min min range
  76080. * @param max max range
  76081. * @returns the number
  76082. */
  76083. static PercentToRange(percent: number, min: number, max: number): number;
  76084. /**
  76085. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  76086. * @param angle The angle to normalize in radian.
  76087. * @return The converted angle.
  76088. */
  76089. static NormalizeRadians(angle: number): number;
  76090. }
  76091. }
  76092. declare module BABYLON {
  76093. /**
  76094. * Constant used to convert a value to gamma space
  76095. * @ignorenaming
  76096. */
  76097. export const ToGammaSpace: number;
  76098. /**
  76099. * Constant used to convert a value to linear space
  76100. * @ignorenaming
  76101. */
  76102. export const ToLinearSpace = 2.2;
  76103. /**
  76104. * Constant used to define the minimal number value in Babylon.js
  76105. * @ignorenaming
  76106. */
  76107. let Epsilon: number;
  76108. }
  76109. declare module BABYLON {
  76110. /**
  76111. * Class used to represent a viewport on screen
  76112. */
  76113. export class Viewport {
  76114. /** viewport left coordinate */
  76115. x: number;
  76116. /** viewport top coordinate */
  76117. y: number;
  76118. /**viewport width */
  76119. width: number;
  76120. /** viewport height */
  76121. height: number;
  76122. /**
  76123. * Creates a Viewport object located at (x, y) and sized (width, height)
  76124. * @param x defines viewport left coordinate
  76125. * @param y defines viewport top coordinate
  76126. * @param width defines the viewport width
  76127. * @param height defines the viewport height
  76128. */
  76129. constructor(
  76130. /** viewport left coordinate */
  76131. x: number,
  76132. /** viewport top coordinate */
  76133. y: number,
  76134. /**viewport width */
  76135. width: number,
  76136. /** viewport height */
  76137. height: number);
  76138. /**
  76139. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  76140. * @param renderWidth defines the rendering width
  76141. * @param renderHeight defines the rendering height
  76142. * @returns a new Viewport
  76143. */
  76144. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  76145. /**
  76146. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  76147. * @param renderWidth defines the rendering width
  76148. * @param renderHeight defines the rendering height
  76149. * @param ref defines the target viewport
  76150. * @returns the current viewport
  76151. */
  76152. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  76153. /**
  76154. * Returns a new Viewport copied from the current one
  76155. * @returns a new Viewport
  76156. */
  76157. clone(): Viewport;
  76158. }
  76159. }
  76160. declare module BABYLON {
  76161. /**
  76162. * Class containing a set of static utilities functions for arrays.
  76163. */
  76164. export class ArrayTools {
  76165. /**
  76166. * Returns an array of the given size filled with element built from the given constructor and the paramters
  76167. * @param size the number of element to construct and put in the array
  76168. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  76169. * @returns a new array filled with new objects
  76170. */
  76171. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  76172. }
  76173. }
  76174. declare module BABYLON {
  76175. /**
  76176. * Class representing a vector containing 2 coordinates
  76177. */
  76178. export class Vector2 {
  76179. /** defines the first coordinate */
  76180. x: number;
  76181. /** defines the second coordinate */
  76182. y: number;
  76183. /**
  76184. * Creates a new Vector2 from the given x and y coordinates
  76185. * @param x defines the first coordinate
  76186. * @param y defines the second coordinate
  76187. */
  76188. constructor(
  76189. /** defines the first coordinate */
  76190. x?: number,
  76191. /** defines the second coordinate */
  76192. y?: number);
  76193. /**
  76194. * Gets a string with the Vector2 coordinates
  76195. * @returns a string with the Vector2 coordinates
  76196. */
  76197. toString(): string;
  76198. /**
  76199. * Gets class name
  76200. * @returns the string "Vector2"
  76201. */
  76202. getClassName(): string;
  76203. /**
  76204. * Gets current vector hash code
  76205. * @returns the Vector2 hash code as a number
  76206. */
  76207. getHashCode(): number;
  76208. /**
  76209. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  76210. * @param array defines the source array
  76211. * @param index defines the offset in source array
  76212. * @returns the current Vector2
  76213. */
  76214. toArray(array: FloatArray, index?: number): Vector2;
  76215. /**
  76216. * Copy the current vector to an array
  76217. * @returns a new array with 2 elements: the Vector2 coordinates.
  76218. */
  76219. asArray(): number[];
  76220. /**
  76221. * Sets the Vector2 coordinates with the given Vector2 coordinates
  76222. * @param source defines the source Vector2
  76223. * @returns the current updated Vector2
  76224. */
  76225. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  76226. /**
  76227. * Sets the Vector2 coordinates with the given floats
  76228. * @param x defines the first coordinate
  76229. * @param y defines the second coordinate
  76230. * @returns the current updated Vector2
  76231. */
  76232. copyFromFloats(x: number, y: number): Vector2;
  76233. /**
  76234. * Sets the Vector2 coordinates with the given floats
  76235. * @param x defines the first coordinate
  76236. * @param y defines the second coordinate
  76237. * @returns the current updated Vector2
  76238. */
  76239. set(x: number, y: number): Vector2;
  76240. /**
  76241. * Add another vector with the current one
  76242. * @param otherVector defines the other vector
  76243. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  76244. */
  76245. add(otherVector: DeepImmutable<Vector2>): Vector2;
  76246. /**
  76247. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  76248. * @param otherVector defines the other vector
  76249. * @param result defines the target vector
  76250. * @returns the unmodified current Vector2
  76251. */
  76252. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  76253. /**
  76254. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  76255. * @param otherVector defines the other vector
  76256. * @returns the current updated Vector2
  76257. */
  76258. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  76259. /**
  76260. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  76261. * @param otherVector defines the other vector
  76262. * @returns a new Vector2
  76263. */
  76264. addVector3(otherVector: Vector3): Vector2;
  76265. /**
  76266. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  76267. * @param otherVector defines the other vector
  76268. * @returns a new Vector2
  76269. */
  76270. subtract(otherVector: Vector2): Vector2;
  76271. /**
  76272. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  76273. * @param otherVector defines the other vector
  76274. * @param result defines the target vector
  76275. * @returns the unmodified current Vector2
  76276. */
  76277. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  76278. /**
  76279. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  76280. * @param otherVector defines the other vector
  76281. * @returns the current updated Vector2
  76282. */
  76283. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  76284. /**
  76285. * Multiplies in place the current Vector2 coordinates by the given ones
  76286. * @param otherVector defines the other vector
  76287. * @returns the current updated Vector2
  76288. */
  76289. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  76290. /**
  76291. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  76292. * @param otherVector defines the other vector
  76293. * @returns a new Vector2
  76294. */
  76295. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  76296. /**
  76297. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  76298. * @param otherVector defines the other vector
  76299. * @param result defines the target vector
  76300. * @returns the unmodified current Vector2
  76301. */
  76302. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  76303. /**
  76304. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  76305. * @param x defines the first coordinate
  76306. * @param y defines the second coordinate
  76307. * @returns a new Vector2
  76308. */
  76309. multiplyByFloats(x: number, y: number): Vector2;
  76310. /**
  76311. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  76312. * @param otherVector defines the other vector
  76313. * @returns a new Vector2
  76314. */
  76315. divide(otherVector: Vector2): Vector2;
  76316. /**
  76317. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  76318. * @param otherVector defines the other vector
  76319. * @param result defines the target vector
  76320. * @returns the unmodified current Vector2
  76321. */
  76322. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  76323. /**
  76324. * Divides the current Vector2 coordinates by the given ones
  76325. * @param otherVector defines the other vector
  76326. * @returns the current updated Vector2
  76327. */
  76328. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  76329. /**
  76330. * Gets a new Vector2 with current Vector2 negated coordinates
  76331. * @returns a new Vector2
  76332. */
  76333. negate(): Vector2;
  76334. /**
  76335. * Negate this vector in place
  76336. * @returns this
  76337. */
  76338. negateInPlace(): Vector2;
  76339. /**
  76340. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  76341. * @param result defines the Vector3 object where to store the result
  76342. * @returns the current Vector2
  76343. */
  76344. negateToRef(result: Vector2): Vector2;
  76345. /**
  76346. * Multiply the Vector2 coordinates by scale
  76347. * @param scale defines the scaling factor
  76348. * @returns the current updated Vector2
  76349. */
  76350. scaleInPlace(scale: number): Vector2;
  76351. /**
  76352. * Returns a new Vector2 scaled by "scale" from the current Vector2
  76353. * @param scale defines the scaling factor
  76354. * @returns a new Vector2
  76355. */
  76356. scale(scale: number): Vector2;
  76357. /**
  76358. * Scale the current Vector2 values by a factor to a given Vector2
  76359. * @param scale defines the scale factor
  76360. * @param result defines the Vector2 object where to store the result
  76361. * @returns the unmodified current Vector2
  76362. */
  76363. scaleToRef(scale: number, result: Vector2): Vector2;
  76364. /**
  76365. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  76366. * @param scale defines the scale factor
  76367. * @param result defines the Vector2 object where to store the result
  76368. * @returns the unmodified current Vector2
  76369. */
  76370. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  76371. /**
  76372. * Gets a boolean if two vectors are equals
  76373. * @param otherVector defines the other vector
  76374. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  76375. */
  76376. equals(otherVector: DeepImmutable<Vector2>): boolean;
  76377. /**
  76378. * Gets a boolean if two vectors are equals (using an epsilon value)
  76379. * @param otherVector defines the other vector
  76380. * @param epsilon defines the minimal distance to consider equality
  76381. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  76382. */
  76383. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  76384. /**
  76385. * Gets a new Vector2 from current Vector2 floored values
  76386. * @returns a new Vector2
  76387. */
  76388. floor(): Vector2;
  76389. /**
  76390. * Gets a new Vector2 from current Vector2 floored values
  76391. * @returns a new Vector2
  76392. */
  76393. fract(): Vector2;
  76394. /**
  76395. * Gets the length of the vector
  76396. * @returns the vector length (float)
  76397. */
  76398. length(): number;
  76399. /**
  76400. * Gets the vector squared length
  76401. * @returns the vector squared length (float)
  76402. */
  76403. lengthSquared(): number;
  76404. /**
  76405. * Normalize the vector
  76406. * @returns the current updated Vector2
  76407. */
  76408. normalize(): Vector2;
  76409. /**
  76410. * Gets a new Vector2 copied from the Vector2
  76411. * @returns a new Vector2
  76412. */
  76413. clone(): Vector2;
  76414. /**
  76415. * Gets a new Vector2(0, 0)
  76416. * @returns a new Vector2
  76417. */
  76418. static Zero(): Vector2;
  76419. /**
  76420. * Gets a new Vector2(1, 1)
  76421. * @returns a new Vector2
  76422. */
  76423. static One(): Vector2;
  76424. /**
  76425. * Gets a new Vector2 set from the given index element of the given array
  76426. * @param array defines the data source
  76427. * @param offset defines the offset in the data source
  76428. * @returns a new Vector2
  76429. */
  76430. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  76431. /**
  76432. * Sets "result" from the given index element of the given array
  76433. * @param array defines the data source
  76434. * @param offset defines the offset in the data source
  76435. * @param result defines the target vector
  76436. */
  76437. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  76438. /**
  76439. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  76440. * @param value1 defines 1st point of control
  76441. * @param value2 defines 2nd point of control
  76442. * @param value3 defines 3rd point of control
  76443. * @param value4 defines 4th point of control
  76444. * @param amount defines the interpolation factor
  76445. * @returns a new Vector2
  76446. */
  76447. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  76448. /**
  76449. * 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".
  76450. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  76451. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  76452. * @param value defines the value to clamp
  76453. * @param min defines the lower limit
  76454. * @param max defines the upper limit
  76455. * @returns a new Vector2
  76456. */
  76457. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  76458. /**
  76459. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  76460. * @param value1 defines the 1st control point
  76461. * @param tangent1 defines the outgoing tangent
  76462. * @param value2 defines the 2nd control point
  76463. * @param tangent2 defines the incoming tangent
  76464. * @param amount defines the interpolation factor
  76465. * @returns a new Vector2
  76466. */
  76467. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  76468. /**
  76469. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  76470. * @param start defines the start vector
  76471. * @param end defines the end vector
  76472. * @param amount defines the interpolation factor
  76473. * @returns a new Vector2
  76474. */
  76475. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  76476. /**
  76477. * Gets the dot product of the vector "left" and the vector "right"
  76478. * @param left defines first vector
  76479. * @param right defines second vector
  76480. * @returns the dot product (float)
  76481. */
  76482. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  76483. /**
  76484. * Returns a new Vector2 equal to the normalized given vector
  76485. * @param vector defines the vector to normalize
  76486. * @returns a new Vector2
  76487. */
  76488. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  76489. /**
  76490. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  76491. * @param left defines 1st vector
  76492. * @param right defines 2nd vector
  76493. * @returns a new Vector2
  76494. */
  76495. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  76496. /**
  76497. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  76498. * @param left defines 1st vector
  76499. * @param right defines 2nd vector
  76500. * @returns a new Vector2
  76501. */
  76502. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  76503. /**
  76504. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  76505. * @param vector defines the vector to transform
  76506. * @param transformation defines the matrix to apply
  76507. * @returns a new Vector2
  76508. */
  76509. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  76510. /**
  76511. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  76512. * @param vector defines the vector to transform
  76513. * @param transformation defines the matrix to apply
  76514. * @param result defines the target vector
  76515. */
  76516. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  76517. /**
  76518. * Determines if a given vector is included in a triangle
  76519. * @param p defines the vector to test
  76520. * @param p0 defines 1st triangle point
  76521. * @param p1 defines 2nd triangle point
  76522. * @param p2 defines 3rd triangle point
  76523. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  76524. */
  76525. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  76526. /**
  76527. * Gets the distance between the vectors "value1" and "value2"
  76528. * @param value1 defines first vector
  76529. * @param value2 defines second vector
  76530. * @returns the distance between vectors
  76531. */
  76532. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  76533. /**
  76534. * Returns the squared distance between the vectors "value1" and "value2"
  76535. * @param value1 defines first vector
  76536. * @param value2 defines second vector
  76537. * @returns the squared distance between vectors
  76538. */
  76539. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  76540. /**
  76541. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  76542. * @param value1 defines first vector
  76543. * @param value2 defines second vector
  76544. * @returns a new Vector2
  76545. */
  76546. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  76547. /**
  76548. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  76549. * @param p defines the middle point
  76550. * @param segA defines one point of the segment
  76551. * @param segB defines the other point of the segment
  76552. * @returns the shortest distance
  76553. */
  76554. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  76555. }
  76556. /**
  76557. * Class used to store (x,y,z) vector representation
  76558. * A Vector3 is the main object used in 3D geometry
  76559. * It can represent etiher the coordinates of a point the space, either a direction
  76560. * Reminder: js uses a left handed forward facing system
  76561. */
  76562. export class Vector3 {
  76563. /**
  76564. * Defines the first coordinates (on X axis)
  76565. */
  76566. x: number;
  76567. /**
  76568. * Defines the second coordinates (on Y axis)
  76569. */
  76570. y: number;
  76571. /**
  76572. * Defines the third coordinates (on Z axis)
  76573. */
  76574. z: number;
  76575. private static _UpReadOnly;
  76576. private static _ZeroReadOnly;
  76577. /**
  76578. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  76579. * @param x defines the first coordinates (on X axis)
  76580. * @param y defines the second coordinates (on Y axis)
  76581. * @param z defines the third coordinates (on Z axis)
  76582. */
  76583. constructor(
  76584. /**
  76585. * Defines the first coordinates (on X axis)
  76586. */
  76587. x?: number,
  76588. /**
  76589. * Defines the second coordinates (on Y axis)
  76590. */
  76591. y?: number,
  76592. /**
  76593. * Defines the third coordinates (on Z axis)
  76594. */
  76595. z?: number);
  76596. /**
  76597. * Creates a string representation of the Vector3
  76598. * @returns a string with the Vector3 coordinates.
  76599. */
  76600. toString(): string;
  76601. /**
  76602. * Gets the class name
  76603. * @returns the string "Vector3"
  76604. */
  76605. getClassName(): string;
  76606. /**
  76607. * Creates the Vector3 hash code
  76608. * @returns a number which tends to be unique between Vector3 instances
  76609. */
  76610. getHashCode(): number;
  76611. /**
  76612. * Creates an array containing three elements : the coordinates of the Vector3
  76613. * @returns a new array of numbers
  76614. */
  76615. asArray(): number[];
  76616. /**
  76617. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  76618. * @param array defines the destination array
  76619. * @param index defines the offset in the destination array
  76620. * @returns the current Vector3
  76621. */
  76622. toArray(array: FloatArray, index?: number): Vector3;
  76623. /**
  76624. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  76625. * @returns a new Quaternion object, computed from the Vector3 coordinates
  76626. */
  76627. toQuaternion(): Quaternion;
  76628. /**
  76629. * Adds the given vector to the current Vector3
  76630. * @param otherVector defines the second operand
  76631. * @returns the current updated Vector3
  76632. */
  76633. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  76634. /**
  76635. * Adds the given coordinates to the current Vector3
  76636. * @param x defines the x coordinate of the operand
  76637. * @param y defines the y coordinate of the operand
  76638. * @param z defines the z coordinate of the operand
  76639. * @returns the current updated Vector3
  76640. */
  76641. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  76642. /**
  76643. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  76644. * @param otherVector defines the second operand
  76645. * @returns the resulting Vector3
  76646. */
  76647. add(otherVector: DeepImmutable<Vector3>): Vector3;
  76648. /**
  76649. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  76650. * @param otherVector defines the second operand
  76651. * @param result defines the Vector3 object where to store the result
  76652. * @returns the current Vector3
  76653. */
  76654. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  76655. /**
  76656. * Subtract the given vector from the current Vector3
  76657. * @param otherVector defines the second operand
  76658. * @returns the current updated Vector3
  76659. */
  76660. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  76661. /**
  76662. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  76663. * @param otherVector defines the second operand
  76664. * @returns the resulting Vector3
  76665. */
  76666. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  76667. /**
  76668. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  76669. * @param otherVector defines the second operand
  76670. * @param result defines the Vector3 object where to store the result
  76671. * @returns the current Vector3
  76672. */
  76673. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  76674. /**
  76675. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  76676. * @param x defines the x coordinate of the operand
  76677. * @param y defines the y coordinate of the operand
  76678. * @param z defines the z coordinate of the operand
  76679. * @returns the resulting Vector3
  76680. */
  76681. subtractFromFloats(x: number, y: number, z: number): Vector3;
  76682. /**
  76683. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  76684. * @param x defines the x coordinate of the operand
  76685. * @param y defines the y coordinate of the operand
  76686. * @param z defines the z coordinate of the operand
  76687. * @param result defines the Vector3 object where to store the result
  76688. * @returns the current Vector3
  76689. */
  76690. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  76691. /**
  76692. * Gets a new Vector3 set with the current Vector3 negated coordinates
  76693. * @returns a new Vector3
  76694. */
  76695. negate(): Vector3;
  76696. /**
  76697. * Negate this vector in place
  76698. * @returns this
  76699. */
  76700. negateInPlace(): Vector3;
  76701. /**
  76702. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  76703. * @param result defines the Vector3 object where to store the result
  76704. * @returns the current Vector3
  76705. */
  76706. negateToRef(result: Vector3): Vector3;
  76707. /**
  76708. * Multiplies the Vector3 coordinates by the float "scale"
  76709. * @param scale defines the multiplier factor
  76710. * @returns the current updated Vector3
  76711. */
  76712. scaleInPlace(scale: number): Vector3;
  76713. /**
  76714. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  76715. * @param scale defines the multiplier factor
  76716. * @returns a new Vector3
  76717. */
  76718. scale(scale: number): Vector3;
  76719. /**
  76720. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  76721. * @param scale defines the multiplier factor
  76722. * @param result defines the Vector3 object where to store the result
  76723. * @returns the current Vector3
  76724. */
  76725. scaleToRef(scale: number, result: Vector3): Vector3;
  76726. /**
  76727. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  76728. * @param scale defines the scale factor
  76729. * @param result defines the Vector3 object where to store the result
  76730. * @returns the unmodified current Vector3
  76731. */
  76732. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  76733. /**
  76734. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  76735. * @param otherVector defines the second operand
  76736. * @returns true if both vectors are equals
  76737. */
  76738. equals(otherVector: DeepImmutable<Vector3>): boolean;
  76739. /**
  76740. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  76741. * @param otherVector defines the second operand
  76742. * @param epsilon defines the minimal distance to define values as equals
  76743. * @returns true if both vectors are distant less than epsilon
  76744. */
  76745. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  76746. /**
  76747. * Returns true if the current Vector3 coordinates equals the given floats
  76748. * @param x defines the x coordinate of the operand
  76749. * @param y defines the y coordinate of the operand
  76750. * @param z defines the z coordinate of the operand
  76751. * @returns true if both vectors are equals
  76752. */
  76753. equalsToFloats(x: number, y: number, z: number): boolean;
  76754. /**
  76755. * Multiplies the current Vector3 coordinates by the given ones
  76756. * @param otherVector defines the second operand
  76757. * @returns the current updated Vector3
  76758. */
  76759. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  76760. /**
  76761. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  76762. * @param otherVector defines the second operand
  76763. * @returns the new Vector3
  76764. */
  76765. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  76766. /**
  76767. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  76768. * @param otherVector defines the second operand
  76769. * @param result defines the Vector3 object where to store the result
  76770. * @returns the current Vector3
  76771. */
  76772. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  76773. /**
  76774. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  76775. * @param x defines the x coordinate of the operand
  76776. * @param y defines the y coordinate of the operand
  76777. * @param z defines the z coordinate of the operand
  76778. * @returns the new Vector3
  76779. */
  76780. multiplyByFloats(x: number, y: number, z: number): Vector3;
  76781. /**
  76782. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  76783. * @param otherVector defines the second operand
  76784. * @returns the new Vector3
  76785. */
  76786. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  76787. /**
  76788. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  76789. * @param otherVector defines the second operand
  76790. * @param result defines the Vector3 object where to store the result
  76791. * @returns the current Vector3
  76792. */
  76793. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  76794. /**
  76795. * Divides the current Vector3 coordinates by the given ones.
  76796. * @param otherVector defines the second operand
  76797. * @returns the current updated Vector3
  76798. */
  76799. divideInPlace(otherVector: Vector3): Vector3;
  76800. /**
  76801. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  76802. * @param other defines the second operand
  76803. * @returns the current updated Vector3
  76804. */
  76805. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  76806. /**
  76807. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  76808. * @param other defines the second operand
  76809. * @returns the current updated Vector3
  76810. */
  76811. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  76812. /**
  76813. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  76814. * @param x defines the x coordinate of the operand
  76815. * @param y defines the y coordinate of the operand
  76816. * @param z defines the z coordinate of the operand
  76817. * @returns the current updated Vector3
  76818. */
  76819. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  76820. /**
  76821. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  76822. * @param x defines the x coordinate of the operand
  76823. * @param y defines the y coordinate of the operand
  76824. * @param z defines the z coordinate of the operand
  76825. * @returns the current updated Vector3
  76826. */
  76827. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  76828. /**
  76829. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  76830. * Check if is non uniform within a certain amount of decimal places to account for this
  76831. * @param epsilon the amount the values can differ
  76832. * @returns if the the vector is non uniform to a certain number of decimal places
  76833. */
  76834. isNonUniformWithinEpsilon(epsilon: number): boolean;
  76835. /**
  76836. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  76837. */
  76838. get isNonUniform(): boolean;
  76839. /**
  76840. * Gets a new Vector3 from current Vector3 floored values
  76841. * @returns a new Vector3
  76842. */
  76843. floor(): Vector3;
  76844. /**
  76845. * Gets a new Vector3 from current Vector3 floored values
  76846. * @returns a new Vector3
  76847. */
  76848. fract(): Vector3;
  76849. /**
  76850. * Gets the length of the Vector3
  76851. * @returns the length of the Vector3
  76852. */
  76853. length(): number;
  76854. /**
  76855. * Gets the squared length of the Vector3
  76856. * @returns squared length of the Vector3
  76857. */
  76858. lengthSquared(): number;
  76859. /**
  76860. * Normalize the current Vector3.
  76861. * Please note that this is an in place operation.
  76862. * @returns the current updated Vector3
  76863. */
  76864. normalize(): Vector3;
  76865. /**
  76866. * Reorders the x y z properties of the vector in place
  76867. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  76868. * @returns the current updated vector
  76869. */
  76870. reorderInPlace(order: string): this;
  76871. /**
  76872. * Rotates the vector around 0,0,0 by a quaternion
  76873. * @param quaternion the rotation quaternion
  76874. * @param result vector to store the result
  76875. * @returns the resulting vector
  76876. */
  76877. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  76878. /**
  76879. * Rotates a vector around a given point
  76880. * @param quaternion the rotation quaternion
  76881. * @param point the point to rotate around
  76882. * @param result vector to store the result
  76883. * @returns the resulting vector
  76884. */
  76885. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  76886. /**
  76887. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  76888. * The cross product is then orthogonal to both current and "other"
  76889. * @param other defines the right operand
  76890. * @returns the cross product
  76891. */
  76892. cross(other: Vector3): Vector3;
  76893. /**
  76894. * Normalize the current Vector3 with the given input length.
  76895. * Please note that this is an in place operation.
  76896. * @param len the length of the vector
  76897. * @returns the current updated Vector3
  76898. */
  76899. normalizeFromLength(len: number): Vector3;
  76900. /**
  76901. * Normalize the current Vector3 to a new vector
  76902. * @returns the new Vector3
  76903. */
  76904. normalizeToNew(): Vector3;
  76905. /**
  76906. * Normalize the current Vector3 to the reference
  76907. * @param reference define the Vector3 to update
  76908. * @returns the updated Vector3
  76909. */
  76910. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  76911. /**
  76912. * Creates a new Vector3 copied from the current Vector3
  76913. * @returns the new Vector3
  76914. */
  76915. clone(): Vector3;
  76916. /**
  76917. * Copies the given vector coordinates to the current Vector3 ones
  76918. * @param source defines the source Vector3
  76919. * @returns the current updated Vector3
  76920. */
  76921. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  76922. /**
  76923. * Copies the given floats to the current Vector3 coordinates
  76924. * @param x defines the x coordinate of the operand
  76925. * @param y defines the y coordinate of the operand
  76926. * @param z defines the z coordinate of the operand
  76927. * @returns the current updated Vector3
  76928. */
  76929. copyFromFloats(x: number, y: number, z: number): Vector3;
  76930. /**
  76931. * Copies the given floats to the current Vector3 coordinates
  76932. * @param x defines the x coordinate of the operand
  76933. * @param y defines the y coordinate of the operand
  76934. * @param z defines the z coordinate of the operand
  76935. * @returns the current updated Vector3
  76936. */
  76937. set(x: number, y: number, z: number): Vector3;
  76938. /**
  76939. * Copies the given float to the current Vector3 coordinates
  76940. * @param v defines the x, y and z coordinates of the operand
  76941. * @returns the current updated Vector3
  76942. */
  76943. setAll(v: number): Vector3;
  76944. /**
  76945. * Get the clip factor between two vectors
  76946. * @param vector0 defines the first operand
  76947. * @param vector1 defines the second operand
  76948. * @param axis defines the axis to use
  76949. * @param size defines the size along the axis
  76950. * @returns the clip factor
  76951. */
  76952. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  76953. /**
  76954. * Get angle between two vectors
  76955. * @param vector0 angle between vector0 and vector1
  76956. * @param vector1 angle between vector0 and vector1
  76957. * @param normal direction of the normal
  76958. * @return the angle between vector0 and vector1
  76959. */
  76960. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  76961. /**
  76962. * Returns a new Vector3 set from the index "offset" of the given array
  76963. * @param array defines the source array
  76964. * @param offset defines the offset in the source array
  76965. * @returns the new Vector3
  76966. */
  76967. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  76968. /**
  76969. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  76970. * @param array defines the source array
  76971. * @param offset defines the offset in the source array
  76972. * @returns the new Vector3
  76973. * @deprecated Please use FromArray instead.
  76974. */
  76975. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  76976. /**
  76977. * Sets the given vector "result" with the element values from the index "offset" of the given array
  76978. * @param array defines the source array
  76979. * @param offset defines the offset in the source array
  76980. * @param result defines the Vector3 where to store the result
  76981. */
  76982. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  76983. /**
  76984. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  76985. * @param array defines the source array
  76986. * @param offset defines the offset in the source array
  76987. * @param result defines the Vector3 where to store the result
  76988. * @deprecated Please use FromArrayToRef instead.
  76989. */
  76990. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  76991. /**
  76992. * Sets the given vector "result" with the given floats.
  76993. * @param x defines the x coordinate of the source
  76994. * @param y defines the y coordinate of the source
  76995. * @param z defines the z coordinate of the source
  76996. * @param result defines the Vector3 where to store the result
  76997. */
  76998. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  76999. /**
  77000. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  77001. * @returns a new empty Vector3
  77002. */
  77003. static Zero(): Vector3;
  77004. /**
  77005. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  77006. * @returns a new unit Vector3
  77007. */
  77008. static One(): Vector3;
  77009. /**
  77010. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  77011. * @returns a new up Vector3
  77012. */
  77013. static Up(): Vector3;
  77014. /**
  77015. * Gets a up Vector3 that must not be updated
  77016. */
  77017. static get UpReadOnly(): DeepImmutable<Vector3>;
  77018. /**
  77019. * Gets a zero Vector3 that must not be updated
  77020. */
  77021. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  77022. /**
  77023. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  77024. * @returns a new down Vector3
  77025. */
  77026. static Down(): Vector3;
  77027. /**
  77028. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  77029. * @returns a new forward Vector3
  77030. */
  77031. static Forward(): Vector3;
  77032. /**
  77033. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  77034. * @returns a new forward Vector3
  77035. */
  77036. static Backward(): Vector3;
  77037. /**
  77038. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  77039. * @returns a new right Vector3
  77040. */
  77041. static Right(): Vector3;
  77042. /**
  77043. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  77044. * @returns a new left Vector3
  77045. */
  77046. static Left(): Vector3;
  77047. /**
  77048. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  77049. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  77050. * @param vector defines the Vector3 to transform
  77051. * @param transformation defines the transformation matrix
  77052. * @returns the transformed Vector3
  77053. */
  77054. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  77055. /**
  77056. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  77057. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  77058. * @param vector defines the Vector3 to transform
  77059. * @param transformation defines the transformation matrix
  77060. * @param result defines the Vector3 where to store the result
  77061. */
  77062. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  77063. /**
  77064. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  77065. * This method computes tranformed coordinates only, not transformed direction vectors
  77066. * @param x define the x coordinate of the source vector
  77067. * @param y define the y coordinate of the source vector
  77068. * @param z define the z coordinate of the source vector
  77069. * @param transformation defines the transformation matrix
  77070. * @param result defines the Vector3 where to store the result
  77071. */
  77072. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  77073. /**
  77074. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  77075. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  77076. * @param vector defines the Vector3 to transform
  77077. * @param transformation defines the transformation matrix
  77078. * @returns the new Vector3
  77079. */
  77080. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  77081. /**
  77082. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  77083. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  77084. * @param vector defines the Vector3 to transform
  77085. * @param transformation defines the transformation matrix
  77086. * @param result defines the Vector3 where to store the result
  77087. */
  77088. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  77089. /**
  77090. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  77091. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  77092. * @param x define the x coordinate of the source vector
  77093. * @param y define the y coordinate of the source vector
  77094. * @param z define the z coordinate of the source vector
  77095. * @param transformation defines the transformation matrix
  77096. * @param result defines the Vector3 where to store the result
  77097. */
  77098. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  77099. /**
  77100. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  77101. * @param value1 defines the first control point
  77102. * @param value2 defines the second control point
  77103. * @param value3 defines the third control point
  77104. * @param value4 defines the fourth control point
  77105. * @param amount defines the amount on the spline to use
  77106. * @returns the new Vector3
  77107. */
  77108. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  77109. /**
  77110. * 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"
  77111. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  77112. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  77113. * @param value defines the current value
  77114. * @param min defines the lower range value
  77115. * @param max defines the upper range value
  77116. * @returns the new Vector3
  77117. */
  77118. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  77119. /**
  77120. * 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"
  77121. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  77122. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  77123. * @param value defines the current value
  77124. * @param min defines the lower range value
  77125. * @param max defines the upper range value
  77126. * @param result defines the Vector3 where to store the result
  77127. */
  77128. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  77129. /**
  77130. * Checks if a given vector is inside a specific range
  77131. * @param v defines the vector to test
  77132. * @param min defines the minimum range
  77133. * @param max defines the maximum range
  77134. */
  77135. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  77136. /**
  77137. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  77138. * @param value1 defines the first control point
  77139. * @param tangent1 defines the first tangent vector
  77140. * @param value2 defines the second control point
  77141. * @param tangent2 defines the second tangent vector
  77142. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  77143. * @returns the new Vector3
  77144. */
  77145. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  77146. /**
  77147. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  77148. * @param start defines the start value
  77149. * @param end defines the end value
  77150. * @param amount max defines amount between both (between 0 and 1)
  77151. * @returns the new Vector3
  77152. */
  77153. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  77154. /**
  77155. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  77156. * @param start defines the start value
  77157. * @param end defines the end value
  77158. * @param amount max defines amount between both (between 0 and 1)
  77159. * @param result defines the Vector3 where to store the result
  77160. */
  77161. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  77162. /**
  77163. * Returns the dot product (float) between the vectors "left" and "right"
  77164. * @param left defines the left operand
  77165. * @param right defines the right operand
  77166. * @returns the dot product
  77167. */
  77168. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  77169. /**
  77170. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  77171. * The cross product is then orthogonal to both "left" and "right"
  77172. * @param left defines the left operand
  77173. * @param right defines the right operand
  77174. * @returns the cross product
  77175. */
  77176. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  77177. /**
  77178. * Sets the given vector "result" with the cross product of "left" and "right"
  77179. * The cross product is then orthogonal to both "left" and "right"
  77180. * @param left defines the left operand
  77181. * @param right defines the right operand
  77182. * @param result defines the Vector3 where to store the result
  77183. */
  77184. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  77185. /**
  77186. * Returns a new Vector3 as the normalization of the given vector
  77187. * @param vector defines the Vector3 to normalize
  77188. * @returns the new Vector3
  77189. */
  77190. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  77191. /**
  77192. * Sets the given vector "result" with the normalization of the given first vector
  77193. * @param vector defines the Vector3 to normalize
  77194. * @param result defines the Vector3 where to store the result
  77195. */
  77196. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  77197. /**
  77198. * Project a Vector3 onto screen space
  77199. * @param vector defines the Vector3 to project
  77200. * @param world defines the world matrix to use
  77201. * @param transform defines the transform (view x projection) matrix to use
  77202. * @param viewport defines the screen viewport to use
  77203. * @returns the new Vector3
  77204. */
  77205. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  77206. /** @hidden */
  77207. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  77208. /**
  77209. * Unproject from screen space to object space
  77210. * @param source defines the screen space Vector3 to use
  77211. * @param viewportWidth defines the current width of the viewport
  77212. * @param viewportHeight defines the current height of the viewport
  77213. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  77214. * @param transform defines the transform (view x projection) matrix to use
  77215. * @returns the new Vector3
  77216. */
  77217. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  77218. /**
  77219. * Unproject from screen space to object space
  77220. * @param source defines the screen space Vector3 to use
  77221. * @param viewportWidth defines the current width of the viewport
  77222. * @param viewportHeight defines the current height of the viewport
  77223. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  77224. * @param view defines the view matrix to use
  77225. * @param projection defines the projection matrix to use
  77226. * @returns the new Vector3
  77227. */
  77228. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  77229. /**
  77230. * Unproject from screen space to object space
  77231. * @param source defines the screen space Vector3 to use
  77232. * @param viewportWidth defines the current width of the viewport
  77233. * @param viewportHeight defines the current height of the viewport
  77234. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  77235. * @param view defines the view matrix to use
  77236. * @param projection defines the projection matrix to use
  77237. * @param result defines the Vector3 where to store the result
  77238. */
  77239. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  77240. /**
  77241. * Unproject from screen space to object space
  77242. * @param sourceX defines the screen space x coordinate to use
  77243. * @param sourceY defines the screen space y coordinate to use
  77244. * @param sourceZ defines the screen space z coordinate to use
  77245. * @param viewportWidth defines the current width of the viewport
  77246. * @param viewportHeight defines the current height of the viewport
  77247. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  77248. * @param view defines the view matrix to use
  77249. * @param projection defines the projection matrix to use
  77250. * @param result defines the Vector3 where to store the result
  77251. */
  77252. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  77253. /**
  77254. * Gets the minimal coordinate values between two Vector3
  77255. * @param left defines the first operand
  77256. * @param right defines the second operand
  77257. * @returns the new Vector3
  77258. */
  77259. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  77260. /**
  77261. * Gets the maximal coordinate values between two Vector3
  77262. * @param left defines the first operand
  77263. * @param right defines the second operand
  77264. * @returns the new Vector3
  77265. */
  77266. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  77267. /**
  77268. * Returns the distance between the vectors "value1" and "value2"
  77269. * @param value1 defines the first operand
  77270. * @param value2 defines the second operand
  77271. * @returns the distance
  77272. */
  77273. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  77274. /**
  77275. * Returns the squared distance between the vectors "value1" and "value2"
  77276. * @param value1 defines the first operand
  77277. * @param value2 defines the second operand
  77278. * @returns the squared distance
  77279. */
  77280. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  77281. /**
  77282. * Returns a new Vector3 located at the center between "value1" and "value2"
  77283. * @param value1 defines the first operand
  77284. * @param value2 defines the second operand
  77285. * @returns the new Vector3
  77286. */
  77287. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  77288. /**
  77289. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  77290. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  77291. * to something in order to rotate it from its local system to the given target system
  77292. * Note: axis1, axis2 and axis3 are normalized during this operation
  77293. * @param axis1 defines the first axis
  77294. * @param axis2 defines the second axis
  77295. * @param axis3 defines the third axis
  77296. * @returns a new Vector3
  77297. */
  77298. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  77299. /**
  77300. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  77301. * @param axis1 defines the first axis
  77302. * @param axis2 defines the second axis
  77303. * @param axis3 defines the third axis
  77304. * @param ref defines the Vector3 where to store the result
  77305. */
  77306. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  77307. }
  77308. /**
  77309. * Vector4 class created for EulerAngle class conversion to Quaternion
  77310. */
  77311. export class Vector4 {
  77312. /** x value of the vector */
  77313. x: number;
  77314. /** y value of the vector */
  77315. y: number;
  77316. /** z value of the vector */
  77317. z: number;
  77318. /** w value of the vector */
  77319. w: number;
  77320. /**
  77321. * Creates a Vector4 object from the given floats.
  77322. * @param x x value of the vector
  77323. * @param y y value of the vector
  77324. * @param z z value of the vector
  77325. * @param w w value of the vector
  77326. */
  77327. constructor(
  77328. /** x value of the vector */
  77329. x: number,
  77330. /** y value of the vector */
  77331. y: number,
  77332. /** z value of the vector */
  77333. z: number,
  77334. /** w value of the vector */
  77335. w: number);
  77336. /**
  77337. * Returns the string with the Vector4 coordinates.
  77338. * @returns a string containing all the vector values
  77339. */
  77340. toString(): string;
  77341. /**
  77342. * Returns the string "Vector4".
  77343. * @returns "Vector4"
  77344. */
  77345. getClassName(): string;
  77346. /**
  77347. * Returns the Vector4 hash code.
  77348. * @returns a unique hash code
  77349. */
  77350. getHashCode(): number;
  77351. /**
  77352. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  77353. * @returns the resulting array
  77354. */
  77355. asArray(): number[];
  77356. /**
  77357. * Populates the given array from the given index with the Vector4 coordinates.
  77358. * @param array array to populate
  77359. * @param index index of the array to start at (default: 0)
  77360. * @returns the Vector4.
  77361. */
  77362. toArray(array: FloatArray, index?: number): Vector4;
  77363. /**
  77364. * Adds the given vector to the current Vector4.
  77365. * @param otherVector the vector to add
  77366. * @returns the updated Vector4.
  77367. */
  77368. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  77369. /**
  77370. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  77371. * @param otherVector the vector to add
  77372. * @returns the resulting vector
  77373. */
  77374. add(otherVector: DeepImmutable<Vector4>): Vector4;
  77375. /**
  77376. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  77377. * @param otherVector the vector to add
  77378. * @param result the vector to store the result
  77379. * @returns the current Vector4.
  77380. */
  77381. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  77382. /**
  77383. * Subtract in place the given vector from the current Vector4.
  77384. * @param otherVector the vector to subtract
  77385. * @returns the updated Vector4.
  77386. */
  77387. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  77388. /**
  77389. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  77390. * @param otherVector the vector to add
  77391. * @returns the new vector with the result
  77392. */
  77393. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  77394. /**
  77395. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  77396. * @param otherVector the vector to subtract
  77397. * @param result the vector to store the result
  77398. * @returns the current Vector4.
  77399. */
  77400. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  77401. /**
  77402. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  77403. */
  77404. /**
  77405. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  77406. * @param x value to subtract
  77407. * @param y value to subtract
  77408. * @param z value to subtract
  77409. * @param w value to subtract
  77410. * @returns new vector containing the result
  77411. */
  77412. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  77413. /**
  77414. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  77415. * @param x value to subtract
  77416. * @param y value to subtract
  77417. * @param z value to subtract
  77418. * @param w value to subtract
  77419. * @param result the vector to store the result in
  77420. * @returns the current Vector4.
  77421. */
  77422. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  77423. /**
  77424. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  77425. * @returns a new vector with the negated values
  77426. */
  77427. negate(): Vector4;
  77428. /**
  77429. * Negate this vector in place
  77430. * @returns this
  77431. */
  77432. negateInPlace(): Vector4;
  77433. /**
  77434. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  77435. * @param result defines the Vector3 object where to store the result
  77436. * @returns the current Vector4
  77437. */
  77438. negateToRef(result: Vector4): Vector4;
  77439. /**
  77440. * Multiplies the current Vector4 coordinates by scale (float).
  77441. * @param scale the number to scale with
  77442. * @returns the updated Vector4.
  77443. */
  77444. scaleInPlace(scale: number): Vector4;
  77445. /**
  77446. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  77447. * @param scale the number to scale with
  77448. * @returns a new vector with the result
  77449. */
  77450. scale(scale: number): Vector4;
  77451. /**
  77452. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  77453. * @param scale the number to scale with
  77454. * @param result a vector to store the result in
  77455. * @returns the current Vector4.
  77456. */
  77457. scaleToRef(scale: number, result: Vector4): Vector4;
  77458. /**
  77459. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  77460. * @param scale defines the scale factor
  77461. * @param result defines the Vector4 object where to store the result
  77462. * @returns the unmodified current Vector4
  77463. */
  77464. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  77465. /**
  77466. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  77467. * @param otherVector the vector to compare against
  77468. * @returns true if they are equal
  77469. */
  77470. equals(otherVector: DeepImmutable<Vector4>): boolean;
  77471. /**
  77472. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  77473. * @param otherVector vector to compare against
  77474. * @param epsilon (Default: very small number)
  77475. * @returns true if they are equal
  77476. */
  77477. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  77478. /**
  77479. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  77480. * @param x x value to compare against
  77481. * @param y y value to compare against
  77482. * @param z z value to compare against
  77483. * @param w w value to compare against
  77484. * @returns true if equal
  77485. */
  77486. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  77487. /**
  77488. * Multiplies in place the current Vector4 by the given one.
  77489. * @param otherVector vector to multiple with
  77490. * @returns the updated Vector4.
  77491. */
  77492. multiplyInPlace(otherVector: Vector4): Vector4;
  77493. /**
  77494. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  77495. * @param otherVector vector to multiple with
  77496. * @returns resulting new vector
  77497. */
  77498. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  77499. /**
  77500. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  77501. * @param otherVector vector to multiple with
  77502. * @param result vector to store the result
  77503. * @returns the current Vector4.
  77504. */
  77505. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  77506. /**
  77507. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  77508. * @param x x value multiply with
  77509. * @param y y value multiply with
  77510. * @param z z value multiply with
  77511. * @param w w value multiply with
  77512. * @returns resulting new vector
  77513. */
  77514. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  77515. /**
  77516. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  77517. * @param otherVector vector to devide with
  77518. * @returns resulting new vector
  77519. */
  77520. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  77521. /**
  77522. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  77523. * @param otherVector vector to devide with
  77524. * @param result vector to store the result
  77525. * @returns the current Vector4.
  77526. */
  77527. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  77528. /**
  77529. * Divides the current Vector3 coordinates by the given ones.
  77530. * @param otherVector vector to devide with
  77531. * @returns the updated Vector3.
  77532. */
  77533. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  77534. /**
  77535. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  77536. * @param other defines the second operand
  77537. * @returns the current updated Vector4
  77538. */
  77539. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  77540. /**
  77541. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  77542. * @param other defines the second operand
  77543. * @returns the current updated Vector4
  77544. */
  77545. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  77546. /**
  77547. * Gets a new Vector4 from current Vector4 floored values
  77548. * @returns a new Vector4
  77549. */
  77550. floor(): Vector4;
  77551. /**
  77552. * Gets a new Vector4 from current Vector3 floored values
  77553. * @returns a new Vector4
  77554. */
  77555. fract(): Vector4;
  77556. /**
  77557. * Returns the Vector4 length (float).
  77558. * @returns the length
  77559. */
  77560. length(): number;
  77561. /**
  77562. * Returns the Vector4 squared length (float).
  77563. * @returns the length squared
  77564. */
  77565. lengthSquared(): number;
  77566. /**
  77567. * Normalizes in place the Vector4.
  77568. * @returns the updated Vector4.
  77569. */
  77570. normalize(): Vector4;
  77571. /**
  77572. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  77573. * @returns this converted to a new vector3
  77574. */
  77575. toVector3(): Vector3;
  77576. /**
  77577. * Returns a new Vector4 copied from the current one.
  77578. * @returns the new cloned vector
  77579. */
  77580. clone(): Vector4;
  77581. /**
  77582. * Updates the current Vector4 with the given one coordinates.
  77583. * @param source the source vector to copy from
  77584. * @returns the updated Vector4.
  77585. */
  77586. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  77587. /**
  77588. * Updates the current Vector4 coordinates with the given floats.
  77589. * @param x float to copy from
  77590. * @param y float to copy from
  77591. * @param z float to copy from
  77592. * @param w float to copy from
  77593. * @returns the updated Vector4.
  77594. */
  77595. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  77596. /**
  77597. * Updates the current Vector4 coordinates with the given floats.
  77598. * @param x float to set from
  77599. * @param y float to set from
  77600. * @param z float to set from
  77601. * @param w float to set from
  77602. * @returns the updated Vector4.
  77603. */
  77604. set(x: number, y: number, z: number, w: number): Vector4;
  77605. /**
  77606. * Copies the given float to the current Vector3 coordinates
  77607. * @param v defines the x, y, z and w coordinates of the operand
  77608. * @returns the current updated Vector3
  77609. */
  77610. setAll(v: number): Vector4;
  77611. /**
  77612. * Returns a new Vector4 set from the starting index of the given array.
  77613. * @param array the array to pull values from
  77614. * @param offset the offset into the array to start at
  77615. * @returns the new vector
  77616. */
  77617. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  77618. /**
  77619. * Updates the given vector "result" from the starting index of the given array.
  77620. * @param array the array to pull values from
  77621. * @param offset the offset into the array to start at
  77622. * @param result the vector to store the result in
  77623. */
  77624. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  77625. /**
  77626. * Updates the given vector "result" from the starting index of the given Float32Array.
  77627. * @param array the array to pull values from
  77628. * @param offset the offset into the array to start at
  77629. * @param result the vector to store the result in
  77630. */
  77631. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  77632. /**
  77633. * Updates the given vector "result" coordinates from the given floats.
  77634. * @param x float to set from
  77635. * @param y float to set from
  77636. * @param z float to set from
  77637. * @param w float to set from
  77638. * @param result the vector to the floats in
  77639. */
  77640. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  77641. /**
  77642. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  77643. * @returns the new vector
  77644. */
  77645. static Zero(): Vector4;
  77646. /**
  77647. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  77648. * @returns the new vector
  77649. */
  77650. static One(): Vector4;
  77651. /**
  77652. * Returns a new normalized Vector4 from the given one.
  77653. * @param vector the vector to normalize
  77654. * @returns the vector
  77655. */
  77656. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  77657. /**
  77658. * Updates the given vector "result" from the normalization of the given one.
  77659. * @param vector the vector to normalize
  77660. * @param result the vector to store the result in
  77661. */
  77662. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  77663. /**
  77664. * Returns a vector with the minimum values from the left and right vectors
  77665. * @param left left vector to minimize
  77666. * @param right right vector to minimize
  77667. * @returns a new vector with the minimum of the left and right vector values
  77668. */
  77669. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  77670. /**
  77671. * Returns a vector with the maximum values from the left and right vectors
  77672. * @param left left vector to maximize
  77673. * @param right right vector to maximize
  77674. * @returns a new vector with the maximum of the left and right vector values
  77675. */
  77676. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  77677. /**
  77678. * Returns the distance (float) between the vectors "value1" and "value2".
  77679. * @param value1 value to calulate the distance between
  77680. * @param value2 value to calulate the distance between
  77681. * @return the distance between the two vectors
  77682. */
  77683. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  77684. /**
  77685. * Returns the squared distance (float) between the vectors "value1" and "value2".
  77686. * @param value1 value to calulate the distance between
  77687. * @param value2 value to calulate the distance between
  77688. * @return the distance between the two vectors squared
  77689. */
  77690. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  77691. /**
  77692. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  77693. * @param value1 value to calulate the center between
  77694. * @param value2 value to calulate the center between
  77695. * @return the center between the two vectors
  77696. */
  77697. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  77698. /**
  77699. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  77700. * This methods computes transformed normalized direction vectors only.
  77701. * @param vector the vector to transform
  77702. * @param transformation the transformation matrix to apply
  77703. * @returns the new vector
  77704. */
  77705. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  77706. /**
  77707. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  77708. * This methods computes transformed normalized direction vectors only.
  77709. * @param vector the vector to transform
  77710. * @param transformation the transformation matrix to apply
  77711. * @param result the vector to store the result in
  77712. */
  77713. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  77714. /**
  77715. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  77716. * This methods computes transformed normalized direction vectors only.
  77717. * @param x value to transform
  77718. * @param y value to transform
  77719. * @param z value to transform
  77720. * @param w value to transform
  77721. * @param transformation the transformation matrix to apply
  77722. * @param result the vector to store the results in
  77723. */
  77724. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  77725. /**
  77726. * Creates a new Vector4 from a Vector3
  77727. * @param source defines the source data
  77728. * @param w defines the 4th component (default is 0)
  77729. * @returns a new Vector4
  77730. */
  77731. static FromVector3(source: Vector3, w?: number): Vector4;
  77732. }
  77733. /**
  77734. * Class used to store quaternion data
  77735. * @see https://en.wikipedia.org/wiki/Quaternion
  77736. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  77737. */
  77738. export class Quaternion {
  77739. /** defines the first component (0 by default) */
  77740. x: number;
  77741. /** defines the second component (0 by default) */
  77742. y: number;
  77743. /** defines the third component (0 by default) */
  77744. z: number;
  77745. /** defines the fourth component (1.0 by default) */
  77746. w: number;
  77747. /**
  77748. * Creates a new Quaternion from the given floats
  77749. * @param x defines the first component (0 by default)
  77750. * @param y defines the second component (0 by default)
  77751. * @param z defines the third component (0 by default)
  77752. * @param w defines the fourth component (1.0 by default)
  77753. */
  77754. constructor(
  77755. /** defines the first component (0 by default) */
  77756. x?: number,
  77757. /** defines the second component (0 by default) */
  77758. y?: number,
  77759. /** defines the third component (0 by default) */
  77760. z?: number,
  77761. /** defines the fourth component (1.0 by default) */
  77762. w?: number);
  77763. /**
  77764. * Gets a string representation for the current quaternion
  77765. * @returns a string with the Quaternion coordinates
  77766. */
  77767. toString(): string;
  77768. /**
  77769. * Gets the class name of the quaternion
  77770. * @returns the string "Quaternion"
  77771. */
  77772. getClassName(): string;
  77773. /**
  77774. * Gets a hash code for this quaternion
  77775. * @returns the quaternion hash code
  77776. */
  77777. getHashCode(): number;
  77778. /**
  77779. * Copy the quaternion to an array
  77780. * @returns a new array populated with 4 elements from the quaternion coordinates
  77781. */
  77782. asArray(): number[];
  77783. /**
  77784. * Check if two quaternions are equals
  77785. * @param otherQuaternion defines the second operand
  77786. * @return true if the current quaternion and the given one coordinates are strictly equals
  77787. */
  77788. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  77789. /**
  77790. * Gets a boolean if two quaternions are equals (using an epsilon value)
  77791. * @param otherQuaternion defines the other quaternion
  77792. * @param epsilon defines the minimal distance to consider equality
  77793. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  77794. */
  77795. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  77796. /**
  77797. * Clone the current quaternion
  77798. * @returns a new quaternion copied from the current one
  77799. */
  77800. clone(): Quaternion;
  77801. /**
  77802. * Copy a quaternion to the current one
  77803. * @param other defines the other quaternion
  77804. * @returns the updated current quaternion
  77805. */
  77806. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  77807. /**
  77808. * Updates the current quaternion with the given float coordinates
  77809. * @param x defines the x coordinate
  77810. * @param y defines the y coordinate
  77811. * @param z defines the z coordinate
  77812. * @param w defines the w coordinate
  77813. * @returns the updated current quaternion
  77814. */
  77815. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  77816. /**
  77817. * Updates the current quaternion from the given float coordinates
  77818. * @param x defines the x coordinate
  77819. * @param y defines the y coordinate
  77820. * @param z defines the z coordinate
  77821. * @param w defines the w coordinate
  77822. * @returns the updated current quaternion
  77823. */
  77824. set(x: number, y: number, z: number, w: number): Quaternion;
  77825. /**
  77826. * Adds two quaternions
  77827. * @param other defines the second operand
  77828. * @returns a new quaternion as the addition result of the given one and the current quaternion
  77829. */
  77830. add(other: DeepImmutable<Quaternion>): Quaternion;
  77831. /**
  77832. * Add a quaternion to the current one
  77833. * @param other defines the quaternion to add
  77834. * @returns the current quaternion
  77835. */
  77836. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  77837. /**
  77838. * Subtract two quaternions
  77839. * @param other defines the second operand
  77840. * @returns a new quaternion as the subtraction result of the given one from the current one
  77841. */
  77842. subtract(other: Quaternion): Quaternion;
  77843. /**
  77844. * Multiplies the current quaternion by a scale factor
  77845. * @param value defines the scale factor
  77846. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  77847. */
  77848. scale(value: number): Quaternion;
  77849. /**
  77850. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  77851. * @param scale defines the scale factor
  77852. * @param result defines the Quaternion object where to store the result
  77853. * @returns the unmodified current quaternion
  77854. */
  77855. scaleToRef(scale: number, result: Quaternion): Quaternion;
  77856. /**
  77857. * Multiplies in place the current quaternion by a scale factor
  77858. * @param value defines the scale factor
  77859. * @returns the current modified quaternion
  77860. */
  77861. scaleInPlace(value: number): Quaternion;
  77862. /**
  77863. * Scale the current quaternion values by a factor and add the result to a given quaternion
  77864. * @param scale defines the scale factor
  77865. * @param result defines the Quaternion object where to store the result
  77866. * @returns the unmodified current quaternion
  77867. */
  77868. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  77869. /**
  77870. * Multiplies two quaternions
  77871. * @param q1 defines the second operand
  77872. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  77873. */
  77874. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  77875. /**
  77876. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  77877. * @param q1 defines the second operand
  77878. * @param result defines the target quaternion
  77879. * @returns the current quaternion
  77880. */
  77881. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  77882. /**
  77883. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  77884. * @param q1 defines the second operand
  77885. * @returns the currentupdated quaternion
  77886. */
  77887. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  77888. /**
  77889. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  77890. * @param ref defines the target quaternion
  77891. * @returns the current quaternion
  77892. */
  77893. conjugateToRef(ref: Quaternion): Quaternion;
  77894. /**
  77895. * Conjugates in place (1-q) the current quaternion
  77896. * @returns the current updated quaternion
  77897. */
  77898. conjugateInPlace(): Quaternion;
  77899. /**
  77900. * Conjugates in place (1-q) the current quaternion
  77901. * @returns a new quaternion
  77902. */
  77903. conjugate(): Quaternion;
  77904. /**
  77905. * Gets length of current quaternion
  77906. * @returns the quaternion length (float)
  77907. */
  77908. length(): number;
  77909. /**
  77910. * Normalize in place the current quaternion
  77911. * @returns the current updated quaternion
  77912. */
  77913. normalize(): Quaternion;
  77914. /**
  77915. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  77916. * @param order is a reserved parameter and is ignore for now
  77917. * @returns a new Vector3 containing the Euler angles
  77918. */
  77919. toEulerAngles(order?: string): Vector3;
  77920. /**
  77921. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  77922. * @param result defines the vector which will be filled with the Euler angles
  77923. * @param order is a reserved parameter and is ignore for now
  77924. * @returns the current unchanged quaternion
  77925. */
  77926. toEulerAnglesToRef(result: Vector3): Quaternion;
  77927. /**
  77928. * Updates the given rotation matrix with the current quaternion values
  77929. * @param result defines the target matrix
  77930. * @returns the current unchanged quaternion
  77931. */
  77932. toRotationMatrix(result: Matrix): Quaternion;
  77933. /**
  77934. * Updates the current quaternion from the given rotation matrix values
  77935. * @param matrix defines the source matrix
  77936. * @returns the current updated quaternion
  77937. */
  77938. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  77939. /**
  77940. * Creates a new quaternion from a rotation matrix
  77941. * @param matrix defines the source matrix
  77942. * @returns a new quaternion created from the given rotation matrix values
  77943. */
  77944. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  77945. /**
  77946. * Updates the given quaternion with the given rotation matrix values
  77947. * @param matrix defines the source matrix
  77948. * @param result defines the target quaternion
  77949. */
  77950. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  77951. /**
  77952. * Returns the dot product (float) between the quaternions "left" and "right"
  77953. * @param left defines the left operand
  77954. * @param right defines the right operand
  77955. * @returns the dot product
  77956. */
  77957. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  77958. /**
  77959. * Checks if the two quaternions are close to each other
  77960. * @param quat0 defines the first quaternion to check
  77961. * @param quat1 defines the second quaternion to check
  77962. * @returns true if the two quaternions are close to each other
  77963. */
  77964. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  77965. /**
  77966. * Creates an empty quaternion
  77967. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  77968. */
  77969. static Zero(): Quaternion;
  77970. /**
  77971. * Inverse a given quaternion
  77972. * @param q defines the source quaternion
  77973. * @returns a new quaternion as the inverted current quaternion
  77974. */
  77975. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  77976. /**
  77977. * Inverse a given quaternion
  77978. * @param q defines the source quaternion
  77979. * @param result the quaternion the result will be stored in
  77980. * @returns the result quaternion
  77981. */
  77982. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  77983. /**
  77984. * Creates an identity quaternion
  77985. * @returns the identity quaternion
  77986. */
  77987. static Identity(): Quaternion;
  77988. /**
  77989. * Gets a boolean indicating if the given quaternion is identity
  77990. * @param quaternion defines the quaternion to check
  77991. * @returns true if the quaternion is identity
  77992. */
  77993. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  77994. /**
  77995. * Creates a quaternion from a rotation around an axis
  77996. * @param axis defines the axis to use
  77997. * @param angle defines the angle to use
  77998. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  77999. */
  78000. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  78001. /**
  78002. * Creates a rotation around an axis and stores it into the given quaternion
  78003. * @param axis defines the axis to use
  78004. * @param angle defines the angle to use
  78005. * @param result defines the target quaternion
  78006. * @returns the target quaternion
  78007. */
  78008. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  78009. /**
  78010. * Creates a new quaternion from data stored into an array
  78011. * @param array defines the data source
  78012. * @param offset defines the offset in the source array where the data starts
  78013. * @returns a new quaternion
  78014. */
  78015. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  78016. /**
  78017. * Updates the given quaternion "result" from the starting index of the given array.
  78018. * @param array the array to pull values from
  78019. * @param offset the offset into the array to start at
  78020. * @param result the quaternion to store the result in
  78021. */
  78022. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  78023. /**
  78024. * Create a quaternion from Euler rotation angles
  78025. * @param x Pitch
  78026. * @param y Yaw
  78027. * @param z Roll
  78028. * @returns the new Quaternion
  78029. */
  78030. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  78031. /**
  78032. * Updates a quaternion from Euler rotation angles
  78033. * @param x Pitch
  78034. * @param y Yaw
  78035. * @param z Roll
  78036. * @param result the quaternion to store the result
  78037. * @returns the updated quaternion
  78038. */
  78039. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  78040. /**
  78041. * Create a quaternion from Euler rotation vector
  78042. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  78043. * @returns the new Quaternion
  78044. */
  78045. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  78046. /**
  78047. * Updates a quaternion from Euler rotation vector
  78048. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  78049. * @param result the quaternion to store the result
  78050. * @returns the updated quaternion
  78051. */
  78052. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  78053. /**
  78054. * Creates a new quaternion from the given Euler float angles (y, x, z)
  78055. * @param yaw defines the rotation around Y axis
  78056. * @param pitch defines the rotation around X axis
  78057. * @param roll defines the rotation around Z axis
  78058. * @returns the new quaternion
  78059. */
  78060. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  78061. /**
  78062. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  78063. * @param yaw defines the rotation around Y axis
  78064. * @param pitch defines the rotation around X axis
  78065. * @param roll defines the rotation around Z axis
  78066. * @param result defines the target quaternion
  78067. */
  78068. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  78069. /**
  78070. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  78071. * @param alpha defines the rotation around first axis
  78072. * @param beta defines the rotation around second axis
  78073. * @param gamma defines the rotation around third axis
  78074. * @returns the new quaternion
  78075. */
  78076. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  78077. /**
  78078. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  78079. * @param alpha defines the rotation around first axis
  78080. * @param beta defines the rotation around second axis
  78081. * @param gamma defines the rotation around third axis
  78082. * @param result defines the target quaternion
  78083. */
  78084. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  78085. /**
  78086. * 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)
  78087. * @param axis1 defines the first axis
  78088. * @param axis2 defines the second axis
  78089. * @param axis3 defines the third axis
  78090. * @returns the new quaternion
  78091. */
  78092. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  78093. /**
  78094. * 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
  78095. * @param axis1 defines the first axis
  78096. * @param axis2 defines the second axis
  78097. * @param axis3 defines the third axis
  78098. * @param ref defines the target quaternion
  78099. */
  78100. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  78101. /**
  78102. * Interpolates between two quaternions
  78103. * @param left defines first quaternion
  78104. * @param right defines second quaternion
  78105. * @param amount defines the gradient to use
  78106. * @returns the new interpolated quaternion
  78107. */
  78108. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  78109. /**
  78110. * Interpolates between two quaternions and stores it into a target quaternion
  78111. * @param left defines first quaternion
  78112. * @param right defines second quaternion
  78113. * @param amount defines the gradient to use
  78114. * @param result defines the target quaternion
  78115. */
  78116. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  78117. /**
  78118. * Interpolate between two quaternions using Hermite interpolation
  78119. * @param value1 defines first quaternion
  78120. * @param tangent1 defines the incoming tangent
  78121. * @param value2 defines second quaternion
  78122. * @param tangent2 defines the outgoing tangent
  78123. * @param amount defines the target quaternion
  78124. * @returns the new interpolated quaternion
  78125. */
  78126. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  78127. }
  78128. /**
  78129. * Class used to store matrix data (4x4)
  78130. */
  78131. export class Matrix {
  78132. private static _updateFlagSeed;
  78133. private static _identityReadOnly;
  78134. private _isIdentity;
  78135. private _isIdentityDirty;
  78136. private _isIdentity3x2;
  78137. private _isIdentity3x2Dirty;
  78138. /**
  78139. * Gets the update flag of the matrix which is an unique number for the matrix.
  78140. * It will be incremented every time the matrix data change.
  78141. * You can use it to speed the comparison between two versions of the same matrix.
  78142. */
  78143. updateFlag: number;
  78144. private readonly _m;
  78145. /**
  78146. * Gets the internal data of the matrix
  78147. */
  78148. get m(): DeepImmutable<Float32Array>;
  78149. /** @hidden */
  78150. _markAsUpdated(): void;
  78151. /** @hidden */
  78152. private _updateIdentityStatus;
  78153. /**
  78154. * Creates an empty matrix (filled with zeros)
  78155. */
  78156. constructor();
  78157. /**
  78158. * Check if the current matrix is identity
  78159. * @returns true is the matrix is the identity matrix
  78160. */
  78161. isIdentity(): boolean;
  78162. /**
  78163. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  78164. * @returns true is the matrix is the identity matrix
  78165. */
  78166. isIdentityAs3x2(): boolean;
  78167. /**
  78168. * Gets the determinant of the matrix
  78169. * @returns the matrix determinant
  78170. */
  78171. determinant(): number;
  78172. /**
  78173. * Returns the matrix as a Float32Array
  78174. * @returns the matrix underlying array
  78175. */
  78176. toArray(): DeepImmutable<Float32Array>;
  78177. /**
  78178. * Returns the matrix as a Float32Array
  78179. * @returns the matrix underlying array.
  78180. */
  78181. asArray(): DeepImmutable<Float32Array>;
  78182. /**
  78183. * Inverts the current matrix in place
  78184. * @returns the current inverted matrix
  78185. */
  78186. invert(): Matrix;
  78187. /**
  78188. * Sets all the matrix elements to zero
  78189. * @returns the current matrix
  78190. */
  78191. reset(): Matrix;
  78192. /**
  78193. * Adds the current matrix with a second one
  78194. * @param other defines the matrix to add
  78195. * @returns a new matrix as the addition of the current matrix and the given one
  78196. */
  78197. add(other: DeepImmutable<Matrix>): Matrix;
  78198. /**
  78199. * Sets the given matrix "result" to the addition of the current matrix and the given one
  78200. * @param other defines the matrix to add
  78201. * @param result defines the target matrix
  78202. * @returns the current matrix
  78203. */
  78204. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  78205. /**
  78206. * Adds in place the given matrix to the current matrix
  78207. * @param other defines the second operand
  78208. * @returns the current updated matrix
  78209. */
  78210. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  78211. /**
  78212. * Sets the given matrix to the current inverted Matrix
  78213. * @param other defines the target matrix
  78214. * @returns the unmodified current matrix
  78215. */
  78216. invertToRef(other: Matrix): Matrix;
  78217. /**
  78218. * add a value at the specified position in the current Matrix
  78219. * @param index the index of the value within the matrix. between 0 and 15.
  78220. * @param value the value to be added
  78221. * @returns the current updated matrix
  78222. */
  78223. addAtIndex(index: number, value: number): Matrix;
  78224. /**
  78225. * mutiply the specified position in the current Matrix by a value
  78226. * @param index the index of the value within the matrix. between 0 and 15.
  78227. * @param value the value to be added
  78228. * @returns the current updated matrix
  78229. */
  78230. multiplyAtIndex(index: number, value: number): Matrix;
  78231. /**
  78232. * Inserts the translation vector (using 3 floats) in the current matrix
  78233. * @param x defines the 1st component of the translation
  78234. * @param y defines the 2nd component of the translation
  78235. * @param z defines the 3rd component of the translation
  78236. * @returns the current updated matrix
  78237. */
  78238. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  78239. /**
  78240. * Adds the translation vector (using 3 floats) in the current matrix
  78241. * @param x defines the 1st component of the translation
  78242. * @param y defines the 2nd component of the translation
  78243. * @param z defines the 3rd component of the translation
  78244. * @returns the current updated matrix
  78245. */
  78246. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  78247. /**
  78248. * Inserts the translation vector in the current matrix
  78249. * @param vector3 defines the translation to insert
  78250. * @returns the current updated matrix
  78251. */
  78252. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  78253. /**
  78254. * Gets the translation value of the current matrix
  78255. * @returns a new Vector3 as the extracted translation from the matrix
  78256. */
  78257. getTranslation(): Vector3;
  78258. /**
  78259. * Fill a Vector3 with the extracted translation from the matrix
  78260. * @param result defines the Vector3 where to store the translation
  78261. * @returns the current matrix
  78262. */
  78263. getTranslationToRef(result: Vector3): Matrix;
  78264. /**
  78265. * Remove rotation and scaling part from the matrix
  78266. * @returns the updated matrix
  78267. */
  78268. removeRotationAndScaling(): Matrix;
  78269. /**
  78270. * Multiply two matrices
  78271. * @param other defines the second operand
  78272. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  78273. */
  78274. multiply(other: DeepImmutable<Matrix>): Matrix;
  78275. /**
  78276. * Copy the current matrix from the given one
  78277. * @param other defines the source matrix
  78278. * @returns the current updated matrix
  78279. */
  78280. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  78281. /**
  78282. * Populates the given array from the starting index with the current matrix values
  78283. * @param array defines the target array
  78284. * @param offset defines the offset in the target array where to start storing values
  78285. * @returns the current matrix
  78286. */
  78287. copyToArray(array: Float32Array, offset?: number): Matrix;
  78288. /**
  78289. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  78290. * @param other defines the second operand
  78291. * @param result defines the matrix where to store the multiplication
  78292. * @returns the current matrix
  78293. */
  78294. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  78295. /**
  78296. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  78297. * @param other defines the second operand
  78298. * @param result defines the array where to store the multiplication
  78299. * @param offset defines the offset in the target array where to start storing values
  78300. * @returns the current matrix
  78301. */
  78302. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  78303. /**
  78304. * Check equality between this matrix and a second one
  78305. * @param value defines the second matrix to compare
  78306. * @returns true is the current matrix and the given one values are strictly equal
  78307. */
  78308. equals(value: DeepImmutable<Matrix>): boolean;
  78309. /**
  78310. * Clone the current matrix
  78311. * @returns a new matrix from the current matrix
  78312. */
  78313. clone(): Matrix;
  78314. /**
  78315. * Returns the name of the current matrix class
  78316. * @returns the string "Matrix"
  78317. */
  78318. getClassName(): string;
  78319. /**
  78320. * Gets the hash code of the current matrix
  78321. * @returns the hash code
  78322. */
  78323. getHashCode(): number;
  78324. /**
  78325. * Decomposes the current Matrix into a translation, rotation and scaling components
  78326. * @param scale defines the scale vector3 given as a reference to update
  78327. * @param rotation defines the rotation quaternion given as a reference to update
  78328. * @param translation defines the translation vector3 given as a reference to update
  78329. * @returns true if operation was successful
  78330. */
  78331. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  78332. /**
  78333. * Gets specific row of the matrix
  78334. * @param index defines the number of the row to get
  78335. * @returns the index-th row of the current matrix as a new Vector4
  78336. */
  78337. getRow(index: number): Nullable<Vector4>;
  78338. /**
  78339. * Sets the index-th row of the current matrix to the vector4 values
  78340. * @param index defines the number of the row to set
  78341. * @param row defines the target vector4
  78342. * @returns the updated current matrix
  78343. */
  78344. setRow(index: number, row: Vector4): Matrix;
  78345. /**
  78346. * Compute the transpose of the matrix
  78347. * @returns the new transposed matrix
  78348. */
  78349. transpose(): Matrix;
  78350. /**
  78351. * Compute the transpose of the matrix and store it in a given matrix
  78352. * @param result defines the target matrix
  78353. * @returns the current matrix
  78354. */
  78355. transposeToRef(result: Matrix): Matrix;
  78356. /**
  78357. * Sets the index-th row of the current matrix with the given 4 x float values
  78358. * @param index defines the row index
  78359. * @param x defines the x component to set
  78360. * @param y defines the y component to set
  78361. * @param z defines the z component to set
  78362. * @param w defines the w component to set
  78363. * @returns the updated current matrix
  78364. */
  78365. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  78366. /**
  78367. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  78368. * @param scale defines the scale factor
  78369. * @returns a new matrix
  78370. */
  78371. scale(scale: number): Matrix;
  78372. /**
  78373. * Scale the current matrix values by a factor to a given result matrix
  78374. * @param scale defines the scale factor
  78375. * @param result defines the matrix to store the result
  78376. * @returns the current matrix
  78377. */
  78378. scaleToRef(scale: number, result: Matrix): Matrix;
  78379. /**
  78380. * Scale the current matrix values by a factor and add the result to a given matrix
  78381. * @param scale defines the scale factor
  78382. * @param result defines the Matrix to store the result
  78383. * @returns the current matrix
  78384. */
  78385. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  78386. /**
  78387. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  78388. * @param ref matrix to store the result
  78389. */
  78390. toNormalMatrix(ref: Matrix): void;
  78391. /**
  78392. * Gets only rotation part of the current matrix
  78393. * @returns a new matrix sets to the extracted rotation matrix from the current one
  78394. */
  78395. getRotationMatrix(): Matrix;
  78396. /**
  78397. * Extracts the rotation matrix from the current one and sets it as the given "result"
  78398. * @param result defines the target matrix to store data to
  78399. * @returns the current matrix
  78400. */
  78401. getRotationMatrixToRef(result: Matrix): Matrix;
  78402. /**
  78403. * Toggles model matrix from being right handed to left handed in place and vice versa
  78404. */
  78405. toggleModelMatrixHandInPlace(): void;
  78406. /**
  78407. * Toggles projection matrix from being right handed to left handed in place and vice versa
  78408. */
  78409. toggleProjectionMatrixHandInPlace(): void;
  78410. /**
  78411. * Creates a matrix from an array
  78412. * @param array defines the source array
  78413. * @param offset defines an offset in the source array
  78414. * @returns a new Matrix set from the starting index of the given array
  78415. */
  78416. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  78417. /**
  78418. * Copy the content of an array into a given matrix
  78419. * @param array defines the source array
  78420. * @param offset defines an offset in the source array
  78421. * @param result defines the target matrix
  78422. */
  78423. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  78424. /**
  78425. * Stores an array into a matrix after having multiplied each component by a given factor
  78426. * @param array defines the source array
  78427. * @param offset defines the offset in the source array
  78428. * @param scale defines the scaling factor
  78429. * @param result defines the target matrix
  78430. */
  78431. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  78432. /**
  78433. * Gets an identity matrix that must not be updated
  78434. */
  78435. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  78436. /**
  78437. * Stores a list of values (16) inside a given matrix
  78438. * @param initialM11 defines 1st value of 1st row
  78439. * @param initialM12 defines 2nd value of 1st row
  78440. * @param initialM13 defines 3rd value of 1st row
  78441. * @param initialM14 defines 4th value of 1st row
  78442. * @param initialM21 defines 1st value of 2nd row
  78443. * @param initialM22 defines 2nd value of 2nd row
  78444. * @param initialM23 defines 3rd value of 2nd row
  78445. * @param initialM24 defines 4th value of 2nd row
  78446. * @param initialM31 defines 1st value of 3rd row
  78447. * @param initialM32 defines 2nd value of 3rd row
  78448. * @param initialM33 defines 3rd value of 3rd row
  78449. * @param initialM34 defines 4th value of 3rd row
  78450. * @param initialM41 defines 1st value of 4th row
  78451. * @param initialM42 defines 2nd value of 4th row
  78452. * @param initialM43 defines 3rd value of 4th row
  78453. * @param initialM44 defines 4th value of 4th row
  78454. * @param result defines the target matrix
  78455. */
  78456. 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;
  78457. /**
  78458. * Creates new matrix from a list of values (16)
  78459. * @param initialM11 defines 1st value of 1st row
  78460. * @param initialM12 defines 2nd value of 1st row
  78461. * @param initialM13 defines 3rd value of 1st row
  78462. * @param initialM14 defines 4th value of 1st row
  78463. * @param initialM21 defines 1st value of 2nd row
  78464. * @param initialM22 defines 2nd value of 2nd row
  78465. * @param initialM23 defines 3rd value of 2nd row
  78466. * @param initialM24 defines 4th value of 2nd row
  78467. * @param initialM31 defines 1st value of 3rd row
  78468. * @param initialM32 defines 2nd value of 3rd row
  78469. * @param initialM33 defines 3rd value of 3rd row
  78470. * @param initialM34 defines 4th value of 3rd row
  78471. * @param initialM41 defines 1st value of 4th row
  78472. * @param initialM42 defines 2nd value of 4th row
  78473. * @param initialM43 defines 3rd value of 4th row
  78474. * @param initialM44 defines 4th value of 4th row
  78475. * @returns the new matrix
  78476. */
  78477. 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;
  78478. /**
  78479. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  78480. * @param scale defines the scale vector3
  78481. * @param rotation defines the rotation quaternion
  78482. * @param translation defines the translation vector3
  78483. * @returns a new matrix
  78484. */
  78485. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  78486. /**
  78487. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  78488. * @param scale defines the scale vector3
  78489. * @param rotation defines the rotation quaternion
  78490. * @param translation defines the translation vector3
  78491. * @param result defines the target matrix
  78492. */
  78493. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  78494. /**
  78495. * Creates a new identity matrix
  78496. * @returns a new identity matrix
  78497. */
  78498. static Identity(): Matrix;
  78499. /**
  78500. * Creates a new identity matrix and stores the result in a given matrix
  78501. * @param result defines the target matrix
  78502. */
  78503. static IdentityToRef(result: Matrix): void;
  78504. /**
  78505. * Creates a new zero matrix
  78506. * @returns a new zero matrix
  78507. */
  78508. static Zero(): Matrix;
  78509. /**
  78510. * Creates a new rotation matrix for "angle" radians around the X axis
  78511. * @param angle defines the angle (in radians) to use
  78512. * @return the new matrix
  78513. */
  78514. static RotationX(angle: number): Matrix;
  78515. /**
  78516. * Creates a new matrix as the invert of a given matrix
  78517. * @param source defines the source matrix
  78518. * @returns the new matrix
  78519. */
  78520. static Invert(source: DeepImmutable<Matrix>): Matrix;
  78521. /**
  78522. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  78523. * @param angle defines the angle (in radians) to use
  78524. * @param result defines the target matrix
  78525. */
  78526. static RotationXToRef(angle: number, result: Matrix): void;
  78527. /**
  78528. * Creates a new rotation matrix for "angle" radians around the Y axis
  78529. * @param angle defines the angle (in radians) to use
  78530. * @return the new matrix
  78531. */
  78532. static RotationY(angle: number): Matrix;
  78533. /**
  78534. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  78535. * @param angle defines the angle (in radians) to use
  78536. * @param result defines the target matrix
  78537. */
  78538. static RotationYToRef(angle: number, result: Matrix): void;
  78539. /**
  78540. * Creates a new rotation matrix for "angle" radians around the Z axis
  78541. * @param angle defines the angle (in radians) to use
  78542. * @return the new matrix
  78543. */
  78544. static RotationZ(angle: number): Matrix;
  78545. /**
  78546. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  78547. * @param angle defines the angle (in radians) to use
  78548. * @param result defines the target matrix
  78549. */
  78550. static RotationZToRef(angle: number, result: Matrix): void;
  78551. /**
  78552. * Creates a new rotation matrix for "angle" radians around the given axis
  78553. * @param axis defines the axis to use
  78554. * @param angle defines the angle (in radians) to use
  78555. * @return the new matrix
  78556. */
  78557. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  78558. /**
  78559. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  78560. * @param axis defines the axis to use
  78561. * @param angle defines the angle (in radians) to use
  78562. * @param result defines the target matrix
  78563. */
  78564. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  78565. /**
  78566. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  78567. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  78568. * @param from defines the vector to align
  78569. * @param to defines the vector to align to
  78570. * @param result defines the target matrix
  78571. */
  78572. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  78573. /**
  78574. * Creates a rotation matrix
  78575. * @param yaw defines the yaw angle in radians (Y axis)
  78576. * @param pitch defines the pitch angle in radians (X axis)
  78577. * @param roll defines the roll angle in radians (X axis)
  78578. * @returns the new rotation matrix
  78579. */
  78580. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  78581. /**
  78582. * Creates a rotation matrix and stores it in a given matrix
  78583. * @param yaw defines the yaw angle in radians (Y axis)
  78584. * @param pitch defines the pitch angle in radians (X axis)
  78585. * @param roll defines the roll angle in radians (X axis)
  78586. * @param result defines the target matrix
  78587. */
  78588. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  78589. /**
  78590. * Creates a scaling matrix
  78591. * @param x defines the scale factor on X axis
  78592. * @param y defines the scale factor on Y axis
  78593. * @param z defines the scale factor on Z axis
  78594. * @returns the new matrix
  78595. */
  78596. static Scaling(x: number, y: number, z: number): Matrix;
  78597. /**
  78598. * Creates a scaling matrix and stores it in a given matrix
  78599. * @param x defines the scale factor on X axis
  78600. * @param y defines the scale factor on Y axis
  78601. * @param z defines the scale factor on Z axis
  78602. * @param result defines the target matrix
  78603. */
  78604. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  78605. /**
  78606. * Creates a translation matrix
  78607. * @param x defines the translation on X axis
  78608. * @param y defines the translation on Y axis
  78609. * @param z defines the translationon Z axis
  78610. * @returns the new matrix
  78611. */
  78612. static Translation(x: number, y: number, z: number): Matrix;
  78613. /**
  78614. * Creates a translation matrix and stores it in a given matrix
  78615. * @param x defines the translation on X axis
  78616. * @param y defines the translation on Y axis
  78617. * @param z defines the translationon Z axis
  78618. * @param result defines the target matrix
  78619. */
  78620. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  78621. /**
  78622. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  78623. * @param startValue defines the start value
  78624. * @param endValue defines the end value
  78625. * @param gradient defines the gradient factor
  78626. * @returns the new matrix
  78627. */
  78628. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  78629. /**
  78630. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  78631. * @param startValue defines the start value
  78632. * @param endValue defines the end value
  78633. * @param gradient defines the gradient factor
  78634. * @param result defines the Matrix object where to store data
  78635. */
  78636. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  78637. /**
  78638. * Builds a new matrix whose values are computed by:
  78639. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  78640. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  78641. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  78642. * @param startValue defines the first matrix
  78643. * @param endValue defines the second matrix
  78644. * @param gradient defines the gradient between the two matrices
  78645. * @returns the new matrix
  78646. */
  78647. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  78648. /**
  78649. * Update a matrix to values which are computed by:
  78650. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  78651. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  78652. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  78653. * @param startValue defines the first matrix
  78654. * @param endValue defines the second matrix
  78655. * @param gradient defines the gradient between the two matrices
  78656. * @param result defines the target matrix
  78657. */
  78658. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  78659. /**
  78660. * 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"
  78661. * This function works in left handed mode
  78662. * @param eye defines the final position of the entity
  78663. * @param target defines where the entity should look at
  78664. * @param up defines the up vector for the entity
  78665. * @returns the new matrix
  78666. */
  78667. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  78668. /**
  78669. * 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".
  78670. * This function works in left handed mode
  78671. * @param eye defines the final position of the entity
  78672. * @param target defines where the entity should look at
  78673. * @param up defines the up vector for the entity
  78674. * @param result defines the target matrix
  78675. */
  78676. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  78677. /**
  78678. * 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"
  78679. * This function works in right handed mode
  78680. * @param eye defines the final position of the entity
  78681. * @param target defines where the entity should look at
  78682. * @param up defines the up vector for the entity
  78683. * @returns the new matrix
  78684. */
  78685. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  78686. /**
  78687. * 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".
  78688. * This function works in right handed mode
  78689. * @param eye defines the final position of the entity
  78690. * @param target defines where the entity should look at
  78691. * @param up defines the up vector for the entity
  78692. * @param result defines the target matrix
  78693. */
  78694. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  78695. /**
  78696. * Create a left-handed orthographic projection matrix
  78697. * @param width defines the viewport width
  78698. * @param height defines the viewport height
  78699. * @param znear defines the near clip plane
  78700. * @param zfar defines the far clip plane
  78701. * @returns a new matrix as a left-handed orthographic projection matrix
  78702. */
  78703. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  78704. /**
  78705. * Store a left-handed orthographic projection to a given matrix
  78706. * @param width defines the viewport width
  78707. * @param height defines the viewport height
  78708. * @param znear defines the near clip plane
  78709. * @param zfar defines the far clip plane
  78710. * @param result defines the target matrix
  78711. */
  78712. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  78713. /**
  78714. * Create a left-handed orthographic projection matrix
  78715. * @param left defines the viewport left coordinate
  78716. * @param right defines the viewport right coordinate
  78717. * @param bottom defines the viewport bottom coordinate
  78718. * @param top defines the viewport top coordinate
  78719. * @param znear defines the near clip plane
  78720. * @param zfar defines the far clip plane
  78721. * @returns a new matrix as a left-handed orthographic projection matrix
  78722. */
  78723. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  78724. /**
  78725. * Stores a left-handed orthographic projection into a given matrix
  78726. * @param left defines the viewport left coordinate
  78727. * @param right defines the viewport right coordinate
  78728. * @param bottom defines the viewport bottom coordinate
  78729. * @param top defines the viewport top coordinate
  78730. * @param znear defines the near clip plane
  78731. * @param zfar defines the far clip plane
  78732. * @param result defines the target matrix
  78733. */
  78734. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  78735. /**
  78736. * Creates a right-handed orthographic projection matrix
  78737. * @param left defines the viewport left coordinate
  78738. * @param right defines the viewport right coordinate
  78739. * @param bottom defines the viewport bottom coordinate
  78740. * @param top defines the viewport top coordinate
  78741. * @param znear defines the near clip plane
  78742. * @param zfar defines the far clip plane
  78743. * @returns a new matrix as a right-handed orthographic projection matrix
  78744. */
  78745. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  78746. /**
  78747. * Stores a right-handed orthographic projection into a given matrix
  78748. * @param left defines the viewport left coordinate
  78749. * @param right defines the viewport right coordinate
  78750. * @param bottom defines the viewport bottom coordinate
  78751. * @param top defines the viewport top coordinate
  78752. * @param znear defines the near clip plane
  78753. * @param zfar defines the far clip plane
  78754. * @param result defines the target matrix
  78755. */
  78756. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  78757. /**
  78758. * Creates a left-handed perspective projection matrix
  78759. * @param width defines the viewport width
  78760. * @param height defines the viewport height
  78761. * @param znear defines the near clip plane
  78762. * @param zfar defines the far clip plane
  78763. * @returns a new matrix as a left-handed perspective projection matrix
  78764. */
  78765. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  78766. /**
  78767. * Creates a left-handed perspective projection matrix
  78768. * @param fov defines the horizontal field of view
  78769. * @param aspect defines the aspect ratio
  78770. * @param znear defines the near clip plane
  78771. * @param zfar defines the far clip plane
  78772. * @returns a new matrix as a left-handed perspective projection matrix
  78773. */
  78774. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  78775. /**
  78776. * Stores a left-handed perspective projection into a given matrix
  78777. * @param fov defines the horizontal field of view
  78778. * @param aspect defines the aspect ratio
  78779. * @param znear defines the near clip plane
  78780. * @param zfar defines the far clip plane
  78781. * @param result defines the target matrix
  78782. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  78783. */
  78784. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  78785. /**
  78786. * Stores a left-handed perspective projection into a given matrix with depth reversed
  78787. * @param fov defines the horizontal field of view
  78788. * @param aspect defines the aspect ratio
  78789. * @param znear defines the near clip plane
  78790. * @param zfar not used as infinity is used as far clip
  78791. * @param result defines the target matrix
  78792. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  78793. */
  78794. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  78795. /**
  78796. * Creates a right-handed perspective projection matrix
  78797. * @param fov defines the horizontal field of view
  78798. * @param aspect defines the aspect ratio
  78799. * @param znear defines the near clip plane
  78800. * @param zfar defines the far clip plane
  78801. * @returns a new matrix as a right-handed perspective projection matrix
  78802. */
  78803. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  78804. /**
  78805. * Stores a right-handed perspective projection into a given matrix
  78806. * @param fov defines the horizontal field of view
  78807. * @param aspect defines the aspect ratio
  78808. * @param znear defines the near clip plane
  78809. * @param zfar defines the far clip plane
  78810. * @param result defines the target matrix
  78811. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  78812. */
  78813. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  78814. /**
  78815. * Stores a right-handed perspective projection into a given matrix
  78816. * @param fov defines the horizontal field of view
  78817. * @param aspect defines the aspect ratio
  78818. * @param znear defines the near clip plane
  78819. * @param zfar not used as infinity is used as far clip
  78820. * @param result defines the target matrix
  78821. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  78822. */
  78823. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  78824. /**
  78825. * Stores a perspective projection for WebVR info a given matrix
  78826. * @param fov defines the field of view
  78827. * @param znear defines the near clip plane
  78828. * @param zfar defines the far clip plane
  78829. * @param result defines the target matrix
  78830. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  78831. */
  78832. static PerspectiveFovWebVRToRef(fov: {
  78833. upDegrees: number;
  78834. downDegrees: number;
  78835. leftDegrees: number;
  78836. rightDegrees: number;
  78837. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  78838. /**
  78839. * Computes a complete transformation matrix
  78840. * @param viewport defines the viewport to use
  78841. * @param world defines the world matrix
  78842. * @param view defines the view matrix
  78843. * @param projection defines the projection matrix
  78844. * @param zmin defines the near clip plane
  78845. * @param zmax defines the far clip plane
  78846. * @returns the transformation matrix
  78847. */
  78848. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  78849. /**
  78850. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  78851. * @param matrix defines the matrix to use
  78852. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  78853. */
  78854. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  78855. /**
  78856. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  78857. * @param matrix defines the matrix to use
  78858. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  78859. */
  78860. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  78861. /**
  78862. * Compute the transpose of a given matrix
  78863. * @param matrix defines the matrix to transpose
  78864. * @returns the new matrix
  78865. */
  78866. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  78867. /**
  78868. * Compute the transpose of a matrix and store it in a target matrix
  78869. * @param matrix defines the matrix to transpose
  78870. * @param result defines the target matrix
  78871. */
  78872. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  78873. /**
  78874. * Computes a reflection matrix from a plane
  78875. * @param plane defines the reflection plane
  78876. * @returns a new matrix
  78877. */
  78878. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  78879. /**
  78880. * Computes a reflection matrix from a plane
  78881. * @param plane defines the reflection plane
  78882. * @param result defines the target matrix
  78883. */
  78884. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  78885. /**
  78886. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  78887. * @param xaxis defines the value of the 1st axis
  78888. * @param yaxis defines the value of the 2nd axis
  78889. * @param zaxis defines the value of the 3rd axis
  78890. * @param result defines the target matrix
  78891. */
  78892. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  78893. /**
  78894. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  78895. * @param quat defines the quaternion to use
  78896. * @param result defines the target matrix
  78897. */
  78898. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  78899. }
  78900. /**
  78901. * @hidden
  78902. */
  78903. export class TmpVectors {
  78904. static Vector2: Vector2[];
  78905. static Vector3: Vector3[];
  78906. static Vector4: Vector4[];
  78907. static Quaternion: Quaternion[];
  78908. static Matrix: Matrix[];
  78909. }
  78910. }
  78911. declare module BABYLON {
  78912. /**
  78913. * Defines potential orientation for back face culling
  78914. */
  78915. export enum Orientation {
  78916. /**
  78917. * Clockwise
  78918. */
  78919. CW = 0,
  78920. /** Counter clockwise */
  78921. CCW = 1
  78922. }
  78923. /** Class used to represent a Bezier curve */
  78924. export class BezierCurve {
  78925. /**
  78926. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  78927. * @param t defines the time
  78928. * @param x1 defines the left coordinate on X axis
  78929. * @param y1 defines the left coordinate on Y axis
  78930. * @param x2 defines the right coordinate on X axis
  78931. * @param y2 defines the right coordinate on Y axis
  78932. * @returns the interpolated value
  78933. */
  78934. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  78935. }
  78936. /**
  78937. * Defines angle representation
  78938. */
  78939. export class Angle {
  78940. private _radians;
  78941. /**
  78942. * Creates an Angle object of "radians" radians (float).
  78943. * @param radians the angle in radians
  78944. */
  78945. constructor(radians: number);
  78946. /**
  78947. * Get value in degrees
  78948. * @returns the Angle value in degrees (float)
  78949. */
  78950. degrees(): number;
  78951. /**
  78952. * Get value in radians
  78953. * @returns the Angle value in radians (float)
  78954. */
  78955. radians(): number;
  78956. /**
  78957. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  78958. * @param a defines first vector
  78959. * @param b defines second vector
  78960. * @returns a new Angle
  78961. */
  78962. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  78963. /**
  78964. * Gets a new Angle object from the given float in radians
  78965. * @param radians defines the angle value in radians
  78966. * @returns a new Angle
  78967. */
  78968. static FromRadians(radians: number): Angle;
  78969. /**
  78970. * Gets a new Angle object from the given float in degrees
  78971. * @param degrees defines the angle value in degrees
  78972. * @returns a new Angle
  78973. */
  78974. static FromDegrees(degrees: number): Angle;
  78975. }
  78976. /**
  78977. * This represents an arc in a 2d space.
  78978. */
  78979. export class Arc2 {
  78980. /** Defines the start point of the arc */
  78981. startPoint: Vector2;
  78982. /** Defines the mid point of the arc */
  78983. midPoint: Vector2;
  78984. /** Defines the end point of the arc */
  78985. endPoint: Vector2;
  78986. /**
  78987. * Defines the center point of the arc.
  78988. */
  78989. centerPoint: Vector2;
  78990. /**
  78991. * Defines the radius of the arc.
  78992. */
  78993. radius: number;
  78994. /**
  78995. * Defines the angle of the arc (from mid point to end point).
  78996. */
  78997. angle: Angle;
  78998. /**
  78999. * Defines the start angle of the arc (from start point to middle point).
  79000. */
  79001. startAngle: Angle;
  79002. /**
  79003. * Defines the orientation of the arc (clock wise/counter clock wise).
  79004. */
  79005. orientation: Orientation;
  79006. /**
  79007. * Creates an Arc object from the three given points : start, middle and end.
  79008. * @param startPoint Defines the start point of the arc
  79009. * @param midPoint Defines the midlle point of the arc
  79010. * @param endPoint Defines the end point of the arc
  79011. */
  79012. constructor(
  79013. /** Defines the start point of the arc */
  79014. startPoint: Vector2,
  79015. /** Defines the mid point of the arc */
  79016. midPoint: Vector2,
  79017. /** Defines the end point of the arc */
  79018. endPoint: Vector2);
  79019. }
  79020. /**
  79021. * Represents a 2D path made up of multiple 2D points
  79022. */
  79023. export class Path2 {
  79024. private _points;
  79025. private _length;
  79026. /**
  79027. * If the path start and end point are the same
  79028. */
  79029. closed: boolean;
  79030. /**
  79031. * Creates a Path2 object from the starting 2D coordinates x and y.
  79032. * @param x the starting points x value
  79033. * @param y the starting points y value
  79034. */
  79035. constructor(x: number, y: number);
  79036. /**
  79037. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  79038. * @param x the added points x value
  79039. * @param y the added points y value
  79040. * @returns the updated Path2.
  79041. */
  79042. addLineTo(x: number, y: number): Path2;
  79043. /**
  79044. * 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.
  79045. * @param midX middle point x value
  79046. * @param midY middle point y value
  79047. * @param endX end point x value
  79048. * @param endY end point y value
  79049. * @param numberOfSegments (default: 36)
  79050. * @returns the updated Path2.
  79051. */
  79052. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  79053. /**
  79054. * Closes the Path2.
  79055. * @returns the Path2.
  79056. */
  79057. close(): Path2;
  79058. /**
  79059. * Gets the sum of the distance between each sequential point in the path
  79060. * @returns the Path2 total length (float).
  79061. */
  79062. length(): number;
  79063. /**
  79064. * Gets the points which construct the path
  79065. * @returns the Path2 internal array of points.
  79066. */
  79067. getPoints(): Vector2[];
  79068. /**
  79069. * Retreives the point at the distance aways from the starting point
  79070. * @param normalizedLengthPosition the length along the path to retreive the point from
  79071. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  79072. */
  79073. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  79074. /**
  79075. * Creates a new path starting from an x and y position
  79076. * @param x starting x value
  79077. * @param y starting y value
  79078. * @returns a new Path2 starting at the coordinates (x, y).
  79079. */
  79080. static StartingAt(x: number, y: number): Path2;
  79081. }
  79082. /**
  79083. * Represents a 3D path made up of multiple 3D points
  79084. */
  79085. export class Path3D {
  79086. /**
  79087. * an array of Vector3, the curve axis of the Path3D
  79088. */
  79089. path: Vector3[];
  79090. private _curve;
  79091. private _distances;
  79092. private _tangents;
  79093. private _normals;
  79094. private _binormals;
  79095. private _raw;
  79096. private _alignTangentsWithPath;
  79097. private readonly _pointAtData;
  79098. /**
  79099. * new Path3D(path, normal, raw)
  79100. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  79101. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  79102. * @param path an array of Vector3, the curve axis of the Path3D
  79103. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  79104. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  79105. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  79106. */
  79107. constructor(
  79108. /**
  79109. * an array of Vector3, the curve axis of the Path3D
  79110. */
  79111. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  79112. /**
  79113. * Returns the Path3D array of successive Vector3 designing its curve.
  79114. * @returns the Path3D array of successive Vector3 designing its curve.
  79115. */
  79116. getCurve(): Vector3[];
  79117. /**
  79118. * Returns the Path3D array of successive Vector3 designing its curve.
  79119. * @returns the Path3D array of successive Vector3 designing its curve.
  79120. */
  79121. getPoints(): Vector3[];
  79122. /**
  79123. * @returns the computed length (float) of the path.
  79124. */
  79125. length(): number;
  79126. /**
  79127. * Returns an array populated with tangent vectors on each Path3D curve point.
  79128. * @returns an array populated with tangent vectors on each Path3D curve point.
  79129. */
  79130. getTangents(): Vector3[];
  79131. /**
  79132. * Returns an array populated with normal vectors on each Path3D curve point.
  79133. * @returns an array populated with normal vectors on each Path3D curve point.
  79134. */
  79135. getNormals(): Vector3[];
  79136. /**
  79137. * Returns an array populated with binormal vectors on each Path3D curve point.
  79138. * @returns an array populated with binormal vectors on each Path3D curve point.
  79139. */
  79140. getBinormals(): Vector3[];
  79141. /**
  79142. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  79143. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  79144. */
  79145. getDistances(): number[];
  79146. /**
  79147. * Returns an interpolated point along this path
  79148. * @param position the position of the point along this path, from 0.0 to 1.0
  79149. * @returns a new Vector3 as the point
  79150. */
  79151. getPointAt(position: number): Vector3;
  79152. /**
  79153. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  79154. * @param position the position of the point along this path, from 0.0 to 1.0
  79155. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  79156. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  79157. */
  79158. getTangentAt(position: number, interpolated?: boolean): Vector3;
  79159. /**
  79160. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  79161. * @param position the position of the point along this path, from 0.0 to 1.0
  79162. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  79163. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  79164. */
  79165. getNormalAt(position: number, interpolated?: boolean): Vector3;
  79166. /**
  79167. * Returns the binormal 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 binormal instead of the binormal of the previous path point.
  79170. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  79171. */
  79172. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  79173. /**
  79174. * Returns the distance (float) 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. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  79177. */
  79178. getDistanceAt(position: number): number;
  79179. /**
  79180. * Returns the array index of the previous point of an interpolated point along this path
  79181. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  79182. * @returns the array index
  79183. */
  79184. getPreviousPointIndexAt(position: number): number;
  79185. /**
  79186. * 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)
  79187. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  79188. * @returns the sub position
  79189. */
  79190. getSubPositionAt(position: number): number;
  79191. /**
  79192. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  79193. * @param target the vector of which to get the closest position to
  79194. * @returns the position of the closest virtual point on this path to the target vector
  79195. */
  79196. getClosestPositionTo(target: Vector3): number;
  79197. /**
  79198. * Returns a sub path (slice) of this path
  79199. * @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
  79200. * @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
  79201. * @returns a sub path (slice) of this path
  79202. */
  79203. slice(start?: number, end?: number): Path3D;
  79204. /**
  79205. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  79206. * @param path path which all values are copied into the curves points
  79207. * @param firstNormal which should be projected onto the curve
  79208. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  79209. * @returns the same object updated.
  79210. */
  79211. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  79212. private _compute;
  79213. private _getFirstNonNullVector;
  79214. private _getLastNonNullVector;
  79215. private _normalVector;
  79216. /**
  79217. * Updates the point at data for an interpolated point along this curve
  79218. * @param position the position of the point along this curve, from 0.0 to 1.0
  79219. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  79220. * @returns the (updated) point at data
  79221. */
  79222. private _updatePointAtData;
  79223. /**
  79224. * Updates the point at data from the specified parameters
  79225. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  79226. * @param point the interpolated point
  79227. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  79228. */
  79229. private _setPointAtData;
  79230. /**
  79231. * Updates the point at interpolation matrix for the tangents, normals and binormals
  79232. */
  79233. private _updateInterpolationMatrix;
  79234. }
  79235. /**
  79236. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  79237. * A Curve3 is designed from a series of successive Vector3.
  79238. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  79239. */
  79240. export class Curve3 {
  79241. private _points;
  79242. private _length;
  79243. /**
  79244. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  79245. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  79246. * @param v1 (Vector3) the control point
  79247. * @param v2 (Vector3) the end point of the Quadratic Bezier
  79248. * @param nbPoints (integer) the wanted number of points in the curve
  79249. * @returns the created Curve3
  79250. */
  79251. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  79252. /**
  79253. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  79254. * @param v0 (Vector3) the origin point of the Cubic Bezier
  79255. * @param v1 (Vector3) the first control point
  79256. * @param v2 (Vector3) the second control point
  79257. * @param v3 (Vector3) the end point of the Cubic Bezier
  79258. * @param nbPoints (integer) the wanted number of points in the curve
  79259. * @returns the created Curve3
  79260. */
  79261. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  79262. /**
  79263. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  79264. * @param p1 (Vector3) the origin point of the Hermite Spline
  79265. * @param t1 (Vector3) the tangent vector at the origin point
  79266. * @param p2 (Vector3) the end point of the Hermite Spline
  79267. * @param t2 (Vector3) the tangent vector at the end point
  79268. * @param nbPoints (integer) the wanted number of points in the curve
  79269. * @returns the created Curve3
  79270. */
  79271. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  79272. /**
  79273. * Returns a Curve3 object along a CatmullRom Spline curve :
  79274. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  79275. * @param nbPoints (integer) the wanted number of points between each curve control points
  79276. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  79277. * @returns the created Curve3
  79278. */
  79279. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  79280. /**
  79281. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  79282. * A Curve3 is designed from a series of successive Vector3.
  79283. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  79284. * @param points points which make up the curve
  79285. */
  79286. constructor(points: Vector3[]);
  79287. /**
  79288. * @returns the Curve3 stored array of successive Vector3
  79289. */
  79290. getPoints(): Vector3[];
  79291. /**
  79292. * @returns the computed length (float) of the curve.
  79293. */
  79294. length(): number;
  79295. /**
  79296. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  79297. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  79298. * curveA and curveB keep unchanged.
  79299. * @param curve the curve to continue from this curve
  79300. * @returns the newly constructed curve
  79301. */
  79302. continue(curve: DeepImmutable<Curve3>): Curve3;
  79303. private _computeLength;
  79304. }
  79305. }
  79306. declare module BABYLON {
  79307. /**
  79308. * This represents the main contract an easing function should follow.
  79309. * Easing functions are used throughout the animation system.
  79310. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  79311. */
  79312. export interface IEasingFunction {
  79313. /**
  79314. * Given an input gradient between 0 and 1, this returns the corrseponding value
  79315. * of the easing function.
  79316. * The link below provides some of the most common examples of easing functions.
  79317. * @see https://easings.net/
  79318. * @param gradient Defines the value between 0 and 1 we want the easing value for
  79319. * @returns the corresponding value on the curve defined by the easing function
  79320. */
  79321. ease(gradient: number): number;
  79322. }
  79323. /**
  79324. * Base class used for every default easing function.
  79325. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  79326. */
  79327. export class EasingFunction implements IEasingFunction {
  79328. /**
  79329. * Interpolation follows the mathematical formula associated with the easing function.
  79330. */
  79331. static readonly EASINGMODE_EASEIN: number;
  79332. /**
  79333. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  79334. */
  79335. static readonly EASINGMODE_EASEOUT: number;
  79336. /**
  79337. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  79338. */
  79339. static readonly EASINGMODE_EASEINOUT: number;
  79340. private _easingMode;
  79341. /**
  79342. * Sets the easing mode of the current function.
  79343. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  79344. */
  79345. setEasingMode(easingMode: number): void;
  79346. /**
  79347. * Gets the current easing mode.
  79348. * @returns the easing mode
  79349. */
  79350. getEasingMode(): number;
  79351. /**
  79352. * @hidden
  79353. */
  79354. easeInCore(gradient: number): number;
  79355. /**
  79356. * Given an input gradient between 0 and 1, this returns the corresponding value
  79357. * of the easing function.
  79358. * @param gradient Defines the value between 0 and 1 we want the easing value for
  79359. * @returns the corresponding value on the curve defined by the easing function
  79360. */
  79361. ease(gradient: number): number;
  79362. }
  79363. /**
  79364. * Easing function with a circle shape (see link below).
  79365. * @see https://easings.net/#easeInCirc
  79366. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  79367. */
  79368. export class CircleEase extends EasingFunction implements IEasingFunction {
  79369. /** @hidden */
  79370. easeInCore(gradient: number): number;
  79371. }
  79372. /**
  79373. * Easing function with a ease back shape (see link below).
  79374. * @see https://easings.net/#easeInBack
  79375. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  79376. */
  79377. export class BackEase extends EasingFunction implements IEasingFunction {
  79378. /** Defines the amplitude of the function */
  79379. amplitude: number;
  79380. /**
  79381. * Instantiates a back ease easing
  79382. * @see https://easings.net/#easeInBack
  79383. * @param amplitude Defines the amplitude of the function
  79384. */
  79385. constructor(
  79386. /** Defines the amplitude of the function */
  79387. amplitude?: number);
  79388. /** @hidden */
  79389. easeInCore(gradient: number): number;
  79390. }
  79391. /**
  79392. * Easing function with a bouncing shape (see link below).
  79393. * @see https://easings.net/#easeInBounce
  79394. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  79395. */
  79396. export class BounceEase extends EasingFunction implements IEasingFunction {
  79397. /** Defines the number of bounces */
  79398. bounces: number;
  79399. /** Defines the amplitude of the bounce */
  79400. bounciness: number;
  79401. /**
  79402. * Instantiates a bounce easing
  79403. * @see https://easings.net/#easeInBounce
  79404. * @param bounces Defines the number of bounces
  79405. * @param bounciness Defines the amplitude of the bounce
  79406. */
  79407. constructor(
  79408. /** Defines the number of bounces */
  79409. bounces?: number,
  79410. /** Defines the amplitude of the bounce */
  79411. bounciness?: number);
  79412. /** @hidden */
  79413. easeInCore(gradient: number): number;
  79414. }
  79415. /**
  79416. * Easing function with a power of 3 shape (see link below).
  79417. * @see https://easings.net/#easeInCubic
  79418. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  79419. */
  79420. export class CubicEase extends EasingFunction implements IEasingFunction {
  79421. /** @hidden */
  79422. easeInCore(gradient: number): number;
  79423. }
  79424. /**
  79425. * Easing function with an elastic shape (see link below).
  79426. * @see https://easings.net/#easeInElastic
  79427. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  79428. */
  79429. export class ElasticEase extends EasingFunction implements IEasingFunction {
  79430. /** Defines the number of oscillations*/
  79431. oscillations: number;
  79432. /** Defines the amplitude of the oscillations*/
  79433. springiness: number;
  79434. /**
  79435. * Instantiates an elastic easing function
  79436. * @see https://easings.net/#easeInElastic
  79437. * @param oscillations Defines the number of oscillations
  79438. * @param springiness Defines the amplitude of the oscillations
  79439. */
  79440. constructor(
  79441. /** Defines the number of oscillations*/
  79442. oscillations?: number,
  79443. /** Defines the amplitude of the oscillations*/
  79444. springiness?: number);
  79445. /** @hidden */
  79446. easeInCore(gradient: number): number;
  79447. }
  79448. /**
  79449. * Easing function with an exponential shape (see link below).
  79450. * @see https://easings.net/#easeInExpo
  79451. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  79452. */
  79453. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  79454. /** Defines the exponent of the function */
  79455. exponent: number;
  79456. /**
  79457. * Instantiates an exponential easing function
  79458. * @see https://easings.net/#easeInExpo
  79459. * @param exponent Defines the exponent of the function
  79460. */
  79461. constructor(
  79462. /** Defines the exponent of the function */
  79463. exponent?: number);
  79464. /** @hidden */
  79465. easeInCore(gradient: number): number;
  79466. }
  79467. /**
  79468. * Easing function with a power shape (see link below).
  79469. * @see https://easings.net/#easeInQuad
  79470. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  79471. */
  79472. export class PowerEase extends EasingFunction implements IEasingFunction {
  79473. /** Defines the power of the function */
  79474. power: number;
  79475. /**
  79476. * Instantiates an power base easing function
  79477. * @see https://easings.net/#easeInQuad
  79478. * @param power Defines the power of the function
  79479. */
  79480. constructor(
  79481. /** Defines the power of the function */
  79482. power?: number);
  79483. /** @hidden */
  79484. easeInCore(gradient: number): number;
  79485. }
  79486. /**
  79487. * Easing function with a power of 2 shape (see link below).
  79488. * @see https://easings.net/#easeInQuad
  79489. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  79490. */
  79491. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  79492. /** @hidden */
  79493. easeInCore(gradient: number): number;
  79494. }
  79495. /**
  79496. * Easing function with a power of 4 shape (see link below).
  79497. * @see https://easings.net/#easeInQuart
  79498. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  79499. */
  79500. export class QuarticEase extends EasingFunction implements IEasingFunction {
  79501. /** @hidden */
  79502. easeInCore(gradient: number): number;
  79503. }
  79504. /**
  79505. * Easing function with a power of 5 shape (see link below).
  79506. * @see https://easings.net/#easeInQuint
  79507. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  79508. */
  79509. export class QuinticEase extends EasingFunction implements IEasingFunction {
  79510. /** @hidden */
  79511. easeInCore(gradient: number): number;
  79512. }
  79513. /**
  79514. * Easing function with a sin shape (see link below).
  79515. * @see https://easings.net/#easeInSine
  79516. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  79517. */
  79518. export class SineEase extends EasingFunction implements IEasingFunction {
  79519. /** @hidden */
  79520. easeInCore(gradient: number): number;
  79521. }
  79522. /**
  79523. * Easing function with a bezier shape (see link below).
  79524. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  79525. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  79526. */
  79527. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  79528. /** Defines the x component of the start tangent in the bezier curve */
  79529. x1: number;
  79530. /** Defines the y component of the start tangent in the bezier curve */
  79531. y1: number;
  79532. /** Defines the x component of the end tangent in the bezier curve */
  79533. x2: number;
  79534. /** Defines the y component of the end tangent in the bezier curve */
  79535. y2: number;
  79536. /**
  79537. * Instantiates a bezier function
  79538. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  79539. * @param x1 Defines the x component of the start tangent in the bezier curve
  79540. * @param y1 Defines the y component of the start tangent in the bezier curve
  79541. * @param x2 Defines the x component of the end tangent in the bezier curve
  79542. * @param y2 Defines the y component of the end tangent in the bezier curve
  79543. */
  79544. constructor(
  79545. /** Defines the x component of the start tangent in the bezier curve */
  79546. x1?: number,
  79547. /** Defines the y component of the start tangent in the bezier curve */
  79548. y1?: number,
  79549. /** Defines the x component of the end tangent in the bezier curve */
  79550. x2?: number,
  79551. /** Defines the y component of the end tangent in the bezier curve */
  79552. y2?: number);
  79553. /** @hidden */
  79554. easeInCore(gradient: number): number;
  79555. }
  79556. }
  79557. declare module BABYLON {
  79558. /**
  79559. * Class used to hold a RBG color
  79560. */
  79561. export class Color3 {
  79562. /**
  79563. * Defines the red component (between 0 and 1, default is 0)
  79564. */
  79565. r: number;
  79566. /**
  79567. * Defines the green component (between 0 and 1, default is 0)
  79568. */
  79569. g: number;
  79570. /**
  79571. * Defines the blue component (between 0 and 1, default is 0)
  79572. */
  79573. b: number;
  79574. /**
  79575. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  79576. * @param r defines the red component (between 0 and 1, default is 0)
  79577. * @param g defines the green component (between 0 and 1, default is 0)
  79578. * @param b defines the blue component (between 0 and 1, default is 0)
  79579. */
  79580. constructor(
  79581. /**
  79582. * Defines the red component (between 0 and 1, default is 0)
  79583. */
  79584. r?: number,
  79585. /**
  79586. * Defines the green component (between 0 and 1, default is 0)
  79587. */
  79588. g?: number,
  79589. /**
  79590. * Defines the blue component (between 0 and 1, default is 0)
  79591. */
  79592. b?: number);
  79593. /**
  79594. * Creates a string with the Color3 current values
  79595. * @returns the string representation of the Color3 object
  79596. */
  79597. toString(): string;
  79598. /**
  79599. * Returns the string "Color3"
  79600. * @returns "Color3"
  79601. */
  79602. getClassName(): string;
  79603. /**
  79604. * Compute the Color3 hash code
  79605. * @returns an unique number that can be used to hash Color3 objects
  79606. */
  79607. getHashCode(): number;
  79608. /**
  79609. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  79610. * @param array defines the array where to store the r,g,b components
  79611. * @param index defines an optional index in the target array to define where to start storing values
  79612. * @returns the current Color3 object
  79613. */
  79614. toArray(array: FloatArray, index?: number): Color3;
  79615. /**
  79616. * Returns a new Color4 object from the current Color3 and the given alpha
  79617. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  79618. * @returns a new Color4 object
  79619. */
  79620. toColor4(alpha?: number): Color4;
  79621. /**
  79622. * Returns a new array populated with 3 numeric elements : red, green and blue values
  79623. * @returns the new array
  79624. */
  79625. asArray(): number[];
  79626. /**
  79627. * Returns the luminance value
  79628. * @returns a float value
  79629. */
  79630. toLuminance(): number;
  79631. /**
  79632. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  79633. * @param otherColor defines the second operand
  79634. * @returns the new Color3 object
  79635. */
  79636. multiply(otherColor: DeepImmutable<Color3>): Color3;
  79637. /**
  79638. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  79639. * @param otherColor defines the second operand
  79640. * @param result defines the Color3 object where to store the result
  79641. * @returns the current Color3
  79642. */
  79643. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  79644. /**
  79645. * Determines equality between Color3 objects
  79646. * @param otherColor defines the second operand
  79647. * @returns true if the rgb values are equal to the given ones
  79648. */
  79649. equals(otherColor: DeepImmutable<Color3>): boolean;
  79650. /**
  79651. * Determines equality between the current Color3 object and a set of r,b,g values
  79652. * @param r defines the red component to check
  79653. * @param g defines the green component to check
  79654. * @param b defines the blue component to check
  79655. * @returns true if the rgb values are equal to the given ones
  79656. */
  79657. equalsFloats(r: number, g: number, b: number): boolean;
  79658. /**
  79659. * Multiplies in place each rgb value by scale
  79660. * @param scale defines the scaling factor
  79661. * @returns the updated Color3
  79662. */
  79663. scale(scale: number): Color3;
  79664. /**
  79665. * Multiplies the rgb values by scale and stores the result into "result"
  79666. * @param scale defines the scaling factor
  79667. * @param result defines the Color3 object where to store the result
  79668. * @returns the unmodified current Color3
  79669. */
  79670. scaleToRef(scale: number, result: Color3): Color3;
  79671. /**
  79672. * Scale the current Color3 values by a factor and add the result to a given Color3
  79673. * @param scale defines the scale factor
  79674. * @param result defines color to store the result into
  79675. * @returns the unmodified current Color3
  79676. */
  79677. scaleAndAddToRef(scale: number, result: Color3): Color3;
  79678. /**
  79679. * Clamps the rgb values by the min and max values and stores the result into "result"
  79680. * @param min defines minimum clamping value (default is 0)
  79681. * @param max defines maximum clamping value (default is 1)
  79682. * @param result defines color to store the result into
  79683. * @returns the original Color3
  79684. */
  79685. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  79686. /**
  79687. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  79688. * @param otherColor defines the second operand
  79689. * @returns the new Color3
  79690. */
  79691. add(otherColor: DeepImmutable<Color3>): Color3;
  79692. /**
  79693. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  79694. * @param otherColor defines the second operand
  79695. * @param result defines Color3 object to store the result into
  79696. * @returns the unmodified current Color3
  79697. */
  79698. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  79699. /**
  79700. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  79701. * @param otherColor defines the second operand
  79702. * @returns the new Color3
  79703. */
  79704. subtract(otherColor: DeepImmutable<Color3>): Color3;
  79705. /**
  79706. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  79707. * @param otherColor defines the second operand
  79708. * @param result defines Color3 object to store the result into
  79709. * @returns the unmodified current Color3
  79710. */
  79711. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  79712. /**
  79713. * Copy the current object
  79714. * @returns a new Color3 copied the current one
  79715. */
  79716. clone(): Color3;
  79717. /**
  79718. * Copies the rgb values from the source in the current Color3
  79719. * @param source defines the source Color3 object
  79720. * @returns the updated Color3 object
  79721. */
  79722. copyFrom(source: DeepImmutable<Color3>): Color3;
  79723. /**
  79724. * Updates the Color3 rgb values from the given floats
  79725. * @param r defines the red component to read from
  79726. * @param g defines the green component to read from
  79727. * @param b defines the blue component to read from
  79728. * @returns the current Color3 object
  79729. */
  79730. copyFromFloats(r: number, g: number, b: number): Color3;
  79731. /**
  79732. * Updates the Color3 rgb values from the given floats
  79733. * @param r defines the red component to read from
  79734. * @param g defines the green component to read from
  79735. * @param b defines the blue component to read from
  79736. * @returns the current Color3 object
  79737. */
  79738. set(r: number, g: number, b: number): Color3;
  79739. /**
  79740. * Compute the Color3 hexadecimal code as a string
  79741. * @returns a string containing the hexadecimal representation of the Color3 object
  79742. */
  79743. toHexString(): string;
  79744. /**
  79745. * Computes a new Color3 converted from the current one to linear space
  79746. * @returns a new Color3 object
  79747. */
  79748. toLinearSpace(): Color3;
  79749. /**
  79750. * Converts current color in rgb space to HSV values
  79751. * @returns a new color3 representing the HSV values
  79752. */
  79753. toHSV(): Color3;
  79754. /**
  79755. * Converts current color in rgb space to HSV values
  79756. * @param result defines the Color3 where to store the HSV values
  79757. */
  79758. toHSVToRef(result: Color3): void;
  79759. /**
  79760. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  79761. * @param convertedColor defines the Color3 object where to store the linear space version
  79762. * @returns the unmodified Color3
  79763. */
  79764. toLinearSpaceToRef(convertedColor: Color3): Color3;
  79765. /**
  79766. * Computes a new Color3 converted from the current one to gamma space
  79767. * @returns a new Color3 object
  79768. */
  79769. toGammaSpace(): Color3;
  79770. /**
  79771. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  79772. * @param convertedColor defines the Color3 object where to store the gamma space version
  79773. * @returns the unmodified Color3
  79774. */
  79775. toGammaSpaceToRef(convertedColor: Color3): Color3;
  79776. private static _BlackReadOnly;
  79777. /**
  79778. * Convert Hue, saturation and value to a Color3 (RGB)
  79779. * @param hue defines the hue
  79780. * @param saturation defines the saturation
  79781. * @param value defines the value
  79782. * @param result defines the Color3 where to store the RGB values
  79783. */
  79784. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  79785. /**
  79786. * Creates a new Color3 from the string containing valid hexadecimal values
  79787. * @param hex defines a string containing valid hexadecimal values
  79788. * @returns a new Color3 object
  79789. */
  79790. static FromHexString(hex: string): Color3;
  79791. /**
  79792. * Creates a new Color3 from the starting index of the given array
  79793. * @param array defines the source array
  79794. * @param offset defines an offset in the source array
  79795. * @returns a new Color3 object
  79796. */
  79797. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  79798. /**
  79799. * Creates a new Color3 from integer values (< 256)
  79800. * @param r defines the red component to read from (value between 0 and 255)
  79801. * @param g defines the green component to read from (value between 0 and 255)
  79802. * @param b defines the blue component to read from (value between 0 and 255)
  79803. * @returns a new Color3 object
  79804. */
  79805. static FromInts(r: number, g: number, b: number): Color3;
  79806. /**
  79807. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  79808. * @param start defines the start Color3 value
  79809. * @param end defines the end Color3 value
  79810. * @param amount defines the gradient value between start and end
  79811. * @returns a new Color3 object
  79812. */
  79813. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  79814. /**
  79815. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  79816. * @param left defines the start value
  79817. * @param right defines the end value
  79818. * @param amount defines the gradient factor
  79819. * @param result defines the Color3 object where to store the result
  79820. */
  79821. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  79822. /**
  79823. * Returns a Color3 value containing a red color
  79824. * @returns a new Color3 object
  79825. */
  79826. static Red(): Color3;
  79827. /**
  79828. * Returns a Color3 value containing a green color
  79829. * @returns a new Color3 object
  79830. */
  79831. static Green(): Color3;
  79832. /**
  79833. * Returns a Color3 value containing a blue color
  79834. * @returns a new Color3 object
  79835. */
  79836. static Blue(): Color3;
  79837. /**
  79838. * Returns a Color3 value containing a black color
  79839. * @returns a new Color3 object
  79840. */
  79841. static Black(): Color3;
  79842. /**
  79843. * Gets a Color3 value containing a black color that must not be updated
  79844. */
  79845. static get BlackReadOnly(): DeepImmutable<Color3>;
  79846. /**
  79847. * Returns a Color3 value containing a white color
  79848. * @returns a new Color3 object
  79849. */
  79850. static White(): Color3;
  79851. /**
  79852. * Returns a Color3 value containing a purple color
  79853. * @returns a new Color3 object
  79854. */
  79855. static Purple(): Color3;
  79856. /**
  79857. * Returns a Color3 value containing a magenta color
  79858. * @returns a new Color3 object
  79859. */
  79860. static Magenta(): Color3;
  79861. /**
  79862. * Returns a Color3 value containing a yellow color
  79863. * @returns a new Color3 object
  79864. */
  79865. static Yellow(): Color3;
  79866. /**
  79867. * Returns a Color3 value containing a gray color
  79868. * @returns a new Color3 object
  79869. */
  79870. static Gray(): Color3;
  79871. /**
  79872. * Returns a Color3 value containing a teal color
  79873. * @returns a new Color3 object
  79874. */
  79875. static Teal(): Color3;
  79876. /**
  79877. * Returns a Color3 value containing a random color
  79878. * @returns a new Color3 object
  79879. */
  79880. static Random(): Color3;
  79881. }
  79882. /**
  79883. * Class used to hold a RBGA color
  79884. */
  79885. export class Color4 {
  79886. /**
  79887. * Defines the red component (between 0 and 1, default is 0)
  79888. */
  79889. r: number;
  79890. /**
  79891. * Defines the green component (between 0 and 1, default is 0)
  79892. */
  79893. g: number;
  79894. /**
  79895. * Defines the blue component (between 0 and 1, default is 0)
  79896. */
  79897. b: number;
  79898. /**
  79899. * Defines the alpha component (between 0 and 1, default is 1)
  79900. */
  79901. a: number;
  79902. /**
  79903. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  79904. * @param r defines the red component (between 0 and 1, default is 0)
  79905. * @param g defines the green component (between 0 and 1, default is 0)
  79906. * @param b defines the blue component (between 0 and 1, default is 0)
  79907. * @param a defines the alpha component (between 0 and 1, default is 1)
  79908. */
  79909. constructor(
  79910. /**
  79911. * Defines the red component (between 0 and 1, default is 0)
  79912. */
  79913. r?: number,
  79914. /**
  79915. * Defines the green component (between 0 and 1, default is 0)
  79916. */
  79917. g?: number,
  79918. /**
  79919. * Defines the blue component (between 0 and 1, default is 0)
  79920. */
  79921. b?: number,
  79922. /**
  79923. * Defines the alpha component (between 0 and 1, default is 1)
  79924. */
  79925. a?: number);
  79926. /**
  79927. * Adds in place the given Color4 values to the current Color4 object
  79928. * @param right defines the second operand
  79929. * @returns the current updated Color4 object
  79930. */
  79931. addInPlace(right: DeepImmutable<Color4>): Color4;
  79932. /**
  79933. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  79934. * @returns the new array
  79935. */
  79936. asArray(): number[];
  79937. /**
  79938. * Stores from the starting index in the given array the Color4 successive values
  79939. * @param array defines the array where to store the r,g,b components
  79940. * @param index defines an optional index in the target array to define where to start storing values
  79941. * @returns the current Color4 object
  79942. */
  79943. toArray(array: number[], index?: number): Color4;
  79944. /**
  79945. * Determines equality between Color4 objects
  79946. * @param otherColor defines the second operand
  79947. * @returns true if the rgba values are equal to the given ones
  79948. */
  79949. equals(otherColor: DeepImmutable<Color4>): boolean;
  79950. /**
  79951. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  79952. * @param right defines the second operand
  79953. * @returns a new Color4 object
  79954. */
  79955. add(right: DeepImmutable<Color4>): Color4;
  79956. /**
  79957. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  79958. * @param right defines the second operand
  79959. * @returns a new Color4 object
  79960. */
  79961. subtract(right: DeepImmutable<Color4>): Color4;
  79962. /**
  79963. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  79964. * @param right defines the second operand
  79965. * @param result defines the Color4 object where to store the result
  79966. * @returns the current Color4 object
  79967. */
  79968. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  79969. /**
  79970. * Creates a new Color4 with the current Color4 values multiplied by scale
  79971. * @param scale defines the scaling factor to apply
  79972. * @returns a new Color4 object
  79973. */
  79974. scale(scale: number): Color4;
  79975. /**
  79976. * Multiplies the current Color4 values by scale and stores the result in "result"
  79977. * @param scale defines the scaling factor to apply
  79978. * @param result defines the Color4 object where to store the result
  79979. * @returns the current unmodified Color4
  79980. */
  79981. scaleToRef(scale: number, result: Color4): Color4;
  79982. /**
  79983. * Scale the current Color4 values by a factor and add the result to a given Color4
  79984. * @param scale defines the scale factor
  79985. * @param result defines the Color4 object where to store the result
  79986. * @returns the unmodified current Color4
  79987. */
  79988. scaleAndAddToRef(scale: number, result: Color4): Color4;
  79989. /**
  79990. * Clamps the rgb values by the min and max values and stores the result into "result"
  79991. * @param min defines minimum clamping value (default is 0)
  79992. * @param max defines maximum clamping value (default is 1)
  79993. * @param result defines color to store the result into.
  79994. * @returns the cuurent Color4
  79995. */
  79996. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  79997. /**
  79998. * Multipy an Color4 value by another and return a new Color4 object
  79999. * @param color defines the Color4 value to multiply by
  80000. * @returns a new Color4 object
  80001. */
  80002. multiply(color: Color4): Color4;
  80003. /**
  80004. * Multipy a Color4 value by another and push the result in a reference value
  80005. * @param color defines the Color4 value to multiply by
  80006. * @param result defines the Color4 to fill the result in
  80007. * @returns the result Color4
  80008. */
  80009. multiplyToRef(color: Color4, result: Color4): Color4;
  80010. /**
  80011. * Creates a string with the Color4 current values
  80012. * @returns the string representation of the Color4 object
  80013. */
  80014. toString(): string;
  80015. /**
  80016. * Returns the string "Color4"
  80017. * @returns "Color4"
  80018. */
  80019. getClassName(): string;
  80020. /**
  80021. * Compute the Color4 hash code
  80022. * @returns an unique number that can be used to hash Color4 objects
  80023. */
  80024. getHashCode(): number;
  80025. /**
  80026. * Creates a new Color4 copied from the current one
  80027. * @returns a new Color4 object
  80028. */
  80029. clone(): Color4;
  80030. /**
  80031. * Copies the given Color4 values into the current one
  80032. * @param source defines the source Color4 object
  80033. * @returns the current updated Color4 object
  80034. */
  80035. copyFrom(source: Color4): Color4;
  80036. /**
  80037. * Copies the given float values into the current one
  80038. * @param r defines the red component to read from
  80039. * @param g defines the green component to read from
  80040. * @param b defines the blue component to read from
  80041. * @param a defines the alpha component to read from
  80042. * @returns the current updated Color4 object
  80043. */
  80044. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  80045. /**
  80046. * Copies the given float values into the current one
  80047. * @param r defines the red component to read from
  80048. * @param g defines the green component to read from
  80049. * @param b defines the blue component to read from
  80050. * @param a defines the alpha component to read from
  80051. * @returns the current updated Color4 object
  80052. */
  80053. set(r: number, g: number, b: number, a: number): Color4;
  80054. /**
  80055. * Compute the Color4 hexadecimal code as a string
  80056. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  80057. * @returns a string containing the hexadecimal representation of the Color4 object
  80058. */
  80059. toHexString(returnAsColor3?: boolean): string;
  80060. /**
  80061. * Computes a new Color4 converted from the current one to linear space
  80062. * @returns a new Color4 object
  80063. */
  80064. toLinearSpace(): Color4;
  80065. /**
  80066. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  80067. * @param convertedColor defines the Color4 object where to store the linear space version
  80068. * @returns the unmodified Color4
  80069. */
  80070. toLinearSpaceToRef(convertedColor: Color4): Color4;
  80071. /**
  80072. * Computes a new Color4 converted from the current one to gamma space
  80073. * @returns a new Color4 object
  80074. */
  80075. toGammaSpace(): Color4;
  80076. /**
  80077. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  80078. * @param convertedColor defines the Color4 object where to store the gamma space version
  80079. * @returns the unmodified Color4
  80080. */
  80081. toGammaSpaceToRef(convertedColor: Color4): Color4;
  80082. /**
  80083. * Creates a new Color4 from the string containing valid hexadecimal values
  80084. * @param hex defines a string containing valid hexadecimal values
  80085. * @returns a new Color4 object
  80086. */
  80087. static FromHexString(hex: string): Color4;
  80088. /**
  80089. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  80090. * @param left defines the start value
  80091. * @param right defines the end value
  80092. * @param amount defines the gradient factor
  80093. * @returns a new Color4 object
  80094. */
  80095. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  80096. /**
  80097. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  80098. * @param left defines the start value
  80099. * @param right defines the end value
  80100. * @param amount defines the gradient factor
  80101. * @param result defines the Color4 object where to store data
  80102. */
  80103. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  80104. /**
  80105. * Creates a new Color4 from a Color3 and an alpha value
  80106. * @param color3 defines the source Color3 to read from
  80107. * @param alpha defines the alpha component (1.0 by default)
  80108. * @returns a new Color4 object
  80109. */
  80110. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  80111. /**
  80112. * Creates a new Color4 from the starting index element of the given array
  80113. * @param array defines the source array to read from
  80114. * @param offset defines the offset in the source array
  80115. * @returns a new Color4 object
  80116. */
  80117. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  80118. /**
  80119. * Creates a new Color3 from integer values (< 256)
  80120. * @param r defines the red component to read from (value between 0 and 255)
  80121. * @param g defines the green component to read from (value between 0 and 255)
  80122. * @param b defines the blue component to read from (value between 0 and 255)
  80123. * @param a defines the alpha component to read from (value between 0 and 255)
  80124. * @returns a new Color3 object
  80125. */
  80126. static FromInts(r: number, g: number, b: number, a: number): Color4;
  80127. /**
  80128. * Check the content of a given array and convert it to an array containing RGBA data
  80129. * If the original array was already containing count * 4 values then it is returned directly
  80130. * @param colors defines the array to check
  80131. * @param count defines the number of RGBA data to expect
  80132. * @returns an array containing count * 4 values (RGBA)
  80133. */
  80134. static CheckColors4(colors: number[], count: number): number[];
  80135. }
  80136. /**
  80137. * @hidden
  80138. */
  80139. export class TmpColors {
  80140. static Color3: Color3[];
  80141. static Color4: Color4[];
  80142. }
  80143. }
  80144. declare module BABYLON {
  80145. /**
  80146. * Defines an interface which represents an animation key frame
  80147. */
  80148. export interface IAnimationKey {
  80149. /**
  80150. * Frame of the key frame
  80151. */
  80152. frame: number;
  80153. /**
  80154. * Value at the specifies key frame
  80155. */
  80156. value: any;
  80157. /**
  80158. * The input tangent for the cubic hermite spline
  80159. */
  80160. inTangent?: any;
  80161. /**
  80162. * The output tangent for the cubic hermite spline
  80163. */
  80164. outTangent?: any;
  80165. /**
  80166. * The animation interpolation type
  80167. */
  80168. interpolation?: AnimationKeyInterpolation;
  80169. }
  80170. /**
  80171. * Enum for the animation key frame interpolation type
  80172. */
  80173. export enum AnimationKeyInterpolation {
  80174. /**
  80175. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  80176. */
  80177. STEP = 1
  80178. }
  80179. }
  80180. declare module BABYLON {
  80181. /**
  80182. * Represents the range of an animation
  80183. */
  80184. export class AnimationRange {
  80185. /**The name of the animation range**/
  80186. name: string;
  80187. /**The starting frame of the animation */
  80188. from: number;
  80189. /**The ending frame of the animation*/
  80190. to: number;
  80191. /**
  80192. * Initializes the range of an animation
  80193. * @param name The name of the animation range
  80194. * @param from The starting frame of the animation
  80195. * @param to The ending frame of the animation
  80196. */
  80197. constructor(
  80198. /**The name of the animation range**/
  80199. name: string,
  80200. /**The starting frame of the animation */
  80201. from: number,
  80202. /**The ending frame of the animation*/
  80203. to: number);
  80204. /**
  80205. * Makes a copy of the animation range
  80206. * @returns A copy of the animation range
  80207. */
  80208. clone(): AnimationRange;
  80209. }
  80210. }
  80211. declare module BABYLON {
  80212. /**
  80213. * Composed of a frame, and an action function
  80214. */
  80215. export class AnimationEvent {
  80216. /** The frame for which the event is triggered **/
  80217. frame: number;
  80218. /** The event to perform when triggered **/
  80219. action: (currentFrame: number) => void;
  80220. /** Specifies if the event should be triggered only once**/
  80221. onlyOnce?: boolean | undefined;
  80222. /**
  80223. * Specifies if the animation event is done
  80224. */
  80225. isDone: boolean;
  80226. /**
  80227. * Initializes the animation event
  80228. * @param frame The frame for which the event is triggered
  80229. * @param action The event to perform when triggered
  80230. * @param onlyOnce Specifies if the event should be triggered only once
  80231. */
  80232. constructor(
  80233. /** The frame for which the event is triggered **/
  80234. frame: number,
  80235. /** The event to perform when triggered **/
  80236. action: (currentFrame: number) => void,
  80237. /** Specifies if the event should be triggered only once**/
  80238. onlyOnce?: boolean | undefined);
  80239. /** @hidden */
  80240. _clone(): AnimationEvent;
  80241. }
  80242. }
  80243. declare module BABYLON {
  80244. /**
  80245. * Interface used to define a behavior
  80246. */
  80247. export interface Behavior<T> {
  80248. /** gets or sets behavior's name */
  80249. name: string;
  80250. /**
  80251. * Function called when the behavior needs to be initialized (after attaching it to a target)
  80252. */
  80253. init(): void;
  80254. /**
  80255. * Called when the behavior is attached to a target
  80256. * @param target defines the target where the behavior is attached to
  80257. */
  80258. attach(target: T): void;
  80259. /**
  80260. * Called when the behavior is detached from its target
  80261. */
  80262. detach(): void;
  80263. }
  80264. /**
  80265. * Interface implemented by classes supporting behaviors
  80266. */
  80267. export interface IBehaviorAware<T> {
  80268. /**
  80269. * Attach a behavior
  80270. * @param behavior defines the behavior to attach
  80271. * @returns the current host
  80272. */
  80273. addBehavior(behavior: Behavior<T>): T;
  80274. /**
  80275. * Remove a behavior from the current object
  80276. * @param behavior defines the behavior to detach
  80277. * @returns the current host
  80278. */
  80279. removeBehavior(behavior: Behavior<T>): T;
  80280. /**
  80281. * Gets a behavior using its name to search
  80282. * @param name defines the name to search
  80283. * @returns the behavior or null if not found
  80284. */
  80285. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  80286. }
  80287. }
  80288. declare module BABYLON {
  80289. /**
  80290. * Defines an array and its length.
  80291. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  80292. */
  80293. export interface ISmartArrayLike<T> {
  80294. /**
  80295. * The data of the array.
  80296. */
  80297. data: Array<T>;
  80298. /**
  80299. * The active length of the array.
  80300. */
  80301. length: number;
  80302. }
  80303. /**
  80304. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  80305. */
  80306. export class SmartArray<T> implements ISmartArrayLike<T> {
  80307. /**
  80308. * The full set of data from the array.
  80309. */
  80310. data: Array<T>;
  80311. /**
  80312. * The active length of the array.
  80313. */
  80314. length: number;
  80315. protected _id: number;
  80316. /**
  80317. * Instantiates a Smart Array.
  80318. * @param capacity defines the default capacity of the array.
  80319. */
  80320. constructor(capacity: number);
  80321. /**
  80322. * Pushes a value at the end of the active data.
  80323. * @param value defines the object to push in the array.
  80324. */
  80325. push(value: T): void;
  80326. /**
  80327. * Iterates over the active data and apply the lambda to them.
  80328. * @param func defines the action to apply on each value.
  80329. */
  80330. forEach(func: (content: T) => void): void;
  80331. /**
  80332. * Sorts the full sets of data.
  80333. * @param compareFn defines the comparison function to apply.
  80334. */
  80335. sort(compareFn: (a: T, b: T) => number): void;
  80336. /**
  80337. * Resets the active data to an empty array.
  80338. */
  80339. reset(): void;
  80340. /**
  80341. * Releases all the data from the array as well as the array.
  80342. */
  80343. dispose(): void;
  80344. /**
  80345. * Concats the active data with a given array.
  80346. * @param array defines the data to concatenate with.
  80347. */
  80348. concat(array: any): void;
  80349. /**
  80350. * Returns the position of a value in the active data.
  80351. * @param value defines the value to find the index for
  80352. * @returns the index if found in the active data otherwise -1
  80353. */
  80354. indexOf(value: T): number;
  80355. /**
  80356. * Returns whether an element is part of the active data.
  80357. * @param value defines the value to look for
  80358. * @returns true if found in the active data otherwise false
  80359. */
  80360. contains(value: T): boolean;
  80361. private static _GlobalId;
  80362. }
  80363. /**
  80364. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  80365. * The data in this array can only be present once
  80366. */
  80367. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  80368. private _duplicateId;
  80369. /**
  80370. * Pushes a value at the end of the active data.
  80371. * THIS DOES NOT PREVENT DUPPLICATE DATA
  80372. * @param value defines the object to push in the array.
  80373. */
  80374. push(value: T): void;
  80375. /**
  80376. * Pushes a value at the end of the active data.
  80377. * If the data is already present, it won t be added again
  80378. * @param value defines the object to push in the array.
  80379. * @returns true if added false if it was already present
  80380. */
  80381. pushNoDuplicate(value: T): boolean;
  80382. /**
  80383. * Resets the active data to an empty array.
  80384. */
  80385. reset(): void;
  80386. /**
  80387. * Concats the active data with a given array.
  80388. * This ensures no dupplicate will be present in the result.
  80389. * @param array defines the data to concatenate with.
  80390. */
  80391. concatWithNoDuplicate(array: any): void;
  80392. }
  80393. }
  80394. declare module BABYLON {
  80395. /**
  80396. * @ignore
  80397. * This is a list of all the different input types that are available in the application.
  80398. * Fo instance: ArcRotateCameraGamepadInput...
  80399. */
  80400. export var CameraInputTypes: {};
  80401. /**
  80402. * This is the contract to implement in order to create a new input class.
  80403. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  80404. */
  80405. export interface ICameraInput<TCamera extends Camera> {
  80406. /**
  80407. * Defines the camera the input is attached to.
  80408. */
  80409. camera: Nullable<TCamera>;
  80410. /**
  80411. * Gets the class name of the current intput.
  80412. * @returns the class name
  80413. */
  80414. getClassName(): string;
  80415. /**
  80416. * Get the friendly name associated with the input class.
  80417. * @returns the input friendly name
  80418. */
  80419. getSimpleName(): string;
  80420. /**
  80421. * Attach the input controls to a specific dom element to get the input from.
  80422. * @param element Defines the element the controls should be listened from
  80423. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  80424. */
  80425. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  80426. /**
  80427. * Detach the current controls from the specified dom element.
  80428. * @param element Defines the element to stop listening the inputs from
  80429. */
  80430. detachControl(element: Nullable<HTMLElement>): void;
  80431. /**
  80432. * Update the current camera state depending on the inputs that have been used this frame.
  80433. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  80434. */
  80435. checkInputs?: () => void;
  80436. }
  80437. /**
  80438. * Represents a map of input types to input instance or input index to input instance.
  80439. */
  80440. export interface CameraInputsMap<TCamera extends Camera> {
  80441. /**
  80442. * Accessor to the input by input type.
  80443. */
  80444. [name: string]: ICameraInput<TCamera>;
  80445. /**
  80446. * Accessor to the input by input index.
  80447. */
  80448. [idx: number]: ICameraInput<TCamera>;
  80449. }
  80450. /**
  80451. * This represents the input manager used within a camera.
  80452. * It helps dealing with all the different kind of input attached to a camera.
  80453. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  80454. */
  80455. export class CameraInputsManager<TCamera extends Camera> {
  80456. /**
  80457. * Defines the list of inputs attahed to the camera.
  80458. */
  80459. attached: CameraInputsMap<TCamera>;
  80460. /**
  80461. * Defines the dom element the camera is collecting inputs from.
  80462. * This is null if the controls have not been attached.
  80463. */
  80464. attachedElement: Nullable<HTMLElement>;
  80465. /**
  80466. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  80467. */
  80468. noPreventDefault: boolean;
  80469. /**
  80470. * Defined the camera the input manager belongs to.
  80471. */
  80472. camera: TCamera;
  80473. /**
  80474. * Update the current camera state depending on the inputs that have been used this frame.
  80475. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  80476. */
  80477. checkInputs: () => void;
  80478. /**
  80479. * Instantiate a new Camera Input Manager.
  80480. * @param camera Defines the camera the input manager blongs to
  80481. */
  80482. constructor(camera: TCamera);
  80483. /**
  80484. * Add an input method to a camera
  80485. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  80486. * @param input camera input method
  80487. */
  80488. add(input: ICameraInput<TCamera>): void;
  80489. /**
  80490. * Remove a specific input method from a camera
  80491. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  80492. * @param inputToRemove camera input method
  80493. */
  80494. remove(inputToRemove: ICameraInput<TCamera>): void;
  80495. /**
  80496. * Remove a specific input type from a camera
  80497. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  80498. * @param inputType the type of the input to remove
  80499. */
  80500. removeByType(inputType: string): void;
  80501. private _addCheckInputs;
  80502. /**
  80503. * Attach the input controls to the currently attached dom element to listen the events from.
  80504. * @param input Defines the input to attach
  80505. */
  80506. attachInput(input: ICameraInput<TCamera>): void;
  80507. /**
  80508. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  80509. * @param element Defines the dom element to collect the events from
  80510. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  80511. */
  80512. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  80513. /**
  80514. * Detach the current manager inputs controls from a specific dom element.
  80515. * @param element Defines the dom element to collect the events from
  80516. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  80517. */
  80518. detachElement(element: HTMLElement, disconnect?: boolean): void;
  80519. /**
  80520. * Rebuild the dynamic inputCheck function from the current list of
  80521. * defined inputs in the manager.
  80522. */
  80523. rebuildInputCheck(): void;
  80524. /**
  80525. * Remove all attached input methods from a camera
  80526. */
  80527. clear(): void;
  80528. /**
  80529. * Serialize the current input manager attached to a camera.
  80530. * This ensures than once parsed,
  80531. * the input associated to the camera will be identical to the current ones
  80532. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  80533. */
  80534. serialize(serializedCamera: any): void;
  80535. /**
  80536. * Parses an input manager serialized JSON to restore the previous list of inputs
  80537. * and states associated to a camera.
  80538. * @param parsedCamera Defines the JSON to parse
  80539. */
  80540. parse(parsedCamera: any): void;
  80541. }
  80542. }
  80543. declare module BABYLON {
  80544. /**
  80545. * Class used to store data that will be store in GPU memory
  80546. */
  80547. export class Buffer {
  80548. private _engine;
  80549. private _buffer;
  80550. /** @hidden */
  80551. _data: Nullable<DataArray>;
  80552. private _updatable;
  80553. private _instanced;
  80554. private _divisor;
  80555. /**
  80556. * Gets the byte stride.
  80557. */
  80558. readonly byteStride: number;
  80559. /**
  80560. * Constructor
  80561. * @param engine the engine
  80562. * @param data the data to use for this buffer
  80563. * @param updatable whether the data is updatable
  80564. * @param stride the stride (optional)
  80565. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  80566. * @param instanced whether the buffer is instanced (optional)
  80567. * @param useBytes set to true if the stride in in bytes (optional)
  80568. * @param divisor sets an optional divisor for instances (1 by default)
  80569. */
  80570. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  80571. /**
  80572. * Create a new VertexBuffer based on the current buffer
  80573. * @param kind defines the vertex buffer kind (position, normal, etc.)
  80574. * @param offset defines offset in the buffer (0 by default)
  80575. * @param size defines the size in floats of attributes (position is 3 for instance)
  80576. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  80577. * @param instanced defines if the vertex buffer contains indexed data
  80578. * @param useBytes defines if the offset and stride are in bytes *
  80579. * @param divisor sets an optional divisor for instances (1 by default)
  80580. * @returns the new vertex buffer
  80581. */
  80582. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  80583. /**
  80584. * Gets a boolean indicating if the Buffer is updatable?
  80585. * @returns true if the buffer is updatable
  80586. */
  80587. isUpdatable(): boolean;
  80588. /**
  80589. * Gets current buffer's data
  80590. * @returns a DataArray or null
  80591. */
  80592. getData(): Nullable<DataArray>;
  80593. /**
  80594. * Gets underlying native buffer
  80595. * @returns underlying native buffer
  80596. */
  80597. getBuffer(): Nullable<DataBuffer>;
  80598. /**
  80599. * Gets the stride in float32 units (i.e. byte stride / 4).
  80600. * May not be an integer if the byte stride is not divisible by 4.
  80601. * @returns the stride in float32 units
  80602. * @deprecated Please use byteStride instead.
  80603. */
  80604. getStrideSize(): number;
  80605. /**
  80606. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  80607. * @param data defines the data to store
  80608. */
  80609. create(data?: Nullable<DataArray>): void;
  80610. /** @hidden */
  80611. _rebuild(): void;
  80612. /**
  80613. * Update current buffer data
  80614. * @param data defines the data to store
  80615. */
  80616. update(data: DataArray): void;
  80617. /**
  80618. * Updates the data directly.
  80619. * @param data the new data
  80620. * @param offset the new offset
  80621. * @param vertexCount the vertex count (optional)
  80622. * @param useBytes set to true if the offset is in bytes
  80623. */
  80624. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  80625. /**
  80626. * Release all resources
  80627. */
  80628. dispose(): void;
  80629. }
  80630. /**
  80631. * Specialized buffer used to store vertex data
  80632. */
  80633. export class VertexBuffer {
  80634. /** @hidden */
  80635. _buffer: Buffer;
  80636. private _kind;
  80637. private _size;
  80638. private _ownsBuffer;
  80639. private _instanced;
  80640. private _instanceDivisor;
  80641. /**
  80642. * The byte type.
  80643. */
  80644. static readonly BYTE: number;
  80645. /**
  80646. * The unsigned byte type.
  80647. */
  80648. static readonly UNSIGNED_BYTE: number;
  80649. /**
  80650. * The short type.
  80651. */
  80652. static readonly SHORT: number;
  80653. /**
  80654. * The unsigned short type.
  80655. */
  80656. static readonly UNSIGNED_SHORT: number;
  80657. /**
  80658. * The integer type.
  80659. */
  80660. static readonly INT: number;
  80661. /**
  80662. * The unsigned integer type.
  80663. */
  80664. static readonly UNSIGNED_INT: number;
  80665. /**
  80666. * The float type.
  80667. */
  80668. static readonly FLOAT: number;
  80669. /**
  80670. * Gets or sets the instance divisor when in instanced mode
  80671. */
  80672. get instanceDivisor(): number;
  80673. set instanceDivisor(value: number);
  80674. /**
  80675. * Gets the byte stride.
  80676. */
  80677. readonly byteStride: number;
  80678. /**
  80679. * Gets the byte offset.
  80680. */
  80681. readonly byteOffset: number;
  80682. /**
  80683. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  80684. */
  80685. readonly normalized: boolean;
  80686. /**
  80687. * Gets the data type of each component in the array.
  80688. */
  80689. readonly type: number;
  80690. /**
  80691. * Constructor
  80692. * @param engine the engine
  80693. * @param data the data to use for this vertex buffer
  80694. * @param kind the vertex buffer kind
  80695. * @param updatable whether the data is updatable
  80696. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  80697. * @param stride the stride (optional)
  80698. * @param instanced whether the buffer is instanced (optional)
  80699. * @param offset the offset of the data (optional)
  80700. * @param size the number of components (optional)
  80701. * @param type the type of the component (optional)
  80702. * @param normalized whether the data contains normalized data (optional)
  80703. * @param useBytes set to true if stride and offset are in bytes (optional)
  80704. * @param divisor defines the instance divisor to use (1 by default)
  80705. */
  80706. 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);
  80707. /** @hidden */
  80708. _rebuild(): void;
  80709. /**
  80710. * Returns the kind of the VertexBuffer (string)
  80711. * @returns a string
  80712. */
  80713. getKind(): string;
  80714. /**
  80715. * Gets a boolean indicating if the VertexBuffer is updatable?
  80716. * @returns true if the buffer is updatable
  80717. */
  80718. isUpdatable(): boolean;
  80719. /**
  80720. * Gets current buffer's data
  80721. * @returns a DataArray or null
  80722. */
  80723. getData(): Nullable<DataArray>;
  80724. /**
  80725. * Gets underlying native buffer
  80726. * @returns underlying native buffer
  80727. */
  80728. getBuffer(): Nullable<DataBuffer>;
  80729. /**
  80730. * Gets the stride in float32 units (i.e. byte stride / 4).
  80731. * May not be an integer if the byte stride is not divisible by 4.
  80732. * @returns the stride in float32 units
  80733. * @deprecated Please use byteStride instead.
  80734. */
  80735. getStrideSize(): number;
  80736. /**
  80737. * Returns the offset as a multiple of the type byte length.
  80738. * @returns the offset in bytes
  80739. * @deprecated Please use byteOffset instead.
  80740. */
  80741. getOffset(): number;
  80742. /**
  80743. * Returns the number of components per vertex attribute (integer)
  80744. * @returns the size in float
  80745. */
  80746. getSize(): number;
  80747. /**
  80748. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  80749. * @returns true if this buffer is instanced
  80750. */
  80751. getIsInstanced(): boolean;
  80752. /**
  80753. * Returns the instancing divisor, zero for non-instanced (integer).
  80754. * @returns a number
  80755. */
  80756. getInstanceDivisor(): number;
  80757. /**
  80758. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  80759. * @param data defines the data to store
  80760. */
  80761. create(data?: DataArray): void;
  80762. /**
  80763. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  80764. * This function will create a new buffer if the current one is not updatable
  80765. * @param data defines the data to store
  80766. */
  80767. update(data: DataArray): void;
  80768. /**
  80769. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  80770. * Returns the directly updated WebGLBuffer.
  80771. * @param data the new data
  80772. * @param offset the new offset
  80773. * @param useBytes set to true if the offset is in bytes
  80774. */
  80775. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  80776. /**
  80777. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  80778. */
  80779. dispose(): void;
  80780. /**
  80781. * Enumerates each value of this vertex buffer as numbers.
  80782. * @param count the number of values to enumerate
  80783. * @param callback the callback function called for each value
  80784. */
  80785. forEach(count: number, callback: (value: number, index: number) => void): void;
  80786. /**
  80787. * Positions
  80788. */
  80789. static readonly PositionKind: string;
  80790. /**
  80791. * Normals
  80792. */
  80793. static readonly NormalKind: string;
  80794. /**
  80795. * Tangents
  80796. */
  80797. static readonly TangentKind: string;
  80798. /**
  80799. * Texture coordinates
  80800. */
  80801. static readonly UVKind: string;
  80802. /**
  80803. * Texture coordinates 2
  80804. */
  80805. static readonly UV2Kind: string;
  80806. /**
  80807. * Texture coordinates 3
  80808. */
  80809. static readonly UV3Kind: string;
  80810. /**
  80811. * Texture coordinates 4
  80812. */
  80813. static readonly UV4Kind: string;
  80814. /**
  80815. * Texture coordinates 5
  80816. */
  80817. static readonly UV5Kind: string;
  80818. /**
  80819. * Texture coordinates 6
  80820. */
  80821. static readonly UV6Kind: string;
  80822. /**
  80823. * Colors
  80824. */
  80825. static readonly ColorKind: string;
  80826. /**
  80827. * Matrix indices (for bones)
  80828. */
  80829. static readonly MatricesIndicesKind: string;
  80830. /**
  80831. * Matrix weights (for bones)
  80832. */
  80833. static readonly MatricesWeightsKind: string;
  80834. /**
  80835. * Additional matrix indices (for bones)
  80836. */
  80837. static readonly MatricesIndicesExtraKind: string;
  80838. /**
  80839. * Additional matrix weights (for bones)
  80840. */
  80841. static readonly MatricesWeightsExtraKind: string;
  80842. /**
  80843. * Deduces the stride given a kind.
  80844. * @param kind The kind string to deduce
  80845. * @returns The deduced stride
  80846. */
  80847. static DeduceStride(kind: string): number;
  80848. /**
  80849. * Gets the byte length of the given type.
  80850. * @param type the type
  80851. * @returns the number of bytes
  80852. */
  80853. static GetTypeByteLength(type: number): number;
  80854. /**
  80855. * Enumerates each value of the given parameters as numbers.
  80856. * @param data the data to enumerate
  80857. * @param byteOffset the byte offset of the data
  80858. * @param byteStride the byte stride of the data
  80859. * @param componentCount the number of components per element
  80860. * @param componentType the type of the component
  80861. * @param count the number of values to enumerate
  80862. * @param normalized whether the data is normalized
  80863. * @param callback the callback function called for each value
  80864. */
  80865. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  80866. private static _GetFloatValue;
  80867. }
  80868. }
  80869. declare module BABYLON {
  80870. /**
  80871. * @hidden
  80872. */
  80873. export class IntersectionInfo {
  80874. bu: Nullable<number>;
  80875. bv: Nullable<number>;
  80876. distance: number;
  80877. faceId: number;
  80878. subMeshId: number;
  80879. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  80880. }
  80881. }
  80882. declare module BABYLON {
  80883. /**
  80884. * Represens a plane by the equation ax + by + cz + d = 0
  80885. */
  80886. export class Plane {
  80887. private static _TmpMatrix;
  80888. /**
  80889. * Normal of the plane (a,b,c)
  80890. */
  80891. normal: Vector3;
  80892. /**
  80893. * d component of the plane
  80894. */
  80895. d: number;
  80896. /**
  80897. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  80898. * @param a a component of the plane
  80899. * @param b b component of the plane
  80900. * @param c c component of the plane
  80901. * @param d d component of the plane
  80902. */
  80903. constructor(a: number, b: number, c: number, d: number);
  80904. /**
  80905. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  80906. */
  80907. asArray(): number[];
  80908. /**
  80909. * @returns a new plane copied from the current Plane.
  80910. */
  80911. clone(): Plane;
  80912. /**
  80913. * @returns the string "Plane".
  80914. */
  80915. getClassName(): string;
  80916. /**
  80917. * @returns the Plane hash code.
  80918. */
  80919. getHashCode(): number;
  80920. /**
  80921. * Normalize the current Plane in place.
  80922. * @returns the updated Plane.
  80923. */
  80924. normalize(): Plane;
  80925. /**
  80926. * Applies a transformation the plane and returns the result
  80927. * @param transformation the transformation matrix to be applied to the plane
  80928. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  80929. */
  80930. transform(transformation: DeepImmutable<Matrix>): Plane;
  80931. /**
  80932. * Calcualtte the dot product between the point and the plane normal
  80933. * @param point point to calculate the dot product with
  80934. * @returns the dot product (float) of the point coordinates and the plane normal.
  80935. */
  80936. dotCoordinate(point: DeepImmutable<Vector3>): number;
  80937. /**
  80938. * Updates the current Plane from the plane defined by the three given points.
  80939. * @param point1 one of the points used to contruct the plane
  80940. * @param point2 one of the points used to contruct the plane
  80941. * @param point3 one of the points used to contruct the plane
  80942. * @returns the updated Plane.
  80943. */
  80944. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  80945. /**
  80946. * Checks if the plane is facing a given direction
  80947. * @param direction the direction to check if the plane is facing
  80948. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  80949. * @returns True is the vector "direction" is the same side than the plane normal.
  80950. */
  80951. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  80952. /**
  80953. * Calculates the distance to a point
  80954. * @param point point to calculate distance to
  80955. * @returns the signed distance (float) from the given point to the Plane.
  80956. */
  80957. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  80958. /**
  80959. * Creates a plane from an array
  80960. * @param array the array to create a plane from
  80961. * @returns a new Plane from the given array.
  80962. */
  80963. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  80964. /**
  80965. * Creates a plane from three points
  80966. * @param point1 point used to create the plane
  80967. * @param point2 point used to create the plane
  80968. * @param point3 point used to create the plane
  80969. * @returns a new Plane defined by the three given points.
  80970. */
  80971. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  80972. /**
  80973. * Creates a plane from an origin point and a normal
  80974. * @param origin origin of the plane to be constructed
  80975. * @param normal normal of the plane to be constructed
  80976. * @returns a new Plane the normal vector to this plane at the given origin point.
  80977. * Note : the vector "normal" is updated because normalized.
  80978. */
  80979. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  80980. /**
  80981. * Calculates the distance from a plane and a point
  80982. * @param origin origin of the plane to be constructed
  80983. * @param normal normal of the plane to be constructed
  80984. * @param point point to calculate distance to
  80985. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  80986. */
  80987. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  80988. }
  80989. }
  80990. declare module BABYLON {
  80991. /**
  80992. * Class used to store bounding sphere information
  80993. */
  80994. export class BoundingSphere {
  80995. /**
  80996. * Gets the center of the bounding sphere in local space
  80997. */
  80998. readonly center: Vector3;
  80999. /**
  81000. * Radius of the bounding sphere in local space
  81001. */
  81002. radius: number;
  81003. /**
  81004. * Gets the center of the bounding sphere in world space
  81005. */
  81006. readonly centerWorld: Vector3;
  81007. /**
  81008. * Radius of the bounding sphere in world space
  81009. */
  81010. radiusWorld: number;
  81011. /**
  81012. * Gets the minimum vector in local space
  81013. */
  81014. readonly minimum: Vector3;
  81015. /**
  81016. * Gets the maximum vector in local space
  81017. */
  81018. readonly maximum: Vector3;
  81019. private _worldMatrix;
  81020. private static readonly TmpVector3;
  81021. /**
  81022. * Creates a new bounding sphere
  81023. * @param min defines the minimum vector (in local space)
  81024. * @param max defines the maximum vector (in local space)
  81025. * @param worldMatrix defines the new world matrix
  81026. */
  81027. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  81028. /**
  81029. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  81030. * @param min defines the new minimum vector (in local space)
  81031. * @param max defines the new maximum vector (in local space)
  81032. * @param worldMatrix defines the new world matrix
  81033. */
  81034. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  81035. /**
  81036. * Scale the current bounding sphere by applying a scale factor
  81037. * @param factor defines the scale factor to apply
  81038. * @returns the current bounding box
  81039. */
  81040. scale(factor: number): BoundingSphere;
  81041. /**
  81042. * Gets the world matrix of the bounding box
  81043. * @returns a matrix
  81044. */
  81045. getWorldMatrix(): DeepImmutable<Matrix>;
  81046. /** @hidden */
  81047. _update(worldMatrix: DeepImmutable<Matrix>): void;
  81048. /**
  81049. * Tests if the bounding sphere is intersecting the frustum planes
  81050. * @param frustumPlanes defines the frustum planes to test
  81051. * @returns true if there is an intersection
  81052. */
  81053. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  81054. /**
  81055. * Tests if the bounding sphere center is in between the frustum planes.
  81056. * Used for optimistic fast inclusion.
  81057. * @param frustumPlanes defines the frustum planes to test
  81058. * @returns true if the sphere center is in between the frustum planes
  81059. */
  81060. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  81061. /**
  81062. * Tests if a point is inside the bounding sphere
  81063. * @param point defines the point to test
  81064. * @returns true if the point is inside the bounding sphere
  81065. */
  81066. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  81067. /**
  81068. * Checks if two sphere intersct
  81069. * @param sphere0 sphere 0
  81070. * @param sphere1 sphere 1
  81071. * @returns true if the speres intersect
  81072. */
  81073. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  81074. }
  81075. }
  81076. declare module BABYLON {
  81077. /**
  81078. * Class used to store bounding box information
  81079. */
  81080. export class BoundingBox implements ICullable {
  81081. /**
  81082. * Gets the 8 vectors representing the bounding box in local space
  81083. */
  81084. readonly vectors: Vector3[];
  81085. /**
  81086. * Gets the center of the bounding box in local space
  81087. */
  81088. readonly center: Vector3;
  81089. /**
  81090. * Gets the center of the bounding box in world space
  81091. */
  81092. readonly centerWorld: Vector3;
  81093. /**
  81094. * Gets the extend size in local space
  81095. */
  81096. readonly extendSize: Vector3;
  81097. /**
  81098. * Gets the extend size in world space
  81099. */
  81100. readonly extendSizeWorld: Vector3;
  81101. /**
  81102. * Gets the OBB (object bounding box) directions
  81103. */
  81104. readonly directions: Vector3[];
  81105. /**
  81106. * Gets the 8 vectors representing the bounding box in world space
  81107. */
  81108. readonly vectorsWorld: Vector3[];
  81109. /**
  81110. * Gets the minimum vector in world space
  81111. */
  81112. readonly minimumWorld: Vector3;
  81113. /**
  81114. * Gets the maximum vector in world space
  81115. */
  81116. readonly maximumWorld: Vector3;
  81117. /**
  81118. * Gets the minimum vector in local space
  81119. */
  81120. readonly minimum: Vector3;
  81121. /**
  81122. * Gets the maximum vector in local space
  81123. */
  81124. readonly maximum: Vector3;
  81125. private _worldMatrix;
  81126. private static readonly TmpVector3;
  81127. /**
  81128. * @hidden
  81129. */
  81130. _tag: number;
  81131. /**
  81132. * Creates a new bounding box
  81133. * @param min defines the minimum vector (in local space)
  81134. * @param max defines the maximum vector (in local space)
  81135. * @param worldMatrix defines the new world matrix
  81136. */
  81137. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  81138. /**
  81139. * Recreates the entire bounding box from scratch as if we call the constructor in place
  81140. * @param min defines the new minimum vector (in local space)
  81141. * @param max defines the new maximum vector (in local space)
  81142. * @param worldMatrix defines the new world matrix
  81143. */
  81144. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  81145. /**
  81146. * Scale the current bounding box by applying a scale factor
  81147. * @param factor defines the scale factor to apply
  81148. * @returns the current bounding box
  81149. */
  81150. scale(factor: number): BoundingBox;
  81151. /**
  81152. * Gets the world matrix of the bounding box
  81153. * @returns a matrix
  81154. */
  81155. getWorldMatrix(): DeepImmutable<Matrix>;
  81156. /** @hidden */
  81157. _update(world: DeepImmutable<Matrix>): void;
  81158. /**
  81159. * Tests if the bounding box is intersecting the frustum planes
  81160. * @param frustumPlanes defines the frustum planes to test
  81161. * @returns true if there is an intersection
  81162. */
  81163. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  81164. /**
  81165. * Tests if the bounding box is entirely inside the frustum planes
  81166. * @param frustumPlanes defines the frustum planes to test
  81167. * @returns true if there is an inclusion
  81168. */
  81169. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  81170. /**
  81171. * Tests if a point is inside the bounding box
  81172. * @param point defines the point to test
  81173. * @returns true if the point is inside the bounding box
  81174. */
  81175. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  81176. /**
  81177. * Tests if the bounding box intersects with a bounding sphere
  81178. * @param sphere defines the sphere to test
  81179. * @returns true if there is an intersection
  81180. */
  81181. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  81182. /**
  81183. * Tests if the bounding box intersects with a box defined by a min and max vectors
  81184. * @param min defines the min vector to use
  81185. * @param max defines the max vector to use
  81186. * @returns true if there is an intersection
  81187. */
  81188. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  81189. /**
  81190. * Tests if two bounding boxes are intersections
  81191. * @param box0 defines the first box to test
  81192. * @param box1 defines the second box to test
  81193. * @returns true if there is an intersection
  81194. */
  81195. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  81196. /**
  81197. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  81198. * @param minPoint defines the minimum vector of the bounding box
  81199. * @param maxPoint defines the maximum vector of the bounding box
  81200. * @param sphereCenter defines the sphere center
  81201. * @param sphereRadius defines the sphere radius
  81202. * @returns true if there is an intersection
  81203. */
  81204. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  81205. /**
  81206. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  81207. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  81208. * @param frustumPlanes defines the frustum planes to test
  81209. * @return true if there is an inclusion
  81210. */
  81211. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  81212. /**
  81213. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  81214. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  81215. * @param frustumPlanes defines the frustum planes to test
  81216. * @return true if there is an intersection
  81217. */
  81218. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  81219. }
  81220. }
  81221. declare module BABYLON {
  81222. /** @hidden */
  81223. export class Collider {
  81224. /** Define if a collision was found */
  81225. collisionFound: boolean;
  81226. /**
  81227. * Define last intersection point in local space
  81228. */
  81229. intersectionPoint: Vector3;
  81230. /**
  81231. * Define last collided mesh
  81232. */
  81233. collidedMesh: Nullable<AbstractMesh>;
  81234. private _collisionPoint;
  81235. private _planeIntersectionPoint;
  81236. private _tempVector;
  81237. private _tempVector2;
  81238. private _tempVector3;
  81239. private _tempVector4;
  81240. private _edge;
  81241. private _baseToVertex;
  81242. private _destinationPoint;
  81243. private _slidePlaneNormal;
  81244. private _displacementVector;
  81245. /** @hidden */
  81246. _radius: Vector3;
  81247. /** @hidden */
  81248. _retry: number;
  81249. private _velocity;
  81250. private _basePoint;
  81251. private _epsilon;
  81252. /** @hidden */
  81253. _velocityWorldLength: number;
  81254. /** @hidden */
  81255. _basePointWorld: Vector3;
  81256. private _velocityWorld;
  81257. private _normalizedVelocity;
  81258. /** @hidden */
  81259. _initialVelocity: Vector3;
  81260. /** @hidden */
  81261. _initialPosition: Vector3;
  81262. private _nearestDistance;
  81263. private _collisionMask;
  81264. get collisionMask(): number;
  81265. set collisionMask(mask: number);
  81266. /**
  81267. * Gets the plane normal used to compute the sliding response (in local space)
  81268. */
  81269. get slidePlaneNormal(): Vector3;
  81270. /** @hidden */
  81271. _initialize(source: Vector3, dir: Vector3, e: number): void;
  81272. /** @hidden */
  81273. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  81274. /** @hidden */
  81275. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  81276. /** @hidden */
  81277. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  81278. /** @hidden */
  81279. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  81280. /** @hidden */
  81281. _getResponse(pos: Vector3, vel: Vector3): void;
  81282. }
  81283. }
  81284. declare module BABYLON {
  81285. /**
  81286. * Interface for cullable objects
  81287. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  81288. */
  81289. export interface ICullable {
  81290. /**
  81291. * Checks if the object or part of the object is in the frustum
  81292. * @param frustumPlanes Camera near/planes
  81293. * @returns true if the object is in frustum otherwise false
  81294. */
  81295. isInFrustum(frustumPlanes: Plane[]): boolean;
  81296. /**
  81297. * Checks if a cullable object (mesh...) is in the camera frustum
  81298. * Unlike isInFrustum this cheks the full bounding box
  81299. * @param frustumPlanes Camera near/planes
  81300. * @returns true if the object is in frustum otherwise false
  81301. */
  81302. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  81303. }
  81304. /**
  81305. * Info for a bounding data of a mesh
  81306. */
  81307. export class BoundingInfo implements ICullable {
  81308. /**
  81309. * Bounding box for the mesh
  81310. */
  81311. readonly boundingBox: BoundingBox;
  81312. /**
  81313. * Bounding sphere for the mesh
  81314. */
  81315. readonly boundingSphere: BoundingSphere;
  81316. private _isLocked;
  81317. private static readonly TmpVector3;
  81318. /**
  81319. * Constructs bounding info
  81320. * @param minimum min vector of the bounding box/sphere
  81321. * @param maximum max vector of the bounding box/sphere
  81322. * @param worldMatrix defines the new world matrix
  81323. */
  81324. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  81325. /**
  81326. * Recreates the entire bounding info from scratch as if we call the constructor in place
  81327. * @param min defines the new minimum vector (in local space)
  81328. * @param max defines the new maximum vector (in local space)
  81329. * @param worldMatrix defines the new world matrix
  81330. */
  81331. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  81332. /**
  81333. * min vector of the bounding box/sphere
  81334. */
  81335. get minimum(): Vector3;
  81336. /**
  81337. * max vector of the bounding box/sphere
  81338. */
  81339. get maximum(): Vector3;
  81340. /**
  81341. * If the info is locked and won't be updated to avoid perf overhead
  81342. */
  81343. get isLocked(): boolean;
  81344. set isLocked(value: boolean);
  81345. /**
  81346. * Updates the bounding sphere and box
  81347. * @param world world matrix to be used to update
  81348. */
  81349. update(world: DeepImmutable<Matrix>): void;
  81350. /**
  81351. * Recreate the bounding info to be centered around a specific point given a specific extend.
  81352. * @param center New center of the bounding info
  81353. * @param extend New extend of the bounding info
  81354. * @returns the current bounding info
  81355. */
  81356. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  81357. /**
  81358. * Scale the current bounding info by applying a scale factor
  81359. * @param factor defines the scale factor to apply
  81360. * @returns the current bounding info
  81361. */
  81362. scale(factor: number): BoundingInfo;
  81363. /**
  81364. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  81365. * @param frustumPlanes defines the frustum to test
  81366. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  81367. * @returns true if the bounding info is in the frustum planes
  81368. */
  81369. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  81370. /**
  81371. * Gets the world distance between the min and max points of the bounding box
  81372. */
  81373. get diagonalLength(): number;
  81374. /**
  81375. * Checks if a cullable object (mesh...) is in the camera frustum
  81376. * Unlike isInFrustum this cheks the full bounding box
  81377. * @param frustumPlanes Camera near/planes
  81378. * @returns true if the object is in frustum otherwise false
  81379. */
  81380. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  81381. /** @hidden */
  81382. _checkCollision(collider: Collider): boolean;
  81383. /**
  81384. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  81385. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  81386. * @param point the point to check intersection with
  81387. * @returns if the point intersects
  81388. */
  81389. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  81390. /**
  81391. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  81392. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  81393. * @param boundingInfo the bounding info to check intersection with
  81394. * @param precise if the intersection should be done using OBB
  81395. * @returns if the bounding info intersects
  81396. */
  81397. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  81398. }
  81399. }
  81400. declare module BABYLON {
  81401. /**
  81402. * Extracts minimum and maximum values from a list of indexed positions
  81403. * @param positions defines the positions to use
  81404. * @param indices defines the indices to the positions
  81405. * @param indexStart defines the start index
  81406. * @param indexCount defines the end index
  81407. * @param bias defines bias value to add to the result
  81408. * @return minimum and maximum values
  81409. */
  81410. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  81411. minimum: Vector3;
  81412. maximum: Vector3;
  81413. };
  81414. /**
  81415. * Extracts minimum and maximum values from a list of positions
  81416. * @param positions defines the positions to use
  81417. * @param start defines the start index in the positions array
  81418. * @param count defines the number of positions to handle
  81419. * @param bias defines bias value to add to the result
  81420. * @param stride defines the stride size to use (distance between two positions in the positions array)
  81421. * @return minimum and maximum values
  81422. */
  81423. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  81424. minimum: Vector3;
  81425. maximum: Vector3;
  81426. };
  81427. }
  81428. declare module BABYLON {
  81429. /** @hidden */
  81430. export class WebGLDataBuffer extends DataBuffer {
  81431. private _buffer;
  81432. constructor(resource: WebGLBuffer);
  81433. get underlyingResource(): any;
  81434. }
  81435. }
  81436. declare module BABYLON {
  81437. /** @hidden */
  81438. export class WebGLPipelineContext implements IPipelineContext {
  81439. engine: ThinEngine;
  81440. program: Nullable<WebGLProgram>;
  81441. context?: WebGLRenderingContext;
  81442. vertexShader?: WebGLShader;
  81443. fragmentShader?: WebGLShader;
  81444. isParallelCompiled: boolean;
  81445. onCompiled?: () => void;
  81446. transformFeedback?: WebGLTransformFeedback | null;
  81447. vertexCompilationError: Nullable<string>;
  81448. fragmentCompilationError: Nullable<string>;
  81449. programLinkError: Nullable<string>;
  81450. programValidationError: Nullable<string>;
  81451. get isAsync(): boolean;
  81452. get isReady(): boolean;
  81453. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  81454. _getVertexShaderCode(): string | null;
  81455. _getFragmentShaderCode(): string | null;
  81456. }
  81457. }
  81458. declare module BABYLON {
  81459. interface ThinEngine {
  81460. /**
  81461. * Create an uniform buffer
  81462. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  81463. * @param elements defines the content of the uniform buffer
  81464. * @returns the webGL uniform buffer
  81465. */
  81466. createUniformBuffer(elements: FloatArray): DataBuffer;
  81467. /**
  81468. * Create a dynamic uniform buffer
  81469. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  81470. * @param elements defines the content of the uniform buffer
  81471. * @returns the webGL uniform buffer
  81472. */
  81473. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  81474. /**
  81475. * Update an existing uniform buffer
  81476. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  81477. * @param uniformBuffer defines the target uniform buffer
  81478. * @param elements defines the content to update
  81479. * @param offset defines the offset in the uniform buffer where update should start
  81480. * @param count defines the size of the data to update
  81481. */
  81482. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  81483. /**
  81484. * Bind an uniform buffer to the current webGL context
  81485. * @param buffer defines the buffer to bind
  81486. */
  81487. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  81488. /**
  81489. * Bind a buffer to the current webGL context at a given location
  81490. * @param buffer defines the buffer to bind
  81491. * @param location defines the index where to bind the buffer
  81492. */
  81493. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  81494. /**
  81495. * Bind a specific block at a given index in a specific shader program
  81496. * @param pipelineContext defines the pipeline context to use
  81497. * @param blockName defines the block name
  81498. * @param index defines the index where to bind the block
  81499. */
  81500. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  81501. }
  81502. }
  81503. declare module BABYLON {
  81504. /**
  81505. * Uniform buffer objects.
  81506. *
  81507. * Handles blocks of uniform on the GPU.
  81508. *
  81509. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  81510. *
  81511. * For more information, please refer to :
  81512. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  81513. */
  81514. export class UniformBuffer {
  81515. private _engine;
  81516. private _buffer;
  81517. private _data;
  81518. private _bufferData;
  81519. private _dynamic?;
  81520. private _uniformLocations;
  81521. private _uniformSizes;
  81522. private _uniformLocationPointer;
  81523. private _needSync;
  81524. private _noUBO;
  81525. private _currentEffect;
  81526. /** @hidden */
  81527. _alreadyBound: boolean;
  81528. private static _MAX_UNIFORM_SIZE;
  81529. private static _tempBuffer;
  81530. /**
  81531. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  81532. * This is dynamic to allow compat with webgl 1 and 2.
  81533. * You will need to pass the name of the uniform as well as the value.
  81534. */
  81535. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  81536. /**
  81537. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  81538. * This is dynamic to allow compat with webgl 1 and 2.
  81539. * You will need to pass the name of the uniform as well as the value.
  81540. */
  81541. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  81542. /**
  81543. * Lambda to Update a single float in a uniform buffer.
  81544. * This is dynamic to allow compat with webgl 1 and 2.
  81545. * You will need to pass the name of the uniform as well as the value.
  81546. */
  81547. updateFloat: (name: string, x: number) => void;
  81548. /**
  81549. * Lambda to Update a vec2 of float in a uniform buffer.
  81550. * This is dynamic to allow compat with webgl 1 and 2.
  81551. * You will need to pass the name of the uniform as well as the value.
  81552. */
  81553. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  81554. /**
  81555. * Lambda to Update a vec3 of float in a uniform buffer.
  81556. * This is dynamic to allow compat with webgl 1 and 2.
  81557. * You will need to pass the name of the uniform as well as the value.
  81558. */
  81559. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  81560. /**
  81561. * Lambda to Update a vec4 of float in a uniform buffer.
  81562. * This is dynamic to allow compat with webgl 1 and 2.
  81563. * You will need to pass the name of the uniform as well as the value.
  81564. */
  81565. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  81566. /**
  81567. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  81568. * This is dynamic to allow compat with webgl 1 and 2.
  81569. * You will need to pass the name of the uniform as well as the value.
  81570. */
  81571. updateMatrix: (name: string, mat: Matrix) => void;
  81572. /**
  81573. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  81574. * This is dynamic to allow compat with webgl 1 and 2.
  81575. * You will need to pass the name of the uniform as well as the value.
  81576. */
  81577. updateVector3: (name: string, vector: Vector3) => void;
  81578. /**
  81579. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  81580. * This is dynamic to allow compat with webgl 1 and 2.
  81581. * You will need to pass the name of the uniform as well as the value.
  81582. */
  81583. updateVector4: (name: string, vector: Vector4) => void;
  81584. /**
  81585. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  81586. * This is dynamic to allow compat with webgl 1 and 2.
  81587. * You will need to pass the name of the uniform as well as the value.
  81588. */
  81589. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  81590. /**
  81591. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  81592. * This is dynamic to allow compat with webgl 1 and 2.
  81593. * You will need to pass the name of the uniform as well as the value.
  81594. */
  81595. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  81596. /**
  81597. * Instantiates a new Uniform buffer objects.
  81598. *
  81599. * Handles blocks of uniform on the GPU.
  81600. *
  81601. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  81602. *
  81603. * For more information, please refer to :
  81604. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  81605. * @param engine Define the engine the buffer is associated with
  81606. * @param data Define the data contained in the buffer
  81607. * @param dynamic Define if the buffer is updatable
  81608. */
  81609. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  81610. /**
  81611. * Indicates if the buffer is using the WebGL2 UBO implementation,
  81612. * or just falling back on setUniformXXX calls.
  81613. */
  81614. get useUbo(): boolean;
  81615. /**
  81616. * Indicates if the WebGL underlying uniform buffer is in sync
  81617. * with the javascript cache data.
  81618. */
  81619. get isSync(): boolean;
  81620. /**
  81621. * Indicates if the WebGL underlying uniform buffer is dynamic.
  81622. * Also, a dynamic UniformBuffer will disable cache verification and always
  81623. * update the underlying WebGL uniform buffer to the GPU.
  81624. * @returns if Dynamic, otherwise false
  81625. */
  81626. isDynamic(): boolean;
  81627. /**
  81628. * The data cache on JS side.
  81629. * @returns the underlying data as a float array
  81630. */
  81631. getData(): Float32Array;
  81632. /**
  81633. * The underlying WebGL Uniform buffer.
  81634. * @returns the webgl buffer
  81635. */
  81636. getBuffer(): Nullable<DataBuffer>;
  81637. /**
  81638. * std140 layout specifies how to align data within an UBO structure.
  81639. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  81640. * for specs.
  81641. */
  81642. private _fillAlignment;
  81643. /**
  81644. * Adds an uniform in the buffer.
  81645. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  81646. * for the layout to be correct !
  81647. * @param name Name of the uniform, as used in the uniform block in the shader.
  81648. * @param size Data size, or data directly.
  81649. */
  81650. addUniform(name: string, size: number | number[]): void;
  81651. /**
  81652. * Adds a Matrix 4x4 to the uniform buffer.
  81653. * @param name Name of the uniform, as used in the uniform block in the shader.
  81654. * @param mat A 4x4 matrix.
  81655. */
  81656. addMatrix(name: string, mat: Matrix): void;
  81657. /**
  81658. * Adds a vec2 to the uniform buffer.
  81659. * @param name Name of the uniform, as used in the uniform block in the shader.
  81660. * @param x Define the x component value of the vec2
  81661. * @param y Define the y component value of the vec2
  81662. */
  81663. addFloat2(name: string, x: number, y: number): void;
  81664. /**
  81665. * Adds a vec3 to the uniform buffer.
  81666. * @param name Name of the uniform, as used in the uniform block in the shader.
  81667. * @param x Define the x component value of the vec3
  81668. * @param y Define the y component value of the vec3
  81669. * @param z Define the z component value of the vec3
  81670. */
  81671. addFloat3(name: string, x: number, y: number, z: number): void;
  81672. /**
  81673. * Adds a vec3 to the uniform buffer.
  81674. * @param name Name of the uniform, as used in the uniform block in the shader.
  81675. * @param color Define the vec3 from a Color
  81676. */
  81677. addColor3(name: string, color: Color3): void;
  81678. /**
  81679. * Adds a vec4 to the uniform buffer.
  81680. * @param name Name of the uniform, as used in the uniform block in the shader.
  81681. * @param color Define the rgb components from a Color
  81682. * @param alpha Define the a component of the vec4
  81683. */
  81684. addColor4(name: string, color: Color3, alpha: number): void;
  81685. /**
  81686. * Adds a vec3 to the uniform buffer.
  81687. * @param name Name of the uniform, as used in the uniform block in the shader.
  81688. * @param vector Define the vec3 components from a Vector
  81689. */
  81690. addVector3(name: string, vector: Vector3): void;
  81691. /**
  81692. * Adds a Matrix 3x3 to the uniform buffer.
  81693. * @param name Name of the uniform, as used in the uniform block in the shader.
  81694. */
  81695. addMatrix3x3(name: string): void;
  81696. /**
  81697. * Adds a Matrix 2x2 to the uniform buffer.
  81698. * @param name Name of the uniform, as used in the uniform block in the shader.
  81699. */
  81700. addMatrix2x2(name: string): void;
  81701. /**
  81702. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  81703. */
  81704. create(): void;
  81705. /** @hidden */
  81706. _rebuild(): void;
  81707. /**
  81708. * Updates the WebGL Uniform Buffer on the GPU.
  81709. * If the `dynamic` flag is set to true, no cache comparison is done.
  81710. * Otherwise, the buffer will be updated only if the cache differs.
  81711. */
  81712. update(): void;
  81713. /**
  81714. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  81715. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  81716. * @param data Define the flattened data
  81717. * @param size Define the size of the data.
  81718. */
  81719. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  81720. private _valueCache;
  81721. private _cacheMatrix;
  81722. private _updateMatrix3x3ForUniform;
  81723. private _updateMatrix3x3ForEffect;
  81724. private _updateMatrix2x2ForEffect;
  81725. private _updateMatrix2x2ForUniform;
  81726. private _updateFloatForEffect;
  81727. private _updateFloatForUniform;
  81728. private _updateFloat2ForEffect;
  81729. private _updateFloat2ForUniform;
  81730. private _updateFloat3ForEffect;
  81731. private _updateFloat3ForUniform;
  81732. private _updateFloat4ForEffect;
  81733. private _updateFloat4ForUniform;
  81734. private _updateMatrixForEffect;
  81735. private _updateMatrixForUniform;
  81736. private _updateVector3ForEffect;
  81737. private _updateVector3ForUniform;
  81738. private _updateVector4ForEffect;
  81739. private _updateVector4ForUniform;
  81740. private _updateColor3ForEffect;
  81741. private _updateColor3ForUniform;
  81742. private _updateColor4ForEffect;
  81743. private _updateColor4ForUniform;
  81744. /**
  81745. * Sets a sampler uniform on the effect.
  81746. * @param name Define the name of the sampler.
  81747. * @param texture Define the texture to set in the sampler
  81748. */
  81749. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  81750. /**
  81751. * Directly updates the value of the uniform in the cache AND on the GPU.
  81752. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  81753. * @param data Define the flattened data
  81754. */
  81755. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  81756. /**
  81757. * Binds this uniform buffer to an effect.
  81758. * @param effect Define the effect to bind the buffer to
  81759. * @param name Name of the uniform block in the shader.
  81760. */
  81761. bindToEffect(effect: Effect, name: string): void;
  81762. /**
  81763. * Disposes the uniform buffer.
  81764. */
  81765. dispose(): void;
  81766. }
  81767. }
  81768. declare module BABYLON {
  81769. /**
  81770. * Enum that determines the text-wrapping mode to use.
  81771. */
  81772. export enum InspectableType {
  81773. /**
  81774. * Checkbox for booleans
  81775. */
  81776. Checkbox = 0,
  81777. /**
  81778. * Sliders for numbers
  81779. */
  81780. Slider = 1,
  81781. /**
  81782. * Vector3
  81783. */
  81784. Vector3 = 2,
  81785. /**
  81786. * Quaternions
  81787. */
  81788. Quaternion = 3,
  81789. /**
  81790. * Color3
  81791. */
  81792. Color3 = 4,
  81793. /**
  81794. * String
  81795. */
  81796. String = 5
  81797. }
  81798. /**
  81799. * Interface used to define custom inspectable properties.
  81800. * This interface is used by the inspector to display custom property grids
  81801. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  81802. */
  81803. export interface IInspectable {
  81804. /**
  81805. * Gets the label to display
  81806. */
  81807. label: string;
  81808. /**
  81809. * Gets the name of the property to edit
  81810. */
  81811. propertyName: string;
  81812. /**
  81813. * Gets the type of the editor to use
  81814. */
  81815. type: InspectableType;
  81816. /**
  81817. * Gets the minimum value of the property when using in "slider" mode
  81818. */
  81819. min?: number;
  81820. /**
  81821. * Gets the maximum value of the property when using in "slider" mode
  81822. */
  81823. max?: number;
  81824. /**
  81825. * Gets the setp to use when using in "slider" mode
  81826. */
  81827. step?: number;
  81828. }
  81829. }
  81830. declare module BABYLON {
  81831. /**
  81832. * Class used to provide helper for timing
  81833. */
  81834. export class TimingTools {
  81835. /**
  81836. * Polyfill for setImmediate
  81837. * @param action defines the action to execute after the current execution block
  81838. */
  81839. static SetImmediate(action: () => void): void;
  81840. }
  81841. }
  81842. declare module BABYLON {
  81843. /**
  81844. * Class used to enable instatition of objects by class name
  81845. */
  81846. export class InstantiationTools {
  81847. /**
  81848. * Use this object to register external classes like custom textures or material
  81849. * to allow the laoders to instantiate them
  81850. */
  81851. static RegisteredExternalClasses: {
  81852. [key: string]: Object;
  81853. };
  81854. /**
  81855. * Tries to instantiate a new object from a given class name
  81856. * @param className defines the class name to instantiate
  81857. * @returns the new object or null if the system was not able to do the instantiation
  81858. */
  81859. static Instantiate(className: string): any;
  81860. }
  81861. }
  81862. declare module BABYLON {
  81863. /**
  81864. * Define options used to create a depth texture
  81865. */
  81866. export class DepthTextureCreationOptions {
  81867. /** Specifies whether or not a stencil should be allocated in the texture */
  81868. generateStencil?: boolean;
  81869. /** Specifies whether or not bilinear filtering is enable on the texture */
  81870. bilinearFiltering?: boolean;
  81871. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  81872. comparisonFunction?: number;
  81873. /** Specifies if the created texture is a cube texture */
  81874. isCube?: boolean;
  81875. }
  81876. }
  81877. declare module BABYLON {
  81878. interface ThinEngine {
  81879. /**
  81880. * Creates a depth stencil cube texture.
  81881. * This is only available in WebGL 2.
  81882. * @param size The size of face edge in the cube texture.
  81883. * @param options The options defining the cube texture.
  81884. * @returns The cube texture
  81885. */
  81886. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  81887. /**
  81888. * Creates a cube texture
  81889. * @param rootUrl defines the url where the files to load is located
  81890. * @param scene defines the current scene
  81891. * @param files defines the list of files to load (1 per face)
  81892. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  81893. * @param onLoad defines an optional callback raised when the texture is loaded
  81894. * @param onError defines an optional callback raised if there is an issue to load the texture
  81895. * @param format defines the format of the data
  81896. * @param forcedExtension defines the extension to use to pick the right loader
  81897. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  81898. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  81899. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  81900. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  81901. * @returns the cube texture as an InternalTexture
  81902. */
  81903. 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;
  81904. /**
  81905. * Creates a cube texture
  81906. * @param rootUrl defines the url where the files to load is located
  81907. * @param scene defines the current scene
  81908. * @param files defines the list of files to load (1 per face)
  81909. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  81910. * @param onLoad defines an optional callback raised when the texture is loaded
  81911. * @param onError defines an optional callback raised if there is an issue to load the texture
  81912. * @param format defines the format of the data
  81913. * @param forcedExtension defines the extension to use to pick the right loader
  81914. * @returns the cube texture as an InternalTexture
  81915. */
  81916. 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;
  81917. /**
  81918. * Creates a cube texture
  81919. * @param rootUrl defines the url where the files to load is located
  81920. * @param scene defines the current scene
  81921. * @param files defines the list of files to load (1 per face)
  81922. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  81923. * @param onLoad defines an optional callback raised when the texture is loaded
  81924. * @param onError defines an optional callback raised if there is an issue to load the texture
  81925. * @param format defines the format of the data
  81926. * @param forcedExtension defines the extension to use to pick the right loader
  81927. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  81928. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  81929. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  81930. * @returns the cube texture as an InternalTexture
  81931. */
  81932. 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;
  81933. /** @hidden */
  81934. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  81935. /** @hidden */
  81936. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  81937. /** @hidden */
  81938. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  81939. /** @hidden */
  81940. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  81941. /**
  81942. * @hidden
  81943. */
  81944. _setCubeMapTextureParams(loadMipmap: boolean): void;
  81945. }
  81946. }
  81947. declare module BABYLON {
  81948. /**
  81949. * Class for creating a cube texture
  81950. */
  81951. export class CubeTexture extends BaseTexture {
  81952. private _delayedOnLoad;
  81953. /**
  81954. * Observable triggered once the texture has been loaded.
  81955. */
  81956. onLoadObservable: Observable<CubeTexture>;
  81957. /**
  81958. * The url of the texture
  81959. */
  81960. url: string;
  81961. /**
  81962. * Gets or sets the center of the bounding box associated with the cube texture.
  81963. * It must define where the camera used to render the texture was set
  81964. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  81965. */
  81966. boundingBoxPosition: Vector3;
  81967. private _boundingBoxSize;
  81968. /**
  81969. * Gets or sets the size of the bounding box associated with the cube texture
  81970. * When defined, the cubemap will switch to local mode
  81971. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  81972. * @example https://www.babylonjs-playground.com/#RNASML
  81973. */
  81974. set boundingBoxSize(value: Vector3);
  81975. /**
  81976. * Returns the bounding box size
  81977. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  81978. */
  81979. get boundingBoxSize(): Vector3;
  81980. protected _rotationY: number;
  81981. /**
  81982. * Sets texture matrix rotation angle around Y axis in radians.
  81983. */
  81984. set rotationY(value: number);
  81985. /**
  81986. * Gets texture matrix rotation angle around Y axis radians.
  81987. */
  81988. get rotationY(): number;
  81989. /**
  81990. * Are mip maps generated for this texture or not.
  81991. */
  81992. get noMipmap(): boolean;
  81993. private _noMipmap;
  81994. private _files;
  81995. protected _forcedExtension: Nullable<string>;
  81996. private _extensions;
  81997. private _textureMatrix;
  81998. private _format;
  81999. private _createPolynomials;
  82000. /** @hidden */
  82001. _prefiltered: boolean;
  82002. /**
  82003. * Creates a cube texture from an array of image urls
  82004. * @param files defines an array of image urls
  82005. * @param scene defines the hosting scene
  82006. * @param noMipmap specifies if mip maps are not used
  82007. * @returns a cube texture
  82008. */
  82009. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  82010. /**
  82011. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  82012. * @param url defines the url of the prefiltered texture
  82013. * @param scene defines the scene the texture is attached to
  82014. * @param forcedExtension defines the extension of the file if different from the url
  82015. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  82016. * @return the prefiltered texture
  82017. */
  82018. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  82019. /**
  82020. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  82021. * as prefiltered data.
  82022. * @param rootUrl defines the url of the texture or the root name of the six images
  82023. * @param scene defines the scene the texture is attached to
  82024. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  82025. * @param noMipmap defines if mipmaps should be created or not
  82026. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  82027. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  82028. * @param onError defines a callback triggered in case of error during load
  82029. * @param format defines the internal format to use for the texture once loaded
  82030. * @param prefiltered defines whether or not the texture is created from prefiltered data
  82031. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  82032. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  82033. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  82034. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  82035. * @return the cube texture
  82036. */
  82037. 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);
  82038. /**
  82039. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  82040. */
  82041. get isPrefiltered(): boolean;
  82042. /**
  82043. * Get the current class name of the texture useful for serialization or dynamic coding.
  82044. * @returns "CubeTexture"
  82045. */
  82046. getClassName(): string;
  82047. /**
  82048. * Update the url (and optional buffer) of this texture if url was null during construction.
  82049. * @param url the url of the texture
  82050. * @param forcedExtension defines the extension to use
  82051. * @param onLoad callback called when the texture is loaded (defaults to null)
  82052. * @param prefiltered Defines whether the updated texture is prefiltered or not
  82053. */
  82054. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  82055. /**
  82056. * Delays loading of the cube texture
  82057. * @param forcedExtension defines the extension to use
  82058. */
  82059. delayLoad(forcedExtension?: string): void;
  82060. /**
  82061. * Returns the reflection texture matrix
  82062. * @returns the reflection texture matrix
  82063. */
  82064. getReflectionTextureMatrix(): Matrix;
  82065. /**
  82066. * Sets the reflection texture matrix
  82067. * @param value Reflection texture matrix
  82068. */
  82069. setReflectionTextureMatrix(value: Matrix): void;
  82070. /**
  82071. * Parses text to create a cube texture
  82072. * @param parsedTexture define the serialized text to read from
  82073. * @param scene defines the hosting scene
  82074. * @param rootUrl defines the root url of the cube texture
  82075. * @returns a cube texture
  82076. */
  82077. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  82078. /**
  82079. * Makes a clone, or deep copy, of the cube texture
  82080. * @returns a new cube texture
  82081. */
  82082. clone(): CubeTexture;
  82083. }
  82084. }
  82085. declare module BABYLON {
  82086. /**
  82087. * Manages the defines for the Material
  82088. */
  82089. export class MaterialDefines {
  82090. /** @hidden */
  82091. protected _keys: string[];
  82092. private _isDirty;
  82093. /** @hidden */
  82094. _renderId: number;
  82095. /** @hidden */
  82096. _areLightsDirty: boolean;
  82097. /** @hidden */
  82098. _areLightsDisposed: boolean;
  82099. /** @hidden */
  82100. _areAttributesDirty: boolean;
  82101. /** @hidden */
  82102. _areTexturesDirty: boolean;
  82103. /** @hidden */
  82104. _areFresnelDirty: boolean;
  82105. /** @hidden */
  82106. _areMiscDirty: boolean;
  82107. /** @hidden */
  82108. _areImageProcessingDirty: boolean;
  82109. /** @hidden */
  82110. _normals: boolean;
  82111. /** @hidden */
  82112. _uvs: boolean;
  82113. /** @hidden */
  82114. _needNormals: boolean;
  82115. /** @hidden */
  82116. _needUVs: boolean;
  82117. [id: string]: any;
  82118. /**
  82119. * Specifies if the material needs to be re-calculated
  82120. */
  82121. get isDirty(): boolean;
  82122. /**
  82123. * Marks the material to indicate that it has been re-calculated
  82124. */
  82125. markAsProcessed(): void;
  82126. /**
  82127. * Marks the material to indicate that it needs to be re-calculated
  82128. */
  82129. markAsUnprocessed(): void;
  82130. /**
  82131. * Marks the material to indicate all of its defines need to be re-calculated
  82132. */
  82133. markAllAsDirty(): void;
  82134. /**
  82135. * Marks the material to indicate that image processing needs to be re-calculated
  82136. */
  82137. markAsImageProcessingDirty(): void;
  82138. /**
  82139. * Marks the material to indicate the lights need to be re-calculated
  82140. * @param disposed Defines whether the light is dirty due to dispose or not
  82141. */
  82142. markAsLightDirty(disposed?: boolean): void;
  82143. /**
  82144. * Marks the attribute state as changed
  82145. */
  82146. markAsAttributesDirty(): void;
  82147. /**
  82148. * Marks the texture state as changed
  82149. */
  82150. markAsTexturesDirty(): void;
  82151. /**
  82152. * Marks the fresnel state as changed
  82153. */
  82154. markAsFresnelDirty(): void;
  82155. /**
  82156. * Marks the misc state as changed
  82157. */
  82158. markAsMiscDirty(): void;
  82159. /**
  82160. * Rebuilds the material defines
  82161. */
  82162. rebuild(): void;
  82163. /**
  82164. * Specifies if two material defines are equal
  82165. * @param other - A material define instance to compare to
  82166. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  82167. */
  82168. isEqual(other: MaterialDefines): boolean;
  82169. /**
  82170. * Clones this instance's defines to another instance
  82171. * @param other - material defines to clone values to
  82172. */
  82173. cloneTo(other: MaterialDefines): void;
  82174. /**
  82175. * Resets the material define values
  82176. */
  82177. reset(): void;
  82178. /**
  82179. * Converts the material define values to a string
  82180. * @returns - String of material define information
  82181. */
  82182. toString(): string;
  82183. }
  82184. }
  82185. declare module BABYLON {
  82186. /**
  82187. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  82188. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  82189. * 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;
  82190. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  82191. */
  82192. export class ColorCurves {
  82193. private _dirty;
  82194. private _tempColor;
  82195. private _globalCurve;
  82196. private _highlightsCurve;
  82197. private _midtonesCurve;
  82198. private _shadowsCurve;
  82199. private _positiveCurve;
  82200. private _negativeCurve;
  82201. private _globalHue;
  82202. private _globalDensity;
  82203. private _globalSaturation;
  82204. private _globalExposure;
  82205. /**
  82206. * Gets the global Hue value.
  82207. * 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).
  82208. */
  82209. get globalHue(): number;
  82210. /**
  82211. * Sets the global Hue value.
  82212. * 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).
  82213. */
  82214. set globalHue(value: number);
  82215. /**
  82216. * Gets the global Density value.
  82217. * 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.
  82218. * Values less than zero provide a filter of opposite hue.
  82219. */
  82220. get globalDensity(): number;
  82221. /**
  82222. * Sets the global Density value.
  82223. * 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.
  82224. * Values less than zero provide a filter of opposite hue.
  82225. */
  82226. set globalDensity(value: number);
  82227. /**
  82228. * Gets the global Saturation value.
  82229. * 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.
  82230. */
  82231. get globalSaturation(): number;
  82232. /**
  82233. * Sets the global Saturation value.
  82234. * 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.
  82235. */
  82236. set globalSaturation(value: number);
  82237. /**
  82238. * Gets the global Exposure value.
  82239. * 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.
  82240. */
  82241. get globalExposure(): number;
  82242. /**
  82243. * Sets the global Exposure value.
  82244. * 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.
  82245. */
  82246. set globalExposure(value: number);
  82247. private _highlightsHue;
  82248. private _highlightsDensity;
  82249. private _highlightsSaturation;
  82250. private _highlightsExposure;
  82251. /**
  82252. * Gets the highlights Hue value.
  82253. * 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).
  82254. */
  82255. get highlightsHue(): number;
  82256. /**
  82257. * Sets the highlights Hue value.
  82258. * 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).
  82259. */
  82260. set highlightsHue(value: number);
  82261. /**
  82262. * Gets the highlights Density value.
  82263. * 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.
  82264. * Values less than zero provide a filter of opposite hue.
  82265. */
  82266. get highlightsDensity(): number;
  82267. /**
  82268. * Sets the highlights Density value.
  82269. * 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.
  82270. * Values less than zero provide a filter of opposite hue.
  82271. */
  82272. set highlightsDensity(value: number);
  82273. /**
  82274. * Gets the highlights Saturation value.
  82275. * 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.
  82276. */
  82277. get highlightsSaturation(): number;
  82278. /**
  82279. * Sets the highlights Saturation value.
  82280. * 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.
  82281. */
  82282. set highlightsSaturation(value: number);
  82283. /**
  82284. * Gets the highlights Exposure value.
  82285. * 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.
  82286. */
  82287. get highlightsExposure(): number;
  82288. /**
  82289. * Sets the highlights Exposure value.
  82290. * 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.
  82291. */
  82292. set highlightsExposure(value: number);
  82293. private _midtonesHue;
  82294. private _midtonesDensity;
  82295. private _midtonesSaturation;
  82296. private _midtonesExposure;
  82297. /**
  82298. * Gets the midtones Hue value.
  82299. * 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).
  82300. */
  82301. get midtonesHue(): number;
  82302. /**
  82303. * Sets the midtones Hue value.
  82304. * 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).
  82305. */
  82306. set midtonesHue(value: number);
  82307. /**
  82308. * Gets the midtones Density value.
  82309. * 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.
  82310. * Values less than zero provide a filter of opposite hue.
  82311. */
  82312. get midtonesDensity(): number;
  82313. /**
  82314. * Sets the midtones Density value.
  82315. * 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.
  82316. * Values less than zero provide a filter of opposite hue.
  82317. */
  82318. set midtonesDensity(value: number);
  82319. /**
  82320. * Gets the midtones Saturation value.
  82321. * 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.
  82322. */
  82323. get midtonesSaturation(): number;
  82324. /**
  82325. * Sets the midtones Saturation value.
  82326. * 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.
  82327. */
  82328. set midtonesSaturation(value: number);
  82329. /**
  82330. * Gets the midtones Exposure value.
  82331. * 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.
  82332. */
  82333. get midtonesExposure(): number;
  82334. /**
  82335. * Sets the midtones Exposure value.
  82336. * 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.
  82337. */
  82338. set midtonesExposure(value: number);
  82339. private _shadowsHue;
  82340. private _shadowsDensity;
  82341. private _shadowsSaturation;
  82342. private _shadowsExposure;
  82343. /**
  82344. * Gets the shadows Hue value.
  82345. * 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).
  82346. */
  82347. get shadowsHue(): number;
  82348. /**
  82349. * Sets the shadows Hue value.
  82350. * 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).
  82351. */
  82352. set shadowsHue(value: number);
  82353. /**
  82354. * Gets the shadows Density value.
  82355. * 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.
  82356. * Values less than zero provide a filter of opposite hue.
  82357. */
  82358. get shadowsDensity(): number;
  82359. /**
  82360. * Sets the shadows Density value.
  82361. * 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.
  82362. * Values less than zero provide a filter of opposite hue.
  82363. */
  82364. set shadowsDensity(value: number);
  82365. /**
  82366. * Gets the shadows Saturation value.
  82367. * 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.
  82368. */
  82369. get shadowsSaturation(): number;
  82370. /**
  82371. * Sets the shadows Saturation value.
  82372. * 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.
  82373. */
  82374. set shadowsSaturation(value: number);
  82375. /**
  82376. * Gets the shadows Exposure value.
  82377. * 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.
  82378. */
  82379. get shadowsExposure(): number;
  82380. /**
  82381. * Sets the shadows Exposure value.
  82382. * 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.
  82383. */
  82384. set shadowsExposure(value: number);
  82385. /**
  82386. * Returns the class name
  82387. * @returns The class name
  82388. */
  82389. getClassName(): string;
  82390. /**
  82391. * Binds the color curves to the shader.
  82392. * @param colorCurves The color curve to bind
  82393. * @param effect The effect to bind to
  82394. * @param positiveUniform The positive uniform shader parameter
  82395. * @param neutralUniform The neutral uniform shader parameter
  82396. * @param negativeUniform The negative uniform shader parameter
  82397. */
  82398. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  82399. /**
  82400. * Prepare the list of uniforms associated with the ColorCurves effects.
  82401. * @param uniformsList The list of uniforms used in the effect
  82402. */
  82403. static PrepareUniforms(uniformsList: string[]): void;
  82404. /**
  82405. * Returns color grading data based on a hue, density, saturation and exposure value.
  82406. * @param filterHue The hue of the color filter.
  82407. * @param filterDensity The density of the color filter.
  82408. * @param saturation The saturation.
  82409. * @param exposure The exposure.
  82410. * @param result The result data container.
  82411. */
  82412. private getColorGradingDataToRef;
  82413. /**
  82414. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  82415. * @param value The input slider value in range [-100,100].
  82416. * @returns Adjusted value.
  82417. */
  82418. private static applyColorGradingSliderNonlinear;
  82419. /**
  82420. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  82421. * @param hue The hue (H) input.
  82422. * @param saturation The saturation (S) input.
  82423. * @param brightness The brightness (B) input.
  82424. * @result An RGBA color represented as Vector4.
  82425. */
  82426. private static fromHSBToRef;
  82427. /**
  82428. * Returns a value clamped between min and max
  82429. * @param value The value to clamp
  82430. * @param min The minimum of value
  82431. * @param max The maximum of value
  82432. * @returns The clamped value.
  82433. */
  82434. private static clamp;
  82435. /**
  82436. * Clones the current color curve instance.
  82437. * @return The cloned curves
  82438. */
  82439. clone(): ColorCurves;
  82440. /**
  82441. * Serializes the current color curve instance to a json representation.
  82442. * @return a JSON representation
  82443. */
  82444. serialize(): any;
  82445. /**
  82446. * Parses the color curve from a json representation.
  82447. * @param source the JSON source to parse
  82448. * @return The parsed curves
  82449. */
  82450. static Parse(source: any): ColorCurves;
  82451. }
  82452. }
  82453. declare module BABYLON {
  82454. /**
  82455. * Interface to follow in your material defines to integrate easily the
  82456. * Image proccessing functions.
  82457. * @hidden
  82458. */
  82459. export interface IImageProcessingConfigurationDefines {
  82460. IMAGEPROCESSING: boolean;
  82461. VIGNETTE: boolean;
  82462. VIGNETTEBLENDMODEMULTIPLY: boolean;
  82463. VIGNETTEBLENDMODEOPAQUE: boolean;
  82464. TONEMAPPING: boolean;
  82465. TONEMAPPING_ACES: boolean;
  82466. CONTRAST: boolean;
  82467. EXPOSURE: boolean;
  82468. COLORCURVES: boolean;
  82469. COLORGRADING: boolean;
  82470. COLORGRADING3D: boolean;
  82471. SAMPLER3DGREENDEPTH: boolean;
  82472. SAMPLER3DBGRMAP: boolean;
  82473. IMAGEPROCESSINGPOSTPROCESS: boolean;
  82474. }
  82475. /**
  82476. * @hidden
  82477. */
  82478. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  82479. IMAGEPROCESSING: boolean;
  82480. VIGNETTE: boolean;
  82481. VIGNETTEBLENDMODEMULTIPLY: boolean;
  82482. VIGNETTEBLENDMODEOPAQUE: boolean;
  82483. TONEMAPPING: boolean;
  82484. TONEMAPPING_ACES: boolean;
  82485. CONTRAST: boolean;
  82486. COLORCURVES: boolean;
  82487. COLORGRADING: boolean;
  82488. COLORGRADING3D: boolean;
  82489. SAMPLER3DGREENDEPTH: boolean;
  82490. SAMPLER3DBGRMAP: boolean;
  82491. IMAGEPROCESSINGPOSTPROCESS: boolean;
  82492. EXPOSURE: boolean;
  82493. constructor();
  82494. }
  82495. /**
  82496. * This groups together the common properties used for image processing either in direct forward pass
  82497. * or through post processing effect depending on the use of the image processing pipeline in your scene
  82498. * or not.
  82499. */
  82500. export class ImageProcessingConfiguration {
  82501. /**
  82502. * Default tone mapping applied in BabylonJS.
  82503. */
  82504. static readonly TONEMAPPING_STANDARD: number;
  82505. /**
  82506. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  82507. * to other engines rendering to increase portability.
  82508. */
  82509. static readonly TONEMAPPING_ACES: number;
  82510. /**
  82511. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  82512. */
  82513. colorCurves: Nullable<ColorCurves>;
  82514. private _colorCurvesEnabled;
  82515. /**
  82516. * Gets wether the color curves effect is enabled.
  82517. */
  82518. get colorCurvesEnabled(): boolean;
  82519. /**
  82520. * Sets wether the color curves effect is enabled.
  82521. */
  82522. set colorCurvesEnabled(value: boolean);
  82523. private _colorGradingTexture;
  82524. /**
  82525. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  82526. */
  82527. get colorGradingTexture(): Nullable<BaseTexture>;
  82528. /**
  82529. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  82530. */
  82531. set colorGradingTexture(value: Nullable<BaseTexture>);
  82532. private _colorGradingEnabled;
  82533. /**
  82534. * Gets wether the color grading effect is enabled.
  82535. */
  82536. get colorGradingEnabled(): boolean;
  82537. /**
  82538. * Sets wether the color grading effect is enabled.
  82539. */
  82540. set colorGradingEnabled(value: boolean);
  82541. private _colorGradingWithGreenDepth;
  82542. /**
  82543. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  82544. */
  82545. get colorGradingWithGreenDepth(): boolean;
  82546. /**
  82547. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  82548. */
  82549. set colorGradingWithGreenDepth(value: boolean);
  82550. private _colorGradingBGR;
  82551. /**
  82552. * Gets wether the color grading texture contains BGR values.
  82553. */
  82554. get colorGradingBGR(): boolean;
  82555. /**
  82556. * Sets wether the color grading texture contains BGR values.
  82557. */
  82558. set colorGradingBGR(value: boolean);
  82559. /** @hidden */
  82560. _exposure: number;
  82561. /**
  82562. * Gets the Exposure used in the effect.
  82563. */
  82564. get exposure(): number;
  82565. /**
  82566. * Sets the Exposure used in the effect.
  82567. */
  82568. set exposure(value: number);
  82569. private _toneMappingEnabled;
  82570. /**
  82571. * Gets wether the tone mapping effect is enabled.
  82572. */
  82573. get toneMappingEnabled(): boolean;
  82574. /**
  82575. * Sets wether the tone mapping effect is enabled.
  82576. */
  82577. set toneMappingEnabled(value: boolean);
  82578. private _toneMappingType;
  82579. /**
  82580. * Gets the type of tone mapping effect.
  82581. */
  82582. get toneMappingType(): number;
  82583. /**
  82584. * Sets the type of tone mapping effect used in BabylonJS.
  82585. */
  82586. set toneMappingType(value: number);
  82587. protected _contrast: number;
  82588. /**
  82589. * Gets the contrast used in the effect.
  82590. */
  82591. get contrast(): number;
  82592. /**
  82593. * Sets the contrast used in the effect.
  82594. */
  82595. set contrast(value: number);
  82596. /**
  82597. * Vignette stretch size.
  82598. */
  82599. vignetteStretch: number;
  82600. /**
  82601. * Vignette centre X Offset.
  82602. */
  82603. vignetteCentreX: number;
  82604. /**
  82605. * Vignette centre Y Offset.
  82606. */
  82607. vignetteCentreY: number;
  82608. /**
  82609. * Vignette weight or intensity of the vignette effect.
  82610. */
  82611. vignetteWeight: number;
  82612. /**
  82613. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  82614. * if vignetteEnabled is set to true.
  82615. */
  82616. vignetteColor: Color4;
  82617. /**
  82618. * Camera field of view used by the Vignette effect.
  82619. */
  82620. vignetteCameraFov: number;
  82621. private _vignetteBlendMode;
  82622. /**
  82623. * Gets the vignette blend mode allowing different kind of effect.
  82624. */
  82625. get vignetteBlendMode(): number;
  82626. /**
  82627. * Sets the vignette blend mode allowing different kind of effect.
  82628. */
  82629. set vignetteBlendMode(value: number);
  82630. private _vignetteEnabled;
  82631. /**
  82632. * Gets wether the vignette effect is enabled.
  82633. */
  82634. get vignetteEnabled(): boolean;
  82635. /**
  82636. * Sets wether the vignette effect is enabled.
  82637. */
  82638. set vignetteEnabled(value: boolean);
  82639. private _applyByPostProcess;
  82640. /**
  82641. * Gets wether the image processing is applied through a post process or not.
  82642. */
  82643. get applyByPostProcess(): boolean;
  82644. /**
  82645. * Sets wether the image processing is applied through a post process or not.
  82646. */
  82647. set applyByPostProcess(value: boolean);
  82648. private _isEnabled;
  82649. /**
  82650. * Gets wether the image processing is enabled or not.
  82651. */
  82652. get isEnabled(): boolean;
  82653. /**
  82654. * Sets wether the image processing is enabled or not.
  82655. */
  82656. set isEnabled(value: boolean);
  82657. /**
  82658. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  82659. */
  82660. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  82661. /**
  82662. * Method called each time the image processing information changes requires to recompile the effect.
  82663. */
  82664. protected _updateParameters(): void;
  82665. /**
  82666. * Gets the current class name.
  82667. * @return "ImageProcessingConfiguration"
  82668. */
  82669. getClassName(): string;
  82670. /**
  82671. * Prepare the list of uniforms associated with the Image Processing effects.
  82672. * @param uniforms The list of uniforms used in the effect
  82673. * @param defines the list of defines currently in use
  82674. */
  82675. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  82676. /**
  82677. * Prepare the list of samplers associated with the Image Processing effects.
  82678. * @param samplersList The list of uniforms used in the effect
  82679. * @param defines the list of defines currently in use
  82680. */
  82681. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  82682. /**
  82683. * Prepare the list of defines associated to the shader.
  82684. * @param defines the list of defines to complete
  82685. * @param forPostProcess Define if we are currently in post process mode or not
  82686. */
  82687. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  82688. /**
  82689. * Returns true if all the image processing information are ready.
  82690. * @returns True if ready, otherwise, false
  82691. */
  82692. isReady(): boolean;
  82693. /**
  82694. * Binds the image processing to the shader.
  82695. * @param effect The effect to bind to
  82696. * @param overrideAspectRatio Override the aspect ratio of the effect
  82697. */
  82698. bind(effect: Effect, overrideAspectRatio?: number): void;
  82699. /**
  82700. * Clones the current image processing instance.
  82701. * @return The cloned image processing
  82702. */
  82703. clone(): ImageProcessingConfiguration;
  82704. /**
  82705. * Serializes the current image processing instance to a json representation.
  82706. * @return a JSON representation
  82707. */
  82708. serialize(): any;
  82709. /**
  82710. * Parses the image processing from a json representation.
  82711. * @param source the JSON source to parse
  82712. * @return The parsed image processing
  82713. */
  82714. static Parse(source: any): ImageProcessingConfiguration;
  82715. private static _VIGNETTEMODE_MULTIPLY;
  82716. private static _VIGNETTEMODE_OPAQUE;
  82717. /**
  82718. * Used to apply the vignette as a mix with the pixel color.
  82719. */
  82720. static get VIGNETTEMODE_MULTIPLY(): number;
  82721. /**
  82722. * Used to apply the vignette as a replacement of the pixel color.
  82723. */
  82724. static get VIGNETTEMODE_OPAQUE(): number;
  82725. }
  82726. }
  82727. declare module BABYLON {
  82728. /** @hidden */
  82729. export var postprocessVertexShader: {
  82730. name: string;
  82731. shader: string;
  82732. };
  82733. }
  82734. declare module BABYLON {
  82735. interface ThinEngine {
  82736. /**
  82737. * Creates a new render target texture
  82738. * @param size defines the size of the texture
  82739. * @param options defines the options used to create the texture
  82740. * @returns a new render target texture stored in an InternalTexture
  82741. */
  82742. createRenderTargetTexture(size: number | {
  82743. width: number;
  82744. height: number;
  82745. layers?: number;
  82746. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  82747. /**
  82748. * Creates a depth stencil texture.
  82749. * This is only available in WebGL 2 or with the depth texture extension available.
  82750. * @param size The size of face edge in the texture.
  82751. * @param options The options defining the texture.
  82752. * @returns The texture
  82753. */
  82754. createDepthStencilTexture(size: number | {
  82755. width: number;
  82756. height: number;
  82757. layers?: number;
  82758. }, options: DepthTextureCreationOptions): InternalTexture;
  82759. /** @hidden */
  82760. _createDepthStencilTexture(size: number | {
  82761. width: number;
  82762. height: number;
  82763. layers?: number;
  82764. }, options: DepthTextureCreationOptions): InternalTexture;
  82765. }
  82766. }
  82767. declare module BABYLON {
  82768. /** Defines supported spaces */
  82769. export enum Space {
  82770. /** Local (object) space */
  82771. LOCAL = 0,
  82772. /** World space */
  82773. WORLD = 1,
  82774. /** Bone space */
  82775. BONE = 2
  82776. }
  82777. /** Defines the 3 main axes */
  82778. export class Axis {
  82779. /** X axis */
  82780. static X: Vector3;
  82781. /** Y axis */
  82782. static Y: Vector3;
  82783. /** Z axis */
  82784. static Z: Vector3;
  82785. }
  82786. }
  82787. declare module BABYLON {
  82788. /**
  82789. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  82790. * This is the base of the follow, arc rotate cameras and Free camera
  82791. * @see http://doc.babylonjs.com/features/cameras
  82792. */
  82793. export class TargetCamera extends Camera {
  82794. private static _RigCamTransformMatrix;
  82795. private static _TargetTransformMatrix;
  82796. private static _TargetFocalPoint;
  82797. /**
  82798. * Define the current direction the camera is moving to
  82799. */
  82800. cameraDirection: Vector3;
  82801. /**
  82802. * Define the current rotation the camera is rotating to
  82803. */
  82804. cameraRotation: Vector2;
  82805. /**
  82806. * When set, the up vector of the camera will be updated by the rotation of the camera
  82807. */
  82808. updateUpVectorFromRotation: boolean;
  82809. private _tmpQuaternion;
  82810. /**
  82811. * Define the current rotation of the camera
  82812. */
  82813. rotation: Vector3;
  82814. /**
  82815. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  82816. */
  82817. rotationQuaternion: Quaternion;
  82818. /**
  82819. * Define the current speed of the camera
  82820. */
  82821. speed: number;
  82822. /**
  82823. * Add constraint to the camera to prevent it to move freely in all directions and
  82824. * around all axis.
  82825. */
  82826. noRotationConstraint: boolean;
  82827. /**
  82828. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  82829. * panning
  82830. */
  82831. invertRotation: boolean;
  82832. /**
  82833. * Speed multiplier for inverse camera panning
  82834. */
  82835. inverseRotationSpeed: number;
  82836. /**
  82837. * Define the current target of the camera as an object or a position.
  82838. */
  82839. lockedTarget: any;
  82840. /** @hidden */
  82841. _currentTarget: Vector3;
  82842. /** @hidden */
  82843. _initialFocalDistance: number;
  82844. /** @hidden */
  82845. _viewMatrix: Matrix;
  82846. /** @hidden */
  82847. _camMatrix: Matrix;
  82848. /** @hidden */
  82849. _cameraTransformMatrix: Matrix;
  82850. /** @hidden */
  82851. _cameraRotationMatrix: Matrix;
  82852. /** @hidden */
  82853. _referencePoint: Vector3;
  82854. /** @hidden */
  82855. _transformedReferencePoint: Vector3;
  82856. protected _globalCurrentTarget: Vector3;
  82857. protected _globalCurrentUpVector: Vector3;
  82858. /** @hidden */
  82859. _reset: () => void;
  82860. private _defaultUp;
  82861. /**
  82862. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  82863. * This is the base of the follow, arc rotate cameras and Free camera
  82864. * @see http://doc.babylonjs.com/features/cameras
  82865. * @param name Defines the name of the camera in the scene
  82866. * @param position Defines the start position of the camera in the scene
  82867. * @param scene Defines the scene the camera belongs to
  82868. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  82869. */
  82870. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  82871. /**
  82872. * Gets the position in front of the camera at a given distance.
  82873. * @param distance The distance from the camera we want the position to be
  82874. * @returns the position
  82875. */
  82876. getFrontPosition(distance: number): Vector3;
  82877. /** @hidden */
  82878. _getLockedTargetPosition(): Nullable<Vector3>;
  82879. private _storedPosition;
  82880. private _storedRotation;
  82881. private _storedRotationQuaternion;
  82882. /**
  82883. * Store current camera state of the camera (fov, position, rotation, etc..)
  82884. * @returns the camera
  82885. */
  82886. storeState(): Camera;
  82887. /**
  82888. * Restored camera state. You must call storeState() first
  82889. * @returns whether it was successful or not
  82890. * @hidden
  82891. */
  82892. _restoreStateValues(): boolean;
  82893. /** @hidden */
  82894. _initCache(): void;
  82895. /** @hidden */
  82896. _updateCache(ignoreParentClass?: boolean): void;
  82897. /** @hidden */
  82898. _isSynchronizedViewMatrix(): boolean;
  82899. /** @hidden */
  82900. _computeLocalCameraSpeed(): number;
  82901. /**
  82902. * Defines the target the camera should look at.
  82903. * @param target Defines the new target as a Vector or a mesh
  82904. */
  82905. setTarget(target: Vector3): void;
  82906. /**
  82907. * Return the current target position of the camera. This value is expressed in local space.
  82908. * @returns the target position
  82909. */
  82910. getTarget(): Vector3;
  82911. /** @hidden */
  82912. _decideIfNeedsToMove(): boolean;
  82913. /** @hidden */
  82914. _updatePosition(): void;
  82915. /** @hidden */
  82916. _checkInputs(): void;
  82917. protected _updateCameraRotationMatrix(): void;
  82918. /**
  82919. * 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)
  82920. * @returns the current camera
  82921. */
  82922. private _rotateUpVectorWithCameraRotationMatrix;
  82923. private _cachedRotationZ;
  82924. private _cachedQuaternionRotationZ;
  82925. /** @hidden */
  82926. _getViewMatrix(): Matrix;
  82927. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  82928. /**
  82929. * @hidden
  82930. */
  82931. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  82932. /**
  82933. * @hidden
  82934. */
  82935. _updateRigCameras(): void;
  82936. private _getRigCamPositionAndTarget;
  82937. /**
  82938. * Gets the current object class name.
  82939. * @return the class name
  82940. */
  82941. getClassName(): string;
  82942. }
  82943. }
  82944. declare module BABYLON {
  82945. /**
  82946. * Gather the list of keyboard event types as constants.
  82947. */
  82948. export class KeyboardEventTypes {
  82949. /**
  82950. * The keydown event is fired when a key becomes active (pressed).
  82951. */
  82952. static readonly KEYDOWN: number;
  82953. /**
  82954. * The keyup event is fired when a key has been released.
  82955. */
  82956. static readonly KEYUP: number;
  82957. }
  82958. /**
  82959. * This class is used to store keyboard related info for the onKeyboardObservable event.
  82960. */
  82961. export class KeyboardInfo {
  82962. /**
  82963. * Defines the type of event (KeyboardEventTypes)
  82964. */
  82965. type: number;
  82966. /**
  82967. * Defines the related dom event
  82968. */
  82969. event: KeyboardEvent;
  82970. /**
  82971. * Instantiates a new keyboard info.
  82972. * This class is used to store keyboard related info for the onKeyboardObservable event.
  82973. * @param type Defines the type of event (KeyboardEventTypes)
  82974. * @param event Defines the related dom event
  82975. */
  82976. constructor(
  82977. /**
  82978. * Defines the type of event (KeyboardEventTypes)
  82979. */
  82980. type: number,
  82981. /**
  82982. * Defines the related dom event
  82983. */
  82984. event: KeyboardEvent);
  82985. }
  82986. /**
  82987. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  82988. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  82989. */
  82990. export class KeyboardInfoPre extends KeyboardInfo {
  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. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  83001. */
  83002. skipOnPointerObservable: boolean;
  83003. /**
  83004. * Instantiates a new keyboard pre info.
  83005. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  83006. * @param type Defines the type of event (KeyboardEventTypes)
  83007. * @param event Defines the related dom event
  83008. */
  83009. constructor(
  83010. /**
  83011. * Defines the type of event (KeyboardEventTypes)
  83012. */
  83013. type: number,
  83014. /**
  83015. * Defines the related dom event
  83016. */
  83017. event: KeyboardEvent);
  83018. }
  83019. }
  83020. declare module BABYLON {
  83021. /**
  83022. * Manage the keyboard inputs to control the movement of a free camera.
  83023. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  83024. */
  83025. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  83026. /**
  83027. * Defines the camera the input is attached to.
  83028. */
  83029. camera: FreeCamera;
  83030. /**
  83031. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  83032. */
  83033. keysUp: number[];
  83034. /**
  83035. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  83036. */
  83037. keysUpward: number[];
  83038. /**
  83039. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  83040. */
  83041. keysDown: number[];
  83042. /**
  83043. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  83044. */
  83045. keysDownward: number[];
  83046. /**
  83047. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  83048. */
  83049. keysLeft: number[];
  83050. /**
  83051. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  83052. */
  83053. keysRight: number[];
  83054. private _keys;
  83055. private _onCanvasBlurObserver;
  83056. private _onKeyboardObserver;
  83057. private _engine;
  83058. private _scene;
  83059. /**
  83060. * Attach the input controls to a specific dom element to get the input from.
  83061. * @param element Defines the element the controls should be listened from
  83062. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  83063. */
  83064. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  83065. /**
  83066. * Detach the current controls from the specified dom element.
  83067. * @param element Defines the element to stop listening the inputs from
  83068. */
  83069. detachControl(element: Nullable<HTMLElement>): void;
  83070. /**
  83071. * Update the current camera state depending on the inputs that have been used this frame.
  83072. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  83073. */
  83074. checkInputs(): void;
  83075. /**
  83076. * Gets the class name of the current intput.
  83077. * @returns the class name
  83078. */
  83079. getClassName(): string;
  83080. /** @hidden */
  83081. _onLostFocus(): void;
  83082. /**
  83083. * Get the friendly name associated with the input class.
  83084. * @returns the input friendly name
  83085. */
  83086. getSimpleName(): string;
  83087. }
  83088. }
  83089. declare module BABYLON {
  83090. /**
  83091. * Interface describing all the common properties and methods a shadow light needs to implement.
  83092. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  83093. * as well as binding the different shadow properties to the effects.
  83094. */
  83095. export interface IShadowLight extends Light {
  83096. /**
  83097. * The light id in the scene (used in scene.findLighById for instance)
  83098. */
  83099. id: string;
  83100. /**
  83101. * The position the shdow will be casted from.
  83102. */
  83103. position: Vector3;
  83104. /**
  83105. * In 2d mode (needCube being false), the direction used to cast the shadow.
  83106. */
  83107. direction: Vector3;
  83108. /**
  83109. * The transformed position. Position of the light in world space taking parenting in account.
  83110. */
  83111. transformedPosition: Vector3;
  83112. /**
  83113. * The transformed direction. Direction of the light in world space taking parenting in account.
  83114. */
  83115. transformedDirection: Vector3;
  83116. /**
  83117. * The friendly name of the light in the scene.
  83118. */
  83119. name: string;
  83120. /**
  83121. * Defines the shadow projection clipping minimum z value.
  83122. */
  83123. shadowMinZ: number;
  83124. /**
  83125. * Defines the shadow projection clipping maximum z value.
  83126. */
  83127. shadowMaxZ: number;
  83128. /**
  83129. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  83130. * @returns true if the information has been computed, false if it does not need to (no parenting)
  83131. */
  83132. computeTransformedInformation(): boolean;
  83133. /**
  83134. * Gets the scene the light belongs to.
  83135. * @returns The scene
  83136. */
  83137. getScene(): Scene;
  83138. /**
  83139. * Callback defining a custom Projection Matrix Builder.
  83140. * This can be used to override the default projection matrix computation.
  83141. */
  83142. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  83143. /**
  83144. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  83145. * @param matrix The materix to updated with the projection information
  83146. * @param viewMatrix The transform matrix of the light
  83147. * @param renderList The list of mesh to render in the map
  83148. * @returns The current light
  83149. */
  83150. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  83151. /**
  83152. * Gets the current depth scale used in ESM.
  83153. * @returns The scale
  83154. */
  83155. getDepthScale(): number;
  83156. /**
  83157. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  83158. * @returns true if a cube texture needs to be use
  83159. */
  83160. needCube(): boolean;
  83161. /**
  83162. * Detects if the projection matrix requires to be recomputed this frame.
  83163. * @returns true if it requires to be recomputed otherwise, false.
  83164. */
  83165. needProjectionMatrixCompute(): boolean;
  83166. /**
  83167. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  83168. */
  83169. forceProjectionMatrixCompute(): void;
  83170. /**
  83171. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  83172. * @param faceIndex The index of the face we are computed the direction to generate shadow
  83173. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  83174. */
  83175. getShadowDirection(faceIndex?: number): Vector3;
  83176. /**
  83177. * Gets the minZ used for shadow according to both the scene and the light.
  83178. * @param activeCamera The camera we are returning the min for
  83179. * @returns the depth min z
  83180. */
  83181. getDepthMinZ(activeCamera: Camera): number;
  83182. /**
  83183. * Gets the maxZ used for shadow according to both the scene and the light.
  83184. * @param activeCamera The camera we are returning the max for
  83185. * @returns the depth max z
  83186. */
  83187. getDepthMaxZ(activeCamera: Camera): number;
  83188. }
  83189. /**
  83190. * Base implementation IShadowLight
  83191. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  83192. */
  83193. export abstract class ShadowLight extends Light implements IShadowLight {
  83194. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  83195. protected _position: Vector3;
  83196. protected _setPosition(value: Vector3): void;
  83197. /**
  83198. * Sets the position the shadow will be casted from. Also use as the light position for both
  83199. * point and spot lights.
  83200. */
  83201. get position(): Vector3;
  83202. /**
  83203. * Sets the position the shadow will be casted from. Also use as the light position for both
  83204. * point and spot lights.
  83205. */
  83206. set position(value: Vector3);
  83207. protected _direction: Vector3;
  83208. protected _setDirection(value: Vector3): void;
  83209. /**
  83210. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  83211. * Also use as the light direction on spot and directional lights.
  83212. */
  83213. get direction(): Vector3;
  83214. /**
  83215. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  83216. * Also use as the light direction on spot and directional lights.
  83217. */
  83218. set direction(value: Vector3);
  83219. protected _shadowMinZ: number;
  83220. /**
  83221. * Gets the shadow projection clipping minimum z value.
  83222. */
  83223. get shadowMinZ(): number;
  83224. /**
  83225. * Sets the shadow projection clipping minimum z value.
  83226. */
  83227. set shadowMinZ(value: number);
  83228. protected _shadowMaxZ: number;
  83229. /**
  83230. * Sets the shadow projection clipping maximum z value.
  83231. */
  83232. get shadowMaxZ(): number;
  83233. /**
  83234. * Gets the shadow projection clipping maximum z value.
  83235. */
  83236. set shadowMaxZ(value: number);
  83237. /**
  83238. * Callback defining a custom Projection Matrix Builder.
  83239. * This can be used to override the default projection matrix computation.
  83240. */
  83241. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  83242. /**
  83243. * The transformed position. Position of the light in world space taking parenting in account.
  83244. */
  83245. transformedPosition: Vector3;
  83246. /**
  83247. * The transformed direction. Direction of the light in world space taking parenting in account.
  83248. */
  83249. transformedDirection: Vector3;
  83250. private _needProjectionMatrixCompute;
  83251. /**
  83252. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  83253. * @returns true if the information has been computed, false if it does not need to (no parenting)
  83254. */
  83255. computeTransformedInformation(): boolean;
  83256. /**
  83257. * Return the depth scale used for the shadow map.
  83258. * @returns the depth scale.
  83259. */
  83260. getDepthScale(): number;
  83261. /**
  83262. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  83263. * @param faceIndex The index of the face we are computed the direction to generate shadow
  83264. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  83265. */
  83266. getShadowDirection(faceIndex?: number): Vector3;
  83267. /**
  83268. * Returns the ShadowLight absolute position in the World.
  83269. * @returns the position vector in world space
  83270. */
  83271. getAbsolutePosition(): Vector3;
  83272. /**
  83273. * Sets the ShadowLight direction toward the passed target.
  83274. * @param target The point to target in local space
  83275. * @returns the updated ShadowLight direction
  83276. */
  83277. setDirectionToTarget(target: Vector3): Vector3;
  83278. /**
  83279. * Returns the light rotation in euler definition.
  83280. * @returns the x y z rotation in local space.
  83281. */
  83282. getRotation(): Vector3;
  83283. /**
  83284. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  83285. * @returns true if a cube texture needs to be use
  83286. */
  83287. needCube(): boolean;
  83288. /**
  83289. * Detects if the projection matrix requires to be recomputed this frame.
  83290. * @returns true if it requires to be recomputed otherwise, false.
  83291. */
  83292. needProjectionMatrixCompute(): boolean;
  83293. /**
  83294. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  83295. */
  83296. forceProjectionMatrixCompute(): void;
  83297. /** @hidden */
  83298. _initCache(): void;
  83299. /** @hidden */
  83300. _isSynchronized(): boolean;
  83301. /**
  83302. * Computes the world matrix of the node
  83303. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  83304. * @returns the world matrix
  83305. */
  83306. computeWorldMatrix(force?: boolean): Matrix;
  83307. /**
  83308. * Gets the minZ used for shadow according to both the scene and the light.
  83309. * @param activeCamera The camera we are returning the min for
  83310. * @returns the depth min z
  83311. */
  83312. getDepthMinZ(activeCamera: Camera): number;
  83313. /**
  83314. * Gets the maxZ used for shadow according to both the scene and the light.
  83315. * @param activeCamera The camera we are returning the max for
  83316. * @returns the depth max z
  83317. */
  83318. getDepthMaxZ(activeCamera: Camera): number;
  83319. /**
  83320. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  83321. * @param matrix The materix to updated with the projection information
  83322. * @param viewMatrix The transform matrix of the light
  83323. * @param renderList The list of mesh to render in the map
  83324. * @returns The current light
  83325. */
  83326. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  83327. }
  83328. }
  83329. declare module BABYLON {
  83330. /**
  83331. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  83332. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  83333. */
  83334. export class EffectFallbacks implements IEffectFallbacks {
  83335. private _defines;
  83336. private _currentRank;
  83337. private _maxRank;
  83338. private _mesh;
  83339. /**
  83340. * Removes the fallback from the bound mesh.
  83341. */
  83342. unBindMesh(): void;
  83343. /**
  83344. * Adds a fallback on the specified property.
  83345. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  83346. * @param define The name of the define in the shader
  83347. */
  83348. addFallback(rank: number, define: string): void;
  83349. /**
  83350. * Sets the mesh to use CPU skinning when needing to fallback.
  83351. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  83352. * @param mesh The mesh to use the fallbacks.
  83353. */
  83354. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  83355. /**
  83356. * Checks to see if more fallbacks are still availible.
  83357. */
  83358. get hasMoreFallbacks(): boolean;
  83359. /**
  83360. * Removes the defines that should be removed when falling back.
  83361. * @param currentDefines defines the current define statements for the shader.
  83362. * @param effect defines the current effect we try to compile
  83363. * @returns The resulting defines with defines of the current rank removed.
  83364. */
  83365. reduce(currentDefines: string, effect: Effect): string;
  83366. }
  83367. }
  83368. declare module BABYLON {
  83369. /**
  83370. * "Static Class" containing the most commonly used helper while dealing with material for
  83371. * rendering purpose.
  83372. *
  83373. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  83374. *
  83375. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  83376. */
  83377. export class MaterialHelper {
  83378. /**
  83379. * Bind the current view position to an effect.
  83380. * @param effect The effect to be bound
  83381. * @param scene The scene the eyes position is used from
  83382. */
  83383. static BindEyePosition(effect: Effect, scene: Scene): void;
  83384. /**
  83385. * Helps preparing the defines values about the UVs in used in the effect.
  83386. * UVs are shared as much as we can accross channels in the shaders.
  83387. * @param texture The texture we are preparing the UVs for
  83388. * @param defines The defines to update
  83389. * @param key The channel key "diffuse", "specular"... used in the shader
  83390. */
  83391. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  83392. /**
  83393. * Binds a texture matrix value to its corrsponding uniform
  83394. * @param texture The texture to bind the matrix for
  83395. * @param uniformBuffer The uniform buffer receivin the data
  83396. * @param key The channel key "diffuse", "specular"... used in the shader
  83397. */
  83398. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  83399. /**
  83400. * Gets the current status of the fog (should it be enabled?)
  83401. * @param mesh defines the mesh to evaluate for fog support
  83402. * @param scene defines the hosting scene
  83403. * @returns true if fog must be enabled
  83404. */
  83405. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  83406. /**
  83407. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  83408. * @param mesh defines the current mesh
  83409. * @param scene defines the current scene
  83410. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  83411. * @param pointsCloud defines if point cloud rendering has to be turned on
  83412. * @param fogEnabled defines if fog has to be turned on
  83413. * @param alphaTest defines if alpha testing has to be turned on
  83414. * @param defines defines the current list of defines
  83415. */
  83416. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  83417. /**
  83418. * Helper used to prepare the list of defines associated with frame values for shader compilation
  83419. * @param scene defines the current scene
  83420. * @param engine defines the current engine
  83421. * @param defines specifies the list of active defines
  83422. * @param useInstances defines if instances have to be turned on
  83423. * @param useClipPlane defines if clip plane have to be turned on
  83424. */
  83425. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  83426. /**
  83427. * Prepares the defines for bones
  83428. * @param mesh The mesh containing the geometry data we will draw
  83429. * @param defines The defines to update
  83430. */
  83431. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  83432. /**
  83433. * Prepares the defines for morph targets
  83434. * @param mesh The mesh containing the geometry data we will draw
  83435. * @param defines The defines to update
  83436. */
  83437. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  83438. /**
  83439. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  83440. * @param mesh The mesh containing the geometry data we will draw
  83441. * @param defines The defines to update
  83442. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  83443. * @param useBones Precise whether bones should be used or not (override mesh info)
  83444. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  83445. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  83446. * @returns false if defines are considered not dirty and have not been checked
  83447. */
  83448. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  83449. /**
  83450. * Prepares the defines related to multiview
  83451. * @param scene The scene we are intending to draw
  83452. * @param defines The defines to update
  83453. */
  83454. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  83455. /**
  83456. * Prepares the defines related to the light information passed in parameter
  83457. * @param scene The scene we are intending to draw
  83458. * @param mesh The mesh the effect is compiling for
  83459. * @param light The light the effect is compiling for
  83460. * @param lightIndex The index of the light
  83461. * @param defines The defines to update
  83462. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  83463. * @param state Defines the current state regarding what is needed (normals, etc...)
  83464. */
  83465. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  83466. needNormals: boolean;
  83467. needRebuild: boolean;
  83468. shadowEnabled: boolean;
  83469. specularEnabled: boolean;
  83470. lightmapMode: boolean;
  83471. }): void;
  83472. /**
  83473. * Prepares the defines related to the light information passed in parameter
  83474. * @param scene The scene we are intending to draw
  83475. * @param mesh The mesh the effect is compiling for
  83476. * @param defines The defines to update
  83477. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  83478. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  83479. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  83480. * @returns true if normals will be required for the rest of the effect
  83481. */
  83482. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  83483. /**
  83484. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  83485. * @param lightIndex defines the light index
  83486. * @param uniformsList The uniform list
  83487. * @param samplersList The sampler list
  83488. * @param projectedLightTexture defines if projected texture must be used
  83489. * @param uniformBuffersList defines an optional list of uniform buffers
  83490. */
  83491. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  83492. /**
  83493. * Prepares the uniforms and samplers list to be used in the effect
  83494. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  83495. * @param samplersList The sampler list
  83496. * @param defines The defines helping in the list generation
  83497. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  83498. */
  83499. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  83500. /**
  83501. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  83502. * @param defines The defines to update while falling back
  83503. * @param fallbacks The authorized effect fallbacks
  83504. * @param maxSimultaneousLights The maximum number of lights allowed
  83505. * @param rank the current rank of the Effect
  83506. * @returns The newly affected rank
  83507. */
  83508. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  83509. private static _TmpMorphInfluencers;
  83510. /**
  83511. * Prepares the list of attributes required for morph targets according to the effect defines.
  83512. * @param attribs The current list of supported attribs
  83513. * @param mesh The mesh to prepare the morph targets attributes for
  83514. * @param influencers The number of influencers
  83515. */
  83516. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  83517. /**
  83518. * Prepares the list of attributes required for morph targets according to the effect defines.
  83519. * @param attribs The current list of supported attribs
  83520. * @param mesh The mesh to prepare the morph targets attributes for
  83521. * @param defines The current Defines of the effect
  83522. */
  83523. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  83524. /**
  83525. * Prepares the list of attributes required for bones according to the effect defines.
  83526. * @param attribs The current list of supported attribs
  83527. * @param mesh The mesh to prepare the bones attributes for
  83528. * @param defines The current Defines of the effect
  83529. * @param fallbacks The current efffect fallback strategy
  83530. */
  83531. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  83532. /**
  83533. * Check and prepare the list of attributes required for instances according to the effect defines.
  83534. * @param attribs The current list of supported attribs
  83535. * @param defines The current MaterialDefines of the effect
  83536. */
  83537. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  83538. /**
  83539. * Add the list of attributes required for instances to the attribs array.
  83540. * @param attribs The current list of supported attribs
  83541. */
  83542. static PushAttributesForInstances(attribs: string[]): void;
  83543. /**
  83544. * Binds the light information to the effect.
  83545. * @param light The light containing the generator
  83546. * @param effect The effect we are binding the data to
  83547. * @param lightIndex The light index in the effect used to render
  83548. */
  83549. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  83550. /**
  83551. * Binds the lights information from the scene to the effect for the given mesh.
  83552. * @param light Light to bind
  83553. * @param lightIndex Light index
  83554. * @param scene The scene where the light belongs to
  83555. * @param effect The effect we are binding the data to
  83556. * @param useSpecular Defines if specular is supported
  83557. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  83558. */
  83559. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  83560. /**
  83561. * Binds the lights information from the scene to the effect for the given mesh.
  83562. * @param scene The scene the lights belongs to
  83563. * @param mesh The mesh we are binding the information to render
  83564. * @param effect The effect we are binding the data to
  83565. * @param defines The generated defines for the effect
  83566. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  83567. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  83568. */
  83569. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  83570. private static _tempFogColor;
  83571. /**
  83572. * Binds the fog information from the scene to the effect for the given mesh.
  83573. * @param scene The scene the lights belongs to
  83574. * @param mesh The mesh we are binding the information to render
  83575. * @param effect The effect we are binding the data to
  83576. * @param linearSpace Defines if the fog effect is applied in linear space
  83577. */
  83578. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  83579. /**
  83580. * Binds the bones information from the mesh to the effect.
  83581. * @param mesh The mesh we are binding the information to render
  83582. * @param effect The effect we are binding the data to
  83583. */
  83584. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  83585. /**
  83586. * Binds the morph targets information from the mesh to the effect.
  83587. * @param abstractMesh The mesh we are binding the information to render
  83588. * @param effect The effect we are binding the data to
  83589. */
  83590. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  83591. /**
  83592. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  83593. * @param defines The generated defines used in the effect
  83594. * @param effect The effect we are binding the data to
  83595. * @param scene The scene we are willing to render with logarithmic scale for
  83596. */
  83597. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  83598. /**
  83599. * Binds the clip plane information from the scene to the effect.
  83600. * @param scene The scene the clip plane information are extracted from
  83601. * @param effect The effect we are binding the data to
  83602. */
  83603. static BindClipPlane(effect: Effect, scene: Scene): void;
  83604. }
  83605. }
  83606. declare module BABYLON {
  83607. /** @hidden */
  83608. export var packingFunctions: {
  83609. name: string;
  83610. shader: string;
  83611. };
  83612. }
  83613. declare module BABYLON {
  83614. /** @hidden */
  83615. export var clipPlaneFragmentDeclaration: {
  83616. name: string;
  83617. shader: string;
  83618. };
  83619. }
  83620. declare module BABYLON {
  83621. /** @hidden */
  83622. export var clipPlaneFragment: {
  83623. name: string;
  83624. shader: string;
  83625. };
  83626. }
  83627. declare module BABYLON {
  83628. /** @hidden */
  83629. export var shadowMapPixelShader: {
  83630. name: string;
  83631. shader: string;
  83632. };
  83633. }
  83634. declare module BABYLON {
  83635. /** @hidden */
  83636. export var bonesDeclaration: {
  83637. name: string;
  83638. shader: string;
  83639. };
  83640. }
  83641. declare module BABYLON {
  83642. /** @hidden */
  83643. export var morphTargetsVertexGlobalDeclaration: {
  83644. name: string;
  83645. shader: string;
  83646. };
  83647. }
  83648. declare module BABYLON {
  83649. /** @hidden */
  83650. export var morphTargetsVertexDeclaration: {
  83651. name: string;
  83652. shader: string;
  83653. };
  83654. }
  83655. declare module BABYLON {
  83656. /** @hidden */
  83657. export var instancesDeclaration: {
  83658. name: string;
  83659. shader: string;
  83660. };
  83661. }
  83662. declare module BABYLON {
  83663. /** @hidden */
  83664. export var helperFunctions: {
  83665. name: string;
  83666. shader: string;
  83667. };
  83668. }
  83669. declare module BABYLON {
  83670. /** @hidden */
  83671. export var clipPlaneVertexDeclaration: {
  83672. name: string;
  83673. shader: string;
  83674. };
  83675. }
  83676. declare module BABYLON {
  83677. /** @hidden */
  83678. export var morphTargetsVertex: {
  83679. name: string;
  83680. shader: string;
  83681. };
  83682. }
  83683. declare module BABYLON {
  83684. /** @hidden */
  83685. export var instancesVertex: {
  83686. name: string;
  83687. shader: string;
  83688. };
  83689. }
  83690. declare module BABYLON {
  83691. /** @hidden */
  83692. export var bonesVertex: {
  83693. name: string;
  83694. shader: string;
  83695. };
  83696. }
  83697. declare module BABYLON {
  83698. /** @hidden */
  83699. export var clipPlaneVertex: {
  83700. name: string;
  83701. shader: string;
  83702. };
  83703. }
  83704. declare module BABYLON {
  83705. /** @hidden */
  83706. export var shadowMapVertexShader: {
  83707. name: string;
  83708. shader: string;
  83709. };
  83710. }
  83711. declare module BABYLON {
  83712. /** @hidden */
  83713. export var depthBoxBlurPixelShader: {
  83714. name: string;
  83715. shader: string;
  83716. };
  83717. }
  83718. declare module BABYLON {
  83719. /**
  83720. * Class representing a ray with position and direction
  83721. */
  83722. export class Ray {
  83723. /** origin point */
  83724. origin: Vector3;
  83725. /** direction */
  83726. direction: Vector3;
  83727. /** length of the ray */
  83728. length: number;
  83729. private static readonly TmpVector3;
  83730. private _tmpRay;
  83731. /**
  83732. * Creates a new ray
  83733. * @param origin origin point
  83734. * @param direction direction
  83735. * @param length length of the ray
  83736. */
  83737. constructor(
  83738. /** origin point */
  83739. origin: Vector3,
  83740. /** direction */
  83741. direction: Vector3,
  83742. /** length of the ray */
  83743. length?: number);
  83744. /**
  83745. * Checks if the ray intersects a box
  83746. * @param minimum bound of the box
  83747. * @param maximum bound of the box
  83748. * @param intersectionTreshold extra extend to be added to the box in all direction
  83749. * @returns if the box was hit
  83750. */
  83751. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  83752. /**
  83753. * Checks if the ray intersects a box
  83754. * @param box the bounding box to check
  83755. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  83756. * @returns if the box was hit
  83757. */
  83758. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  83759. /**
  83760. * If the ray hits a sphere
  83761. * @param sphere the bounding sphere to check
  83762. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  83763. * @returns true if it hits the sphere
  83764. */
  83765. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  83766. /**
  83767. * If the ray hits a triange
  83768. * @param vertex0 triangle vertex
  83769. * @param vertex1 triangle vertex
  83770. * @param vertex2 triangle vertex
  83771. * @returns intersection information if hit
  83772. */
  83773. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  83774. /**
  83775. * Checks if ray intersects a plane
  83776. * @param plane the plane to check
  83777. * @returns the distance away it was hit
  83778. */
  83779. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  83780. /**
  83781. * Calculate the intercept of a ray on a given axis
  83782. * @param axis to check 'x' | 'y' | 'z'
  83783. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  83784. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  83785. */
  83786. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  83787. /**
  83788. * Checks if ray intersects a mesh
  83789. * @param mesh the mesh to check
  83790. * @param fastCheck if only the bounding box should checked
  83791. * @returns picking info of the intersecton
  83792. */
  83793. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  83794. /**
  83795. * Checks if ray intersects a mesh
  83796. * @param meshes the meshes to check
  83797. * @param fastCheck if only the bounding box should checked
  83798. * @param results array to store result in
  83799. * @returns Array of picking infos
  83800. */
  83801. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  83802. private _comparePickingInfo;
  83803. private static smallnum;
  83804. private static rayl;
  83805. /**
  83806. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  83807. * @param sega the first point of the segment to test the intersection against
  83808. * @param segb the second point of the segment to test the intersection against
  83809. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  83810. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  83811. */
  83812. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  83813. /**
  83814. * Update the ray from viewport position
  83815. * @param x position
  83816. * @param y y position
  83817. * @param viewportWidth viewport width
  83818. * @param viewportHeight viewport height
  83819. * @param world world matrix
  83820. * @param view view matrix
  83821. * @param projection projection matrix
  83822. * @returns this ray updated
  83823. */
  83824. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  83825. /**
  83826. * Creates a ray with origin and direction of 0,0,0
  83827. * @returns the new ray
  83828. */
  83829. static Zero(): Ray;
  83830. /**
  83831. * Creates a new ray from screen space and viewport
  83832. * @param x position
  83833. * @param y y position
  83834. * @param viewportWidth viewport width
  83835. * @param viewportHeight viewport height
  83836. * @param world world matrix
  83837. * @param view view matrix
  83838. * @param projection projection matrix
  83839. * @returns new ray
  83840. */
  83841. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  83842. /**
  83843. * 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
  83844. * transformed to the given world matrix.
  83845. * @param origin The origin point
  83846. * @param end The end point
  83847. * @param world a matrix to transform the ray to. Default is the identity matrix.
  83848. * @returns the new ray
  83849. */
  83850. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  83851. /**
  83852. * Transforms a ray by a matrix
  83853. * @param ray ray to transform
  83854. * @param matrix matrix to apply
  83855. * @returns the resulting new ray
  83856. */
  83857. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  83858. /**
  83859. * Transforms a ray by a matrix
  83860. * @param ray ray to transform
  83861. * @param matrix matrix to apply
  83862. * @param result ray to store result in
  83863. */
  83864. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  83865. /**
  83866. * Unproject a ray from screen space to object space
  83867. * @param sourceX defines the screen space x coordinate to use
  83868. * @param sourceY defines the screen space y coordinate to use
  83869. * @param viewportWidth defines the current width of the viewport
  83870. * @param viewportHeight defines the current height of the viewport
  83871. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  83872. * @param view defines the view matrix to use
  83873. * @param projection defines the projection matrix to use
  83874. */
  83875. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  83876. }
  83877. /**
  83878. * Type used to define predicate used to select faces when a mesh intersection is detected
  83879. */
  83880. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  83881. interface Scene {
  83882. /** @hidden */
  83883. _tempPickingRay: Nullable<Ray>;
  83884. /** @hidden */
  83885. _cachedRayForTransform: Ray;
  83886. /** @hidden */
  83887. _pickWithRayInverseMatrix: Matrix;
  83888. /** @hidden */
  83889. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  83890. /** @hidden */
  83891. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  83892. }
  83893. }
  83894. declare module BABYLON {
  83895. /**
  83896. * Groups all the scene component constants in one place to ease maintenance.
  83897. * @hidden
  83898. */
  83899. export class SceneComponentConstants {
  83900. static readonly NAME_EFFECTLAYER: string;
  83901. static readonly NAME_LAYER: string;
  83902. static readonly NAME_LENSFLARESYSTEM: string;
  83903. static readonly NAME_BOUNDINGBOXRENDERER: string;
  83904. static readonly NAME_PARTICLESYSTEM: string;
  83905. static readonly NAME_GAMEPAD: string;
  83906. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  83907. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  83908. static readonly NAME_DEPTHRENDERER: string;
  83909. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  83910. static readonly NAME_SPRITE: string;
  83911. static readonly NAME_OUTLINERENDERER: string;
  83912. static readonly NAME_PROCEDURALTEXTURE: string;
  83913. static readonly NAME_SHADOWGENERATOR: string;
  83914. static readonly NAME_OCTREE: string;
  83915. static readonly NAME_PHYSICSENGINE: string;
  83916. static readonly NAME_AUDIO: string;
  83917. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  83918. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  83919. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  83920. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  83921. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  83922. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  83923. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  83924. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  83925. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  83926. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  83927. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  83928. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  83929. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  83930. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  83931. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  83932. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  83933. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  83934. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  83935. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  83936. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  83937. static readonly STEP_AFTERRENDER_AUDIO: number;
  83938. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  83939. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  83940. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  83941. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  83942. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  83943. static readonly STEP_POINTERMOVE_SPRITE: number;
  83944. static readonly STEP_POINTERDOWN_SPRITE: number;
  83945. static readonly STEP_POINTERUP_SPRITE: number;
  83946. }
  83947. /**
  83948. * This represents a scene component.
  83949. *
  83950. * This is used to decouple the dependency the scene is having on the different workloads like
  83951. * layers, post processes...
  83952. */
  83953. export interface ISceneComponent {
  83954. /**
  83955. * The name of the component. Each component must have a unique name.
  83956. */
  83957. name: string;
  83958. /**
  83959. * The scene the component belongs to.
  83960. */
  83961. scene: Scene;
  83962. /**
  83963. * Register the component to one instance of a scene.
  83964. */
  83965. register(): void;
  83966. /**
  83967. * Rebuilds the elements related to this component in case of
  83968. * context lost for instance.
  83969. */
  83970. rebuild(): void;
  83971. /**
  83972. * Disposes the component and the associated ressources.
  83973. */
  83974. dispose(): void;
  83975. }
  83976. /**
  83977. * This represents a SERIALIZABLE scene component.
  83978. *
  83979. * This extends Scene Component to add Serialization methods on top.
  83980. */
  83981. export interface ISceneSerializableComponent extends ISceneComponent {
  83982. /**
  83983. * Adds all the elements from the container to the scene
  83984. * @param container the container holding the elements
  83985. */
  83986. addFromContainer(container: AbstractScene): void;
  83987. /**
  83988. * Removes all the elements in the container from the scene
  83989. * @param container contains the elements to remove
  83990. * @param dispose if the removed element should be disposed (default: false)
  83991. */
  83992. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  83993. /**
  83994. * Serializes the component data to the specified json object
  83995. * @param serializationObject The object to serialize to
  83996. */
  83997. serialize(serializationObject: any): void;
  83998. }
  83999. /**
  84000. * Strong typing of a Mesh related stage step action
  84001. */
  84002. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  84003. /**
  84004. * Strong typing of a Evaluate Sub Mesh related stage step action
  84005. */
  84006. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  84007. /**
  84008. * Strong typing of a Active Mesh related stage step action
  84009. */
  84010. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  84011. /**
  84012. * Strong typing of a Camera related stage step action
  84013. */
  84014. export type CameraStageAction = (camera: Camera) => void;
  84015. /**
  84016. * Strong typing of a Camera Frame buffer related stage step action
  84017. */
  84018. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  84019. /**
  84020. * Strong typing of a Render Target related stage step action
  84021. */
  84022. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  84023. /**
  84024. * Strong typing of a RenderingGroup related stage step action
  84025. */
  84026. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  84027. /**
  84028. * Strong typing of a Mesh Render related stage step action
  84029. */
  84030. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  84031. /**
  84032. * Strong typing of a simple stage step action
  84033. */
  84034. export type SimpleStageAction = () => void;
  84035. /**
  84036. * Strong typing of a render target action.
  84037. */
  84038. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  84039. /**
  84040. * Strong typing of a pointer move action.
  84041. */
  84042. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  84043. /**
  84044. * Strong typing of a pointer up/down action.
  84045. */
  84046. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  84047. /**
  84048. * Representation of a stage in the scene (Basically a list of ordered steps)
  84049. * @hidden
  84050. */
  84051. export class Stage<T extends Function> extends Array<{
  84052. index: number;
  84053. component: ISceneComponent;
  84054. action: T;
  84055. }> {
  84056. /**
  84057. * Hide ctor from the rest of the world.
  84058. * @param items The items to add.
  84059. */
  84060. private constructor();
  84061. /**
  84062. * Creates a new Stage.
  84063. * @returns A new instance of a Stage
  84064. */
  84065. static Create<T extends Function>(): Stage<T>;
  84066. /**
  84067. * Registers a step in an ordered way in the targeted stage.
  84068. * @param index Defines the position to register the step in
  84069. * @param component Defines the component attached to the step
  84070. * @param action Defines the action to launch during the step
  84071. */
  84072. registerStep(index: number, component: ISceneComponent, action: T): void;
  84073. /**
  84074. * Clears all the steps from the stage.
  84075. */
  84076. clear(): void;
  84077. }
  84078. }
  84079. declare module BABYLON {
  84080. interface Scene {
  84081. /** @hidden */
  84082. _pointerOverSprite: Nullable<Sprite>;
  84083. /** @hidden */
  84084. _pickedDownSprite: Nullable<Sprite>;
  84085. /** @hidden */
  84086. _tempSpritePickingRay: Nullable<Ray>;
  84087. /**
  84088. * All of the sprite managers added to this scene
  84089. * @see http://doc.babylonjs.com/babylon101/sprites
  84090. */
  84091. spriteManagers: Array<ISpriteManager>;
  84092. /**
  84093. * An event triggered when sprites rendering is about to start
  84094. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  84095. */
  84096. onBeforeSpritesRenderingObservable: Observable<Scene>;
  84097. /**
  84098. * An event triggered when sprites rendering is done
  84099. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  84100. */
  84101. onAfterSpritesRenderingObservable: Observable<Scene>;
  84102. /** @hidden */
  84103. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  84104. /** Launch a ray to try to pick a sprite in the scene
  84105. * @param x position on screen
  84106. * @param y position on screen
  84107. * @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
  84108. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  84109. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  84110. * @returns a PickingInfo
  84111. */
  84112. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  84113. /** Use the given ray to pick a sprite in the scene
  84114. * @param ray The ray (in world space) to use to pick meshes
  84115. * @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
  84116. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  84117. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  84118. * @returns a PickingInfo
  84119. */
  84120. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  84121. /** @hidden */
  84122. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  84123. /** Launch a ray to try to pick sprites in the scene
  84124. * @param x position on screen
  84125. * @param y position on screen
  84126. * @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
  84127. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  84128. * @returns a PickingInfo array
  84129. */
  84130. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  84131. /** Use the given ray to pick sprites in the scene
  84132. * @param ray The ray (in world space) to use to pick meshes
  84133. * @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
  84134. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  84135. * @returns a PickingInfo array
  84136. */
  84137. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  84138. /**
  84139. * Force the sprite under the pointer
  84140. * @param sprite defines the sprite to use
  84141. */
  84142. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  84143. /**
  84144. * Gets the sprite under the pointer
  84145. * @returns a Sprite or null if no sprite is under the pointer
  84146. */
  84147. getPointerOverSprite(): Nullable<Sprite>;
  84148. }
  84149. /**
  84150. * Defines the sprite scene component responsible to manage sprites
  84151. * in a given scene.
  84152. */
  84153. export class SpriteSceneComponent implements ISceneComponent {
  84154. /**
  84155. * The component name helpfull to identify the component in the list of scene components.
  84156. */
  84157. readonly name: string;
  84158. /**
  84159. * The scene the component belongs to.
  84160. */
  84161. scene: Scene;
  84162. /** @hidden */
  84163. private _spritePredicate;
  84164. /**
  84165. * Creates a new instance of the component for the given scene
  84166. * @param scene Defines the scene to register the component in
  84167. */
  84168. constructor(scene: Scene);
  84169. /**
  84170. * Registers the component in a given scene
  84171. */
  84172. register(): void;
  84173. /**
  84174. * Rebuilds the elements related to this component in case of
  84175. * context lost for instance.
  84176. */
  84177. rebuild(): void;
  84178. /**
  84179. * Disposes the component and the associated ressources.
  84180. */
  84181. dispose(): void;
  84182. private _pickSpriteButKeepRay;
  84183. private _pointerMove;
  84184. private _pointerDown;
  84185. private _pointerUp;
  84186. }
  84187. }
  84188. declare module BABYLON {
  84189. /** @hidden */
  84190. export var fogFragmentDeclaration: {
  84191. name: string;
  84192. shader: string;
  84193. };
  84194. }
  84195. declare module BABYLON {
  84196. /** @hidden */
  84197. export var fogFragment: {
  84198. name: string;
  84199. shader: string;
  84200. };
  84201. }
  84202. declare module BABYLON {
  84203. /** @hidden */
  84204. export var spritesPixelShader: {
  84205. name: string;
  84206. shader: string;
  84207. };
  84208. }
  84209. declare module BABYLON {
  84210. /** @hidden */
  84211. export var fogVertexDeclaration: {
  84212. name: string;
  84213. shader: string;
  84214. };
  84215. }
  84216. declare module BABYLON {
  84217. /** @hidden */
  84218. export var spritesVertexShader: {
  84219. name: string;
  84220. shader: string;
  84221. };
  84222. }
  84223. declare module BABYLON {
  84224. /**
  84225. * Defines the minimum interface to fullfil in order to be a sprite manager.
  84226. */
  84227. export interface ISpriteManager extends IDisposable {
  84228. /**
  84229. * Restricts the camera to viewing objects with the same layerMask.
  84230. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  84231. */
  84232. layerMask: number;
  84233. /**
  84234. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  84235. */
  84236. isPickable: boolean;
  84237. /**
  84238. * Specifies the rendering group id for this mesh (0 by default)
  84239. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  84240. */
  84241. renderingGroupId: number;
  84242. /**
  84243. * Defines the list of sprites managed by the manager.
  84244. */
  84245. sprites: Array<Sprite>;
  84246. /**
  84247. * Tests the intersection of a sprite with a specific ray.
  84248. * @param ray The ray we are sending to test the collision
  84249. * @param camera The camera space we are sending rays in
  84250. * @param predicate A predicate allowing excluding sprites from the list of object to test
  84251. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  84252. * @returns picking info or null.
  84253. */
  84254. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  84255. /**
  84256. * Intersects the sprites with a ray
  84257. * @param ray defines the ray to intersect with
  84258. * @param camera defines the current active camera
  84259. * @param predicate defines a predicate used to select candidate sprites
  84260. * @returns null if no hit or a PickingInfo array
  84261. */
  84262. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  84263. /**
  84264. * Renders the list of sprites on screen.
  84265. */
  84266. render(): void;
  84267. }
  84268. /**
  84269. * Class used to manage multiple sprites on the same spritesheet
  84270. * @see http://doc.babylonjs.com/babylon101/sprites
  84271. */
  84272. export class SpriteManager implements ISpriteManager {
  84273. /** defines the manager's name */
  84274. name: string;
  84275. /** Gets the list of sprites */
  84276. sprites: Sprite[];
  84277. /** Gets or sets the rendering group id (0 by default) */
  84278. renderingGroupId: number;
  84279. /** Gets or sets camera layer mask */
  84280. layerMask: number;
  84281. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  84282. fogEnabled: boolean;
  84283. /** Gets or sets a boolean indicating if the sprites are pickable */
  84284. isPickable: boolean;
  84285. /** Defines the default width of a cell in the spritesheet */
  84286. cellWidth: number;
  84287. /** Defines the default height of a cell in the spritesheet */
  84288. cellHeight: number;
  84289. /** Associative array from JSON sprite data file */
  84290. private _cellData;
  84291. /** Array of sprite names from JSON sprite data file */
  84292. private _spriteMap;
  84293. /** True when packed cell data from JSON file is ready*/
  84294. private _packedAndReady;
  84295. /**
  84296. * An event triggered when the manager is disposed.
  84297. */
  84298. onDisposeObservable: Observable<SpriteManager>;
  84299. private _onDisposeObserver;
  84300. /**
  84301. * Callback called when the manager is disposed
  84302. */
  84303. set onDispose(callback: () => void);
  84304. private _capacity;
  84305. private _fromPacked;
  84306. private _spriteTexture;
  84307. private _epsilon;
  84308. private _scene;
  84309. private _vertexData;
  84310. private _buffer;
  84311. private _vertexBuffers;
  84312. private _indexBuffer;
  84313. private _effectBase;
  84314. private _effectFog;
  84315. /**
  84316. * Gets or sets the spritesheet texture
  84317. */
  84318. get texture(): Texture;
  84319. set texture(value: Texture);
  84320. private _blendMode;
  84321. /**
  84322. * Blend mode use to render the particle, it can be any of
  84323. * the static Constants.ALPHA_x properties provided in this class.
  84324. * Default value is Constants.ALPHA_COMBINE
  84325. */
  84326. get blendMode(): number;
  84327. set blendMode(blendMode: number);
  84328. /** Disables writing to the depth buffer when rendering the sprites.
  84329. * It can be handy to disable depth writing when using textures without alpha channel
  84330. * and setting some specific blend modes.
  84331. */
  84332. disableDepthWrite: boolean;
  84333. /**
  84334. * Creates a new sprite manager
  84335. * @param name defines the manager's name
  84336. * @param imgUrl defines the sprite sheet url
  84337. * @param capacity defines the maximum allowed number of sprites
  84338. * @param cellSize defines the size of a sprite cell
  84339. * @param scene defines the hosting scene
  84340. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  84341. * @param samplingMode defines the smapling mode to use with spritesheet
  84342. * @param fromPacked set to false; do not alter
  84343. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  84344. */
  84345. constructor(
  84346. /** defines the manager's name */
  84347. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  84348. private _makePacked;
  84349. private _appendSpriteVertex;
  84350. /**
  84351. * Intersects the sprites with a ray
  84352. * @param ray defines the ray to intersect with
  84353. * @param camera defines the current active camera
  84354. * @param predicate defines a predicate used to select candidate sprites
  84355. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  84356. * @returns null if no hit or a PickingInfo
  84357. */
  84358. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  84359. /**
  84360. * Intersects the sprites with a ray
  84361. * @param ray defines the ray to intersect with
  84362. * @param camera defines the current active camera
  84363. * @param predicate defines a predicate used to select candidate sprites
  84364. * @returns null if no hit or a PickingInfo array
  84365. */
  84366. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  84367. /**
  84368. * Render all child sprites
  84369. */
  84370. render(): void;
  84371. /**
  84372. * Release associated resources
  84373. */
  84374. dispose(): void;
  84375. }
  84376. }
  84377. declare module BABYLON {
  84378. /** Interface used by value gradients (color, factor, ...) */
  84379. export interface IValueGradient {
  84380. /**
  84381. * Gets or sets the gradient value (between 0 and 1)
  84382. */
  84383. gradient: number;
  84384. }
  84385. /** Class used to store color4 gradient */
  84386. export class ColorGradient implements IValueGradient {
  84387. /**
  84388. * Gets or sets the gradient value (between 0 and 1)
  84389. */
  84390. gradient: number;
  84391. /**
  84392. * Gets or sets first associated color
  84393. */
  84394. color1: Color4;
  84395. /**
  84396. * Gets or sets second associated color
  84397. */
  84398. color2?: Color4 | undefined;
  84399. /**
  84400. * Creates a new color4 gradient
  84401. * @param gradient gets or sets the gradient value (between 0 and 1)
  84402. * @param color1 gets or sets first associated color
  84403. * @param color2 gets or sets first second color
  84404. */
  84405. constructor(
  84406. /**
  84407. * Gets or sets the gradient value (between 0 and 1)
  84408. */
  84409. gradient: number,
  84410. /**
  84411. * Gets or sets first associated color
  84412. */
  84413. color1: Color4,
  84414. /**
  84415. * Gets or sets second associated color
  84416. */
  84417. color2?: Color4 | undefined);
  84418. /**
  84419. * Will get a color picked randomly between color1 and color2.
  84420. * If color2 is undefined then color1 will be used
  84421. * @param result defines the target Color4 to store the result in
  84422. */
  84423. getColorToRef(result: Color4): void;
  84424. }
  84425. /** Class used to store color 3 gradient */
  84426. export class Color3Gradient implements IValueGradient {
  84427. /**
  84428. * Gets or sets the gradient value (between 0 and 1)
  84429. */
  84430. gradient: number;
  84431. /**
  84432. * Gets or sets the associated color
  84433. */
  84434. color: Color3;
  84435. /**
  84436. * Creates a new color3 gradient
  84437. * @param gradient gets or sets the gradient value (between 0 and 1)
  84438. * @param color gets or sets associated color
  84439. */
  84440. constructor(
  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. /** Class used to store factor gradient */
  84451. export class FactorGradient implements IValueGradient {
  84452. /**
  84453. * Gets or sets the gradient value (between 0 and 1)
  84454. */
  84455. gradient: number;
  84456. /**
  84457. * Gets or sets first associated factor
  84458. */
  84459. factor1: number;
  84460. /**
  84461. * Gets or sets second associated factor
  84462. */
  84463. factor2?: number | undefined;
  84464. /**
  84465. * Creates a new factor gradient
  84466. * @param gradient gets or sets the gradient value (between 0 and 1)
  84467. * @param factor1 gets or sets first associated factor
  84468. * @param factor2 gets or sets second associated factor
  84469. */
  84470. constructor(
  84471. /**
  84472. * Gets or sets the gradient value (between 0 and 1)
  84473. */
  84474. gradient: number,
  84475. /**
  84476. * Gets or sets first associated factor
  84477. */
  84478. factor1: number,
  84479. /**
  84480. * Gets or sets second associated factor
  84481. */
  84482. factor2?: number | undefined);
  84483. /**
  84484. * Will get a number picked randomly between factor1 and factor2.
  84485. * If factor2 is undefined then factor1 will be used
  84486. * @returns the picked number
  84487. */
  84488. getFactor(): number;
  84489. }
  84490. /**
  84491. * Helper used to simplify some generic gradient tasks
  84492. */
  84493. export class GradientHelper {
  84494. /**
  84495. * Gets the current gradient from an array of IValueGradient
  84496. * @param ratio defines the current ratio to get
  84497. * @param gradients defines the array of IValueGradient
  84498. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  84499. */
  84500. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  84501. }
  84502. }
  84503. declare module BABYLON {
  84504. /**
  84505. * Interface for the size containing width and height
  84506. */
  84507. export interface ISize {
  84508. /**
  84509. * Width
  84510. */
  84511. width: number;
  84512. /**
  84513. * Heighht
  84514. */
  84515. height: number;
  84516. }
  84517. /**
  84518. * Size containing widht and height
  84519. */
  84520. export class Size implements ISize {
  84521. /**
  84522. * Width
  84523. */
  84524. width: number;
  84525. /**
  84526. * Height
  84527. */
  84528. height: number;
  84529. /**
  84530. * Creates a Size object from the given width and height (floats).
  84531. * @param width width of the new size
  84532. * @param height height of the new size
  84533. */
  84534. constructor(width: number, height: number);
  84535. /**
  84536. * Returns a string with the Size width and height
  84537. * @returns a string with the Size width and height
  84538. */
  84539. toString(): string;
  84540. /**
  84541. * "Size"
  84542. * @returns the string "Size"
  84543. */
  84544. getClassName(): string;
  84545. /**
  84546. * Returns the Size hash code.
  84547. * @returns a hash code for a unique width and height
  84548. */
  84549. getHashCode(): number;
  84550. /**
  84551. * Updates the current size from the given one.
  84552. * @param src the given size
  84553. */
  84554. copyFrom(src: Size): void;
  84555. /**
  84556. * Updates in place the current Size from the given floats.
  84557. * @param width width of the new size
  84558. * @param height height of the new size
  84559. * @returns the updated Size.
  84560. */
  84561. copyFromFloats(width: number, height: number): Size;
  84562. /**
  84563. * Updates in place the current Size from the given floats.
  84564. * @param width width to set
  84565. * @param height height to set
  84566. * @returns the updated Size.
  84567. */
  84568. set(width: number, height: number): Size;
  84569. /**
  84570. * Multiplies the width and height by numbers
  84571. * @param w factor to multiple the width by
  84572. * @param h factor to multiple the height by
  84573. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  84574. */
  84575. multiplyByFloats(w: number, h: number): Size;
  84576. /**
  84577. * Clones the size
  84578. * @returns a new Size copied from the given one.
  84579. */
  84580. clone(): Size;
  84581. /**
  84582. * True if the current Size and the given one width and height are strictly equal.
  84583. * @param other the other size to compare against
  84584. * @returns True if the current Size and the given one width and height are strictly equal.
  84585. */
  84586. equals(other: Size): boolean;
  84587. /**
  84588. * The surface of the Size : width * height (float).
  84589. */
  84590. get surface(): number;
  84591. /**
  84592. * Create a new size of zero
  84593. * @returns a new Size set to (0.0, 0.0)
  84594. */
  84595. static Zero(): Size;
  84596. /**
  84597. * Sums the width and height of two sizes
  84598. * @param otherSize size to add to this size
  84599. * @returns a new Size set as the addition result of the current Size and the given one.
  84600. */
  84601. add(otherSize: Size): Size;
  84602. /**
  84603. * Subtracts the width and height of two
  84604. * @param otherSize size to subtract to this size
  84605. * @returns a new Size set as the subtraction result of the given one from the current Size.
  84606. */
  84607. subtract(otherSize: Size): Size;
  84608. /**
  84609. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  84610. * @param start starting size to lerp between
  84611. * @param end end size to lerp between
  84612. * @param amount amount to lerp between the start and end values
  84613. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  84614. */
  84615. static Lerp(start: Size, end: Size, amount: number): Size;
  84616. }
  84617. }
  84618. declare module BABYLON {
  84619. interface ThinEngine {
  84620. /**
  84621. * Creates a dynamic texture
  84622. * @param width defines the width of the texture
  84623. * @param height defines the height of the texture
  84624. * @param generateMipMaps defines if the engine should generate the mip levels
  84625. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  84626. * @returns the dynamic texture inside an InternalTexture
  84627. */
  84628. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  84629. /**
  84630. * Update the content of a dynamic texture
  84631. * @param texture defines the texture to update
  84632. * @param canvas defines the canvas containing the source
  84633. * @param invertY defines if data must be stored with Y axis inverted
  84634. * @param premulAlpha defines if alpha is stored as premultiplied
  84635. * @param format defines the format of the data
  84636. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  84637. */
  84638. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  84639. }
  84640. }
  84641. declare module BABYLON {
  84642. /**
  84643. * Helper class used to generate a canvas to manipulate images
  84644. */
  84645. export class CanvasGenerator {
  84646. /**
  84647. * Create a new canvas (or offscreen canvas depending on the context)
  84648. * @param width defines the expected width
  84649. * @param height defines the expected height
  84650. * @return a new canvas or offscreen canvas
  84651. */
  84652. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  84653. }
  84654. }
  84655. declare module BABYLON {
  84656. /**
  84657. * A class extending Texture allowing drawing on a texture
  84658. * @see http://doc.babylonjs.com/how_to/dynamictexture
  84659. */
  84660. export class DynamicTexture extends Texture {
  84661. private _generateMipMaps;
  84662. private _canvas;
  84663. private _context;
  84664. private _engine;
  84665. /**
  84666. * Creates a DynamicTexture
  84667. * @param name defines the name of the texture
  84668. * @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
  84669. * @param scene defines the scene where you want the texture
  84670. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  84671. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  84672. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  84673. */
  84674. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  84675. /**
  84676. * Get the current class name of the texture useful for serialization or dynamic coding.
  84677. * @returns "DynamicTexture"
  84678. */
  84679. getClassName(): string;
  84680. /**
  84681. * Gets the current state of canRescale
  84682. */
  84683. get canRescale(): boolean;
  84684. private _recreate;
  84685. /**
  84686. * Scales the texture
  84687. * @param ratio the scale factor to apply to both width and height
  84688. */
  84689. scale(ratio: number): void;
  84690. /**
  84691. * Resizes the texture
  84692. * @param width the new width
  84693. * @param height the new height
  84694. */
  84695. scaleTo(width: number, height: number): void;
  84696. /**
  84697. * Gets the context of the canvas used by the texture
  84698. * @returns the canvas context of the dynamic texture
  84699. */
  84700. getContext(): CanvasRenderingContext2D;
  84701. /**
  84702. * Clears the texture
  84703. */
  84704. clear(): void;
  84705. /**
  84706. * Updates the texture
  84707. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  84708. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  84709. */
  84710. update(invertY?: boolean, premulAlpha?: boolean): void;
  84711. /**
  84712. * Draws text onto the texture
  84713. * @param text defines the text to be drawn
  84714. * @param x defines the placement of the text from the left
  84715. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  84716. * @param font defines the font to be used with font-style, font-size, font-name
  84717. * @param color defines the color used for the text
  84718. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  84719. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  84720. * @param update defines whether texture is immediately update (default is true)
  84721. */
  84722. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  84723. /**
  84724. * Clones the texture
  84725. * @returns the clone of the texture.
  84726. */
  84727. clone(): DynamicTexture;
  84728. /**
  84729. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  84730. * @returns a serialized dynamic texture object
  84731. */
  84732. serialize(): any;
  84733. /** @hidden */
  84734. _rebuild(): void;
  84735. }
  84736. }
  84737. declare module BABYLON {
  84738. interface Engine {
  84739. /**
  84740. * Creates a raw texture
  84741. * @param data defines the data to store in the texture
  84742. * @param width defines the width of the texture
  84743. * @param height defines the height of the texture
  84744. * @param format defines the format of the data
  84745. * @param generateMipMaps defines if the engine should generate the mip levels
  84746. * @param invertY defines if data must be stored with Y axis inverted
  84747. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  84748. * @param compression defines the compression used (null by default)
  84749. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  84750. * @returns the raw texture inside an InternalTexture
  84751. */
  84752. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  84753. /**
  84754. * Update a raw texture
  84755. * @param texture defines the texture to update
  84756. * @param data defines the data to store in the texture
  84757. * @param format defines the format of the data
  84758. * @param invertY defines if data must be stored with Y axis inverted
  84759. */
  84760. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  84761. /**
  84762. * Update a raw texture
  84763. * @param texture defines the texture to update
  84764. * @param data defines the data to store in the texture
  84765. * @param format defines the format of the data
  84766. * @param invertY defines if data must be stored with Y axis inverted
  84767. * @param compression defines the compression used (null by default)
  84768. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  84769. */
  84770. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  84771. /**
  84772. * Creates a new raw cube texture
  84773. * @param data defines the array of data to use to create each face
  84774. * @param size defines the size of the textures
  84775. * @param format defines the format of the data
  84776. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  84777. * @param generateMipMaps defines if the engine should generate the mip levels
  84778. * @param invertY defines if data must be stored with Y axis inverted
  84779. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  84780. * @param compression defines the compression used (null by default)
  84781. * @returns the cube texture as an InternalTexture
  84782. */
  84783. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  84784. /**
  84785. * Update a raw cube texture
  84786. * @param texture defines the texture to udpdate
  84787. * @param data defines the data to store
  84788. * @param format defines the data format
  84789. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  84790. * @param invertY defines if data must be stored with Y axis inverted
  84791. */
  84792. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  84793. /**
  84794. * Update a raw cube texture
  84795. * @param texture defines the texture to udpdate
  84796. * @param data defines the data to store
  84797. * @param format defines the data format
  84798. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  84799. * @param invertY defines if data must be stored with Y axis inverted
  84800. * @param compression defines the compression used (null by default)
  84801. */
  84802. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  84803. /**
  84804. * Update a raw cube texture
  84805. * @param texture defines the texture to udpdate
  84806. * @param data defines the data to store
  84807. * @param format defines the data format
  84808. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  84809. * @param invertY defines if data must be stored with Y axis inverted
  84810. * @param compression defines the compression used (null by default)
  84811. * @param level defines which level of the texture to update
  84812. */
  84813. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  84814. /**
  84815. * Creates a new raw cube texture from a specified url
  84816. * @param url defines the url where the data is located
  84817. * @param scene defines the current scene
  84818. * @param size defines the size of the textures
  84819. * @param format defines the format of the data
  84820. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  84821. * @param noMipmap defines if the engine should avoid generating the mip levels
  84822. * @param callback defines a callback used to extract texture data from loaded data
  84823. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  84824. * @param onLoad defines a callback called when texture is loaded
  84825. * @param onError defines a callback called if there is an error
  84826. * @returns the cube texture as an InternalTexture
  84827. */
  84828. 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;
  84829. /**
  84830. * Creates a new raw cube texture from a specified url
  84831. * @param url defines the url where the data is located
  84832. * @param scene defines the current scene
  84833. * @param size defines the size of the textures
  84834. * @param format defines the format of the data
  84835. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  84836. * @param noMipmap defines if the engine should avoid generating the mip levels
  84837. * @param callback defines a callback used to extract texture data from loaded data
  84838. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  84839. * @param onLoad defines a callback called when texture is loaded
  84840. * @param onError defines a callback called if there is an error
  84841. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  84842. * @param invertY defines if data must be stored with Y axis inverted
  84843. * @returns the cube texture as an InternalTexture
  84844. */
  84845. 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;
  84846. /**
  84847. * Creates a new raw 3D texture
  84848. * @param data defines the data used to create the texture
  84849. * @param width defines the width of the texture
  84850. * @param height defines the height of the texture
  84851. * @param depth defines the depth of the texture
  84852. * @param format defines the format of the texture
  84853. * @param generateMipMaps defines if the engine must generate mip levels
  84854. * @param invertY defines if data must be stored with Y axis inverted
  84855. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  84856. * @param compression defines the compressed used (can be null)
  84857. * @param textureType defines the compressed used (can be null)
  84858. * @returns a new raw 3D texture (stored in an InternalTexture)
  84859. */
  84860. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  84861. /**
  84862. * Update a raw 3D texture
  84863. * @param texture defines the texture to update
  84864. * @param data defines the data to store
  84865. * @param format defines the data format
  84866. * @param invertY defines if data must be stored with Y axis inverted
  84867. */
  84868. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  84869. /**
  84870. * Update a raw 3D texture
  84871. * @param texture defines the texture to update
  84872. * @param data defines the data to store
  84873. * @param format defines the data format
  84874. * @param invertY defines if data must be stored with Y axis inverted
  84875. * @param compression defines the used compression (can be null)
  84876. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  84877. */
  84878. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  84879. /**
  84880. * Creates a new raw 2D array texture
  84881. * @param data defines the data used to create the texture
  84882. * @param width defines the width of the texture
  84883. * @param height defines the height of the texture
  84884. * @param depth defines the number of layers of the texture
  84885. * @param format defines the format of the texture
  84886. * @param generateMipMaps defines if the engine must generate mip levels
  84887. * @param invertY defines if data must be stored with Y axis inverted
  84888. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  84889. * @param compression defines the compressed used (can be null)
  84890. * @param textureType defines the compressed used (can be null)
  84891. * @returns a new raw 2D array texture (stored in an InternalTexture)
  84892. */
  84893. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  84894. /**
  84895. * Update a raw 2D array texture
  84896. * @param texture defines the texture to update
  84897. * @param data defines the data to store
  84898. * @param format defines the data format
  84899. * @param invertY defines if data must be stored with Y axis inverted
  84900. */
  84901. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  84902. /**
  84903. * Update a raw 2D array texture
  84904. * @param texture defines the texture to update
  84905. * @param data defines the data to store
  84906. * @param format defines the data format
  84907. * @param invertY defines if data must be stored with Y axis inverted
  84908. * @param compression defines the used compression (can be null)
  84909. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  84910. */
  84911. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  84912. }
  84913. }
  84914. declare module BABYLON {
  84915. /**
  84916. * Raw texture can help creating a texture directly from an array of data.
  84917. * This can be super useful if you either get the data from an uncompressed source or
  84918. * if you wish to create your texture pixel by pixel.
  84919. */
  84920. export class RawTexture extends Texture {
  84921. /**
  84922. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  84923. */
  84924. format: number;
  84925. private _engine;
  84926. /**
  84927. * Instantiates a new RawTexture.
  84928. * Raw texture can help creating a texture directly from an array of data.
  84929. * This can be super useful if you either get the data from an uncompressed source or
  84930. * if you wish to create your texture pixel by pixel.
  84931. * @param data define the array of data to use to create the texture
  84932. * @param width define the width of the texture
  84933. * @param height define the height of the texture
  84934. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  84935. * @param scene define the scene the texture belongs to
  84936. * @param generateMipMaps define whether mip maps should be generated or not
  84937. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  84938. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  84939. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  84940. */
  84941. constructor(data: ArrayBufferView, width: number, height: number,
  84942. /**
  84943. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  84944. */
  84945. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  84946. /**
  84947. * Updates the texture underlying data.
  84948. * @param data Define the new data of the texture
  84949. */
  84950. update(data: ArrayBufferView): void;
  84951. /**
  84952. * Creates a luminance texture from some data.
  84953. * @param data Define the texture data
  84954. * @param width Define the width of the texture
  84955. * @param height Define the height of the texture
  84956. * @param scene Define the scene the texture belongs to
  84957. * @param generateMipMaps Define whether or not to create mip maps for the texture
  84958. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  84959. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  84960. * @returns the luminance texture
  84961. */
  84962. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  84963. /**
  84964. * Creates a luminance alpha texture from some data.
  84965. * @param data Define the texture data
  84966. * @param width Define the width of the texture
  84967. * @param height Define the height of the texture
  84968. * @param scene Define the scene the texture belongs to
  84969. * @param generateMipMaps Define whether or not to create mip maps for the texture
  84970. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  84971. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  84972. * @returns the luminance alpha texture
  84973. */
  84974. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  84975. /**
  84976. * Creates an alpha texture from some data.
  84977. * @param data Define the texture data
  84978. * @param width Define the width of the texture
  84979. * @param height Define the height of the texture
  84980. * @param scene Define the scene the texture belongs to
  84981. * @param generateMipMaps Define whether or not to create mip maps for the texture
  84982. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  84983. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  84984. * @returns the alpha texture
  84985. */
  84986. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  84987. /**
  84988. * Creates a RGB texture from some data.
  84989. * @param data Define the texture data
  84990. * @param width Define the width of the texture
  84991. * @param height Define the height of the texture
  84992. * @param scene Define the scene the texture belongs to
  84993. * @param generateMipMaps Define whether or not to create mip maps for the texture
  84994. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  84995. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  84996. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  84997. * @returns the RGB alpha texture
  84998. */
  84999. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  85000. /**
  85001. * Creates a RGBA texture from some data.
  85002. * @param data Define the texture data
  85003. * @param width Define the width of the texture
  85004. * @param height Define the height of the texture
  85005. * @param scene Define the scene the texture belongs to
  85006. * @param generateMipMaps Define whether or not to create mip maps for the texture
  85007. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  85008. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  85009. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  85010. * @returns the RGBA texture
  85011. */
  85012. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  85013. /**
  85014. * Creates a R texture from some data.
  85015. * @param data Define the texture data
  85016. * @param width Define the width of the texture
  85017. * @param height Define the height of the texture
  85018. * @param scene Define the scene the texture belongs to
  85019. * @param generateMipMaps Define whether or not to create mip maps for the texture
  85020. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  85021. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  85022. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  85023. * @returns the R texture
  85024. */
  85025. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  85026. }
  85027. }
  85028. declare module BABYLON {
  85029. interface AbstractScene {
  85030. /**
  85031. * The list of procedural textures added to the scene
  85032. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  85033. */
  85034. proceduralTextures: Array<ProceduralTexture>;
  85035. }
  85036. /**
  85037. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  85038. * in a given scene.
  85039. */
  85040. export class ProceduralTextureSceneComponent implements ISceneComponent {
  85041. /**
  85042. * The component name helpfull to identify the component in the list of scene components.
  85043. */
  85044. readonly name: string;
  85045. /**
  85046. * The scene the component belongs to.
  85047. */
  85048. scene: Scene;
  85049. /**
  85050. * Creates a new instance of the component for the given scene
  85051. * @param scene Defines the scene to register the component in
  85052. */
  85053. constructor(scene: Scene);
  85054. /**
  85055. * Registers the component in a given scene
  85056. */
  85057. register(): void;
  85058. /**
  85059. * Rebuilds the elements related to this component in case of
  85060. * context lost for instance.
  85061. */
  85062. rebuild(): void;
  85063. /**
  85064. * Disposes the component and the associated ressources.
  85065. */
  85066. dispose(): void;
  85067. private _beforeClear;
  85068. }
  85069. }
  85070. declare module BABYLON {
  85071. interface ThinEngine {
  85072. /**
  85073. * Creates a new render target cube texture
  85074. * @param size defines the size of the texture
  85075. * @param options defines the options used to create the texture
  85076. * @returns a new render target cube texture stored in an InternalTexture
  85077. */
  85078. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  85079. }
  85080. }
  85081. declare module BABYLON {
  85082. /** @hidden */
  85083. export var proceduralVertexShader: {
  85084. name: string;
  85085. shader: string;
  85086. };
  85087. }
  85088. declare module BABYLON {
  85089. /**
  85090. * 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.
  85091. * This is the base class of any Procedural texture and contains most of the shareable code.
  85092. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  85093. */
  85094. export class ProceduralTexture extends Texture {
  85095. isCube: boolean;
  85096. /**
  85097. * Define if the texture is enabled or not (disabled texture will not render)
  85098. */
  85099. isEnabled: boolean;
  85100. /**
  85101. * Define if the texture must be cleared before rendering (default is true)
  85102. */
  85103. autoClear: boolean;
  85104. /**
  85105. * Callback called when the texture is generated
  85106. */
  85107. onGenerated: () => void;
  85108. /**
  85109. * Event raised when the texture is generated
  85110. */
  85111. onGeneratedObservable: Observable<ProceduralTexture>;
  85112. /** @hidden */
  85113. _generateMipMaps: boolean;
  85114. /** @hidden **/
  85115. _effect: Effect;
  85116. /** @hidden */
  85117. _textures: {
  85118. [key: string]: Texture;
  85119. };
  85120. /** @hidden */
  85121. protected _fallbackTexture: Nullable<Texture>;
  85122. private _size;
  85123. private _currentRefreshId;
  85124. private _frameId;
  85125. private _refreshRate;
  85126. private _vertexBuffers;
  85127. private _indexBuffer;
  85128. private _uniforms;
  85129. private _samplers;
  85130. private _fragment;
  85131. private _floats;
  85132. private _ints;
  85133. private _floatsArrays;
  85134. private _colors3;
  85135. private _colors4;
  85136. private _vectors2;
  85137. private _vectors3;
  85138. private _matrices;
  85139. private _fallbackTextureUsed;
  85140. private _engine;
  85141. private _cachedDefines;
  85142. private _contentUpdateId;
  85143. private _contentData;
  85144. /**
  85145. * Instantiates a new procedural texture.
  85146. * 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.
  85147. * This is the base class of any Procedural texture and contains most of the shareable code.
  85148. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  85149. * @param name Define the name of the texture
  85150. * @param size Define the size of the texture to create
  85151. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  85152. * @param scene Define the scene the texture belongs to
  85153. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  85154. * @param generateMipMaps Define if the texture should creates mip maps or not
  85155. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  85156. */
  85157. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  85158. /**
  85159. * The effect that is created when initializing the post process.
  85160. * @returns The created effect corresponding the the postprocess.
  85161. */
  85162. getEffect(): Effect;
  85163. /**
  85164. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  85165. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  85166. */
  85167. getContent(): Nullable<ArrayBufferView>;
  85168. private _createIndexBuffer;
  85169. /** @hidden */
  85170. _rebuild(): void;
  85171. /**
  85172. * Resets the texture in order to recreate its associated resources.
  85173. * This can be called in case of context loss
  85174. */
  85175. reset(): void;
  85176. protected _getDefines(): string;
  85177. /**
  85178. * Is the texture ready to be used ? (rendered at least once)
  85179. * @returns true if ready, otherwise, false.
  85180. */
  85181. isReady(): boolean;
  85182. /**
  85183. * Resets the refresh counter of the texture and start bak from scratch.
  85184. * Could be useful to regenerate the texture if it is setup to render only once.
  85185. */
  85186. resetRefreshCounter(): void;
  85187. /**
  85188. * Set the fragment shader to use in order to render the texture.
  85189. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  85190. */
  85191. setFragment(fragment: any): void;
  85192. /**
  85193. * Define the refresh rate of the texture or the rendering frequency.
  85194. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  85195. */
  85196. get refreshRate(): number;
  85197. set refreshRate(value: number);
  85198. /** @hidden */
  85199. _shouldRender(): boolean;
  85200. /**
  85201. * Get the size the texture is rendering at.
  85202. * @returns the size (texture is always squared)
  85203. */
  85204. getRenderSize(): number;
  85205. /**
  85206. * Resize the texture to new value.
  85207. * @param size Define the new size the texture should have
  85208. * @param generateMipMaps Define whether the new texture should create mip maps
  85209. */
  85210. resize(size: number, generateMipMaps: boolean): void;
  85211. private _checkUniform;
  85212. /**
  85213. * Set a texture in the shader program used to render.
  85214. * @param name Define the name of the uniform samplers as defined in the shader
  85215. * @param texture Define the texture to bind to this sampler
  85216. * @return the texture itself allowing "fluent" like uniform updates
  85217. */
  85218. setTexture(name: string, texture: Texture): ProceduralTexture;
  85219. /**
  85220. * Set a float in the shader.
  85221. * @param name Define the name of the uniform as defined in the shader
  85222. * @param value Define the value to give to the uniform
  85223. * @return the texture itself allowing "fluent" like uniform updates
  85224. */
  85225. setFloat(name: string, value: number): ProceduralTexture;
  85226. /**
  85227. * Set a int in the shader.
  85228. * @param name Define the name of the uniform as defined in the shader
  85229. * @param value Define the value to give to the uniform
  85230. * @return the texture itself allowing "fluent" like uniform updates
  85231. */
  85232. setInt(name: string, value: number): ProceduralTexture;
  85233. /**
  85234. * Set an array of floats 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. setFloats(name: string, value: number[]): ProceduralTexture;
  85240. /**
  85241. * Set a vec3 in the shader from a Color3.
  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. setColor3(name: string, value: Color3): ProceduralTexture;
  85247. /**
  85248. * Set a vec4 in the shader from a Color4.
  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. setColor4(name: string, value: Color4): ProceduralTexture;
  85254. /**
  85255. * Set a vec2 in the shader from a Vector2.
  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. setVector2(name: string, value: Vector2): ProceduralTexture;
  85261. /**
  85262. * Set a vec3 in the shader from a Vector3.
  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. setVector3(name: string, value: Vector3): ProceduralTexture;
  85268. /**
  85269. * Set a mat4 in the shader from a MAtrix.
  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. setMatrix(name: string, value: Matrix): ProceduralTexture;
  85275. /**
  85276. * Render the texture to its associated render target.
  85277. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  85278. */
  85279. render(useCameraPostProcess?: boolean): void;
  85280. /**
  85281. * Clone the texture.
  85282. * @returns the cloned texture
  85283. */
  85284. clone(): ProceduralTexture;
  85285. /**
  85286. * Dispose the texture and release its asoociated resources.
  85287. */
  85288. dispose(): void;
  85289. }
  85290. }
  85291. declare module BABYLON {
  85292. /**
  85293. * This represents the base class for particle system in Babylon.
  85294. * 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.
  85295. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  85296. * @example https://doc.babylonjs.com/babylon101/particles
  85297. */
  85298. export class BaseParticleSystem {
  85299. /**
  85300. * Source color is added to the destination color without alpha affecting the result
  85301. */
  85302. static BLENDMODE_ONEONE: number;
  85303. /**
  85304. * Blend current color and particle color using particle’s alpha
  85305. */
  85306. static BLENDMODE_STANDARD: number;
  85307. /**
  85308. * Add current color and particle color multiplied by particle’s alpha
  85309. */
  85310. static BLENDMODE_ADD: number;
  85311. /**
  85312. * Multiply current color with particle color
  85313. */
  85314. static BLENDMODE_MULTIPLY: number;
  85315. /**
  85316. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  85317. */
  85318. static BLENDMODE_MULTIPLYADD: number;
  85319. /**
  85320. * List of animations used by the particle system.
  85321. */
  85322. animations: Animation[];
  85323. /**
  85324. * Gets or sets the unique id of the particle system
  85325. */
  85326. uniqueId: number;
  85327. /**
  85328. * The id of the Particle system.
  85329. */
  85330. id: string;
  85331. /**
  85332. * The friendly name of the Particle system.
  85333. */
  85334. name: string;
  85335. /**
  85336. * Snippet ID if the particle system was created from the snippet server
  85337. */
  85338. snippetId: string;
  85339. /**
  85340. * The rendering group used by the Particle system to chose when to render.
  85341. */
  85342. renderingGroupId: number;
  85343. /**
  85344. * The emitter represents the Mesh or position we are attaching the particle system to.
  85345. */
  85346. emitter: Nullable<AbstractMesh | Vector3>;
  85347. /**
  85348. * The maximum number of particles to emit per frame
  85349. */
  85350. emitRate: number;
  85351. /**
  85352. * If you want to launch only a few particles at once, that can be done, as well.
  85353. */
  85354. manualEmitCount: number;
  85355. /**
  85356. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  85357. */
  85358. updateSpeed: number;
  85359. /**
  85360. * The amount of time the particle system is running (depends of the overall update speed).
  85361. */
  85362. targetStopDuration: number;
  85363. /**
  85364. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  85365. */
  85366. disposeOnStop: boolean;
  85367. /**
  85368. * Minimum power of emitting particles.
  85369. */
  85370. minEmitPower: number;
  85371. /**
  85372. * Maximum power of emitting particles.
  85373. */
  85374. maxEmitPower: number;
  85375. /**
  85376. * Minimum life time of emitting particles.
  85377. */
  85378. minLifeTime: number;
  85379. /**
  85380. * Maximum life time of emitting particles.
  85381. */
  85382. maxLifeTime: number;
  85383. /**
  85384. * Minimum Size of emitting particles.
  85385. */
  85386. minSize: number;
  85387. /**
  85388. * Maximum Size of emitting particles.
  85389. */
  85390. maxSize: number;
  85391. /**
  85392. * Minimum scale of emitting particles on X axis.
  85393. */
  85394. minScaleX: number;
  85395. /**
  85396. * Maximum scale of emitting particles on X axis.
  85397. */
  85398. maxScaleX: number;
  85399. /**
  85400. * Minimum scale of emitting particles on Y axis.
  85401. */
  85402. minScaleY: number;
  85403. /**
  85404. * Maximum scale of emitting particles on Y axis.
  85405. */
  85406. maxScaleY: number;
  85407. /**
  85408. * Gets or sets the minimal initial rotation in radians.
  85409. */
  85410. minInitialRotation: number;
  85411. /**
  85412. * Gets or sets the maximal initial rotation in radians.
  85413. */
  85414. maxInitialRotation: number;
  85415. /**
  85416. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  85417. */
  85418. minAngularSpeed: number;
  85419. /**
  85420. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  85421. */
  85422. maxAngularSpeed: number;
  85423. /**
  85424. * The texture used to render each particle. (this can be a spritesheet)
  85425. */
  85426. particleTexture: Nullable<Texture>;
  85427. /**
  85428. * The layer mask we are rendering the particles through.
  85429. */
  85430. layerMask: number;
  85431. /**
  85432. * This can help using your own shader to render the particle system.
  85433. * The according effect will be created
  85434. */
  85435. customShader: any;
  85436. /**
  85437. * By default particle system starts as soon as they are created. This prevents the
  85438. * automatic start to happen and let you decide when to start emitting particles.
  85439. */
  85440. preventAutoStart: boolean;
  85441. private _noiseTexture;
  85442. /**
  85443. * Gets or sets a texture used to add random noise to particle positions
  85444. */
  85445. get noiseTexture(): Nullable<ProceduralTexture>;
  85446. set noiseTexture(value: Nullable<ProceduralTexture>);
  85447. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  85448. noiseStrength: Vector3;
  85449. /**
  85450. * Callback triggered when the particle animation is ending.
  85451. */
  85452. onAnimationEnd: Nullable<() => void>;
  85453. /**
  85454. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  85455. */
  85456. blendMode: number;
  85457. /**
  85458. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  85459. * to override the particles.
  85460. */
  85461. forceDepthWrite: boolean;
  85462. /** 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 */
  85463. preWarmCycles: number;
  85464. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  85465. preWarmStepOffset: number;
  85466. /**
  85467. * 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)
  85468. */
  85469. spriteCellChangeSpeed: number;
  85470. /**
  85471. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  85472. */
  85473. startSpriteCellID: number;
  85474. /**
  85475. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  85476. */
  85477. endSpriteCellID: number;
  85478. /**
  85479. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  85480. */
  85481. spriteCellWidth: number;
  85482. /**
  85483. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  85484. */
  85485. spriteCellHeight: number;
  85486. /**
  85487. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  85488. */
  85489. spriteRandomStartCell: boolean;
  85490. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  85491. translationPivot: Vector2;
  85492. /** @hidden */
  85493. protected _isAnimationSheetEnabled: boolean;
  85494. /**
  85495. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  85496. */
  85497. beginAnimationOnStart: boolean;
  85498. /**
  85499. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  85500. */
  85501. beginAnimationFrom: number;
  85502. /**
  85503. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  85504. */
  85505. beginAnimationTo: number;
  85506. /**
  85507. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  85508. */
  85509. beginAnimationLoop: boolean;
  85510. /**
  85511. * Gets or sets a world offset applied to all particles
  85512. */
  85513. worldOffset: Vector3;
  85514. /**
  85515. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  85516. */
  85517. get isAnimationSheetEnabled(): boolean;
  85518. set isAnimationSheetEnabled(value: boolean);
  85519. /**
  85520. * Get hosting scene
  85521. * @returns the scene
  85522. */
  85523. getScene(): Scene;
  85524. /**
  85525. * You can use gravity if you want to give an orientation to your particles.
  85526. */
  85527. gravity: Vector3;
  85528. protected _colorGradients: Nullable<Array<ColorGradient>>;
  85529. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  85530. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  85531. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  85532. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  85533. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  85534. protected _dragGradients: Nullable<Array<FactorGradient>>;
  85535. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  85536. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  85537. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  85538. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  85539. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  85540. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  85541. /**
  85542. * Defines the delay in milliseconds before starting the system (0 by default)
  85543. */
  85544. startDelay: number;
  85545. /**
  85546. * Gets the current list of drag gradients.
  85547. * You must use addDragGradient and removeDragGradient to udpate this list
  85548. * @returns the list of drag gradients
  85549. */
  85550. getDragGradients(): Nullable<Array<FactorGradient>>;
  85551. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  85552. limitVelocityDamping: number;
  85553. /**
  85554. * Gets the current list of limit velocity gradients.
  85555. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  85556. * @returns the list of limit velocity gradients
  85557. */
  85558. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  85559. /**
  85560. * Gets the current list of color gradients.
  85561. * You must use addColorGradient and removeColorGradient to udpate this list
  85562. * @returns the list of color gradients
  85563. */
  85564. getColorGradients(): Nullable<Array<ColorGradient>>;
  85565. /**
  85566. * Gets the current list of size gradients.
  85567. * You must use addSizeGradient and removeSizeGradient to udpate this list
  85568. * @returns the list of size gradients
  85569. */
  85570. getSizeGradients(): Nullable<Array<FactorGradient>>;
  85571. /**
  85572. * Gets the current list of color remap gradients.
  85573. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  85574. * @returns the list of color remap gradients
  85575. */
  85576. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  85577. /**
  85578. * Gets the current list of alpha remap gradients.
  85579. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  85580. * @returns the list of alpha remap gradients
  85581. */
  85582. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  85583. /**
  85584. * Gets the current list of life time gradients.
  85585. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  85586. * @returns the list of life time gradients
  85587. */
  85588. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  85589. /**
  85590. * Gets the current list of angular speed gradients.
  85591. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  85592. * @returns the list of angular speed gradients
  85593. */
  85594. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  85595. /**
  85596. * Gets the current list of velocity gradients.
  85597. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  85598. * @returns the list of velocity gradients
  85599. */
  85600. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  85601. /**
  85602. * Gets the current list of start size gradients.
  85603. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  85604. * @returns the list of start size gradients
  85605. */
  85606. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  85607. /**
  85608. * Gets the current list of emit rate gradients.
  85609. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  85610. * @returns the list of emit rate gradients
  85611. */
  85612. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  85613. /**
  85614. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  85615. * This only works when particleEmitterTyps is a BoxParticleEmitter
  85616. */
  85617. get direction1(): Vector3;
  85618. set direction1(value: Vector3);
  85619. /**
  85620. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  85621. * This only works when particleEmitterTyps is a BoxParticleEmitter
  85622. */
  85623. get direction2(): Vector3;
  85624. set direction2(value: Vector3);
  85625. /**
  85626. * 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.
  85627. * This only works when particleEmitterTyps is a BoxParticleEmitter
  85628. */
  85629. get minEmitBox(): Vector3;
  85630. set minEmitBox(value: Vector3);
  85631. /**
  85632. * 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.
  85633. * This only works when particleEmitterTyps is a BoxParticleEmitter
  85634. */
  85635. get maxEmitBox(): Vector3;
  85636. set maxEmitBox(value: Vector3);
  85637. /**
  85638. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  85639. */
  85640. color1: Color4;
  85641. /**
  85642. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  85643. */
  85644. color2: Color4;
  85645. /**
  85646. * Color the particle will have at the end of its lifetime
  85647. */
  85648. colorDead: Color4;
  85649. /**
  85650. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  85651. */
  85652. textureMask: Color4;
  85653. /**
  85654. * The particle emitter type defines the emitter used by the particle system.
  85655. * It can be for example box, sphere, or cone...
  85656. */
  85657. particleEmitterType: IParticleEmitterType;
  85658. /** @hidden */
  85659. _isSubEmitter: boolean;
  85660. /**
  85661. * Gets or sets the billboard mode to use when isBillboardBased = true.
  85662. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  85663. */
  85664. billboardMode: number;
  85665. protected _isBillboardBased: boolean;
  85666. /**
  85667. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  85668. */
  85669. get isBillboardBased(): boolean;
  85670. set isBillboardBased(value: boolean);
  85671. /**
  85672. * The scene the particle system belongs to.
  85673. */
  85674. protected _scene: Scene;
  85675. /**
  85676. * Local cache of defines for image processing.
  85677. */
  85678. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  85679. /**
  85680. * Default configuration related to image processing available in the standard Material.
  85681. */
  85682. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  85683. /**
  85684. * Gets the image processing configuration used either in this material.
  85685. */
  85686. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  85687. /**
  85688. * Sets the Default image processing configuration used either in the this material.
  85689. *
  85690. * If sets to null, the scene one is in use.
  85691. */
  85692. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  85693. /**
  85694. * Attaches a new image processing configuration to the Standard Material.
  85695. * @param configuration
  85696. */
  85697. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  85698. /** @hidden */
  85699. protected _reset(): void;
  85700. /** @hidden */
  85701. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  85702. /**
  85703. * Instantiates a particle system.
  85704. * 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.
  85705. * @param name The name of the particle system
  85706. */
  85707. constructor(name: string);
  85708. /**
  85709. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  85710. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  85711. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  85712. * @returns the emitter
  85713. */
  85714. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  85715. /**
  85716. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  85717. * @param radius The radius of the hemisphere to emit from
  85718. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  85719. * @returns the emitter
  85720. */
  85721. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  85722. /**
  85723. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  85724. * @param radius The radius of the sphere to emit from
  85725. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  85726. * @returns the emitter
  85727. */
  85728. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  85729. /**
  85730. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  85731. * @param radius The radius of the sphere to emit from
  85732. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  85733. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  85734. * @returns the emitter
  85735. */
  85736. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  85737. /**
  85738. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  85739. * @param radius The radius of the emission cylinder
  85740. * @param height The height of the emission cylinder
  85741. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  85742. * @param directionRandomizer How much to randomize the particle direction [0-1]
  85743. * @returns the emitter
  85744. */
  85745. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  85746. /**
  85747. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  85748. * @param radius The radius of the cylinder to emit from
  85749. * @param height The height of the emission cylinder
  85750. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  85751. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  85752. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  85753. * @returns the emitter
  85754. */
  85755. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  85756. /**
  85757. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  85758. * @param radius The radius of the cone to emit from
  85759. * @param angle The base angle of the cone
  85760. * @returns the emitter
  85761. */
  85762. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  85763. /**
  85764. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  85765. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  85766. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  85767. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  85768. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  85769. * @returns the emitter
  85770. */
  85771. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  85772. }
  85773. }
  85774. declare module BABYLON {
  85775. /**
  85776. * Type of sub emitter
  85777. */
  85778. export enum SubEmitterType {
  85779. /**
  85780. * Attached to the particle over it's lifetime
  85781. */
  85782. ATTACHED = 0,
  85783. /**
  85784. * Created when the particle dies
  85785. */
  85786. END = 1
  85787. }
  85788. /**
  85789. * Sub emitter class used to emit particles from an existing particle
  85790. */
  85791. export class SubEmitter {
  85792. /**
  85793. * the particle system to be used by the sub emitter
  85794. */
  85795. particleSystem: ParticleSystem;
  85796. /**
  85797. * Type of the submitter (Default: END)
  85798. */
  85799. type: SubEmitterType;
  85800. /**
  85801. * 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)
  85802. * Note: This only is supported when using an emitter of type Mesh
  85803. */
  85804. inheritDirection: boolean;
  85805. /**
  85806. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  85807. */
  85808. inheritedVelocityAmount: number;
  85809. /**
  85810. * Creates a sub emitter
  85811. * @param particleSystem the particle system to be used by the sub emitter
  85812. */
  85813. constructor(
  85814. /**
  85815. * the particle system to be used by the sub emitter
  85816. */
  85817. particleSystem: ParticleSystem);
  85818. /**
  85819. * Clones the sub emitter
  85820. * @returns the cloned sub emitter
  85821. */
  85822. clone(): SubEmitter;
  85823. /**
  85824. * Serialize current object to a JSON object
  85825. * @returns the serialized object
  85826. */
  85827. serialize(): any;
  85828. /** @hidden */
  85829. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  85830. /**
  85831. * Creates a new SubEmitter from a serialized JSON version
  85832. * @param serializationObject defines the JSON object to read from
  85833. * @param scene defines the hosting scene
  85834. * @param rootUrl defines the rootUrl for data loading
  85835. * @returns a new SubEmitter
  85836. */
  85837. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  85838. /** Release associated resources */
  85839. dispose(): void;
  85840. }
  85841. }
  85842. declare module BABYLON {
  85843. /** @hidden */
  85844. export var imageProcessingDeclaration: {
  85845. name: string;
  85846. shader: string;
  85847. };
  85848. }
  85849. declare module BABYLON {
  85850. /** @hidden */
  85851. export var imageProcessingFunctions: {
  85852. name: string;
  85853. shader: string;
  85854. };
  85855. }
  85856. declare module BABYLON {
  85857. /** @hidden */
  85858. export var particlesPixelShader: {
  85859. name: string;
  85860. shader: string;
  85861. };
  85862. }
  85863. declare module BABYLON {
  85864. /** @hidden */
  85865. export var particlesVertexShader: {
  85866. name: string;
  85867. shader: string;
  85868. };
  85869. }
  85870. declare module BABYLON {
  85871. /**
  85872. * This represents a particle system in Babylon.
  85873. * 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.
  85874. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  85875. * @example https://doc.babylonjs.com/babylon101/particles
  85876. */
  85877. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  85878. /**
  85879. * Billboard mode will only apply to Y axis
  85880. */
  85881. static readonly BILLBOARDMODE_Y: number;
  85882. /**
  85883. * Billboard mode will apply to all axes
  85884. */
  85885. static readonly BILLBOARDMODE_ALL: number;
  85886. /**
  85887. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  85888. */
  85889. static readonly BILLBOARDMODE_STRETCHED: number;
  85890. /**
  85891. * This function can be defined to provide custom update for active particles.
  85892. * This function will be called instead of regular update (age, position, color, etc.).
  85893. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  85894. */
  85895. updateFunction: (particles: Particle[]) => void;
  85896. private _emitterWorldMatrix;
  85897. /**
  85898. * This function can be defined to specify initial direction for every new particle.
  85899. * It by default use the emitterType defined function
  85900. */
  85901. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  85902. /**
  85903. * This function can be defined to specify initial position for every new particle.
  85904. * It by default use the emitterType defined function
  85905. */
  85906. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  85907. /**
  85908. * @hidden
  85909. */
  85910. _inheritedVelocityOffset: Vector3;
  85911. /**
  85912. * An event triggered when the system is disposed
  85913. */
  85914. onDisposeObservable: Observable<ParticleSystem>;
  85915. private _onDisposeObserver;
  85916. /**
  85917. * Sets a callback that will be triggered when the system is disposed
  85918. */
  85919. set onDispose(callback: () => void);
  85920. private _particles;
  85921. private _epsilon;
  85922. private _capacity;
  85923. private _stockParticles;
  85924. private _newPartsExcess;
  85925. private _vertexData;
  85926. private _vertexBuffer;
  85927. private _vertexBuffers;
  85928. private _spriteBuffer;
  85929. private _indexBuffer;
  85930. private _effect;
  85931. private _customEffect;
  85932. private _cachedDefines;
  85933. private _scaledColorStep;
  85934. private _colorDiff;
  85935. private _scaledDirection;
  85936. private _scaledGravity;
  85937. private _currentRenderId;
  85938. private _alive;
  85939. private _useInstancing;
  85940. private _started;
  85941. private _stopped;
  85942. private _actualFrame;
  85943. private _scaledUpdateSpeed;
  85944. private _vertexBufferSize;
  85945. /** @hidden */
  85946. _currentEmitRateGradient: Nullable<FactorGradient>;
  85947. /** @hidden */
  85948. _currentEmitRate1: number;
  85949. /** @hidden */
  85950. _currentEmitRate2: number;
  85951. /** @hidden */
  85952. _currentStartSizeGradient: Nullable<FactorGradient>;
  85953. /** @hidden */
  85954. _currentStartSize1: number;
  85955. /** @hidden */
  85956. _currentStartSize2: number;
  85957. private readonly _rawTextureWidth;
  85958. private _rampGradientsTexture;
  85959. private _useRampGradients;
  85960. /** Gets or sets a boolean indicating that ramp gradients must be used
  85961. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  85962. */
  85963. get useRampGradients(): boolean;
  85964. set useRampGradients(value: boolean);
  85965. /**
  85966. * 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.
  85967. * 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: [])
  85968. */
  85969. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  85970. private _subEmitters;
  85971. /**
  85972. * @hidden
  85973. * If the particle systems emitter should be disposed when the particle system is disposed
  85974. */
  85975. _disposeEmitterOnDispose: boolean;
  85976. /**
  85977. * The current active Sub-systems, this property is used by the root particle system only.
  85978. */
  85979. activeSubSystems: Array<ParticleSystem>;
  85980. /**
  85981. * Specifies if the particles are updated in emitter local space or world space
  85982. */
  85983. isLocal: boolean;
  85984. private _rootParticleSystem;
  85985. /**
  85986. * Gets the current list of active particles
  85987. */
  85988. get particles(): Particle[];
  85989. /**
  85990. * Gets the number of particles active at the same time.
  85991. * @returns The number of active particles.
  85992. */
  85993. getActiveCount(): number;
  85994. /**
  85995. * Returns the string "ParticleSystem"
  85996. * @returns a string containing the class name
  85997. */
  85998. getClassName(): string;
  85999. /**
  86000. * Gets a boolean indicating that the system is stopping
  86001. * @returns true if the system is currently stopping
  86002. */
  86003. isStopping(): boolean;
  86004. /**
  86005. * Instantiates a particle system.
  86006. * 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.
  86007. * @param name The name of the particle system
  86008. * @param capacity The max number of particles alive at the same time
  86009. * @param scene The scene the particle system belongs to
  86010. * @param customEffect a custom effect used to change the way particles are rendered by default
  86011. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  86012. * @param epsilon Offset used to render the particles
  86013. */
  86014. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  86015. private _addFactorGradient;
  86016. private _removeFactorGradient;
  86017. /**
  86018. * Adds a new life time gradient
  86019. * @param gradient defines the gradient to use (between 0 and 1)
  86020. * @param factor defines the life time factor to affect to the specified gradient
  86021. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86022. * @returns the current particle system
  86023. */
  86024. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86025. /**
  86026. * Remove a specific life time gradient
  86027. * @param gradient defines the gradient to remove
  86028. * @returns the current particle system
  86029. */
  86030. removeLifeTimeGradient(gradient: number): IParticleSystem;
  86031. /**
  86032. * Adds a new size gradient
  86033. * @param gradient defines the gradient to use (between 0 and 1)
  86034. * @param factor defines the size 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. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86039. /**
  86040. * Remove a specific size gradient
  86041. * @param gradient defines the gradient to remove
  86042. * @returns the current particle system
  86043. */
  86044. removeSizeGradient(gradient: number): IParticleSystem;
  86045. /**
  86046. * Adds a new color remap gradient
  86047. * @param gradient defines the gradient to use (between 0 and 1)
  86048. * @param min defines the color remap minimal range
  86049. * @param max defines the color remap maximal range
  86050. * @returns the current particle system
  86051. */
  86052. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  86053. /**
  86054. * Remove a specific color remap gradient
  86055. * @param gradient defines the gradient to remove
  86056. * @returns the current particle system
  86057. */
  86058. removeColorRemapGradient(gradient: number): IParticleSystem;
  86059. /**
  86060. * Adds a new alpha remap gradient
  86061. * @param gradient defines the gradient to use (between 0 and 1)
  86062. * @param min defines the alpha remap minimal range
  86063. * @param max defines the alpha remap maximal range
  86064. * @returns the current particle system
  86065. */
  86066. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  86067. /**
  86068. * Remove a specific alpha remap gradient
  86069. * @param gradient defines the gradient to remove
  86070. * @returns the current particle system
  86071. */
  86072. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  86073. /**
  86074. * Adds a new angular speed gradient
  86075. * @param gradient defines the gradient to use (between 0 and 1)
  86076. * @param factor defines the angular speed to affect to the specified gradient
  86077. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86078. * @returns the current particle system
  86079. */
  86080. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86081. /**
  86082. * Remove a specific angular speed gradient
  86083. * @param gradient defines the gradient to remove
  86084. * @returns the current particle system
  86085. */
  86086. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  86087. /**
  86088. * Adds a new velocity gradient
  86089. * @param gradient defines the gradient to use (between 0 and 1)
  86090. * @param factor defines the velocity 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. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86095. /**
  86096. * Remove a specific velocity gradient
  86097. * @param gradient defines the gradient to remove
  86098. * @returns the current particle system
  86099. */
  86100. removeVelocityGradient(gradient: number): IParticleSystem;
  86101. /**
  86102. * Adds a new limit velocity gradient
  86103. * @param gradient defines the gradient to use (between 0 and 1)
  86104. * @param factor defines the limit velocity value 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. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86109. /**
  86110. * Remove a specific limit velocity gradient
  86111. * @param gradient defines the gradient to remove
  86112. * @returns the current particle system
  86113. */
  86114. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  86115. /**
  86116. * Adds a new drag gradient
  86117. * @param gradient defines the gradient to use (between 0 and 1)
  86118. * @param factor defines the drag 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. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86123. /**
  86124. * Remove a specific drag gradient
  86125. * @param gradient defines the gradient to remove
  86126. * @returns the current particle system
  86127. */
  86128. removeDragGradient(gradient: number): IParticleSystem;
  86129. /**
  86130. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  86131. * @param gradient defines the gradient to use (between 0 and 1)
  86132. * @param factor defines the emit rate 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. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86137. /**
  86138. * Remove a specific emit rate gradient
  86139. * @param gradient defines the gradient to remove
  86140. * @returns the current particle system
  86141. */
  86142. removeEmitRateGradient(gradient: number): IParticleSystem;
  86143. /**
  86144. * Adds a new start size 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 start size 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. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86151. /**
  86152. * Remove a specific start size gradient
  86153. * @param gradient defines the gradient to remove
  86154. * @returns the current particle system
  86155. */
  86156. removeStartSizeGradient(gradient: number): IParticleSystem;
  86157. private _createRampGradientTexture;
  86158. /**
  86159. * Gets the current list of ramp gradients.
  86160. * You must use addRampGradient and removeRampGradient to udpate this list
  86161. * @returns the list of ramp gradients
  86162. */
  86163. getRampGradients(): Nullable<Array<Color3Gradient>>;
  86164. /** Force the system to rebuild all gradients that need to be resync */
  86165. forceRefreshGradients(): void;
  86166. private _syncRampGradientTexture;
  86167. /**
  86168. * Adds a new ramp gradient used to remap particle colors
  86169. * @param gradient defines the gradient to use (between 0 and 1)
  86170. * @param color defines the color to affect to the specified gradient
  86171. * @returns the current particle system
  86172. */
  86173. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  86174. /**
  86175. * Remove a specific ramp gradient
  86176. * @param gradient defines the gradient to remove
  86177. * @returns the current particle system
  86178. */
  86179. removeRampGradient(gradient: number): ParticleSystem;
  86180. /**
  86181. * Adds a new color gradient
  86182. * @param gradient defines the gradient to use (between 0 and 1)
  86183. * @param color1 defines the color to affect to the specified gradient
  86184. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  86185. * @returns this particle system
  86186. */
  86187. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  86188. /**
  86189. * Remove a specific color gradient
  86190. * @param gradient defines the gradient to remove
  86191. * @returns this particle system
  86192. */
  86193. removeColorGradient(gradient: number): IParticleSystem;
  86194. private _fetchR;
  86195. protected _reset(): void;
  86196. private _resetEffect;
  86197. private _createVertexBuffers;
  86198. private _createIndexBuffer;
  86199. /**
  86200. * Gets the maximum number of particles active at the same time.
  86201. * @returns The max number of active particles.
  86202. */
  86203. getCapacity(): number;
  86204. /**
  86205. * Gets whether there are still active particles in the system.
  86206. * @returns True if it is alive, otherwise false.
  86207. */
  86208. isAlive(): boolean;
  86209. /**
  86210. * Gets if the system has been started. (Note: this will still be true after stop is called)
  86211. * @returns True if it has been started, otherwise false.
  86212. */
  86213. isStarted(): boolean;
  86214. private _prepareSubEmitterInternalArray;
  86215. /**
  86216. * Starts the particle system and begins to emit
  86217. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  86218. */
  86219. start(delay?: number): void;
  86220. /**
  86221. * Stops the particle system.
  86222. * @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.
  86223. */
  86224. stop(stopSubEmitters?: boolean): void;
  86225. /**
  86226. * Remove all active particles
  86227. */
  86228. reset(): void;
  86229. /**
  86230. * @hidden (for internal use only)
  86231. */
  86232. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  86233. /**
  86234. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  86235. * Its lifetime will start back at 0.
  86236. */
  86237. recycleParticle: (particle: Particle) => void;
  86238. private _stopSubEmitters;
  86239. private _createParticle;
  86240. private _removeFromRoot;
  86241. private _emitFromParticle;
  86242. private _update;
  86243. /** @hidden */
  86244. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  86245. /** @hidden */
  86246. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  86247. /** @hidden */
  86248. private _getEffect;
  86249. /**
  86250. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  86251. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  86252. */
  86253. animate(preWarmOnly?: boolean): void;
  86254. private _appendParticleVertices;
  86255. /**
  86256. * Rebuilds the particle system.
  86257. */
  86258. rebuild(): void;
  86259. /**
  86260. * Is this system ready to be used/rendered
  86261. * @return true if the system is ready
  86262. */
  86263. isReady(): boolean;
  86264. private _render;
  86265. /**
  86266. * Renders the particle system in its current state.
  86267. * @returns the current number of particles
  86268. */
  86269. render(): number;
  86270. /**
  86271. * Disposes the particle system and free the associated resources
  86272. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  86273. */
  86274. dispose(disposeTexture?: boolean): void;
  86275. /**
  86276. * Clones the particle system.
  86277. * @param name The name of the cloned object
  86278. * @param newEmitter The new emitter to use
  86279. * @returns the cloned particle system
  86280. */
  86281. clone(name: string, newEmitter: any): ParticleSystem;
  86282. /**
  86283. * Serializes the particle system to a JSON object
  86284. * @param serializeTexture defines if the texture must be serialized as well
  86285. * @returns the JSON object
  86286. */
  86287. serialize(serializeTexture?: boolean): any;
  86288. /** @hidden */
  86289. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  86290. /** @hidden */
  86291. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  86292. /**
  86293. * Parses a JSON object to create a particle system.
  86294. * @param parsedParticleSystem The JSON object to parse
  86295. * @param scene The scene to create the particle system in
  86296. * @param rootUrl The root url to use to load external dependencies like texture
  86297. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  86298. * @returns the Parsed particle system
  86299. */
  86300. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  86301. }
  86302. }
  86303. declare module BABYLON {
  86304. /**
  86305. * A particle represents one of the element emitted by a particle system.
  86306. * This is mainly define by its coordinates, direction, velocity and age.
  86307. */
  86308. export class Particle {
  86309. /**
  86310. * The particle system the particle belongs to.
  86311. */
  86312. particleSystem: ParticleSystem;
  86313. private static _Count;
  86314. /**
  86315. * Unique ID of the particle
  86316. */
  86317. id: number;
  86318. /**
  86319. * The world position of the particle in the scene.
  86320. */
  86321. position: Vector3;
  86322. /**
  86323. * The world direction of the particle in the scene.
  86324. */
  86325. direction: Vector3;
  86326. /**
  86327. * The color of the particle.
  86328. */
  86329. color: Color4;
  86330. /**
  86331. * The color change of the particle per step.
  86332. */
  86333. colorStep: Color4;
  86334. /**
  86335. * Defines how long will the life of the particle be.
  86336. */
  86337. lifeTime: number;
  86338. /**
  86339. * The current age of the particle.
  86340. */
  86341. age: number;
  86342. /**
  86343. * The current size of the particle.
  86344. */
  86345. size: number;
  86346. /**
  86347. * The current scale of the particle.
  86348. */
  86349. scale: Vector2;
  86350. /**
  86351. * The current angle of the particle.
  86352. */
  86353. angle: number;
  86354. /**
  86355. * Defines how fast is the angle changing.
  86356. */
  86357. angularSpeed: number;
  86358. /**
  86359. * Defines the cell index used by the particle to be rendered from a sprite.
  86360. */
  86361. cellIndex: number;
  86362. /**
  86363. * The information required to support color remapping
  86364. */
  86365. remapData: Vector4;
  86366. /** @hidden */
  86367. _randomCellOffset?: number;
  86368. /** @hidden */
  86369. _initialDirection: Nullable<Vector3>;
  86370. /** @hidden */
  86371. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  86372. /** @hidden */
  86373. _initialStartSpriteCellID: number;
  86374. /** @hidden */
  86375. _initialEndSpriteCellID: number;
  86376. /** @hidden */
  86377. _currentColorGradient: Nullable<ColorGradient>;
  86378. /** @hidden */
  86379. _currentColor1: Color4;
  86380. /** @hidden */
  86381. _currentColor2: Color4;
  86382. /** @hidden */
  86383. _currentSizeGradient: Nullable<FactorGradient>;
  86384. /** @hidden */
  86385. _currentSize1: number;
  86386. /** @hidden */
  86387. _currentSize2: number;
  86388. /** @hidden */
  86389. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  86390. /** @hidden */
  86391. _currentAngularSpeed1: number;
  86392. /** @hidden */
  86393. _currentAngularSpeed2: number;
  86394. /** @hidden */
  86395. _currentVelocityGradient: Nullable<FactorGradient>;
  86396. /** @hidden */
  86397. _currentVelocity1: number;
  86398. /** @hidden */
  86399. _currentVelocity2: number;
  86400. /** @hidden */
  86401. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  86402. /** @hidden */
  86403. _currentLimitVelocity1: number;
  86404. /** @hidden */
  86405. _currentLimitVelocity2: number;
  86406. /** @hidden */
  86407. _currentDragGradient: Nullable<FactorGradient>;
  86408. /** @hidden */
  86409. _currentDrag1: number;
  86410. /** @hidden */
  86411. _currentDrag2: number;
  86412. /** @hidden */
  86413. _randomNoiseCoordinates1: Vector3;
  86414. /** @hidden */
  86415. _randomNoiseCoordinates2: Vector3;
  86416. /** @hidden */
  86417. _localPosition?: Vector3;
  86418. /**
  86419. * Creates a new instance Particle
  86420. * @param particleSystem the particle system the particle belongs to
  86421. */
  86422. constructor(
  86423. /**
  86424. * The particle system the particle belongs to.
  86425. */
  86426. particleSystem: ParticleSystem);
  86427. private updateCellInfoFromSystem;
  86428. /**
  86429. * Defines how the sprite cell index is updated for the particle
  86430. */
  86431. updateCellIndex(): void;
  86432. /** @hidden */
  86433. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  86434. /** @hidden */
  86435. _inheritParticleInfoToSubEmitters(): void;
  86436. /** @hidden */
  86437. _reset(): void;
  86438. /**
  86439. * Copy the properties of particle to another one.
  86440. * @param other the particle to copy the information to.
  86441. */
  86442. copyTo(other: Particle): void;
  86443. }
  86444. }
  86445. declare module BABYLON {
  86446. /**
  86447. * Particle emitter represents a volume emitting particles.
  86448. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  86449. */
  86450. export interface IParticleEmitterType {
  86451. /**
  86452. * Called by the particle System when the direction is computed for the created particle.
  86453. * @param worldMatrix is the world matrix of the particle system
  86454. * @param directionToUpdate is the direction vector to update with the result
  86455. * @param particle is the particle we are computed the direction for
  86456. * @param isLocal defines if the direction should be set in local space
  86457. */
  86458. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  86459. /**
  86460. * Called by the particle System when the position is computed for the created particle.
  86461. * @param worldMatrix is the world matrix of the particle system
  86462. * @param positionToUpdate is the position vector to update with the result
  86463. * @param particle is the particle we are computed the position for
  86464. * @param isLocal defines if the position should be set in local space
  86465. */
  86466. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  86467. /**
  86468. * Clones the current emitter and returns a copy of it
  86469. * @returns the new emitter
  86470. */
  86471. clone(): IParticleEmitterType;
  86472. /**
  86473. * Called by the GPUParticleSystem to setup the update shader
  86474. * @param effect defines the update shader
  86475. */
  86476. applyToShader(effect: Effect): void;
  86477. /**
  86478. * Returns a string to use to update the GPU particles update shader
  86479. * @returns the effect defines string
  86480. */
  86481. getEffectDefines(): string;
  86482. /**
  86483. * Returns a string representing the class name
  86484. * @returns a string containing the class name
  86485. */
  86486. getClassName(): string;
  86487. /**
  86488. * Serializes the particle system to a JSON object.
  86489. * @returns the JSON object
  86490. */
  86491. serialize(): any;
  86492. /**
  86493. * Parse properties from a JSON object
  86494. * @param serializationObject defines the JSON object
  86495. * @param scene defines the hosting scene
  86496. */
  86497. parse(serializationObject: any, scene: Scene): void;
  86498. }
  86499. }
  86500. declare module BABYLON {
  86501. /**
  86502. * Particle emitter emitting particles from the inside of a box.
  86503. * It emits the particles randomly between 2 given directions.
  86504. */
  86505. export class BoxParticleEmitter implements IParticleEmitterType {
  86506. /**
  86507. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  86508. */
  86509. direction1: Vector3;
  86510. /**
  86511. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  86512. */
  86513. direction2: Vector3;
  86514. /**
  86515. * 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.
  86516. */
  86517. minEmitBox: Vector3;
  86518. /**
  86519. * 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.
  86520. */
  86521. maxEmitBox: Vector3;
  86522. /**
  86523. * Creates a new instance BoxParticleEmitter
  86524. */
  86525. constructor();
  86526. /**
  86527. * Called by the particle System when the direction is computed for the created particle.
  86528. * @param worldMatrix is the world matrix of the particle system
  86529. * @param directionToUpdate is the direction vector to update with the result
  86530. * @param particle is the particle we are computed the direction for
  86531. * @param isLocal defines if the direction should be set in local space
  86532. */
  86533. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  86534. /**
  86535. * Called by the particle System when the position is computed for the created particle.
  86536. * @param worldMatrix is the world matrix of the particle system
  86537. * @param positionToUpdate is the position vector to update with the result
  86538. * @param particle is the particle we are computed the position for
  86539. * @param isLocal defines if the position should be set in local space
  86540. */
  86541. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  86542. /**
  86543. * Clones the current emitter and returns a copy of it
  86544. * @returns the new emitter
  86545. */
  86546. clone(): BoxParticleEmitter;
  86547. /**
  86548. * Called by the GPUParticleSystem to setup the update shader
  86549. * @param effect defines the update shader
  86550. */
  86551. applyToShader(effect: Effect): void;
  86552. /**
  86553. * Returns a string to use to update the GPU particles update shader
  86554. * @returns a string containng the defines string
  86555. */
  86556. getEffectDefines(): string;
  86557. /**
  86558. * Returns the string "BoxParticleEmitter"
  86559. * @returns a string containing the class name
  86560. */
  86561. getClassName(): string;
  86562. /**
  86563. * Serializes the particle system to a JSON object.
  86564. * @returns the JSON object
  86565. */
  86566. serialize(): any;
  86567. /**
  86568. * Parse properties from a JSON object
  86569. * @param serializationObject defines the JSON object
  86570. */
  86571. parse(serializationObject: any): void;
  86572. }
  86573. }
  86574. declare module BABYLON {
  86575. /**
  86576. * Particle emitter emitting particles from the inside of a cone.
  86577. * It emits the particles alongside the cone volume from the base to the particle.
  86578. * The emission direction might be randomized.
  86579. */
  86580. export class ConeParticleEmitter implements IParticleEmitterType {
  86581. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  86582. directionRandomizer: number;
  86583. private _radius;
  86584. private _angle;
  86585. private _height;
  86586. /**
  86587. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  86588. */
  86589. radiusRange: number;
  86590. /**
  86591. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  86592. */
  86593. heightRange: number;
  86594. /**
  86595. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  86596. */
  86597. emitFromSpawnPointOnly: boolean;
  86598. /**
  86599. * Gets or sets the radius of the emission cone
  86600. */
  86601. get radius(): number;
  86602. set radius(value: number);
  86603. /**
  86604. * Gets or sets the angle of the emission cone
  86605. */
  86606. get angle(): number;
  86607. set angle(value: number);
  86608. private _buildHeight;
  86609. /**
  86610. * Creates a new instance ConeParticleEmitter
  86611. * @param radius the radius of the emission cone (1 by default)
  86612. * @param angle the cone base angle (PI by default)
  86613. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  86614. */
  86615. constructor(radius?: number, angle?: number,
  86616. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  86617. directionRandomizer?: number);
  86618. /**
  86619. * Called by the particle System when the direction is computed for the created particle.
  86620. * @param worldMatrix is the world matrix of the particle system
  86621. * @param directionToUpdate is the direction vector to update with the result
  86622. * @param particle is the particle we are computed the direction for
  86623. * @param isLocal defines if the direction should be set in local space
  86624. */
  86625. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  86626. /**
  86627. * Called by the particle System when the position is computed for the created particle.
  86628. * @param worldMatrix is the world matrix of the particle system
  86629. * @param positionToUpdate is the position vector to update with the result
  86630. * @param particle is the particle we are computed the position for
  86631. * @param isLocal defines if the position should be set in local space
  86632. */
  86633. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  86634. /**
  86635. * Clones the current emitter and returns a copy of it
  86636. * @returns the new emitter
  86637. */
  86638. clone(): ConeParticleEmitter;
  86639. /**
  86640. * Called by the GPUParticleSystem to setup the update shader
  86641. * @param effect defines the update shader
  86642. */
  86643. applyToShader(effect: Effect): void;
  86644. /**
  86645. * Returns a string to use to update the GPU particles update shader
  86646. * @returns a string containng the defines string
  86647. */
  86648. getEffectDefines(): string;
  86649. /**
  86650. * Returns the string "ConeParticleEmitter"
  86651. * @returns a string containing the class name
  86652. */
  86653. getClassName(): string;
  86654. /**
  86655. * Serializes the particle system to a JSON object.
  86656. * @returns the JSON object
  86657. */
  86658. serialize(): any;
  86659. /**
  86660. * Parse properties from a JSON object
  86661. * @param serializationObject defines the JSON object
  86662. */
  86663. parse(serializationObject: any): void;
  86664. }
  86665. }
  86666. declare module BABYLON {
  86667. /**
  86668. * Particle emitter emitting particles from the inside of a cylinder.
  86669. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  86670. */
  86671. export class CylinderParticleEmitter implements IParticleEmitterType {
  86672. /**
  86673. * The radius of the emission cylinder.
  86674. */
  86675. radius: number;
  86676. /**
  86677. * The height of the emission cylinder.
  86678. */
  86679. height: number;
  86680. /**
  86681. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  86682. */
  86683. radiusRange: number;
  86684. /**
  86685. * How much to randomize the particle direction [0-1].
  86686. */
  86687. directionRandomizer: number;
  86688. /**
  86689. * Creates a new instance CylinderParticleEmitter
  86690. * @param radius the radius of the emission cylinder (1 by default)
  86691. * @param height the height of the emission cylinder (1 by default)
  86692. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  86693. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  86694. */
  86695. constructor(
  86696. /**
  86697. * The radius of the emission cylinder.
  86698. */
  86699. radius?: number,
  86700. /**
  86701. * The height of the emission cylinder.
  86702. */
  86703. height?: number,
  86704. /**
  86705. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  86706. */
  86707. radiusRange?: number,
  86708. /**
  86709. * How much to randomize the particle direction [0-1].
  86710. */
  86711. directionRandomizer?: number);
  86712. /**
  86713. * Called by the particle System when the direction is computed for the created particle.
  86714. * @param worldMatrix is the world matrix of the particle system
  86715. * @param directionToUpdate is the direction vector to update with the result
  86716. * @param particle is the particle we are computed the direction for
  86717. * @param isLocal defines if the direction should be set in local space
  86718. */
  86719. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  86720. /**
  86721. * Called by the particle System when the position is computed for the created particle.
  86722. * @param worldMatrix is the world matrix of the particle system
  86723. * @param positionToUpdate is the position vector to update with the result
  86724. * @param particle is the particle we are computed the position for
  86725. * @param isLocal defines if the position should be set in local space
  86726. */
  86727. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  86728. /**
  86729. * Clones the current emitter and returns a copy of it
  86730. * @returns the new emitter
  86731. */
  86732. clone(): CylinderParticleEmitter;
  86733. /**
  86734. * Called by the GPUParticleSystem to setup the update shader
  86735. * @param effect defines the update shader
  86736. */
  86737. applyToShader(effect: Effect): void;
  86738. /**
  86739. * Returns a string to use to update the GPU particles update shader
  86740. * @returns a string containng the defines string
  86741. */
  86742. getEffectDefines(): string;
  86743. /**
  86744. * Returns the string "CylinderParticleEmitter"
  86745. * @returns a string containing the class name
  86746. */
  86747. getClassName(): string;
  86748. /**
  86749. * Serializes the particle system to a JSON object.
  86750. * @returns the JSON object
  86751. */
  86752. serialize(): any;
  86753. /**
  86754. * Parse properties from a JSON object
  86755. * @param serializationObject defines the JSON object
  86756. */
  86757. parse(serializationObject: any): void;
  86758. }
  86759. /**
  86760. * Particle emitter emitting particles from the inside of a cylinder.
  86761. * It emits the particles randomly between two vectors.
  86762. */
  86763. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  86764. /**
  86765. * The min limit of the emission direction.
  86766. */
  86767. direction1: Vector3;
  86768. /**
  86769. * The max limit of the emission direction.
  86770. */
  86771. direction2: Vector3;
  86772. /**
  86773. * Creates a new instance CylinderDirectedParticleEmitter
  86774. * @param radius the radius of the emission cylinder (1 by default)
  86775. * @param height the height of the emission cylinder (1 by default)
  86776. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  86777. * @param direction1 the min limit of the emission direction (up vector by default)
  86778. * @param direction2 the max limit of the emission direction (up vector by default)
  86779. */
  86780. constructor(radius?: number, height?: number, radiusRange?: number,
  86781. /**
  86782. * The min limit of the emission direction.
  86783. */
  86784. direction1?: Vector3,
  86785. /**
  86786. * The max limit of the emission direction.
  86787. */
  86788. direction2?: Vector3);
  86789. /**
  86790. * Called by the particle System when the direction is computed for the created particle.
  86791. * @param worldMatrix is the world matrix of the particle system
  86792. * @param directionToUpdate is the direction vector to update with the result
  86793. * @param particle is the particle we are computed the direction for
  86794. */
  86795. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  86796. /**
  86797. * Clones the current emitter and returns a copy of it
  86798. * @returns the new emitter
  86799. */
  86800. clone(): CylinderDirectedParticleEmitter;
  86801. /**
  86802. * Called by the GPUParticleSystem to setup the update shader
  86803. * @param effect defines the update shader
  86804. */
  86805. applyToShader(effect: Effect): void;
  86806. /**
  86807. * Returns a string to use to update the GPU particles update shader
  86808. * @returns a string containng the defines string
  86809. */
  86810. getEffectDefines(): string;
  86811. /**
  86812. * Returns the string "CylinderDirectedParticleEmitter"
  86813. * @returns a string containing the class name
  86814. */
  86815. getClassName(): string;
  86816. /**
  86817. * Serializes the particle system to a JSON object.
  86818. * @returns the JSON object
  86819. */
  86820. serialize(): any;
  86821. /**
  86822. * Parse properties from a JSON object
  86823. * @param serializationObject defines the JSON object
  86824. */
  86825. parse(serializationObject: any): void;
  86826. }
  86827. }
  86828. declare module BABYLON {
  86829. /**
  86830. * Particle emitter emitting particles from the inside of a hemisphere.
  86831. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  86832. */
  86833. export class HemisphericParticleEmitter implements IParticleEmitterType {
  86834. /**
  86835. * The radius of the emission hemisphere.
  86836. */
  86837. radius: number;
  86838. /**
  86839. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  86840. */
  86841. radiusRange: number;
  86842. /**
  86843. * How much to randomize the particle direction [0-1].
  86844. */
  86845. directionRandomizer: number;
  86846. /**
  86847. * Creates a new instance HemisphericParticleEmitter
  86848. * @param radius the radius of the emission hemisphere (1 by default)
  86849. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  86850. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  86851. */
  86852. constructor(
  86853. /**
  86854. * The radius of the emission hemisphere.
  86855. */
  86856. radius?: number,
  86857. /**
  86858. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  86859. */
  86860. radiusRange?: number,
  86861. /**
  86862. * How much to randomize the particle direction [0-1].
  86863. */
  86864. directionRandomizer?: number);
  86865. /**
  86866. * Called by the particle System when the direction is computed for the created particle.
  86867. * @param worldMatrix is the world matrix of the particle system
  86868. * @param directionToUpdate is the direction vector to update with the result
  86869. * @param particle is the particle we are computed the direction for
  86870. * @param isLocal defines if the direction should be set in local space
  86871. */
  86872. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  86873. /**
  86874. * Called by the particle System when the position is computed for the created particle.
  86875. * @param worldMatrix is the world matrix of the particle system
  86876. * @param positionToUpdate is the position vector to update with the result
  86877. * @param particle is the particle we are computed the position for
  86878. * @param isLocal defines if the position should be set in local space
  86879. */
  86880. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  86881. /**
  86882. * Clones the current emitter and returns a copy of it
  86883. * @returns the new emitter
  86884. */
  86885. clone(): HemisphericParticleEmitter;
  86886. /**
  86887. * Called by the GPUParticleSystem to setup the update shader
  86888. * @param effect defines the update shader
  86889. */
  86890. applyToShader(effect: Effect): void;
  86891. /**
  86892. * Returns a string to use to update the GPU particles update shader
  86893. * @returns a string containng the defines string
  86894. */
  86895. getEffectDefines(): string;
  86896. /**
  86897. * Returns the string "HemisphericParticleEmitter"
  86898. * @returns a string containing the class name
  86899. */
  86900. getClassName(): string;
  86901. /**
  86902. * Serializes the particle system to a JSON object.
  86903. * @returns the JSON object
  86904. */
  86905. serialize(): any;
  86906. /**
  86907. * Parse properties from a JSON object
  86908. * @param serializationObject defines the JSON object
  86909. */
  86910. parse(serializationObject: any): void;
  86911. }
  86912. }
  86913. declare module BABYLON {
  86914. /**
  86915. * Particle emitter emitting particles from a point.
  86916. * It emits the particles randomly between 2 given directions.
  86917. */
  86918. export class PointParticleEmitter implements IParticleEmitterType {
  86919. /**
  86920. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  86921. */
  86922. direction1: Vector3;
  86923. /**
  86924. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  86925. */
  86926. direction2: Vector3;
  86927. /**
  86928. * Creates a new instance PointParticleEmitter
  86929. */
  86930. constructor();
  86931. /**
  86932. * Called by the particle System when the direction is computed for the created particle.
  86933. * @param worldMatrix is the world matrix of the particle system
  86934. * @param directionToUpdate is the direction vector to update with the result
  86935. * @param particle is the particle we are computed the direction for
  86936. * @param isLocal defines if the direction should be set in local space
  86937. */
  86938. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  86939. /**
  86940. * Called by the particle System when the position is computed for the created particle.
  86941. * @param worldMatrix is the world matrix of the particle system
  86942. * @param positionToUpdate is the position vector to update with the result
  86943. * @param particle is the particle we are computed the position for
  86944. * @param isLocal defines if the position should be set in local space
  86945. */
  86946. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  86947. /**
  86948. * Clones the current emitter and returns a copy of it
  86949. * @returns the new emitter
  86950. */
  86951. clone(): PointParticleEmitter;
  86952. /**
  86953. * Called by the GPUParticleSystem to setup the update shader
  86954. * @param effect defines the update shader
  86955. */
  86956. applyToShader(effect: Effect): void;
  86957. /**
  86958. * Returns a string to use to update the GPU particles update shader
  86959. * @returns a string containng the defines string
  86960. */
  86961. getEffectDefines(): string;
  86962. /**
  86963. * Returns the string "PointParticleEmitter"
  86964. * @returns a string containing the class name
  86965. */
  86966. getClassName(): string;
  86967. /**
  86968. * Serializes the particle system to a JSON object.
  86969. * @returns the JSON object
  86970. */
  86971. serialize(): any;
  86972. /**
  86973. * Parse properties from a JSON object
  86974. * @param serializationObject defines the JSON object
  86975. */
  86976. parse(serializationObject: any): void;
  86977. }
  86978. }
  86979. declare module BABYLON {
  86980. /**
  86981. * Particle emitter emitting particles from the inside of a sphere.
  86982. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  86983. */
  86984. export class SphereParticleEmitter implements IParticleEmitterType {
  86985. /**
  86986. * The radius of the emission sphere.
  86987. */
  86988. radius: number;
  86989. /**
  86990. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  86991. */
  86992. radiusRange: number;
  86993. /**
  86994. * How much to randomize the particle direction [0-1].
  86995. */
  86996. directionRandomizer: number;
  86997. /**
  86998. * Creates a new instance SphereParticleEmitter
  86999. * @param radius the radius of the emission sphere (1 by default)
  87000. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  87001. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  87002. */
  87003. constructor(
  87004. /**
  87005. * The radius of the emission sphere.
  87006. */
  87007. radius?: number,
  87008. /**
  87009. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  87010. */
  87011. radiusRange?: number,
  87012. /**
  87013. * How much to randomize the particle direction [0-1].
  87014. */
  87015. directionRandomizer?: number);
  87016. /**
  87017. * Called by the particle System when the direction is computed for the created particle.
  87018. * @param worldMatrix is the world matrix of the particle system
  87019. * @param directionToUpdate is the direction vector to update with the result
  87020. * @param particle is the particle we are computed the direction for
  87021. * @param isLocal defines if the direction should be set in local space
  87022. */
  87023. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  87024. /**
  87025. * Called by the particle System when the position is computed for the created particle.
  87026. * @param worldMatrix is the world matrix of the particle system
  87027. * @param positionToUpdate is the position vector to update with the result
  87028. * @param particle is the particle we are computed the position for
  87029. * @param isLocal defines if the position should be set in local space
  87030. */
  87031. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  87032. /**
  87033. * Clones the current emitter and returns a copy of it
  87034. * @returns the new emitter
  87035. */
  87036. clone(): SphereParticleEmitter;
  87037. /**
  87038. * Called by the GPUParticleSystem to setup the update shader
  87039. * @param effect defines the update shader
  87040. */
  87041. applyToShader(effect: Effect): void;
  87042. /**
  87043. * Returns a string to use to update the GPU particles update shader
  87044. * @returns a string containng the defines string
  87045. */
  87046. getEffectDefines(): string;
  87047. /**
  87048. * Returns the string "SphereParticleEmitter"
  87049. * @returns a string containing the class name
  87050. */
  87051. getClassName(): string;
  87052. /**
  87053. * Serializes the particle system to a JSON object.
  87054. * @returns the JSON object
  87055. */
  87056. serialize(): any;
  87057. /**
  87058. * Parse properties from a JSON object
  87059. * @param serializationObject defines the JSON object
  87060. */
  87061. parse(serializationObject: any): void;
  87062. }
  87063. /**
  87064. * Particle emitter emitting particles from the inside of a sphere.
  87065. * It emits the particles randomly between two vectors.
  87066. */
  87067. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  87068. /**
  87069. * The min limit of the emission direction.
  87070. */
  87071. direction1: Vector3;
  87072. /**
  87073. * The max limit of the emission direction.
  87074. */
  87075. direction2: Vector3;
  87076. /**
  87077. * Creates a new instance SphereDirectedParticleEmitter
  87078. * @param radius the radius of the emission sphere (1 by default)
  87079. * @param direction1 the min limit of the emission direction (up vector by default)
  87080. * @param direction2 the max limit of the emission direction (up vector by default)
  87081. */
  87082. constructor(radius?: number,
  87083. /**
  87084. * The min limit of the emission direction.
  87085. */
  87086. direction1?: Vector3,
  87087. /**
  87088. * The max limit of the emission direction.
  87089. */
  87090. direction2?: Vector3);
  87091. /**
  87092. * Called by the particle System when the direction is computed for the created particle.
  87093. * @param worldMatrix is the world matrix of the particle system
  87094. * @param directionToUpdate is the direction vector to update with the result
  87095. * @param particle is the particle we are computed the direction for
  87096. */
  87097. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  87098. /**
  87099. * Clones the current emitter and returns a copy of it
  87100. * @returns the new emitter
  87101. */
  87102. clone(): SphereDirectedParticleEmitter;
  87103. /**
  87104. * Called by the GPUParticleSystem to setup the update shader
  87105. * @param effect defines the update shader
  87106. */
  87107. applyToShader(effect: Effect): void;
  87108. /**
  87109. * Returns a string to use to update the GPU particles update shader
  87110. * @returns a string containng the defines string
  87111. */
  87112. getEffectDefines(): string;
  87113. /**
  87114. * Returns the string "SphereDirectedParticleEmitter"
  87115. * @returns a string containing the class name
  87116. */
  87117. getClassName(): string;
  87118. /**
  87119. * Serializes the particle system to a JSON object.
  87120. * @returns the JSON object
  87121. */
  87122. serialize(): any;
  87123. /**
  87124. * Parse properties from a JSON object
  87125. * @param serializationObject defines the JSON object
  87126. */
  87127. parse(serializationObject: any): void;
  87128. }
  87129. }
  87130. declare module BABYLON {
  87131. /**
  87132. * Particle emitter emitting particles from a custom list of positions.
  87133. */
  87134. export class CustomParticleEmitter implements IParticleEmitterType {
  87135. /**
  87136. * Gets or sets the position generator that will create the inital position of each particle.
  87137. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  87138. */
  87139. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  87140. /**
  87141. * Gets or sets the destination generator that will create the final destination of each particle.
  87142. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  87143. */
  87144. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  87145. /**
  87146. * Creates a new instance CustomParticleEmitter
  87147. */
  87148. constructor();
  87149. /**
  87150. * Called by the particle System when the direction is computed for the created particle.
  87151. * @param worldMatrix is the world matrix of the particle system
  87152. * @param directionToUpdate is the direction vector to update with the result
  87153. * @param particle is the particle we are computed the direction for
  87154. * @param isLocal defines if the direction should be set in local space
  87155. */
  87156. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  87157. /**
  87158. * Called by the particle System when the position is computed for the created particle.
  87159. * @param worldMatrix is the world matrix of the particle system
  87160. * @param positionToUpdate is the position vector to update with the result
  87161. * @param particle is the particle we are computed the position for
  87162. * @param isLocal defines if the position should be set in local space
  87163. */
  87164. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  87165. /**
  87166. * Clones the current emitter and returns a copy of it
  87167. * @returns the new emitter
  87168. */
  87169. clone(): CustomParticleEmitter;
  87170. /**
  87171. * Called by the GPUParticleSystem to setup the update shader
  87172. * @param effect defines the update shader
  87173. */
  87174. applyToShader(effect: Effect): void;
  87175. /**
  87176. * Returns a string to use to update the GPU particles update shader
  87177. * @returns a string containng the defines string
  87178. */
  87179. getEffectDefines(): string;
  87180. /**
  87181. * Returns the string "PointParticleEmitter"
  87182. * @returns a string containing the class name
  87183. */
  87184. getClassName(): string;
  87185. /**
  87186. * Serializes the particle system to a JSON object.
  87187. * @returns the JSON object
  87188. */
  87189. serialize(): any;
  87190. /**
  87191. * Parse properties from a JSON object
  87192. * @param serializationObject defines the JSON object
  87193. */
  87194. parse(serializationObject: any): void;
  87195. }
  87196. }
  87197. declare module BABYLON {
  87198. /**
  87199. * Particle emitter emitting particles from the inside of a box.
  87200. * It emits the particles randomly between 2 given directions.
  87201. */
  87202. export class MeshParticleEmitter implements IParticleEmitterType {
  87203. private _indices;
  87204. private _positions;
  87205. private _normals;
  87206. private _storedNormal;
  87207. private _mesh;
  87208. /**
  87209. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  87210. */
  87211. direction1: Vector3;
  87212. /**
  87213. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  87214. */
  87215. direction2: Vector3;
  87216. /**
  87217. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  87218. */
  87219. useMeshNormalsForDirection: boolean;
  87220. /** Defines the mesh to use as source */
  87221. get mesh(): Nullable<AbstractMesh>;
  87222. set mesh(value: Nullable<AbstractMesh>);
  87223. /**
  87224. * Creates a new instance MeshParticleEmitter
  87225. * @param mesh defines the mesh to use as source
  87226. */
  87227. constructor(mesh?: Nullable<AbstractMesh>);
  87228. /**
  87229. * Called by the particle System when the direction is computed for the created particle.
  87230. * @param worldMatrix is the world matrix of the particle system
  87231. * @param directionToUpdate is the direction vector to update with the result
  87232. * @param particle is the particle we are computed the direction for
  87233. * @param isLocal defines if the direction should be set in local space
  87234. */
  87235. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  87236. /**
  87237. * Called by the particle System when the position is computed for the created particle.
  87238. * @param worldMatrix is the world matrix of the particle system
  87239. * @param positionToUpdate is the position vector to update with the result
  87240. * @param particle is the particle we are computed the position for
  87241. * @param isLocal defines if the position should be set in local space
  87242. */
  87243. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  87244. /**
  87245. * Clones the current emitter and returns a copy of it
  87246. * @returns the new emitter
  87247. */
  87248. clone(): MeshParticleEmitter;
  87249. /**
  87250. * Called by the GPUParticleSystem to setup the update shader
  87251. * @param effect defines the update shader
  87252. */
  87253. applyToShader(effect: Effect): void;
  87254. /**
  87255. * Returns a string to use to update the GPU particles update shader
  87256. * @returns a string containng the defines string
  87257. */
  87258. getEffectDefines(): string;
  87259. /**
  87260. * Returns the string "BoxParticleEmitter"
  87261. * @returns a string containing the class name
  87262. */
  87263. getClassName(): string;
  87264. /**
  87265. * Serializes the particle system to a JSON object.
  87266. * @returns the JSON object
  87267. */
  87268. serialize(): any;
  87269. /**
  87270. * Parse properties from a JSON object
  87271. * @param serializationObject defines the JSON object
  87272. * @param scene defines the hosting scene
  87273. */
  87274. parse(serializationObject: any, scene: Scene): void;
  87275. }
  87276. }
  87277. declare module BABYLON {
  87278. /**
  87279. * Interface representing a particle system in Babylon.js.
  87280. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  87281. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  87282. */
  87283. export interface IParticleSystem {
  87284. /**
  87285. * List of animations used by the particle system.
  87286. */
  87287. animations: Animation[];
  87288. /**
  87289. * The id of the Particle system.
  87290. */
  87291. id: string;
  87292. /**
  87293. * The name of the Particle system.
  87294. */
  87295. name: string;
  87296. /**
  87297. * The emitter represents the Mesh or position we are attaching the particle system to.
  87298. */
  87299. emitter: Nullable<AbstractMesh | Vector3>;
  87300. /**
  87301. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  87302. */
  87303. isBillboardBased: boolean;
  87304. /**
  87305. * The rendering group used by the Particle system to chose when to render.
  87306. */
  87307. renderingGroupId: number;
  87308. /**
  87309. * The layer mask we are rendering the particles through.
  87310. */
  87311. layerMask: number;
  87312. /**
  87313. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  87314. */
  87315. updateSpeed: number;
  87316. /**
  87317. * The amount of time the particle system is running (depends of the overall update speed).
  87318. */
  87319. targetStopDuration: number;
  87320. /**
  87321. * The texture used to render each particle. (this can be a spritesheet)
  87322. */
  87323. particleTexture: Nullable<Texture>;
  87324. /**
  87325. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  87326. */
  87327. blendMode: number;
  87328. /**
  87329. * Minimum life time of emitting particles.
  87330. */
  87331. minLifeTime: number;
  87332. /**
  87333. * Maximum life time of emitting particles.
  87334. */
  87335. maxLifeTime: number;
  87336. /**
  87337. * Minimum Size of emitting particles.
  87338. */
  87339. minSize: number;
  87340. /**
  87341. * Maximum Size of emitting particles.
  87342. */
  87343. maxSize: number;
  87344. /**
  87345. * Minimum scale of emitting particles on X axis.
  87346. */
  87347. minScaleX: number;
  87348. /**
  87349. * Maximum scale of emitting particles on X axis.
  87350. */
  87351. maxScaleX: number;
  87352. /**
  87353. * Minimum scale of emitting particles on Y axis.
  87354. */
  87355. minScaleY: number;
  87356. /**
  87357. * Maximum scale of emitting particles on Y axis.
  87358. */
  87359. maxScaleY: number;
  87360. /**
  87361. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  87362. */
  87363. color1: Color4;
  87364. /**
  87365. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  87366. */
  87367. color2: Color4;
  87368. /**
  87369. * Color the particle will have at the end of its lifetime.
  87370. */
  87371. colorDead: Color4;
  87372. /**
  87373. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  87374. */
  87375. emitRate: number;
  87376. /**
  87377. * You can use gravity if you want to give an orientation to your particles.
  87378. */
  87379. gravity: Vector3;
  87380. /**
  87381. * Minimum power of emitting particles.
  87382. */
  87383. minEmitPower: number;
  87384. /**
  87385. * Maximum power of emitting particles.
  87386. */
  87387. maxEmitPower: number;
  87388. /**
  87389. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  87390. */
  87391. minAngularSpeed: number;
  87392. /**
  87393. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  87394. */
  87395. maxAngularSpeed: number;
  87396. /**
  87397. * Gets or sets the minimal initial rotation in radians.
  87398. */
  87399. minInitialRotation: number;
  87400. /**
  87401. * Gets or sets the maximal initial rotation in radians.
  87402. */
  87403. maxInitialRotation: number;
  87404. /**
  87405. * The particle emitter type defines the emitter used by the particle system.
  87406. * It can be for example box, sphere, or cone...
  87407. */
  87408. particleEmitterType: Nullable<IParticleEmitterType>;
  87409. /**
  87410. * Defines the delay in milliseconds before starting the system (0 by default)
  87411. */
  87412. startDelay: number;
  87413. /**
  87414. * 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
  87415. */
  87416. preWarmCycles: number;
  87417. /**
  87418. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  87419. */
  87420. preWarmStepOffset: number;
  87421. /**
  87422. * 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)
  87423. */
  87424. spriteCellChangeSpeed: number;
  87425. /**
  87426. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  87427. */
  87428. startSpriteCellID: number;
  87429. /**
  87430. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  87431. */
  87432. endSpriteCellID: number;
  87433. /**
  87434. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  87435. */
  87436. spriteCellWidth: number;
  87437. /**
  87438. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  87439. */
  87440. spriteCellHeight: number;
  87441. /**
  87442. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  87443. */
  87444. spriteRandomStartCell: boolean;
  87445. /**
  87446. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  87447. */
  87448. isAnimationSheetEnabled: boolean;
  87449. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  87450. translationPivot: Vector2;
  87451. /**
  87452. * Gets or sets a texture used to add random noise to particle positions
  87453. */
  87454. noiseTexture: Nullable<BaseTexture>;
  87455. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  87456. noiseStrength: Vector3;
  87457. /**
  87458. * Gets or sets the billboard mode to use when isBillboardBased = true.
  87459. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  87460. */
  87461. billboardMode: number;
  87462. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  87463. limitVelocityDamping: number;
  87464. /**
  87465. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  87466. */
  87467. beginAnimationOnStart: boolean;
  87468. /**
  87469. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  87470. */
  87471. beginAnimationFrom: number;
  87472. /**
  87473. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  87474. */
  87475. beginAnimationTo: number;
  87476. /**
  87477. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  87478. */
  87479. beginAnimationLoop: boolean;
  87480. /**
  87481. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  87482. */
  87483. disposeOnStop: boolean;
  87484. /**
  87485. * Specifies if the particles are updated in emitter local space or world space
  87486. */
  87487. isLocal: boolean;
  87488. /** Snippet ID if the particle system was created from the snippet server */
  87489. snippetId: string;
  87490. /**
  87491. * Gets the maximum number of particles active at the same time.
  87492. * @returns The max number of active particles.
  87493. */
  87494. getCapacity(): number;
  87495. /**
  87496. * Gets the number of particles active at the same time.
  87497. * @returns The number of active particles.
  87498. */
  87499. getActiveCount(): number;
  87500. /**
  87501. * Gets if the system has been started. (Note: this will still be true after stop is called)
  87502. * @returns True if it has been started, otherwise false.
  87503. */
  87504. isStarted(): boolean;
  87505. /**
  87506. * Animates the particle system for this frame.
  87507. */
  87508. animate(): void;
  87509. /**
  87510. * Renders the particle system in its current state.
  87511. * @returns the current number of particles
  87512. */
  87513. render(): number;
  87514. /**
  87515. * Dispose the particle system and frees its associated resources.
  87516. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  87517. */
  87518. dispose(disposeTexture?: boolean): void;
  87519. /**
  87520. * Clones the particle system.
  87521. * @param name The name of the cloned object
  87522. * @param newEmitter The new emitter to use
  87523. * @returns the cloned particle system
  87524. */
  87525. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  87526. /**
  87527. * Serializes the particle system to a JSON object
  87528. * @param serializeTexture defines if the texture must be serialized as well
  87529. * @returns the JSON object
  87530. */
  87531. serialize(serializeTexture: boolean): any;
  87532. /**
  87533. * Rebuild the particle system
  87534. */
  87535. rebuild(): void;
  87536. /** Force the system to rebuild all gradients that need to be resync */
  87537. forceRefreshGradients(): void;
  87538. /**
  87539. * Starts the particle system and begins to emit
  87540. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  87541. */
  87542. start(delay?: number): void;
  87543. /**
  87544. * Stops the particle system.
  87545. */
  87546. stop(): void;
  87547. /**
  87548. * Remove all active particles
  87549. */
  87550. reset(): void;
  87551. /**
  87552. * Gets a boolean indicating that the system is stopping
  87553. * @returns true if the system is currently stopping
  87554. */
  87555. isStopping(): boolean;
  87556. /**
  87557. * Is this system ready to be used/rendered
  87558. * @return true if the system is ready
  87559. */
  87560. isReady(): boolean;
  87561. /**
  87562. * Returns the string "ParticleSystem"
  87563. * @returns a string containing the class name
  87564. */
  87565. getClassName(): string;
  87566. /**
  87567. * Adds a new color gradient
  87568. * @param gradient defines the gradient to use (between 0 and 1)
  87569. * @param color1 defines the color to affect to the specified gradient
  87570. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  87571. * @returns the current particle system
  87572. */
  87573. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  87574. /**
  87575. * Remove a specific color gradient
  87576. * @param gradient defines the gradient to remove
  87577. * @returns the current particle system
  87578. */
  87579. removeColorGradient(gradient: number): IParticleSystem;
  87580. /**
  87581. * Adds a new size gradient
  87582. * @param gradient defines the gradient to use (between 0 and 1)
  87583. * @param factor defines the size factor to affect to the specified gradient
  87584. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87585. * @returns the current particle system
  87586. */
  87587. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87588. /**
  87589. * Remove a specific size gradient
  87590. * @param gradient defines the gradient to remove
  87591. * @returns the current particle system
  87592. */
  87593. removeSizeGradient(gradient: number): IParticleSystem;
  87594. /**
  87595. * Gets the current list of color gradients.
  87596. * You must use addColorGradient and removeColorGradient to udpate this list
  87597. * @returns the list of color gradients
  87598. */
  87599. getColorGradients(): Nullable<Array<ColorGradient>>;
  87600. /**
  87601. * Gets the current list of size gradients.
  87602. * You must use addSizeGradient and removeSizeGradient to udpate this list
  87603. * @returns the list of size gradients
  87604. */
  87605. getSizeGradients(): Nullable<Array<FactorGradient>>;
  87606. /**
  87607. * Gets the current list of angular speed gradients.
  87608. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  87609. * @returns the list of angular speed gradients
  87610. */
  87611. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  87612. /**
  87613. * Adds a new angular speed gradient
  87614. * @param gradient defines the gradient to use (between 0 and 1)
  87615. * @param factor defines the angular speed to affect to the specified gradient
  87616. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87617. * @returns the current particle system
  87618. */
  87619. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87620. /**
  87621. * Remove a specific angular speed gradient
  87622. * @param gradient defines the gradient to remove
  87623. * @returns the current particle system
  87624. */
  87625. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  87626. /**
  87627. * Gets the current list of velocity gradients.
  87628. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  87629. * @returns the list of velocity gradients
  87630. */
  87631. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  87632. /**
  87633. * Adds a new velocity gradient
  87634. * @param gradient defines the gradient to use (between 0 and 1)
  87635. * @param factor defines the velocity to affect to the specified gradient
  87636. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87637. * @returns the current particle system
  87638. */
  87639. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87640. /**
  87641. * Remove a specific velocity gradient
  87642. * @param gradient defines the gradient to remove
  87643. * @returns the current particle system
  87644. */
  87645. removeVelocityGradient(gradient: number): IParticleSystem;
  87646. /**
  87647. * Gets the current list of limit velocity gradients.
  87648. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  87649. * @returns the list of limit velocity gradients
  87650. */
  87651. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  87652. /**
  87653. * Adds a new limit velocity gradient
  87654. * @param gradient defines the gradient to use (between 0 and 1)
  87655. * @param factor defines the limit velocity to affect to the specified gradient
  87656. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87657. * @returns the current particle system
  87658. */
  87659. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87660. /**
  87661. * Remove a specific limit velocity gradient
  87662. * @param gradient defines the gradient to remove
  87663. * @returns the current particle system
  87664. */
  87665. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  87666. /**
  87667. * Adds a new drag gradient
  87668. * @param gradient defines the gradient to use (between 0 and 1)
  87669. * @param factor defines the drag 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. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87674. /**
  87675. * Remove a specific drag gradient
  87676. * @param gradient defines the gradient to remove
  87677. * @returns the current particle system
  87678. */
  87679. removeDragGradient(gradient: number): IParticleSystem;
  87680. /**
  87681. * Gets the current list of drag gradients.
  87682. * You must use addDragGradient and removeDragGradient to udpate this list
  87683. * @returns the list of drag gradients
  87684. */
  87685. getDragGradients(): Nullable<Array<FactorGradient>>;
  87686. /**
  87687. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  87688. * @param gradient defines the gradient to use (between 0 and 1)
  87689. * @param factor defines the emit rate to affect to the specified gradient
  87690. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87691. * @returns the current particle system
  87692. */
  87693. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87694. /**
  87695. * Remove a specific emit rate gradient
  87696. * @param gradient defines the gradient to remove
  87697. * @returns the current particle system
  87698. */
  87699. removeEmitRateGradient(gradient: number): IParticleSystem;
  87700. /**
  87701. * Gets the current list of emit rate gradients.
  87702. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  87703. * @returns the list of emit rate gradients
  87704. */
  87705. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  87706. /**
  87707. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  87708. * @param gradient defines the gradient to use (between 0 and 1)
  87709. * @param factor defines the start size to affect to the specified gradient
  87710. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87711. * @returns the current particle system
  87712. */
  87713. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87714. /**
  87715. * Remove a specific start size gradient
  87716. * @param gradient defines the gradient to remove
  87717. * @returns the current particle system
  87718. */
  87719. removeStartSizeGradient(gradient: number): IParticleSystem;
  87720. /**
  87721. * Gets the current list of start size gradients.
  87722. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  87723. * @returns the list of start size gradients
  87724. */
  87725. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  87726. /**
  87727. * Adds a new life time gradient
  87728. * @param gradient defines the gradient to use (between 0 and 1)
  87729. * @param factor defines the life time factor to affect to the specified gradient
  87730. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87731. * @returns the current particle system
  87732. */
  87733. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87734. /**
  87735. * Remove a specific life time gradient
  87736. * @param gradient defines the gradient to remove
  87737. * @returns the current particle system
  87738. */
  87739. removeLifeTimeGradient(gradient: number): IParticleSystem;
  87740. /**
  87741. * Gets the current list of life time gradients.
  87742. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  87743. * @returns the list of life time gradients
  87744. */
  87745. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  87746. /**
  87747. * Gets the current list of color gradients.
  87748. * You must use addColorGradient and removeColorGradient to udpate this list
  87749. * @returns the list of color gradients
  87750. */
  87751. getColorGradients(): Nullable<Array<ColorGradient>>;
  87752. /**
  87753. * Adds a new ramp gradient used to remap particle colors
  87754. * @param gradient defines the gradient to use (between 0 and 1)
  87755. * @param color defines the color to affect to the specified gradient
  87756. * @returns the current particle system
  87757. */
  87758. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  87759. /**
  87760. * Gets the current list of ramp gradients.
  87761. * You must use addRampGradient and removeRampGradient to udpate this list
  87762. * @returns the list of ramp gradients
  87763. */
  87764. getRampGradients(): Nullable<Array<Color3Gradient>>;
  87765. /** Gets or sets a boolean indicating that ramp gradients must be used
  87766. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  87767. */
  87768. useRampGradients: boolean;
  87769. /**
  87770. * Adds a new color remap gradient
  87771. * @param gradient defines the gradient to use (between 0 and 1)
  87772. * @param min defines the color remap minimal range
  87773. * @param max defines the color remap maximal range
  87774. * @returns the current particle system
  87775. */
  87776. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  87777. /**
  87778. * Gets the current list of color remap gradients.
  87779. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  87780. * @returns the list of color remap gradients
  87781. */
  87782. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  87783. /**
  87784. * Adds a new alpha remap gradient
  87785. * @param gradient defines the gradient to use (between 0 and 1)
  87786. * @param min defines the alpha remap minimal range
  87787. * @param max defines the alpha remap maximal range
  87788. * @returns the current particle system
  87789. */
  87790. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  87791. /**
  87792. * Gets the current list of alpha remap gradients.
  87793. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  87794. * @returns the list of alpha remap gradients
  87795. */
  87796. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  87797. /**
  87798. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  87799. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  87800. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  87801. * @returns the emitter
  87802. */
  87803. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  87804. /**
  87805. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  87806. * @param radius The radius of the hemisphere to emit from
  87807. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  87808. * @returns the emitter
  87809. */
  87810. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  87811. /**
  87812. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  87813. * @param radius The radius of the sphere to emit from
  87814. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  87815. * @returns the emitter
  87816. */
  87817. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  87818. /**
  87819. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  87820. * @param radius The radius of the sphere to emit from
  87821. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  87822. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  87823. * @returns the emitter
  87824. */
  87825. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  87826. /**
  87827. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  87828. * @param radius The radius of the emission cylinder
  87829. * @param height The height of the emission cylinder
  87830. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  87831. * @param directionRandomizer How much to randomize the particle direction [0-1]
  87832. * @returns the emitter
  87833. */
  87834. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  87835. /**
  87836. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  87837. * @param radius The radius of the cylinder to emit from
  87838. * @param height The height of the emission cylinder
  87839. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  87840. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  87841. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  87842. * @returns the emitter
  87843. */
  87844. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  87845. /**
  87846. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  87847. * @param radius The radius of the cone to emit from
  87848. * @param angle The base angle of the cone
  87849. * @returns the emitter
  87850. */
  87851. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  87852. /**
  87853. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  87854. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  87855. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  87856. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  87857. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  87858. * @returns the emitter
  87859. */
  87860. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  87861. /**
  87862. * Get hosting scene
  87863. * @returns the scene
  87864. */
  87865. getScene(): Scene;
  87866. }
  87867. }
  87868. declare module BABYLON {
  87869. /**
  87870. * 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.
  87871. * @see https://doc.babylonjs.com/how_to/transformnode
  87872. */
  87873. export class TransformNode extends Node {
  87874. /**
  87875. * Object will not rotate to face the camera
  87876. */
  87877. static BILLBOARDMODE_NONE: number;
  87878. /**
  87879. * Object will rotate to face the camera but only on the x axis
  87880. */
  87881. static BILLBOARDMODE_X: number;
  87882. /**
  87883. * Object will rotate to face the camera but only on the y axis
  87884. */
  87885. static BILLBOARDMODE_Y: number;
  87886. /**
  87887. * Object will rotate to face the camera but only on the z axis
  87888. */
  87889. static BILLBOARDMODE_Z: number;
  87890. /**
  87891. * Object will rotate to face the camera
  87892. */
  87893. static BILLBOARDMODE_ALL: number;
  87894. /**
  87895. * Object will rotate to face the camera's position instead of orientation
  87896. */
  87897. static BILLBOARDMODE_USE_POSITION: number;
  87898. private _forward;
  87899. private _forwardInverted;
  87900. private _up;
  87901. private _right;
  87902. private _rightInverted;
  87903. private _position;
  87904. private _rotation;
  87905. private _rotationQuaternion;
  87906. protected _scaling: Vector3;
  87907. protected _isDirty: boolean;
  87908. private _transformToBoneReferal;
  87909. private _isAbsoluteSynced;
  87910. private _billboardMode;
  87911. /**
  87912. * Gets or sets the billboard mode. Default is 0.
  87913. *
  87914. * | Value | Type | Description |
  87915. * | --- | --- | --- |
  87916. * | 0 | BILLBOARDMODE_NONE | |
  87917. * | 1 | BILLBOARDMODE_X | |
  87918. * | 2 | BILLBOARDMODE_Y | |
  87919. * | 4 | BILLBOARDMODE_Z | |
  87920. * | 7 | BILLBOARDMODE_ALL | |
  87921. *
  87922. */
  87923. get billboardMode(): number;
  87924. set billboardMode(value: number);
  87925. private _preserveParentRotationForBillboard;
  87926. /**
  87927. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  87928. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  87929. */
  87930. get preserveParentRotationForBillboard(): boolean;
  87931. set preserveParentRotationForBillboard(value: boolean);
  87932. /**
  87933. * 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
  87934. */
  87935. scalingDeterminant: number;
  87936. private _infiniteDistance;
  87937. /**
  87938. * Gets or sets the distance of the object to max, often used by skybox
  87939. */
  87940. get infiniteDistance(): boolean;
  87941. set infiniteDistance(value: boolean);
  87942. /**
  87943. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  87944. * By default the system will update normals to compensate
  87945. */
  87946. ignoreNonUniformScaling: boolean;
  87947. /**
  87948. * 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
  87949. */
  87950. reIntegrateRotationIntoRotationQuaternion: boolean;
  87951. /** @hidden */
  87952. _poseMatrix: Nullable<Matrix>;
  87953. /** @hidden */
  87954. _localMatrix: Matrix;
  87955. private _usePivotMatrix;
  87956. private _absolutePosition;
  87957. private _absoluteScaling;
  87958. private _absoluteRotationQuaternion;
  87959. private _pivotMatrix;
  87960. private _pivotMatrixInverse;
  87961. protected _postMultiplyPivotMatrix: boolean;
  87962. protected _isWorldMatrixFrozen: boolean;
  87963. /** @hidden */
  87964. _indexInSceneTransformNodesArray: number;
  87965. /**
  87966. * An event triggered after the world matrix is updated
  87967. */
  87968. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  87969. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  87970. /**
  87971. * Gets a string identifying the name of the class
  87972. * @returns "TransformNode" string
  87973. */
  87974. getClassName(): string;
  87975. /**
  87976. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  87977. */
  87978. get position(): Vector3;
  87979. set position(newPosition: Vector3);
  87980. /**
  87981. * 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)).
  87982. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  87983. */
  87984. get rotation(): Vector3;
  87985. set rotation(newRotation: Vector3);
  87986. /**
  87987. * 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)).
  87988. */
  87989. get scaling(): Vector3;
  87990. set scaling(newScaling: Vector3);
  87991. /**
  87992. * 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).
  87993. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  87994. */
  87995. get rotationQuaternion(): Nullable<Quaternion>;
  87996. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  87997. /**
  87998. * The forward direction of that transform in world space.
  87999. */
  88000. get forward(): Vector3;
  88001. /**
  88002. * The up direction of that transform in world space.
  88003. */
  88004. get up(): Vector3;
  88005. /**
  88006. * The right direction of that transform in world space.
  88007. */
  88008. get right(): Vector3;
  88009. /**
  88010. * Copies the parameter passed Matrix into the mesh Pose matrix.
  88011. * @param matrix the matrix to copy the pose from
  88012. * @returns this TransformNode.
  88013. */
  88014. updatePoseMatrix(matrix: Matrix): TransformNode;
  88015. /**
  88016. * Returns the mesh Pose matrix.
  88017. * @returns the pose matrix
  88018. */
  88019. getPoseMatrix(): Matrix;
  88020. /** @hidden */
  88021. _isSynchronized(): boolean;
  88022. /** @hidden */
  88023. _initCache(): void;
  88024. /**
  88025. * Flag the transform node as dirty (Forcing it to update everything)
  88026. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  88027. * @returns this transform node
  88028. */
  88029. markAsDirty(property: string): TransformNode;
  88030. /**
  88031. * Returns the current mesh absolute position.
  88032. * Returns a Vector3.
  88033. */
  88034. get absolutePosition(): Vector3;
  88035. /**
  88036. * Returns the current mesh absolute scaling.
  88037. * Returns a Vector3.
  88038. */
  88039. get absoluteScaling(): Vector3;
  88040. /**
  88041. * Returns the current mesh absolute rotation.
  88042. * Returns a Quaternion.
  88043. */
  88044. get absoluteRotationQuaternion(): Quaternion;
  88045. /**
  88046. * Sets a new matrix to apply before all other transformation
  88047. * @param matrix defines the transform matrix
  88048. * @returns the current TransformNode
  88049. */
  88050. setPreTransformMatrix(matrix: Matrix): TransformNode;
  88051. /**
  88052. * Sets a new pivot matrix to the current node
  88053. * @param matrix defines the new pivot matrix to use
  88054. * @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
  88055. * @returns the current TransformNode
  88056. */
  88057. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  88058. /**
  88059. * Returns the mesh pivot matrix.
  88060. * Default : Identity.
  88061. * @returns the matrix
  88062. */
  88063. getPivotMatrix(): Matrix;
  88064. /**
  88065. * Instantiate (when possible) or clone that node with its hierarchy
  88066. * @param newParent defines the new parent to use for the instance (or clone)
  88067. * @param options defines options to configure how copy is done
  88068. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  88069. * @returns an instance (or a clone) of the current node with its hiearchy
  88070. */
  88071. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  88072. doNotInstantiate: boolean;
  88073. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  88074. /**
  88075. * Prevents the World matrix to be computed any longer
  88076. * @param newWorldMatrix defines an optional matrix to use as world matrix
  88077. * @returns the TransformNode.
  88078. */
  88079. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  88080. /**
  88081. * Allows back the World matrix computation.
  88082. * @returns the TransformNode.
  88083. */
  88084. unfreezeWorldMatrix(): this;
  88085. /**
  88086. * True if the World matrix has been frozen.
  88087. */
  88088. get isWorldMatrixFrozen(): boolean;
  88089. /**
  88090. * Retuns the mesh absolute position in the World.
  88091. * @returns a Vector3.
  88092. */
  88093. getAbsolutePosition(): Vector3;
  88094. /**
  88095. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  88096. * @param absolutePosition the absolute position to set
  88097. * @returns the TransformNode.
  88098. */
  88099. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  88100. /**
  88101. * Sets the mesh position in its local space.
  88102. * @param vector3 the position to set in localspace
  88103. * @returns the TransformNode.
  88104. */
  88105. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  88106. /**
  88107. * Returns the mesh position in the local space from the current World matrix values.
  88108. * @returns a new Vector3.
  88109. */
  88110. getPositionExpressedInLocalSpace(): Vector3;
  88111. /**
  88112. * Translates the mesh along the passed Vector3 in its local space.
  88113. * @param vector3 the distance to translate in localspace
  88114. * @returns the TransformNode.
  88115. */
  88116. locallyTranslate(vector3: Vector3): TransformNode;
  88117. private static _lookAtVectorCache;
  88118. /**
  88119. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  88120. * @param targetPoint the position (must be in same space as current mesh) to look at
  88121. * @param yawCor optional yaw (y-axis) correction in radians
  88122. * @param pitchCor optional pitch (x-axis) correction in radians
  88123. * @param rollCor optional roll (z-axis) correction in radians
  88124. * @param space the choosen space of the target
  88125. * @returns the TransformNode.
  88126. */
  88127. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  88128. /**
  88129. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  88130. * This Vector3 is expressed in the World space.
  88131. * @param localAxis axis to rotate
  88132. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  88133. */
  88134. getDirection(localAxis: Vector3): Vector3;
  88135. /**
  88136. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  88137. * localAxis is expressed in the mesh local space.
  88138. * result is computed in the Wordl space from the mesh World matrix.
  88139. * @param localAxis axis to rotate
  88140. * @param result the resulting transformnode
  88141. * @returns this TransformNode.
  88142. */
  88143. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  88144. /**
  88145. * Sets this transform node rotation to the given local axis.
  88146. * @param localAxis the axis in local space
  88147. * @param yawCor optional yaw (y-axis) correction in radians
  88148. * @param pitchCor optional pitch (x-axis) correction in radians
  88149. * @param rollCor optional roll (z-axis) correction in radians
  88150. * @returns this TransformNode
  88151. */
  88152. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  88153. /**
  88154. * Sets a new pivot point to the current node
  88155. * @param point defines the new pivot point to use
  88156. * @param space defines if the point is in world or local space (local by default)
  88157. * @returns the current TransformNode
  88158. */
  88159. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  88160. /**
  88161. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  88162. * @returns the pivot point
  88163. */
  88164. getPivotPoint(): Vector3;
  88165. /**
  88166. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  88167. * @param result the vector3 to store the result
  88168. * @returns this TransformNode.
  88169. */
  88170. getPivotPointToRef(result: Vector3): TransformNode;
  88171. /**
  88172. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  88173. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  88174. */
  88175. getAbsolutePivotPoint(): Vector3;
  88176. /**
  88177. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  88178. * @param result vector3 to store the result
  88179. * @returns this TransformNode.
  88180. */
  88181. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  88182. /**
  88183. * Defines the passed node as the parent of the current node.
  88184. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  88185. * @see https://doc.babylonjs.com/how_to/parenting
  88186. * @param node the node ot set as the parent
  88187. * @returns this TransformNode.
  88188. */
  88189. setParent(node: Nullable<Node>): TransformNode;
  88190. private _nonUniformScaling;
  88191. /**
  88192. * True if the scaling property of this object is non uniform eg. (1,2,1)
  88193. */
  88194. get nonUniformScaling(): boolean;
  88195. /** @hidden */
  88196. _updateNonUniformScalingState(value: boolean): boolean;
  88197. /**
  88198. * Attach the current TransformNode to another TransformNode associated with a bone
  88199. * @param bone Bone affecting the TransformNode
  88200. * @param affectedTransformNode TransformNode associated with the bone
  88201. * @returns this object
  88202. */
  88203. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  88204. /**
  88205. * Detach the transform node if its associated with a bone
  88206. * @returns this object
  88207. */
  88208. detachFromBone(): TransformNode;
  88209. private static _rotationAxisCache;
  88210. /**
  88211. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  88212. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  88213. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  88214. * The passed axis is also normalized.
  88215. * @param axis the axis to rotate around
  88216. * @param amount the amount to rotate in radians
  88217. * @param space Space to rotate in (Default: local)
  88218. * @returns the TransformNode.
  88219. */
  88220. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  88221. /**
  88222. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  88223. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  88224. * The passed axis is also normalized. .
  88225. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  88226. * @param point the point to rotate around
  88227. * @param axis the axis to rotate around
  88228. * @param amount the amount to rotate in radians
  88229. * @returns the TransformNode
  88230. */
  88231. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  88232. /**
  88233. * Translates the mesh along the axis vector for the passed distance in the given space.
  88234. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  88235. * @param axis the axis to translate in
  88236. * @param distance the distance to translate
  88237. * @param space Space to rotate in (Default: local)
  88238. * @returns the TransformNode.
  88239. */
  88240. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  88241. /**
  88242. * Adds a rotation step to the mesh current rotation.
  88243. * x, y, z are Euler angles expressed in radians.
  88244. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  88245. * This means this rotation is made in the mesh local space only.
  88246. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  88247. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  88248. * ```javascript
  88249. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  88250. * ```
  88251. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  88252. * 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.
  88253. * @param x Rotation to add
  88254. * @param y Rotation to add
  88255. * @param z Rotation to add
  88256. * @returns the TransformNode.
  88257. */
  88258. addRotation(x: number, y: number, z: number): TransformNode;
  88259. /**
  88260. * @hidden
  88261. */
  88262. protected _getEffectiveParent(): Nullable<Node>;
  88263. /**
  88264. * Computes the world matrix of the node
  88265. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  88266. * @returns the world matrix
  88267. */
  88268. computeWorldMatrix(force?: boolean): Matrix;
  88269. /**
  88270. * Resets this nodeTransform's local matrix to Matrix.Identity().
  88271. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  88272. */
  88273. resetLocalMatrix(independentOfChildren?: boolean): void;
  88274. protected _afterComputeWorldMatrix(): void;
  88275. /**
  88276. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  88277. * @param func callback function to add
  88278. *
  88279. * @returns the TransformNode.
  88280. */
  88281. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  88282. /**
  88283. * Removes a registered callback function.
  88284. * @param func callback function to remove
  88285. * @returns the TransformNode.
  88286. */
  88287. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  88288. /**
  88289. * Gets the position of the current mesh in camera space
  88290. * @param camera defines the camera to use
  88291. * @returns a position
  88292. */
  88293. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  88294. /**
  88295. * Returns the distance from the mesh to the active camera
  88296. * @param camera defines the camera to use
  88297. * @returns the distance
  88298. */
  88299. getDistanceToCamera(camera?: Nullable<Camera>): number;
  88300. /**
  88301. * Clone the current transform node
  88302. * @param name Name of the new clone
  88303. * @param newParent New parent for the clone
  88304. * @param doNotCloneChildren Do not clone children hierarchy
  88305. * @returns the new transform node
  88306. */
  88307. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  88308. /**
  88309. * Serializes the objects information.
  88310. * @param currentSerializationObject defines the object to serialize in
  88311. * @returns the serialized object
  88312. */
  88313. serialize(currentSerializationObject?: any): any;
  88314. /**
  88315. * Returns a new TransformNode object parsed from the source provided.
  88316. * @param parsedTransformNode is the source.
  88317. * @param scene the scne the object belongs to
  88318. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  88319. * @returns a new TransformNode object parsed from the source provided.
  88320. */
  88321. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  88322. /**
  88323. * Get all child-transformNodes of this node
  88324. * @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
  88325. * @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
  88326. * @returns an array of TransformNode
  88327. */
  88328. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  88329. /**
  88330. * Releases resources associated with this transform node.
  88331. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  88332. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  88333. */
  88334. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  88335. /**
  88336. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  88337. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  88338. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  88339. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  88340. * @returns the current mesh
  88341. */
  88342. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  88343. private _syncAbsoluteScalingAndRotation;
  88344. }
  88345. }
  88346. declare module BABYLON {
  88347. /**
  88348. * Class used to override all child animations of a given target
  88349. */
  88350. export class AnimationPropertiesOverride {
  88351. /**
  88352. * Gets or sets a value indicating if animation blending must be used
  88353. */
  88354. enableBlending: boolean;
  88355. /**
  88356. * Gets or sets the blending speed to use when enableBlending is true
  88357. */
  88358. blendingSpeed: number;
  88359. /**
  88360. * Gets or sets the default loop mode to use
  88361. */
  88362. loopMode: number;
  88363. }
  88364. }
  88365. declare module BABYLON {
  88366. /**
  88367. * Class used to store bone information
  88368. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  88369. */
  88370. export class Bone extends Node {
  88371. /**
  88372. * defines the bone name
  88373. */
  88374. name: string;
  88375. private static _tmpVecs;
  88376. private static _tmpQuat;
  88377. private static _tmpMats;
  88378. /**
  88379. * Gets the list of child bones
  88380. */
  88381. children: Bone[];
  88382. /** Gets the animations associated with this bone */
  88383. animations: Animation[];
  88384. /**
  88385. * Gets or sets bone length
  88386. */
  88387. length: number;
  88388. /**
  88389. * @hidden Internal only
  88390. * Set this value to map this bone to a different index in the transform matrices
  88391. * Set this value to -1 to exclude the bone from the transform matrices
  88392. */
  88393. _index: Nullable<number>;
  88394. private _skeleton;
  88395. private _localMatrix;
  88396. private _restPose;
  88397. private _baseMatrix;
  88398. private _absoluteTransform;
  88399. private _invertedAbsoluteTransform;
  88400. private _parent;
  88401. private _scalingDeterminant;
  88402. private _worldTransform;
  88403. private _localScaling;
  88404. private _localRotation;
  88405. private _localPosition;
  88406. private _needToDecompose;
  88407. private _needToCompose;
  88408. /** @hidden */
  88409. _linkedTransformNode: Nullable<TransformNode>;
  88410. /** @hidden */
  88411. _waitingTransformNodeId: Nullable<string>;
  88412. /** @hidden */
  88413. get _matrix(): Matrix;
  88414. /** @hidden */
  88415. set _matrix(value: Matrix);
  88416. /**
  88417. * Create a new bone
  88418. * @param name defines the bone name
  88419. * @param skeleton defines the parent skeleton
  88420. * @param parentBone defines the parent (can be null if the bone is the root)
  88421. * @param localMatrix defines the local matrix
  88422. * @param restPose defines the rest pose matrix
  88423. * @param baseMatrix defines the base matrix
  88424. * @param index defines index of the bone in the hiearchy
  88425. */
  88426. constructor(
  88427. /**
  88428. * defines the bone name
  88429. */
  88430. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  88431. /**
  88432. * Gets the current object class name.
  88433. * @return the class name
  88434. */
  88435. getClassName(): string;
  88436. /**
  88437. * Gets the parent skeleton
  88438. * @returns a skeleton
  88439. */
  88440. getSkeleton(): Skeleton;
  88441. /**
  88442. * Gets parent bone
  88443. * @returns a bone or null if the bone is the root of the bone hierarchy
  88444. */
  88445. getParent(): Nullable<Bone>;
  88446. /**
  88447. * Returns an array containing the root bones
  88448. * @returns an array containing the root bones
  88449. */
  88450. getChildren(): Array<Bone>;
  88451. /**
  88452. * Gets the node index in matrix array generated for rendering
  88453. * @returns the node index
  88454. */
  88455. getIndex(): number;
  88456. /**
  88457. * Sets the parent bone
  88458. * @param parent defines the parent (can be null if the bone is the root)
  88459. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  88460. */
  88461. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  88462. /**
  88463. * Gets the local matrix
  88464. * @returns a matrix
  88465. */
  88466. getLocalMatrix(): Matrix;
  88467. /**
  88468. * Gets the base matrix (initial matrix which remains unchanged)
  88469. * @returns a matrix
  88470. */
  88471. getBaseMatrix(): Matrix;
  88472. /**
  88473. * Gets the rest pose matrix
  88474. * @returns a matrix
  88475. */
  88476. getRestPose(): Matrix;
  88477. /**
  88478. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  88479. */
  88480. getWorldMatrix(): Matrix;
  88481. /**
  88482. * Sets the local matrix to rest pose matrix
  88483. */
  88484. returnToRest(): void;
  88485. /**
  88486. * Gets the inverse of the absolute transform matrix.
  88487. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  88488. * @returns a matrix
  88489. */
  88490. getInvertedAbsoluteTransform(): Matrix;
  88491. /**
  88492. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  88493. * @returns a matrix
  88494. */
  88495. getAbsoluteTransform(): Matrix;
  88496. /**
  88497. * Links with the given transform node.
  88498. * The local matrix of this bone is copied from the transform node every frame.
  88499. * @param transformNode defines the transform node to link to
  88500. */
  88501. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  88502. /**
  88503. * Gets the node used to drive the bone's transformation
  88504. * @returns a transform node or null
  88505. */
  88506. getTransformNode(): Nullable<TransformNode>;
  88507. /** Gets or sets current position (in local space) */
  88508. get position(): Vector3;
  88509. set position(newPosition: Vector3);
  88510. /** Gets or sets current rotation (in local space) */
  88511. get rotation(): Vector3;
  88512. set rotation(newRotation: Vector3);
  88513. /** Gets or sets current rotation quaternion (in local space) */
  88514. get rotationQuaternion(): Quaternion;
  88515. set rotationQuaternion(newRotation: Quaternion);
  88516. /** Gets or sets current scaling (in local space) */
  88517. get scaling(): Vector3;
  88518. set scaling(newScaling: Vector3);
  88519. /**
  88520. * Gets the animation properties override
  88521. */
  88522. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  88523. private _decompose;
  88524. private _compose;
  88525. /**
  88526. * Update the base and local matrices
  88527. * @param matrix defines the new base or local matrix
  88528. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  88529. * @param updateLocalMatrix defines if the local matrix should be updated
  88530. */
  88531. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  88532. /** @hidden */
  88533. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  88534. /**
  88535. * Flag the bone as dirty (Forcing it to update everything)
  88536. */
  88537. markAsDirty(): void;
  88538. /** @hidden */
  88539. _markAsDirtyAndCompose(): void;
  88540. private _markAsDirtyAndDecompose;
  88541. /**
  88542. * Translate the bone in local or world space
  88543. * @param vec The amount to translate the bone
  88544. * @param space The space that the translation is in
  88545. * @param mesh The mesh that this bone is attached to. This is only used in world space
  88546. */
  88547. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  88548. /**
  88549. * Set the postion of the bone in local or world space
  88550. * @param position The position to set the bone
  88551. * @param space The space that the position is in
  88552. * @param mesh The mesh that this bone is attached to. This is only used in world space
  88553. */
  88554. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  88555. /**
  88556. * Set the absolute position of the bone (world space)
  88557. * @param position The position to set the bone
  88558. * @param mesh The mesh that this bone is attached to
  88559. */
  88560. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  88561. /**
  88562. * Scale the bone on the x, y and z axes (in local space)
  88563. * @param x The amount to scale the bone on the x axis
  88564. * @param y The amount to scale the bone on the y axis
  88565. * @param z The amount to scale the bone on the z axis
  88566. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  88567. */
  88568. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  88569. /**
  88570. * Set the bone scaling in local space
  88571. * @param scale defines the scaling vector
  88572. */
  88573. setScale(scale: Vector3): void;
  88574. /**
  88575. * Gets the current scaling in local space
  88576. * @returns the current scaling vector
  88577. */
  88578. getScale(): Vector3;
  88579. /**
  88580. * Gets the current scaling in local space and stores it in a target vector
  88581. * @param result defines the target vector
  88582. */
  88583. getScaleToRef(result: Vector3): void;
  88584. /**
  88585. * Set the yaw, pitch, and roll of the bone in local or world space
  88586. * @param yaw The rotation of the bone on the y axis
  88587. * @param pitch The rotation of the bone on the x axis
  88588. * @param roll The rotation of the bone on the z axis
  88589. * @param space The space that the axes of rotation are in
  88590. * @param mesh The mesh that this bone is attached to. This is only used in world space
  88591. */
  88592. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  88593. /**
  88594. * Add a rotation to the bone on an axis in local or world space
  88595. * @param axis The axis to rotate the bone on
  88596. * @param amount The amount to rotate the bone
  88597. * @param space The space that the axis is in
  88598. * @param mesh The mesh that this bone is attached to. This is only used in world space
  88599. */
  88600. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  88601. /**
  88602. * Set the rotation of the bone to a particular axis angle in local or world space
  88603. * @param axis The axis to rotate the bone on
  88604. * @param angle The angle that the bone should be rotated to
  88605. * @param space The space that the axis is in
  88606. * @param mesh The mesh that this bone is attached to. This is only used in world space
  88607. */
  88608. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  88609. /**
  88610. * Set the euler rotation of the bone in local of world space
  88611. * @param rotation The euler rotation that the bone should be set to
  88612. * @param space The space that the rotation is in
  88613. * @param mesh The mesh that this bone is attached to. This is only used in world space
  88614. */
  88615. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  88616. /**
  88617. * Set the quaternion rotation of the bone in local of world space
  88618. * @param quat The quaternion rotation that the bone should be set to
  88619. * @param space The space that the rotation is in
  88620. * @param mesh The mesh that this bone is attached to. This is only used in world space
  88621. */
  88622. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  88623. /**
  88624. * Set the rotation matrix of the bone in local of world space
  88625. * @param rotMat The rotation matrix 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. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  88630. private _rotateWithMatrix;
  88631. private _getNegativeRotationToRef;
  88632. /**
  88633. * Get the position of the bone in local or world space
  88634. * @param space The space that the returned position is in
  88635. * @param mesh The mesh that this bone is attached to. This is only used in world space
  88636. * @returns The position of the bone
  88637. */
  88638. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  88639. /**
  88640. * Copy the position of the bone to a vector3 in local or world space
  88641. * @param space The space that the returned position is in
  88642. * @param mesh The mesh that this bone is attached to. This is only used in world space
  88643. * @param result The vector3 to copy the position to
  88644. */
  88645. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  88646. /**
  88647. * Get the absolute position of the bone (world space)
  88648. * @param mesh The mesh that this bone is attached to
  88649. * @returns The absolute position of the bone
  88650. */
  88651. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  88652. /**
  88653. * Copy the absolute position of the bone (world space) to the result param
  88654. * @param mesh The mesh that this bone is attached to
  88655. * @param result The vector3 to copy the absolute position to
  88656. */
  88657. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  88658. /**
  88659. * Compute the absolute transforms of this bone and its children
  88660. */
  88661. computeAbsoluteTransforms(): void;
  88662. /**
  88663. * Get the world direction from an axis that is in the local space of the bone
  88664. * @param localAxis The local direction that is used to compute the world direction
  88665. * @param mesh The mesh that this bone is attached to
  88666. * @returns The world direction
  88667. */
  88668. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  88669. /**
  88670. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  88671. * @param localAxis The local direction that is used to compute the world direction
  88672. * @param mesh The mesh that this bone is attached to
  88673. * @param result The vector3 that the world direction will be copied to
  88674. */
  88675. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  88676. /**
  88677. * Get the euler rotation of the bone in local or world space
  88678. * @param space The space that the rotation should be in
  88679. * @param mesh The mesh that this bone is attached to. This is only used in world space
  88680. * @returns The euler rotation
  88681. */
  88682. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  88683. /**
  88684. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  88685. * @param space The space that the rotation should be in
  88686. * @param mesh The mesh that this bone is attached to. This is only used in world space
  88687. * @param result The vector3 that the rotation should be copied to
  88688. */
  88689. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  88690. /**
  88691. * Get the quaternion rotation of the bone in either 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 quaternion rotation
  88695. */
  88696. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  88697. /**
  88698. * Copy the quaternion rotation of the bone to a quaternion. 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 quaternion that the rotation should be copied to
  88702. */
  88703. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  88704. /**
  88705. * Get the rotation matrix of the bone in 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 rotation matrix
  88709. */
  88710. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  88711. /**
  88712. * Copy the rotation matrix of the bone to a matrix. 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. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  88718. /**
  88719. * Get the world position of a point that is in the local space of the bone
  88720. * @param position The local position
  88721. * @param mesh The mesh that this bone is attached to
  88722. * @returns The world position
  88723. */
  88724. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  88725. /**
  88726. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  88727. * @param position The local position
  88728. * @param mesh The mesh that this bone is attached to
  88729. * @param result The vector3 that the world position should be copied to
  88730. */
  88731. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  88732. /**
  88733. * Get the local position of a point that is in world space
  88734. * @param position The world position
  88735. * @param mesh The mesh that this bone is attached to
  88736. * @returns The local position
  88737. */
  88738. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  88739. /**
  88740. * Get the local position of a point that is in world space and copy it to the result param
  88741. * @param position The world position
  88742. * @param mesh The mesh that this bone is attached to
  88743. * @param result The vector3 that the local position should be copied to
  88744. */
  88745. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  88746. }
  88747. }
  88748. declare module BABYLON {
  88749. /**
  88750. * Defines a runtime animation
  88751. */
  88752. export class RuntimeAnimation {
  88753. private _events;
  88754. /**
  88755. * The current frame of the runtime animation
  88756. */
  88757. private _currentFrame;
  88758. /**
  88759. * The animation used by the runtime animation
  88760. */
  88761. private _animation;
  88762. /**
  88763. * The target of the runtime animation
  88764. */
  88765. private _target;
  88766. /**
  88767. * The initiating animatable
  88768. */
  88769. private _host;
  88770. /**
  88771. * The original value of the runtime animation
  88772. */
  88773. private _originalValue;
  88774. /**
  88775. * The original blend value of the runtime animation
  88776. */
  88777. private _originalBlendValue;
  88778. /**
  88779. * The offsets cache of the runtime animation
  88780. */
  88781. private _offsetsCache;
  88782. /**
  88783. * The high limits cache of the runtime animation
  88784. */
  88785. private _highLimitsCache;
  88786. /**
  88787. * Specifies if the runtime animation has been stopped
  88788. */
  88789. private _stopped;
  88790. /**
  88791. * The blending factor of the runtime animation
  88792. */
  88793. private _blendingFactor;
  88794. /**
  88795. * The BabylonJS scene
  88796. */
  88797. private _scene;
  88798. /**
  88799. * The current value of the runtime animation
  88800. */
  88801. private _currentValue;
  88802. /** @hidden */
  88803. _animationState: _IAnimationState;
  88804. /**
  88805. * The active target of the runtime animation
  88806. */
  88807. private _activeTargets;
  88808. private _currentActiveTarget;
  88809. private _directTarget;
  88810. /**
  88811. * The target path of the runtime animation
  88812. */
  88813. private _targetPath;
  88814. /**
  88815. * The weight of the runtime animation
  88816. */
  88817. private _weight;
  88818. /**
  88819. * The ratio offset of the runtime animation
  88820. */
  88821. private _ratioOffset;
  88822. /**
  88823. * The previous delay of the runtime animation
  88824. */
  88825. private _previousDelay;
  88826. /**
  88827. * The previous ratio of the runtime animation
  88828. */
  88829. private _previousRatio;
  88830. private _enableBlending;
  88831. private _keys;
  88832. private _minFrame;
  88833. private _maxFrame;
  88834. private _minValue;
  88835. private _maxValue;
  88836. private _targetIsArray;
  88837. /**
  88838. * Gets the current frame of the runtime animation
  88839. */
  88840. get currentFrame(): number;
  88841. /**
  88842. * Gets the weight of the runtime animation
  88843. */
  88844. get weight(): number;
  88845. /**
  88846. * Gets the current value of the runtime animation
  88847. */
  88848. get currentValue(): any;
  88849. /**
  88850. * Gets the target path of the runtime animation
  88851. */
  88852. get targetPath(): string;
  88853. /**
  88854. * Gets the actual target of the runtime animation
  88855. */
  88856. get target(): any;
  88857. /**
  88858. * Gets the additive state of the runtime animation
  88859. */
  88860. get isAdditive(): boolean;
  88861. /** @hidden */
  88862. _onLoop: () => void;
  88863. /**
  88864. * Create a new RuntimeAnimation object
  88865. * @param target defines the target of the animation
  88866. * @param animation defines the source animation object
  88867. * @param scene defines the hosting scene
  88868. * @param host defines the initiating Animatable
  88869. */
  88870. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  88871. private _preparePath;
  88872. /**
  88873. * Gets the animation from the runtime animation
  88874. */
  88875. get animation(): Animation;
  88876. /**
  88877. * Resets the runtime animation to the beginning
  88878. * @param restoreOriginal defines whether to restore the target property to the original value
  88879. */
  88880. reset(restoreOriginal?: boolean): void;
  88881. /**
  88882. * Specifies if the runtime animation is stopped
  88883. * @returns Boolean specifying if the runtime animation is stopped
  88884. */
  88885. isStopped(): boolean;
  88886. /**
  88887. * Disposes of the runtime animation
  88888. */
  88889. dispose(): void;
  88890. /**
  88891. * Apply the interpolated value to the target
  88892. * @param currentValue defines the value computed by the animation
  88893. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  88894. */
  88895. setValue(currentValue: any, weight: number): void;
  88896. private _getOriginalValues;
  88897. private _setValue;
  88898. /**
  88899. * Gets the loop pmode of the runtime animation
  88900. * @returns Loop Mode
  88901. */
  88902. private _getCorrectLoopMode;
  88903. /**
  88904. * Move the current animation to a given frame
  88905. * @param frame defines the frame to move to
  88906. */
  88907. goToFrame(frame: number): void;
  88908. /**
  88909. * @hidden Internal use only
  88910. */
  88911. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  88912. /**
  88913. * Execute the current animation
  88914. * @param delay defines the delay to add to the current frame
  88915. * @param from defines the lower bound of the animation range
  88916. * @param to defines the upper bound of the animation range
  88917. * @param loop defines if the current animation must loop
  88918. * @param speedRatio defines the current speed ratio
  88919. * @param weight defines the weight of the animation (default is -1 so no weight)
  88920. * @param onLoop optional callback called when animation loops
  88921. * @returns a boolean indicating if the animation is running
  88922. */
  88923. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  88924. }
  88925. }
  88926. declare module BABYLON {
  88927. /**
  88928. * Class used to store an actual running animation
  88929. */
  88930. export class Animatable {
  88931. /** defines the target object */
  88932. target: any;
  88933. /** defines the starting frame number (default is 0) */
  88934. fromFrame: number;
  88935. /** defines the ending frame number (default is 100) */
  88936. toFrame: number;
  88937. /** defines if the animation must loop (default is false) */
  88938. loopAnimation: boolean;
  88939. /** defines a callback to call when animation ends if it is not looping */
  88940. onAnimationEnd?: (() => void) | null | undefined;
  88941. /** defines a callback to call when animation loops */
  88942. onAnimationLoop?: (() => void) | null | undefined;
  88943. /** defines whether the animation should be evaluated additively */
  88944. isAdditive: boolean;
  88945. private _localDelayOffset;
  88946. private _pausedDelay;
  88947. private _runtimeAnimations;
  88948. private _paused;
  88949. private _scene;
  88950. private _speedRatio;
  88951. private _weight;
  88952. private _syncRoot;
  88953. /**
  88954. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  88955. * This will only apply for non looping animation (default is true)
  88956. */
  88957. disposeOnEnd: boolean;
  88958. /**
  88959. * Gets a boolean indicating if the animation has started
  88960. */
  88961. animationStarted: boolean;
  88962. /**
  88963. * Observer raised when the animation ends
  88964. */
  88965. onAnimationEndObservable: Observable<Animatable>;
  88966. /**
  88967. * Observer raised when the animation loops
  88968. */
  88969. onAnimationLoopObservable: Observable<Animatable>;
  88970. /**
  88971. * Gets the root Animatable used to synchronize and normalize animations
  88972. */
  88973. get syncRoot(): Nullable<Animatable>;
  88974. /**
  88975. * Gets the current frame of the first RuntimeAnimation
  88976. * Used to synchronize Animatables
  88977. */
  88978. get masterFrame(): number;
  88979. /**
  88980. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  88981. */
  88982. get weight(): number;
  88983. set weight(value: number);
  88984. /**
  88985. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  88986. */
  88987. get speedRatio(): number;
  88988. set speedRatio(value: number);
  88989. /**
  88990. * Creates a new Animatable
  88991. * @param scene defines the hosting scene
  88992. * @param target defines the target object
  88993. * @param fromFrame defines the starting frame number (default is 0)
  88994. * @param toFrame defines the ending frame number (default is 100)
  88995. * @param loopAnimation defines if the animation must loop (default is false)
  88996. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  88997. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  88998. * @param animations defines a group of animation to add to the new Animatable
  88999. * @param onAnimationLoop defines a callback to call when animation loops
  89000. * @param isAdditive defines whether the animation should be evaluated additively
  89001. */
  89002. constructor(scene: Scene,
  89003. /** defines the target object */
  89004. target: any,
  89005. /** defines the starting frame number (default is 0) */
  89006. fromFrame?: number,
  89007. /** defines the ending frame number (default is 100) */
  89008. toFrame?: number,
  89009. /** defines if the animation must loop (default is false) */
  89010. loopAnimation?: boolean, speedRatio?: number,
  89011. /** defines a callback to call when animation ends if it is not looping */
  89012. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  89013. /** defines a callback to call when animation loops */
  89014. onAnimationLoop?: (() => void) | null | undefined,
  89015. /** defines whether the animation should be evaluated additively */
  89016. isAdditive?: boolean);
  89017. /**
  89018. * Synchronize and normalize current Animatable with a source Animatable
  89019. * This is useful when using animation weights and when animations are not of the same length
  89020. * @param root defines the root Animatable to synchronize with
  89021. * @returns the current Animatable
  89022. */
  89023. syncWith(root: Animatable): Animatable;
  89024. /**
  89025. * Gets the list of runtime animations
  89026. * @returns an array of RuntimeAnimation
  89027. */
  89028. getAnimations(): RuntimeAnimation[];
  89029. /**
  89030. * Adds more animations to the current animatable
  89031. * @param target defines the target of the animations
  89032. * @param animations defines the new animations to add
  89033. */
  89034. appendAnimations(target: any, animations: Animation[]): void;
  89035. /**
  89036. * Gets the source animation for a specific property
  89037. * @param property defines the propertyu to look for
  89038. * @returns null or the source animation for the given property
  89039. */
  89040. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  89041. /**
  89042. * Gets the runtime animation for a specific property
  89043. * @param property defines the propertyu to look for
  89044. * @returns null or the runtime animation for the given property
  89045. */
  89046. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  89047. /**
  89048. * Resets the animatable to its original state
  89049. */
  89050. reset(): void;
  89051. /**
  89052. * Allows the animatable to blend with current running animations
  89053. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  89054. * @param blendingSpeed defines the blending speed to use
  89055. */
  89056. enableBlending(blendingSpeed: number): void;
  89057. /**
  89058. * Disable animation blending
  89059. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  89060. */
  89061. disableBlending(): void;
  89062. /**
  89063. * Jump directly to a given frame
  89064. * @param frame defines the frame to jump to
  89065. */
  89066. goToFrame(frame: number): void;
  89067. /**
  89068. * Pause the animation
  89069. */
  89070. pause(): void;
  89071. /**
  89072. * Restart the animation
  89073. */
  89074. restart(): void;
  89075. private _raiseOnAnimationEnd;
  89076. /**
  89077. * Stop and delete the current animation
  89078. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  89079. * @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)
  89080. */
  89081. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  89082. /**
  89083. * Wait asynchronously for the animation to end
  89084. * @returns a promise which will be fullfilled when the animation ends
  89085. */
  89086. waitAsync(): Promise<Animatable>;
  89087. /** @hidden */
  89088. _animate(delay: number): boolean;
  89089. }
  89090. interface Scene {
  89091. /** @hidden */
  89092. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  89093. /** @hidden */
  89094. _processLateAnimationBindingsForMatrices(holder: {
  89095. totalWeight: number;
  89096. totalAdditiveWeight: number;
  89097. animations: RuntimeAnimation[];
  89098. additiveAnimations: RuntimeAnimation[];
  89099. originalValue: Matrix;
  89100. }): any;
  89101. /** @hidden */
  89102. _processLateAnimationBindingsForQuaternions(holder: {
  89103. totalWeight: number;
  89104. totalAdditiveWeight: number;
  89105. animations: RuntimeAnimation[];
  89106. additiveAnimations: RuntimeAnimation[];
  89107. originalValue: Quaternion;
  89108. }, refQuaternion: Quaternion): Quaternion;
  89109. /** @hidden */
  89110. _processLateAnimationBindings(): void;
  89111. /**
  89112. * Will start the animation sequence of a given target
  89113. * @param target defines the target
  89114. * @param from defines from which frame should animation start
  89115. * @param to defines until which frame should animation run.
  89116. * @param weight defines the weight to apply to the animation (1.0 by default)
  89117. * @param loop defines if the animation loops
  89118. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  89119. * @param onAnimationEnd defines the function to be executed when the animation ends
  89120. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  89121. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  89122. * @param onAnimationLoop defines the callback to call when an animation loops
  89123. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  89124. * @returns the animatable object created for this animation
  89125. */
  89126. 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;
  89127. /**
  89128. * Will start the animation sequence of a given target
  89129. * @param target defines the target
  89130. * @param from defines from which frame should animation start
  89131. * @param to defines until which frame should animation run.
  89132. * @param loop defines if the animation loops
  89133. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  89134. * @param onAnimationEnd defines the function to be executed when the animation ends
  89135. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  89136. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  89137. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  89138. * @param onAnimationLoop defines the callback to call when an animation loops
  89139. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  89140. * @returns the animatable object created for this animation
  89141. */
  89142. 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;
  89143. /**
  89144. * Will start the animation sequence of a given target and its hierarchy
  89145. * @param target defines the target
  89146. * @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.
  89147. * @param from defines from which frame should animation start
  89148. * @param to defines until which frame should animation run.
  89149. * @param loop defines if the animation loops
  89150. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  89151. * @param onAnimationEnd defines the function to be executed when the animation ends
  89152. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  89153. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  89154. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  89155. * @param onAnimationLoop defines the callback to call when an animation loops
  89156. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  89157. * @returns the list of created animatables
  89158. */
  89159. 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[];
  89160. /**
  89161. * Begin a new animation on a given node
  89162. * @param target defines the target where the animation will take place
  89163. * @param animations defines the list of animations to start
  89164. * @param from defines the initial value
  89165. * @param to defines the final value
  89166. * @param loop defines if you want animation to loop (off by default)
  89167. * @param speedRatio defines the speed ratio to apply to all animations
  89168. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  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. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  89174. /**
  89175. * Begin a new animation on a given node and its hierarchy
  89176. * @param target defines the root node where the animation will take place
  89177. * @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.
  89178. * @param animations defines the list of animations to start
  89179. * @param from defines the initial value
  89180. * @param to defines the final value
  89181. * @param loop defines if you want animation to loop (off by default)
  89182. * @param speedRatio defines the speed ratio to apply to all animations
  89183. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  89184. * @param onAnimationLoop defines the callback to call when an animation loops
  89185. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  89186. * @returns the list of animatables created for all nodes
  89187. */
  89188. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  89189. /**
  89190. * Gets the animatable associated with a specific target
  89191. * @param target defines the target of the animatable
  89192. * @returns the required animatable if found
  89193. */
  89194. getAnimatableByTarget(target: any): Nullable<Animatable>;
  89195. /**
  89196. * Gets all animatables associated with a given target
  89197. * @param target defines the target to look animatables for
  89198. * @returns an array of Animatables
  89199. */
  89200. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  89201. /**
  89202. * Stops and removes all animations that have been applied to the scene
  89203. */
  89204. stopAllAnimations(): void;
  89205. /**
  89206. * Gets the current delta time used by animation engine
  89207. */
  89208. deltaTime: number;
  89209. }
  89210. interface Bone {
  89211. /**
  89212. * Copy an animation range from another bone
  89213. * @param source defines the source bone
  89214. * @param rangeName defines the range name to copy
  89215. * @param frameOffset defines the frame offset
  89216. * @param rescaleAsRequired defines if rescaling must be applied if required
  89217. * @param skelDimensionsRatio defines the scaling ratio
  89218. * @returns true if operation was successful
  89219. */
  89220. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  89221. }
  89222. }
  89223. declare module BABYLON {
  89224. /**
  89225. * Class used to handle skinning animations
  89226. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  89227. */
  89228. export class Skeleton implements IAnimatable {
  89229. /** defines the skeleton name */
  89230. name: string;
  89231. /** defines the skeleton Id */
  89232. id: string;
  89233. /**
  89234. * Defines the list of child bones
  89235. */
  89236. bones: Bone[];
  89237. /**
  89238. * Defines an estimate of the dimension of the skeleton at rest
  89239. */
  89240. dimensionsAtRest: Vector3;
  89241. /**
  89242. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  89243. */
  89244. needInitialSkinMatrix: boolean;
  89245. /**
  89246. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  89247. */
  89248. overrideMesh: Nullable<AbstractMesh>;
  89249. /**
  89250. * Gets the list of animations attached to this skeleton
  89251. */
  89252. animations: Array<Animation>;
  89253. private _scene;
  89254. private _isDirty;
  89255. private _transformMatrices;
  89256. private _transformMatrixTexture;
  89257. private _meshesWithPoseMatrix;
  89258. private _animatables;
  89259. private _identity;
  89260. private _synchronizedWithMesh;
  89261. private _ranges;
  89262. private _lastAbsoluteTransformsUpdateId;
  89263. private _canUseTextureForBones;
  89264. private _uniqueId;
  89265. /** @hidden */
  89266. _numBonesWithLinkedTransformNode: number;
  89267. /** @hidden */
  89268. _hasWaitingData: Nullable<boolean>;
  89269. /**
  89270. * Specifies if the skeleton should be serialized
  89271. */
  89272. doNotSerialize: boolean;
  89273. private _useTextureToStoreBoneMatrices;
  89274. /**
  89275. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  89276. * Please note that this option is not available if the hardware does not support it
  89277. */
  89278. get useTextureToStoreBoneMatrices(): boolean;
  89279. set useTextureToStoreBoneMatrices(value: boolean);
  89280. private _animationPropertiesOverride;
  89281. /**
  89282. * Gets or sets the animation properties override
  89283. */
  89284. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  89285. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  89286. /**
  89287. * List of inspectable custom properties (used by the Inspector)
  89288. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  89289. */
  89290. inspectableCustomProperties: IInspectable[];
  89291. /**
  89292. * An observable triggered before computing the skeleton's matrices
  89293. */
  89294. onBeforeComputeObservable: Observable<Skeleton>;
  89295. /**
  89296. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  89297. */
  89298. get isUsingTextureForMatrices(): boolean;
  89299. /**
  89300. * Gets the unique ID of this skeleton
  89301. */
  89302. get uniqueId(): number;
  89303. /**
  89304. * Creates a new skeleton
  89305. * @param name defines the skeleton name
  89306. * @param id defines the skeleton Id
  89307. * @param scene defines the hosting scene
  89308. */
  89309. constructor(
  89310. /** defines the skeleton name */
  89311. name: string,
  89312. /** defines the skeleton Id */
  89313. id: string, scene: Scene);
  89314. /**
  89315. * Gets the current object class name.
  89316. * @return the class name
  89317. */
  89318. getClassName(): string;
  89319. /**
  89320. * Returns an array containing the root bones
  89321. * @returns an array containing the root bones
  89322. */
  89323. getChildren(): Array<Bone>;
  89324. /**
  89325. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  89326. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  89327. * @returns a Float32Array containing matrices data
  89328. */
  89329. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  89330. /**
  89331. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  89332. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  89333. * @returns a raw texture containing the data
  89334. */
  89335. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  89336. /**
  89337. * Gets the current hosting scene
  89338. * @returns a scene object
  89339. */
  89340. getScene(): Scene;
  89341. /**
  89342. * Gets a string representing the current skeleton data
  89343. * @param fullDetails defines a boolean indicating if we want a verbose version
  89344. * @returns a string representing the current skeleton data
  89345. */
  89346. toString(fullDetails?: boolean): string;
  89347. /**
  89348. * Get bone's index searching by name
  89349. * @param name defines bone's name to search for
  89350. * @return the indice of the bone. Returns -1 if not found
  89351. */
  89352. getBoneIndexByName(name: string): number;
  89353. /**
  89354. * Creater a new animation range
  89355. * @param name defines the name of the range
  89356. * @param from defines the start key
  89357. * @param to defines the end key
  89358. */
  89359. createAnimationRange(name: string, from: number, to: number): void;
  89360. /**
  89361. * Delete a specific animation range
  89362. * @param name defines the name of the range
  89363. * @param deleteFrames defines if frames must be removed as well
  89364. */
  89365. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  89366. /**
  89367. * Gets a specific animation range
  89368. * @param name defines the name of the range to look for
  89369. * @returns the requested animation range or null if not found
  89370. */
  89371. getAnimationRange(name: string): Nullable<AnimationRange>;
  89372. /**
  89373. * Gets the list of all animation ranges defined on this skeleton
  89374. * @returns an array
  89375. */
  89376. getAnimationRanges(): Nullable<AnimationRange>[];
  89377. /**
  89378. * Copy animation range from a source skeleton.
  89379. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  89380. * @param source defines the source skeleton
  89381. * @param name defines the name of the range to copy
  89382. * @param rescaleAsRequired defines if rescaling must be applied if required
  89383. * @returns true if operation was successful
  89384. */
  89385. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  89386. /**
  89387. * Forces the skeleton to go to rest pose
  89388. */
  89389. returnToRest(): void;
  89390. private _getHighestAnimationFrame;
  89391. /**
  89392. * Begin a specific animation range
  89393. * @param name defines the name of the range to start
  89394. * @param loop defines if looping must be turned on (false by default)
  89395. * @param speedRatio defines the speed ratio to apply (1 by default)
  89396. * @param onAnimationEnd defines a callback which will be called when animation will end
  89397. * @returns a new animatable
  89398. */
  89399. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  89400. /**
  89401. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  89402. * @param skeleton defines the Skeleton containing the animation range to convert
  89403. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  89404. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  89405. * @returns the original skeleton
  89406. */
  89407. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  89408. /** @hidden */
  89409. _markAsDirty(): void;
  89410. /** @hidden */
  89411. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  89412. /** @hidden */
  89413. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  89414. private _computeTransformMatrices;
  89415. /**
  89416. * Build all resources required to render a skeleton
  89417. */
  89418. prepare(): void;
  89419. /**
  89420. * Gets the list of animatables currently running for this skeleton
  89421. * @returns an array of animatables
  89422. */
  89423. getAnimatables(): IAnimatable[];
  89424. /**
  89425. * Clone the current skeleton
  89426. * @param name defines the name of the new skeleton
  89427. * @param id defines the id of the new skeleton
  89428. * @returns the new skeleton
  89429. */
  89430. clone(name: string, id?: string): Skeleton;
  89431. /**
  89432. * Enable animation blending for this skeleton
  89433. * @param blendingSpeed defines the blending speed to apply
  89434. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  89435. */
  89436. enableBlending(blendingSpeed?: number): void;
  89437. /**
  89438. * Releases all resources associated with the current skeleton
  89439. */
  89440. dispose(): void;
  89441. /**
  89442. * Serialize the skeleton in a JSON object
  89443. * @returns a JSON object
  89444. */
  89445. serialize(): any;
  89446. /**
  89447. * Creates a new skeleton from serialized data
  89448. * @param parsedSkeleton defines the serialized data
  89449. * @param scene defines the hosting scene
  89450. * @returns a new skeleton
  89451. */
  89452. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  89453. /**
  89454. * Compute all node absolute transforms
  89455. * @param forceUpdate defines if computation must be done even if cache is up to date
  89456. */
  89457. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  89458. /**
  89459. * Gets the root pose matrix
  89460. * @returns a matrix
  89461. */
  89462. getPoseMatrix(): Nullable<Matrix>;
  89463. /**
  89464. * Sorts bones per internal index
  89465. */
  89466. sortBones(): void;
  89467. private _sortBones;
  89468. }
  89469. }
  89470. declare module BABYLON {
  89471. /**
  89472. * Creates an instance based on a source mesh.
  89473. */
  89474. export class InstancedMesh extends AbstractMesh {
  89475. private _sourceMesh;
  89476. private _currentLOD;
  89477. /** @hidden */
  89478. _indexInSourceMeshInstanceArray: number;
  89479. constructor(name: string, source: Mesh);
  89480. /**
  89481. * Returns the string "InstancedMesh".
  89482. */
  89483. getClassName(): string;
  89484. /** Gets the list of lights affecting that mesh */
  89485. get lightSources(): Light[];
  89486. _resyncLightSources(): void;
  89487. _resyncLightSource(light: Light): void;
  89488. _removeLightSource(light: Light, dispose: boolean): void;
  89489. /**
  89490. * If the source mesh receives shadows
  89491. */
  89492. get receiveShadows(): boolean;
  89493. /**
  89494. * The material of the source mesh
  89495. */
  89496. get material(): Nullable<Material>;
  89497. /**
  89498. * Visibility of the source mesh
  89499. */
  89500. get visibility(): number;
  89501. /**
  89502. * Skeleton of the source mesh
  89503. */
  89504. get skeleton(): Nullable<Skeleton>;
  89505. /**
  89506. * Rendering ground id of the source mesh
  89507. */
  89508. get renderingGroupId(): number;
  89509. set renderingGroupId(value: number);
  89510. /**
  89511. * Returns the total number of vertices (integer).
  89512. */
  89513. getTotalVertices(): number;
  89514. /**
  89515. * Returns a positive integer : the total number of indices in this mesh geometry.
  89516. * @returns the numner of indices or zero if the mesh has no geometry.
  89517. */
  89518. getTotalIndices(): number;
  89519. /**
  89520. * The source mesh of the instance
  89521. */
  89522. get sourceMesh(): Mesh;
  89523. /**
  89524. * Is this node ready to be used/rendered
  89525. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  89526. * @return {boolean} is it ready
  89527. */
  89528. isReady(completeCheck?: boolean): boolean;
  89529. /**
  89530. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  89531. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  89532. * @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.
  89533. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  89534. */
  89535. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  89536. /**
  89537. * Sets the vertex data of the mesh geometry for the requested `kind`.
  89538. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  89539. * The `data` are either a numeric array either a Float32Array.
  89540. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  89541. * 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).
  89542. * Note that a new underlying VertexBuffer object is created each call.
  89543. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  89544. *
  89545. * Possible `kind` values :
  89546. * - VertexBuffer.PositionKind
  89547. * - VertexBuffer.UVKind
  89548. * - VertexBuffer.UV2Kind
  89549. * - VertexBuffer.UV3Kind
  89550. * - VertexBuffer.UV4Kind
  89551. * - VertexBuffer.UV5Kind
  89552. * - VertexBuffer.UV6Kind
  89553. * - VertexBuffer.ColorKind
  89554. * - VertexBuffer.MatricesIndicesKind
  89555. * - VertexBuffer.MatricesIndicesExtraKind
  89556. * - VertexBuffer.MatricesWeightsKind
  89557. * - VertexBuffer.MatricesWeightsExtraKind
  89558. *
  89559. * Returns the Mesh.
  89560. */
  89561. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  89562. /**
  89563. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  89564. * If the mesh has no geometry, it is simply returned as it is.
  89565. * The `data` are either a numeric array either a Float32Array.
  89566. * No new underlying VertexBuffer object is created.
  89567. * 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.
  89568. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  89569. *
  89570. * Possible `kind` values :
  89571. * - VertexBuffer.PositionKind
  89572. * - VertexBuffer.UVKind
  89573. * - VertexBuffer.UV2Kind
  89574. * - VertexBuffer.UV3Kind
  89575. * - VertexBuffer.UV4Kind
  89576. * - VertexBuffer.UV5Kind
  89577. * - VertexBuffer.UV6Kind
  89578. * - VertexBuffer.ColorKind
  89579. * - VertexBuffer.MatricesIndicesKind
  89580. * - VertexBuffer.MatricesIndicesExtraKind
  89581. * - VertexBuffer.MatricesWeightsKind
  89582. * - VertexBuffer.MatricesWeightsExtraKind
  89583. *
  89584. * Returns the Mesh.
  89585. */
  89586. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  89587. /**
  89588. * Sets the mesh indices.
  89589. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  89590. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  89591. * This method creates a new index buffer each call.
  89592. * Returns the Mesh.
  89593. */
  89594. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  89595. /**
  89596. * Boolean : True if the mesh owns the requested kind of data.
  89597. */
  89598. isVerticesDataPresent(kind: string): boolean;
  89599. /**
  89600. * Returns an array of indices (IndicesArray).
  89601. */
  89602. getIndices(): Nullable<IndicesArray>;
  89603. get _positions(): Nullable<Vector3[]>;
  89604. /**
  89605. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  89606. * This means the mesh underlying bounding box and sphere are recomputed.
  89607. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  89608. * @returns the current mesh
  89609. */
  89610. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  89611. /** @hidden */
  89612. _preActivate(): InstancedMesh;
  89613. /** @hidden */
  89614. _activate(renderId: number, intermediateRendering: boolean): boolean;
  89615. /** @hidden */
  89616. _postActivate(): void;
  89617. getWorldMatrix(): Matrix;
  89618. get isAnInstance(): boolean;
  89619. /**
  89620. * Returns the current associated LOD AbstractMesh.
  89621. */
  89622. getLOD(camera: Camera): AbstractMesh;
  89623. /** @hidden */
  89624. _preActivateForIntermediateRendering(renderId: number): Mesh;
  89625. /** @hidden */
  89626. _syncSubMeshes(): InstancedMesh;
  89627. /** @hidden */
  89628. _generatePointsArray(): boolean;
  89629. /**
  89630. * Creates a new InstancedMesh from the current mesh.
  89631. * - name (string) : the cloned mesh name
  89632. * - newParent (optional Node) : the optional Node to parent the clone to.
  89633. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  89634. *
  89635. * Returns the clone.
  89636. */
  89637. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  89638. /**
  89639. * Disposes the InstancedMesh.
  89640. * Returns nothing.
  89641. */
  89642. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  89643. }
  89644. interface Mesh {
  89645. /**
  89646. * Register a custom buffer that will be instanced
  89647. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  89648. * @param kind defines the buffer kind
  89649. * @param stride defines the stride in floats
  89650. */
  89651. registerInstancedBuffer(kind: string, stride: number): void;
  89652. /** @hidden */
  89653. _userInstancedBuffersStorage: {
  89654. data: {
  89655. [key: string]: Float32Array;
  89656. };
  89657. sizes: {
  89658. [key: string]: number;
  89659. };
  89660. vertexBuffers: {
  89661. [key: string]: Nullable<VertexBuffer>;
  89662. };
  89663. strides: {
  89664. [key: string]: number;
  89665. };
  89666. };
  89667. }
  89668. interface AbstractMesh {
  89669. /**
  89670. * Object used to store instanced buffers defined by user
  89671. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  89672. */
  89673. instancedBuffers: {
  89674. [key: string]: any;
  89675. };
  89676. }
  89677. }
  89678. declare module BABYLON {
  89679. /**
  89680. * Defines the options associated with the creation of a shader material.
  89681. */
  89682. export interface IShaderMaterialOptions {
  89683. /**
  89684. * Does the material work in alpha blend mode
  89685. */
  89686. needAlphaBlending: boolean;
  89687. /**
  89688. * Does the material work in alpha test mode
  89689. */
  89690. needAlphaTesting: boolean;
  89691. /**
  89692. * The list of attribute names used in the shader
  89693. */
  89694. attributes: string[];
  89695. /**
  89696. * The list of unifrom names used in the shader
  89697. */
  89698. uniforms: string[];
  89699. /**
  89700. * The list of UBO names used in the shader
  89701. */
  89702. uniformBuffers: string[];
  89703. /**
  89704. * The list of sampler names used in the shader
  89705. */
  89706. samplers: string[];
  89707. /**
  89708. * The list of defines used in the shader
  89709. */
  89710. defines: string[];
  89711. }
  89712. /**
  89713. * 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.
  89714. *
  89715. * This returned material effects how the mesh will look based on the code in the shaders.
  89716. *
  89717. * @see http://doc.babylonjs.com/how_to/shader_material
  89718. */
  89719. export class ShaderMaterial extends Material {
  89720. private _shaderPath;
  89721. private _options;
  89722. private _textures;
  89723. private _textureArrays;
  89724. private _floats;
  89725. private _ints;
  89726. private _floatsArrays;
  89727. private _colors3;
  89728. private _colors3Arrays;
  89729. private _colors4;
  89730. private _colors4Arrays;
  89731. private _vectors2;
  89732. private _vectors3;
  89733. private _vectors4;
  89734. private _matrices;
  89735. private _matrixArrays;
  89736. private _matrices3x3;
  89737. private _matrices2x2;
  89738. private _vectors2Arrays;
  89739. private _vectors3Arrays;
  89740. private _vectors4Arrays;
  89741. private _cachedWorldViewMatrix;
  89742. private _cachedWorldViewProjectionMatrix;
  89743. private _renderId;
  89744. private _multiview;
  89745. /**
  89746. * Instantiate a new shader material.
  89747. * 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.
  89748. * This returned material effects how the mesh will look based on the code in the shaders.
  89749. * @see http://doc.babylonjs.com/how_to/shader_material
  89750. * @param name Define the name of the material in the scene
  89751. * @param scene Define the scene the material belongs to
  89752. * @param shaderPath Defines the route to the shader code in one of three ways:
  89753. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  89754. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  89755. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  89756. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  89757. * @param options Define the options used to create the shader
  89758. */
  89759. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  89760. /**
  89761. * Gets the shader path used to define the shader code
  89762. * It can be modified to trigger a new compilation
  89763. */
  89764. get shaderPath(): any;
  89765. /**
  89766. * Sets the shader path used to define the shader code
  89767. * It can be modified to trigger a new compilation
  89768. */
  89769. set shaderPath(shaderPath: any);
  89770. /**
  89771. * Gets the options used to compile the shader.
  89772. * They can be modified to trigger a new compilation
  89773. */
  89774. get options(): IShaderMaterialOptions;
  89775. /**
  89776. * Gets the current class name of the material e.g. "ShaderMaterial"
  89777. * Mainly use in serialization.
  89778. * @returns the class name
  89779. */
  89780. getClassName(): string;
  89781. /**
  89782. * Specifies if the material will require alpha blending
  89783. * @returns a boolean specifying if alpha blending is needed
  89784. */
  89785. needAlphaBlending(): boolean;
  89786. /**
  89787. * Specifies if this material should be rendered in alpha test mode
  89788. * @returns a boolean specifying if an alpha test is needed.
  89789. */
  89790. needAlphaTesting(): boolean;
  89791. private _checkUniform;
  89792. /**
  89793. * Set a texture in the shader.
  89794. * @param name Define the name of the uniform samplers as defined in the shader
  89795. * @param texture Define the texture to bind to this sampler
  89796. * @return the material itself allowing "fluent" like uniform updates
  89797. */
  89798. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  89799. /**
  89800. * Set a texture array in the shader.
  89801. * @param name Define the name of the uniform sampler array as defined in the shader
  89802. * @param textures Define the list of textures to bind to this sampler
  89803. * @return the material itself allowing "fluent" like uniform updates
  89804. */
  89805. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  89806. /**
  89807. * Set a float in the shader.
  89808. * @param name Define the name of the uniform as defined in the shader
  89809. * @param value Define the value to give to the uniform
  89810. * @return the material itself allowing "fluent" like uniform updates
  89811. */
  89812. setFloat(name: string, value: number): ShaderMaterial;
  89813. /**
  89814. * Set a int in the shader.
  89815. * @param name Define the name of the uniform as defined in the shader
  89816. * @param value Define the value to give to the uniform
  89817. * @return the material itself allowing "fluent" like uniform updates
  89818. */
  89819. setInt(name: string, value: number): ShaderMaterial;
  89820. /**
  89821. * Set an array of floats 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. setFloats(name: string, value: number[]): ShaderMaterial;
  89827. /**
  89828. * Set a vec3 in the shader from a Color3.
  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. setColor3(name: string, value: Color3): ShaderMaterial;
  89834. /**
  89835. * Set a vec3 array in the shader from a Color3 array.
  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. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  89841. /**
  89842. * Set a vec4 in the shader from a Color4.
  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. setColor4(name: string, value: Color4): ShaderMaterial;
  89848. /**
  89849. * Set a vec4 array in the shader from a Color4 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. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  89855. /**
  89856. * Set a vec2 in the shader from a Vector2.
  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. setVector2(name: string, value: Vector2): ShaderMaterial;
  89862. /**
  89863. * Set a vec3 in the shader from a Vector3.
  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. setVector3(name: string, value: Vector3): ShaderMaterial;
  89869. /**
  89870. * Set a vec4 in the shader from a Vector4.
  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. setVector4(name: string, value: Vector4): ShaderMaterial;
  89876. /**
  89877. * Set a mat4 in the shader from a Matrix.
  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. setMatrix(name: string, value: Matrix): ShaderMaterial;
  89883. /**
  89884. * Set a float32Array in the shader from a matrix array.
  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. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  89890. /**
  89891. * Set a mat3 in the shader from a Float32Array.
  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. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  89897. /**
  89898. * Set a mat2 in the shader from a Float32Array.
  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. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  89904. /**
  89905. * Set a vec2 array in the shader from a number array.
  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. setArray2(name: string, value: number[]): ShaderMaterial;
  89911. /**
  89912. * Set a vec3 array in the shader from a number array.
  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. setArray3(name: string, value: number[]): ShaderMaterial;
  89918. /**
  89919. * Set a vec4 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. setArray4(name: string, value: number[]): ShaderMaterial;
  89925. private _checkCache;
  89926. /**
  89927. * Specifies that the submesh is ready to be used
  89928. * @param mesh defines the mesh to check
  89929. * @param subMesh defines which submesh to check
  89930. * @param useInstances specifies that instances should be used
  89931. * @returns a boolean indicating that the submesh is ready or not
  89932. */
  89933. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  89934. /**
  89935. * Checks if the material is ready to render the requested mesh
  89936. * @param mesh Define the mesh to render
  89937. * @param useInstances Define whether or not the material is used with instances
  89938. * @returns true if ready, otherwise false
  89939. */
  89940. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  89941. /**
  89942. * Binds the world matrix to the material
  89943. * @param world defines the world transformation matrix
  89944. */
  89945. bindOnlyWorldMatrix(world: Matrix): void;
  89946. /**
  89947. * Binds the material to the mesh
  89948. * @param world defines the world transformation matrix
  89949. * @param mesh defines the mesh to bind the material to
  89950. */
  89951. bind(world: Matrix, mesh?: Mesh): void;
  89952. /**
  89953. * Gets the active textures from the material
  89954. * @returns an array of textures
  89955. */
  89956. getActiveTextures(): BaseTexture[];
  89957. /**
  89958. * Specifies if the material uses a texture
  89959. * @param texture defines the texture to check against the material
  89960. * @returns a boolean specifying if the material uses the texture
  89961. */
  89962. hasTexture(texture: BaseTexture): boolean;
  89963. /**
  89964. * Makes a duplicate of the material, and gives it a new name
  89965. * @param name defines the new name for the duplicated material
  89966. * @returns the cloned material
  89967. */
  89968. clone(name: string): ShaderMaterial;
  89969. /**
  89970. * Disposes the material
  89971. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  89972. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  89973. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  89974. */
  89975. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  89976. /**
  89977. * Serializes this material in a JSON representation
  89978. * @returns the serialized material object
  89979. */
  89980. serialize(): any;
  89981. /**
  89982. * Creates a shader material from parsed shader material data
  89983. * @param source defines the JSON represnetation of the material
  89984. * @param scene defines the hosting scene
  89985. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  89986. * @returns a new material
  89987. */
  89988. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  89989. }
  89990. }
  89991. declare module BABYLON {
  89992. /** @hidden */
  89993. export var colorPixelShader: {
  89994. name: string;
  89995. shader: string;
  89996. };
  89997. }
  89998. declare module BABYLON {
  89999. /** @hidden */
  90000. export var colorVertexShader: {
  90001. name: string;
  90002. shader: string;
  90003. };
  90004. }
  90005. declare module BABYLON {
  90006. /**
  90007. * Line mesh
  90008. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  90009. */
  90010. export class LinesMesh extends Mesh {
  90011. /**
  90012. * If vertex color should be applied to the mesh
  90013. */
  90014. readonly useVertexColor?: boolean | undefined;
  90015. /**
  90016. * If vertex alpha should be applied to the mesh
  90017. */
  90018. readonly useVertexAlpha?: boolean | undefined;
  90019. /**
  90020. * Color of the line (Default: White)
  90021. */
  90022. color: Color3;
  90023. /**
  90024. * Alpha of the line (Default: 1)
  90025. */
  90026. alpha: number;
  90027. /**
  90028. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  90029. * This margin is expressed in world space coordinates, so its value may vary.
  90030. * Default value is 0.1
  90031. */
  90032. intersectionThreshold: number;
  90033. private _colorShader;
  90034. private color4;
  90035. /**
  90036. * Creates a new LinesMesh
  90037. * @param name defines the name
  90038. * @param scene defines the hosting scene
  90039. * @param parent defines the parent mesh if any
  90040. * @param source defines the optional source LinesMesh used to clone data from
  90041. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  90042. * When false, achieved by calling a clone(), also passing False.
  90043. * This will make creation of children, recursive.
  90044. * @param useVertexColor defines if this LinesMesh supports vertex color
  90045. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  90046. */
  90047. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  90048. /**
  90049. * If vertex color should be applied to the mesh
  90050. */
  90051. useVertexColor?: boolean | undefined,
  90052. /**
  90053. * If vertex alpha should be applied to the mesh
  90054. */
  90055. useVertexAlpha?: boolean | undefined);
  90056. private _addClipPlaneDefine;
  90057. private _removeClipPlaneDefine;
  90058. isReady(): boolean;
  90059. /**
  90060. * Returns the string "LineMesh"
  90061. */
  90062. getClassName(): string;
  90063. /**
  90064. * @hidden
  90065. */
  90066. get material(): Material;
  90067. /**
  90068. * @hidden
  90069. */
  90070. set material(value: Material);
  90071. /**
  90072. * @hidden
  90073. */
  90074. get checkCollisions(): boolean;
  90075. /** @hidden */
  90076. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  90077. /** @hidden */
  90078. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  90079. /**
  90080. * Disposes of the line mesh
  90081. * @param doNotRecurse If children should be disposed
  90082. */
  90083. dispose(doNotRecurse?: boolean): void;
  90084. /**
  90085. * Returns a new LineMesh object cloned from the current one.
  90086. */
  90087. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  90088. /**
  90089. * Creates a new InstancedLinesMesh object from the mesh model.
  90090. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  90091. * @param name defines the name of the new instance
  90092. * @returns a new InstancedLinesMesh
  90093. */
  90094. createInstance(name: string): InstancedLinesMesh;
  90095. }
  90096. /**
  90097. * Creates an instance based on a source LinesMesh
  90098. */
  90099. export class InstancedLinesMesh extends InstancedMesh {
  90100. /**
  90101. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  90102. * This margin is expressed in world space coordinates, so its value may vary.
  90103. * Initilized with the intersectionThreshold value of the source LinesMesh
  90104. */
  90105. intersectionThreshold: number;
  90106. constructor(name: string, source: LinesMesh);
  90107. /**
  90108. * Returns the string "InstancedLinesMesh".
  90109. */
  90110. getClassName(): string;
  90111. }
  90112. }
  90113. declare module BABYLON {
  90114. /** @hidden */
  90115. export var linePixelShader: {
  90116. name: string;
  90117. shader: string;
  90118. };
  90119. }
  90120. declare module BABYLON {
  90121. /** @hidden */
  90122. export var lineVertexShader: {
  90123. name: string;
  90124. shader: string;
  90125. };
  90126. }
  90127. declare module BABYLON {
  90128. interface AbstractMesh {
  90129. /**
  90130. * Gets the edgesRenderer associated with the mesh
  90131. */
  90132. edgesRenderer: Nullable<EdgesRenderer>;
  90133. }
  90134. interface LinesMesh {
  90135. /**
  90136. * Enables the edge rendering mode on the mesh.
  90137. * This mode makes the mesh edges visible
  90138. * @param epsilon defines the maximal distance between two angles to detect a face
  90139. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  90140. * @returns the currentAbstractMesh
  90141. * @see https://www.babylonjs-playground.com/#19O9TU#0
  90142. */
  90143. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  90144. }
  90145. interface InstancedLinesMesh {
  90146. /**
  90147. * Enables the edge rendering mode on the mesh.
  90148. * This mode makes the mesh edges visible
  90149. * @param epsilon defines the maximal distance between two angles to detect a face
  90150. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  90151. * @returns the current InstancedLinesMesh
  90152. * @see https://www.babylonjs-playground.com/#19O9TU#0
  90153. */
  90154. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  90155. }
  90156. /**
  90157. * Defines the minimum contract an Edges renderer should follow.
  90158. */
  90159. export interface IEdgesRenderer extends IDisposable {
  90160. /**
  90161. * Gets or sets a boolean indicating if the edgesRenderer is active
  90162. */
  90163. isEnabled: boolean;
  90164. /**
  90165. * Renders the edges of the attached mesh,
  90166. */
  90167. render(): void;
  90168. /**
  90169. * Checks wether or not the edges renderer is ready to render.
  90170. * @return true if ready, otherwise false.
  90171. */
  90172. isReady(): boolean;
  90173. }
  90174. /**
  90175. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  90176. */
  90177. export class EdgesRenderer implements IEdgesRenderer {
  90178. /**
  90179. * Define the size of the edges with an orthographic camera
  90180. */
  90181. edgesWidthScalerForOrthographic: number;
  90182. /**
  90183. * Define the size of the edges with a perspective camera
  90184. */
  90185. edgesWidthScalerForPerspective: number;
  90186. protected _source: AbstractMesh;
  90187. protected _linesPositions: number[];
  90188. protected _linesNormals: number[];
  90189. protected _linesIndices: number[];
  90190. protected _epsilon: number;
  90191. protected _indicesCount: number;
  90192. protected _lineShader: ShaderMaterial;
  90193. protected _ib: DataBuffer;
  90194. protected _buffers: {
  90195. [key: string]: Nullable<VertexBuffer>;
  90196. };
  90197. protected _checkVerticesInsteadOfIndices: boolean;
  90198. private _meshRebuildObserver;
  90199. private _meshDisposeObserver;
  90200. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  90201. isEnabled: boolean;
  90202. /**
  90203. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  90204. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  90205. * @param source Mesh used to create edges
  90206. * @param epsilon sum of angles in adjacency to check for edge
  90207. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  90208. * @param generateEdgesLines - should generate Lines or only prepare resources.
  90209. */
  90210. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  90211. protected _prepareRessources(): void;
  90212. /** @hidden */
  90213. _rebuild(): void;
  90214. /**
  90215. * Releases the required resources for the edges renderer
  90216. */
  90217. dispose(): void;
  90218. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  90219. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  90220. /**
  90221. * Checks if the pair of p0 and p1 is en edge
  90222. * @param faceIndex
  90223. * @param edge
  90224. * @param faceNormals
  90225. * @param p0
  90226. * @param p1
  90227. * @private
  90228. */
  90229. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  90230. /**
  90231. * push line into the position, normal and index buffer
  90232. * @protected
  90233. */
  90234. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  90235. /**
  90236. * Generates lines edges from adjacencjes
  90237. * @private
  90238. */
  90239. _generateEdgesLines(): void;
  90240. /**
  90241. * Checks wether or not the edges renderer is ready to render.
  90242. * @return true if ready, otherwise false.
  90243. */
  90244. isReady(): boolean;
  90245. /**
  90246. * Renders the edges of the attached mesh,
  90247. */
  90248. render(): void;
  90249. }
  90250. /**
  90251. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  90252. */
  90253. export class LineEdgesRenderer extends EdgesRenderer {
  90254. /**
  90255. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  90256. * @param source LineMesh used to generate edges
  90257. * @param epsilon not important (specified angle for edge detection)
  90258. * @param checkVerticesInsteadOfIndices not important for LineMesh
  90259. */
  90260. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  90261. /**
  90262. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  90263. */
  90264. _generateEdgesLines(): void;
  90265. }
  90266. }
  90267. declare module BABYLON {
  90268. /**
  90269. * This represents the object necessary to create a rendering group.
  90270. * This is exclusively used and created by the rendering manager.
  90271. * To modify the behavior, you use the available helpers in your scene or meshes.
  90272. * @hidden
  90273. */
  90274. export class RenderingGroup {
  90275. index: number;
  90276. private static _zeroVector;
  90277. private _scene;
  90278. private _opaqueSubMeshes;
  90279. private _transparentSubMeshes;
  90280. private _alphaTestSubMeshes;
  90281. private _depthOnlySubMeshes;
  90282. private _particleSystems;
  90283. private _spriteManagers;
  90284. private _opaqueSortCompareFn;
  90285. private _alphaTestSortCompareFn;
  90286. private _transparentSortCompareFn;
  90287. private _renderOpaque;
  90288. private _renderAlphaTest;
  90289. private _renderTransparent;
  90290. /** @hidden */
  90291. _edgesRenderers: SmartArray<IEdgesRenderer>;
  90292. onBeforeTransparentRendering: () => void;
  90293. /**
  90294. * Set the opaque sort comparison function.
  90295. * If null the sub meshes will be render in the order they were created
  90296. */
  90297. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  90298. /**
  90299. * Set the alpha test sort comparison function.
  90300. * If null the sub meshes will be render in the order they were created
  90301. */
  90302. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  90303. /**
  90304. * Set the transparent sort comparison function.
  90305. * If null the sub meshes will be render in the order they were created
  90306. */
  90307. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  90308. /**
  90309. * Creates a new rendering group.
  90310. * @param index The rendering group index
  90311. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  90312. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  90313. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  90314. */
  90315. 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>);
  90316. /**
  90317. * Render all the sub meshes contained in the group.
  90318. * @param customRenderFunction Used to override the default render behaviour of the group.
  90319. * @returns true if rendered some submeshes.
  90320. */
  90321. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  90322. /**
  90323. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  90324. * @param subMeshes The submeshes to render
  90325. */
  90326. private renderOpaqueSorted;
  90327. /**
  90328. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  90329. * @param subMeshes The submeshes to render
  90330. */
  90331. private renderAlphaTestSorted;
  90332. /**
  90333. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  90334. * @param subMeshes The submeshes to render
  90335. */
  90336. private renderTransparentSorted;
  90337. /**
  90338. * Renders the submeshes in a specified order.
  90339. * @param subMeshes The submeshes to sort before render
  90340. * @param sortCompareFn The comparison function use to sort
  90341. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  90342. * @param transparent Specifies to activate blending if true
  90343. */
  90344. private static renderSorted;
  90345. /**
  90346. * Renders the submeshes in the order they were dispatched (no sort applied).
  90347. * @param subMeshes The submeshes to render
  90348. */
  90349. private static renderUnsorted;
  90350. /**
  90351. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  90352. * are rendered back to front if in the same alpha index.
  90353. *
  90354. * @param a The first submesh
  90355. * @param b The second submesh
  90356. * @returns The result of the comparison
  90357. */
  90358. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  90359. /**
  90360. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  90361. * are rendered back to front.
  90362. *
  90363. * @param a The first submesh
  90364. * @param b The second submesh
  90365. * @returns The result of the comparison
  90366. */
  90367. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  90368. /**
  90369. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  90370. * are rendered front to back (prevent overdraw).
  90371. *
  90372. * @param a The first submesh
  90373. * @param b The second submesh
  90374. * @returns The result of the comparison
  90375. */
  90376. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  90377. /**
  90378. * Resets the different lists of submeshes to prepare a new frame.
  90379. */
  90380. prepare(): void;
  90381. dispose(): void;
  90382. /**
  90383. * Inserts the submesh in its correct queue depending on its material.
  90384. * @param subMesh The submesh to dispatch
  90385. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  90386. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  90387. */
  90388. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  90389. dispatchSprites(spriteManager: ISpriteManager): void;
  90390. dispatchParticles(particleSystem: IParticleSystem): void;
  90391. private _renderParticles;
  90392. private _renderSprites;
  90393. }
  90394. }
  90395. declare module BABYLON {
  90396. /**
  90397. * Interface describing the different options available in the rendering manager
  90398. * regarding Auto Clear between groups.
  90399. */
  90400. export interface IRenderingManagerAutoClearSetup {
  90401. /**
  90402. * Defines whether or not autoclear is enable.
  90403. */
  90404. autoClear: boolean;
  90405. /**
  90406. * Defines whether or not to autoclear the depth buffer.
  90407. */
  90408. depth: boolean;
  90409. /**
  90410. * Defines whether or not to autoclear the stencil buffer.
  90411. */
  90412. stencil: boolean;
  90413. }
  90414. /**
  90415. * This class is used by the onRenderingGroupObservable
  90416. */
  90417. export class RenderingGroupInfo {
  90418. /**
  90419. * The Scene that being rendered
  90420. */
  90421. scene: Scene;
  90422. /**
  90423. * The camera currently used for the rendering pass
  90424. */
  90425. camera: Nullable<Camera>;
  90426. /**
  90427. * The ID of the renderingGroup being processed
  90428. */
  90429. renderingGroupId: number;
  90430. }
  90431. /**
  90432. * This is the manager responsible of all the rendering for meshes sprites and particles.
  90433. * It is enable to manage the different groups as well as the different necessary sort functions.
  90434. * This should not be used directly aside of the few static configurations
  90435. */
  90436. export class RenderingManager {
  90437. /**
  90438. * The max id used for rendering groups (not included)
  90439. */
  90440. static MAX_RENDERINGGROUPS: number;
  90441. /**
  90442. * The min id used for rendering groups (included)
  90443. */
  90444. static MIN_RENDERINGGROUPS: number;
  90445. /**
  90446. * Used to globally prevent autoclearing scenes.
  90447. */
  90448. static AUTOCLEAR: boolean;
  90449. /**
  90450. * @hidden
  90451. */
  90452. _useSceneAutoClearSetup: boolean;
  90453. private _scene;
  90454. private _renderingGroups;
  90455. private _depthStencilBufferAlreadyCleaned;
  90456. private _autoClearDepthStencil;
  90457. private _customOpaqueSortCompareFn;
  90458. private _customAlphaTestSortCompareFn;
  90459. private _customTransparentSortCompareFn;
  90460. private _renderingGroupInfo;
  90461. /**
  90462. * Instantiates a new rendering group for a particular scene
  90463. * @param scene Defines the scene the groups belongs to
  90464. */
  90465. constructor(scene: Scene);
  90466. private _clearDepthStencilBuffer;
  90467. /**
  90468. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  90469. * @hidden
  90470. */
  90471. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  90472. /**
  90473. * Resets the different information of the group to prepare a new frame
  90474. * @hidden
  90475. */
  90476. reset(): void;
  90477. /**
  90478. * Dispose and release the group and its associated resources.
  90479. * @hidden
  90480. */
  90481. dispose(): void;
  90482. /**
  90483. * Clear the info related to rendering groups preventing retention points during dispose.
  90484. */
  90485. freeRenderingGroups(): void;
  90486. private _prepareRenderingGroup;
  90487. /**
  90488. * Add a sprite manager to the rendering manager in order to render it this frame.
  90489. * @param spriteManager Define the sprite manager to render
  90490. */
  90491. dispatchSprites(spriteManager: ISpriteManager): void;
  90492. /**
  90493. * Add a particle system to the rendering manager in order to render it this frame.
  90494. * @param particleSystem Define the particle system to render
  90495. */
  90496. dispatchParticles(particleSystem: IParticleSystem): void;
  90497. /**
  90498. * Add a submesh to the manager in order to render it this frame
  90499. * @param subMesh The submesh to dispatch
  90500. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  90501. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  90502. */
  90503. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  90504. /**
  90505. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  90506. * This allowed control for front to back rendering or reversly depending of the special needs.
  90507. *
  90508. * @param renderingGroupId The rendering group id corresponding to its index
  90509. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  90510. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  90511. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  90512. */
  90513. 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;
  90514. /**
  90515. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  90516. *
  90517. * @param renderingGroupId The rendering group id corresponding to its index
  90518. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  90519. * @param depth Automatically clears depth between groups if true and autoClear is true.
  90520. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  90521. */
  90522. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  90523. /**
  90524. * Gets the current auto clear configuration for one rendering group of the rendering
  90525. * manager.
  90526. * @param index the rendering group index to get the information for
  90527. * @returns The auto clear setup for the requested rendering group
  90528. */
  90529. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  90530. }
  90531. }
  90532. declare module BABYLON {
  90533. /**
  90534. * Defines the options associated with the creation of a custom shader for a shadow generator.
  90535. */
  90536. export interface ICustomShaderOptions {
  90537. /**
  90538. * Gets or sets the custom shader name to use
  90539. */
  90540. shaderName: string;
  90541. /**
  90542. * The list of attribute names used in the shader
  90543. */
  90544. attributes?: string[];
  90545. /**
  90546. * The list of unifrom names used in the shader
  90547. */
  90548. uniforms?: string[];
  90549. /**
  90550. * The list of sampler names used in the shader
  90551. */
  90552. samplers?: string[];
  90553. /**
  90554. * The list of defines used in the shader
  90555. */
  90556. defines?: string[];
  90557. }
  90558. /**
  90559. * Interface to implement to create a shadow generator compatible with BJS.
  90560. */
  90561. export interface IShadowGenerator {
  90562. /**
  90563. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  90564. * @returns The render target texture if present otherwise, null
  90565. */
  90566. getShadowMap(): Nullable<RenderTargetTexture>;
  90567. /**
  90568. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  90569. * @param subMesh The submesh we want to render in the shadow map
  90570. * @param useInstances Defines wether will draw in the map using instances
  90571. * @returns true if ready otherwise, false
  90572. */
  90573. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  90574. /**
  90575. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  90576. * @param defines Defines of the material we want to update
  90577. * @param lightIndex Index of the light in the enabled light list of the material
  90578. */
  90579. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  90580. /**
  90581. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  90582. * defined in the generator but impacting the effect).
  90583. * It implies the unifroms available on the materials are the standard BJS ones.
  90584. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  90585. * @param effect The effect we are binfing the information for
  90586. */
  90587. bindShadowLight(lightIndex: string, effect: Effect): void;
  90588. /**
  90589. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  90590. * (eq to shadow prjection matrix * light transform matrix)
  90591. * @returns The transform matrix used to create the shadow map
  90592. */
  90593. getTransformMatrix(): Matrix;
  90594. /**
  90595. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  90596. * Cube and 2D textures for instance.
  90597. */
  90598. recreateShadowMap(): void;
  90599. /**
  90600. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  90601. * @param onCompiled Callback triggered at the and of the effects compilation
  90602. * @param options Sets of optional options forcing the compilation with different modes
  90603. */
  90604. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  90605. useInstances: boolean;
  90606. }>): void;
  90607. /**
  90608. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  90609. * @param options Sets of optional options forcing the compilation with different modes
  90610. * @returns A promise that resolves when the compilation completes
  90611. */
  90612. forceCompilationAsync(options?: Partial<{
  90613. useInstances: boolean;
  90614. }>): Promise<void>;
  90615. /**
  90616. * Serializes the shadow generator setup to a json object.
  90617. * @returns The serialized JSON object
  90618. */
  90619. serialize(): any;
  90620. /**
  90621. * Disposes the Shadow map and related Textures and effects.
  90622. */
  90623. dispose(): void;
  90624. }
  90625. /**
  90626. * Default implementation IShadowGenerator.
  90627. * This is the main object responsible of generating shadows in the framework.
  90628. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  90629. */
  90630. export class ShadowGenerator implements IShadowGenerator {
  90631. /**
  90632. * Name of the shadow generator class
  90633. */
  90634. static CLASSNAME: string;
  90635. /**
  90636. * Shadow generator mode None: no filtering applied.
  90637. */
  90638. static readonly FILTER_NONE: number;
  90639. /**
  90640. * Shadow generator mode ESM: Exponential Shadow Mapping.
  90641. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  90642. */
  90643. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  90644. /**
  90645. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  90646. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  90647. */
  90648. static readonly FILTER_POISSONSAMPLING: number;
  90649. /**
  90650. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  90651. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  90652. */
  90653. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  90654. /**
  90655. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  90656. * edge artifacts on steep falloff.
  90657. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  90658. */
  90659. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  90660. /**
  90661. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  90662. * edge artifacts on steep falloff.
  90663. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  90664. */
  90665. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  90666. /**
  90667. * Shadow generator mode PCF: Percentage Closer Filtering
  90668. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  90669. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  90670. */
  90671. static readonly FILTER_PCF: number;
  90672. /**
  90673. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  90674. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  90675. * Contact Hardening
  90676. */
  90677. static readonly FILTER_PCSS: number;
  90678. /**
  90679. * Reserved for PCF and PCSS
  90680. * Highest Quality.
  90681. *
  90682. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  90683. *
  90684. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  90685. */
  90686. static readonly QUALITY_HIGH: number;
  90687. /**
  90688. * Reserved for PCF and PCSS
  90689. * Good tradeoff for quality/perf cross devices
  90690. *
  90691. * Execute PCF on a 3*3 kernel.
  90692. *
  90693. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  90694. */
  90695. static readonly QUALITY_MEDIUM: number;
  90696. /**
  90697. * Reserved for PCF and PCSS
  90698. * The lowest quality but the fastest.
  90699. *
  90700. * Execute PCF on a 1*1 kernel.
  90701. *
  90702. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  90703. */
  90704. static readonly QUALITY_LOW: number;
  90705. /** Gets or sets the custom shader name to use */
  90706. customShaderOptions: ICustomShaderOptions;
  90707. /**
  90708. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  90709. */
  90710. onBeforeShadowMapRenderObservable: Observable<Effect>;
  90711. /**
  90712. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  90713. */
  90714. onAfterShadowMapRenderObservable: Observable<Effect>;
  90715. /**
  90716. * Observable triggered before a mesh is rendered in the shadow map.
  90717. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  90718. */
  90719. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  90720. /**
  90721. * Observable triggered after a mesh is rendered in the shadow map.
  90722. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  90723. */
  90724. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  90725. protected _bias: number;
  90726. /**
  90727. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  90728. */
  90729. get bias(): number;
  90730. /**
  90731. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  90732. */
  90733. set bias(bias: number);
  90734. protected _normalBias: number;
  90735. /**
  90736. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  90737. */
  90738. get normalBias(): number;
  90739. /**
  90740. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  90741. */
  90742. set normalBias(normalBias: number);
  90743. protected _blurBoxOffset: number;
  90744. /**
  90745. * Gets the blur box offset: offset applied during the blur pass.
  90746. * Only useful if useKernelBlur = false
  90747. */
  90748. get blurBoxOffset(): number;
  90749. /**
  90750. * Sets the blur box offset: offset applied during the blur pass.
  90751. * Only useful if useKernelBlur = false
  90752. */
  90753. set blurBoxOffset(value: number);
  90754. protected _blurScale: number;
  90755. /**
  90756. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  90757. * 2 means half of the size.
  90758. */
  90759. get blurScale(): number;
  90760. /**
  90761. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  90762. * 2 means half of the size.
  90763. */
  90764. set blurScale(value: number);
  90765. protected _blurKernel: number;
  90766. /**
  90767. * Gets the blur kernel: kernel size of the blur pass.
  90768. * Only useful if useKernelBlur = true
  90769. */
  90770. get blurKernel(): number;
  90771. /**
  90772. * Sets the blur kernel: kernel size of the blur pass.
  90773. * Only useful if useKernelBlur = true
  90774. */
  90775. set blurKernel(value: number);
  90776. protected _useKernelBlur: boolean;
  90777. /**
  90778. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  90779. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  90780. */
  90781. get useKernelBlur(): boolean;
  90782. /**
  90783. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  90784. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  90785. */
  90786. set useKernelBlur(value: boolean);
  90787. protected _depthScale: number;
  90788. /**
  90789. * Gets the depth scale used in ESM mode.
  90790. */
  90791. get depthScale(): number;
  90792. /**
  90793. * Sets the depth scale used in ESM mode.
  90794. * This can override the scale stored on the light.
  90795. */
  90796. set depthScale(value: number);
  90797. protected _validateFilter(filter: number): number;
  90798. protected _filter: number;
  90799. /**
  90800. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  90801. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  90802. */
  90803. get filter(): number;
  90804. /**
  90805. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  90806. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  90807. */
  90808. set filter(value: number);
  90809. /**
  90810. * Gets if the current filter is set to Poisson Sampling.
  90811. */
  90812. get usePoissonSampling(): boolean;
  90813. /**
  90814. * Sets the current filter to Poisson Sampling.
  90815. */
  90816. set usePoissonSampling(value: boolean);
  90817. /**
  90818. * Gets if the current filter is set to ESM.
  90819. */
  90820. get useExponentialShadowMap(): boolean;
  90821. /**
  90822. * Sets the current filter is to ESM.
  90823. */
  90824. set useExponentialShadowMap(value: boolean);
  90825. /**
  90826. * Gets if the current filter is set to filtered ESM.
  90827. */
  90828. get useBlurExponentialShadowMap(): boolean;
  90829. /**
  90830. * Gets if the current filter is set to filtered ESM.
  90831. */
  90832. set useBlurExponentialShadowMap(value: boolean);
  90833. /**
  90834. * Gets if the current filter is set to "close ESM" (using the inverse of the
  90835. * exponential to prevent steep falloff artifacts).
  90836. */
  90837. get useCloseExponentialShadowMap(): boolean;
  90838. /**
  90839. * Sets the current filter to "close ESM" (using the inverse of the
  90840. * exponential to prevent steep falloff artifacts).
  90841. */
  90842. set useCloseExponentialShadowMap(value: boolean);
  90843. /**
  90844. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  90845. * exponential to prevent steep falloff artifacts).
  90846. */
  90847. get useBlurCloseExponentialShadowMap(): boolean;
  90848. /**
  90849. * Sets the current filter to filtered "close ESM" (using the inverse of the
  90850. * exponential to prevent steep falloff artifacts).
  90851. */
  90852. set useBlurCloseExponentialShadowMap(value: boolean);
  90853. /**
  90854. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  90855. */
  90856. get usePercentageCloserFiltering(): boolean;
  90857. /**
  90858. * Sets the current filter to "PCF" (percentage closer filtering).
  90859. */
  90860. set usePercentageCloserFiltering(value: boolean);
  90861. protected _filteringQuality: number;
  90862. /**
  90863. * Gets the PCF or PCSS Quality.
  90864. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  90865. */
  90866. get filteringQuality(): number;
  90867. /**
  90868. * Sets the PCF or PCSS Quality.
  90869. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  90870. */
  90871. set filteringQuality(filteringQuality: number);
  90872. /**
  90873. * Gets if the current filter is set to "PCSS" (contact hardening).
  90874. */
  90875. get useContactHardeningShadow(): boolean;
  90876. /**
  90877. * Sets the current filter to "PCSS" (contact hardening).
  90878. */
  90879. set useContactHardeningShadow(value: boolean);
  90880. protected _contactHardeningLightSizeUVRatio: number;
  90881. /**
  90882. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  90883. * Using a ratio helps keeping shape stability independently of the map size.
  90884. *
  90885. * It does not account for the light projection as it was having too much
  90886. * instability during the light setup or during light position changes.
  90887. *
  90888. * Only valid if useContactHardeningShadow is true.
  90889. */
  90890. get contactHardeningLightSizeUVRatio(): number;
  90891. /**
  90892. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  90893. * Using a ratio helps keeping shape stability independently of the map size.
  90894. *
  90895. * It does not account for the light projection as it was having too much
  90896. * instability during the light setup or during light position changes.
  90897. *
  90898. * Only valid if useContactHardeningShadow is true.
  90899. */
  90900. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  90901. protected _darkness: number;
  90902. /** Gets or sets the actual darkness of a shadow */
  90903. get darkness(): number;
  90904. set darkness(value: number);
  90905. /**
  90906. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  90907. * 0 means strongest and 1 would means no shadow.
  90908. * @returns the darkness.
  90909. */
  90910. getDarkness(): number;
  90911. /**
  90912. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  90913. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  90914. * @returns the shadow generator allowing fluent coding.
  90915. */
  90916. setDarkness(darkness: number): ShadowGenerator;
  90917. protected _transparencyShadow: boolean;
  90918. /** Gets or sets the ability to have transparent shadow */
  90919. get transparencyShadow(): boolean;
  90920. set transparencyShadow(value: boolean);
  90921. /**
  90922. * Sets the ability to have transparent shadow (boolean).
  90923. * @param transparent True if transparent else False
  90924. * @returns the shadow generator allowing fluent coding
  90925. */
  90926. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  90927. protected _shadowMap: Nullable<RenderTargetTexture>;
  90928. protected _shadowMap2: Nullable<RenderTargetTexture>;
  90929. /**
  90930. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  90931. * @returns The render target texture if present otherwise, null
  90932. */
  90933. getShadowMap(): Nullable<RenderTargetTexture>;
  90934. /**
  90935. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  90936. * @returns The render target texture if the shadow map is present otherwise, null
  90937. */
  90938. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  90939. /**
  90940. * Gets the class name of that object
  90941. * @returns "ShadowGenerator"
  90942. */
  90943. getClassName(): string;
  90944. /**
  90945. * Helper function to add a mesh and its descendants to the list of shadow casters.
  90946. * @param mesh Mesh to add
  90947. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  90948. * @returns the Shadow Generator itself
  90949. */
  90950. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  90951. /**
  90952. * Helper function to remove a mesh and its descendants from the list of shadow casters
  90953. * @param mesh Mesh to remove
  90954. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  90955. * @returns the Shadow Generator itself
  90956. */
  90957. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  90958. /**
  90959. * Controls the extent to which the shadows fade out at the edge of the frustum
  90960. */
  90961. frustumEdgeFalloff: number;
  90962. protected _light: IShadowLight;
  90963. /**
  90964. * Returns the associated light object.
  90965. * @returns the light generating the shadow
  90966. */
  90967. getLight(): IShadowLight;
  90968. /**
  90969. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  90970. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  90971. * It might on the other hand introduce peter panning.
  90972. */
  90973. forceBackFacesOnly: boolean;
  90974. protected _scene: Scene;
  90975. protected _lightDirection: Vector3;
  90976. protected _effect: Effect;
  90977. protected _viewMatrix: Matrix;
  90978. protected _projectionMatrix: Matrix;
  90979. protected _transformMatrix: Matrix;
  90980. protected _cachedPosition: Vector3;
  90981. protected _cachedDirection: Vector3;
  90982. protected _cachedDefines: string;
  90983. protected _currentRenderID: number;
  90984. protected _boxBlurPostprocess: Nullable<PostProcess>;
  90985. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  90986. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  90987. protected _blurPostProcesses: PostProcess[];
  90988. protected _mapSize: number;
  90989. protected _currentFaceIndex: number;
  90990. protected _currentFaceIndexCache: number;
  90991. protected _textureType: number;
  90992. protected _defaultTextureMatrix: Matrix;
  90993. protected _storedUniqueId: Nullable<number>;
  90994. /** @hidden */
  90995. static _SceneComponentInitialization: (scene: Scene) => void;
  90996. /**
  90997. * Creates a ShadowGenerator object.
  90998. * A ShadowGenerator is the required tool to use the shadows.
  90999. * Each light casting shadows needs to use its own ShadowGenerator.
  91000. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  91001. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  91002. * @param light The light object generating the shadows.
  91003. * @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.
  91004. */
  91005. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  91006. protected _initializeGenerator(): void;
  91007. protected _createTargetRenderTexture(): void;
  91008. protected _initializeShadowMap(): void;
  91009. protected _initializeBlurRTTAndPostProcesses(): void;
  91010. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  91011. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect): void;
  91012. protected _renderSubMeshForShadowMap(subMesh: SubMesh): void;
  91013. protected _applyFilterValues(): void;
  91014. /**
  91015. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  91016. * @param onCompiled Callback triggered at the and of the effects compilation
  91017. * @param options Sets of optional options forcing the compilation with different modes
  91018. */
  91019. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  91020. useInstances: boolean;
  91021. }>): void;
  91022. /**
  91023. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  91024. * @param options Sets of optional options forcing the compilation with different modes
  91025. * @returns A promise that resolves when the compilation completes
  91026. */
  91027. forceCompilationAsync(options?: Partial<{
  91028. useInstances: boolean;
  91029. }>): Promise<void>;
  91030. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  91031. /**
  91032. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  91033. * @param subMesh The submesh we want to render in the shadow map
  91034. * @param useInstances Defines wether will draw in the map using instances
  91035. * @returns true if ready otherwise, false
  91036. */
  91037. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  91038. /**
  91039. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  91040. * @param defines Defines of the material we want to update
  91041. * @param lightIndex Index of the light in the enabled light list of the material
  91042. */
  91043. prepareDefines(defines: any, lightIndex: number): void;
  91044. /**
  91045. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  91046. * defined in the generator but impacting the effect).
  91047. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  91048. * @param effect The effect we are binfing the information for
  91049. */
  91050. bindShadowLight(lightIndex: string, effect: Effect): void;
  91051. /**
  91052. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  91053. * (eq to shadow prjection matrix * light transform matrix)
  91054. * @returns The transform matrix used to create the shadow map
  91055. */
  91056. getTransformMatrix(): Matrix;
  91057. /**
  91058. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  91059. * Cube and 2D textures for instance.
  91060. */
  91061. recreateShadowMap(): void;
  91062. protected _disposeBlurPostProcesses(): void;
  91063. protected _disposeRTTandPostProcesses(): void;
  91064. /**
  91065. * Disposes the ShadowGenerator.
  91066. * Returns nothing.
  91067. */
  91068. dispose(): void;
  91069. /**
  91070. * Serializes the shadow generator setup to a json object.
  91071. * @returns The serialized JSON object
  91072. */
  91073. serialize(): any;
  91074. /**
  91075. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  91076. * @param parsedShadowGenerator The JSON object to parse
  91077. * @param scene The scene to create the shadow map for
  91078. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  91079. * @returns The parsed shadow generator
  91080. */
  91081. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  91082. }
  91083. }
  91084. declare module BABYLON {
  91085. /**
  91086. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  91087. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  91088. * 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.
  91089. */
  91090. export abstract class Light extends Node {
  91091. /**
  91092. * Falloff Default: light is falling off following the material specification:
  91093. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  91094. */
  91095. static readonly FALLOFF_DEFAULT: number;
  91096. /**
  91097. * Falloff Physical: light is falling off following the inverse squared distance law.
  91098. */
  91099. static readonly FALLOFF_PHYSICAL: number;
  91100. /**
  91101. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  91102. * to enhance interoperability with other engines.
  91103. */
  91104. static readonly FALLOFF_GLTF: number;
  91105. /**
  91106. * Falloff Standard: light is falling off like in the standard material
  91107. * to enhance interoperability with other materials.
  91108. */
  91109. static readonly FALLOFF_STANDARD: number;
  91110. /**
  91111. * If every light affecting the material is in this lightmapMode,
  91112. * material.lightmapTexture adds or multiplies
  91113. * (depends on material.useLightmapAsShadowmap)
  91114. * after every other light calculations.
  91115. */
  91116. static readonly LIGHTMAP_DEFAULT: number;
  91117. /**
  91118. * material.lightmapTexture as only diffuse lighting from this light
  91119. * adds only specular lighting from this light
  91120. * adds dynamic shadows
  91121. */
  91122. static readonly LIGHTMAP_SPECULAR: number;
  91123. /**
  91124. * material.lightmapTexture as only lighting
  91125. * no light calculation from this light
  91126. * only adds dynamic shadows from this light
  91127. */
  91128. static readonly LIGHTMAP_SHADOWSONLY: number;
  91129. /**
  91130. * Each light type uses the default quantity according to its type:
  91131. * point/spot lights use luminous intensity
  91132. * directional lights use illuminance
  91133. */
  91134. static readonly INTENSITYMODE_AUTOMATIC: number;
  91135. /**
  91136. * lumen (lm)
  91137. */
  91138. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  91139. /**
  91140. * candela (lm/sr)
  91141. */
  91142. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  91143. /**
  91144. * lux (lm/m^2)
  91145. */
  91146. static readonly INTENSITYMODE_ILLUMINANCE: number;
  91147. /**
  91148. * nit (cd/m^2)
  91149. */
  91150. static readonly INTENSITYMODE_LUMINANCE: number;
  91151. /**
  91152. * Light type const id of the point light.
  91153. */
  91154. static readonly LIGHTTYPEID_POINTLIGHT: number;
  91155. /**
  91156. * Light type const id of the directional light.
  91157. */
  91158. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  91159. /**
  91160. * Light type const id of the spot light.
  91161. */
  91162. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  91163. /**
  91164. * Light type const id of the hemispheric light.
  91165. */
  91166. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  91167. /**
  91168. * Diffuse gives the basic color to an object.
  91169. */
  91170. diffuse: Color3;
  91171. /**
  91172. * Specular produces a highlight color on an object.
  91173. * Note: This is note affecting PBR materials.
  91174. */
  91175. specular: Color3;
  91176. /**
  91177. * Defines the falloff type for this light. This lets overrriding how punctual light are
  91178. * falling off base on range or angle.
  91179. * This can be set to any values in Light.FALLOFF_x.
  91180. *
  91181. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  91182. * other types of materials.
  91183. */
  91184. falloffType: number;
  91185. /**
  91186. * Strength of the light.
  91187. * Note: By default it is define in the framework own unit.
  91188. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  91189. */
  91190. intensity: number;
  91191. private _range;
  91192. protected _inverseSquaredRange: number;
  91193. /**
  91194. * Defines how far from the source the light is impacting in scene units.
  91195. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  91196. */
  91197. get range(): number;
  91198. /**
  91199. * Defines how far from the source the light is impacting in scene units.
  91200. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  91201. */
  91202. set range(value: number);
  91203. /**
  91204. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  91205. * of light.
  91206. */
  91207. private _photometricScale;
  91208. private _intensityMode;
  91209. /**
  91210. * Gets the photometric scale used to interpret the intensity.
  91211. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  91212. */
  91213. get intensityMode(): number;
  91214. /**
  91215. * Sets the photometric scale used to interpret the intensity.
  91216. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  91217. */
  91218. set intensityMode(value: number);
  91219. private _radius;
  91220. /**
  91221. * Gets the light radius used by PBR Materials to simulate soft area lights.
  91222. */
  91223. get radius(): number;
  91224. /**
  91225. * sets the light radius used by PBR Materials to simulate soft area lights.
  91226. */
  91227. set radius(value: number);
  91228. private _renderPriority;
  91229. /**
  91230. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  91231. * exceeding the number allowed of the materials.
  91232. */
  91233. renderPriority: number;
  91234. private _shadowEnabled;
  91235. /**
  91236. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  91237. * the current shadow generator.
  91238. */
  91239. get shadowEnabled(): boolean;
  91240. /**
  91241. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  91242. * the current shadow generator.
  91243. */
  91244. set shadowEnabled(value: boolean);
  91245. private _includedOnlyMeshes;
  91246. /**
  91247. * Gets the only meshes impacted by this light.
  91248. */
  91249. get includedOnlyMeshes(): AbstractMesh[];
  91250. /**
  91251. * Sets the only meshes impacted by this light.
  91252. */
  91253. set includedOnlyMeshes(value: AbstractMesh[]);
  91254. private _excludedMeshes;
  91255. /**
  91256. * Gets the meshes not impacted by this light.
  91257. */
  91258. get excludedMeshes(): AbstractMesh[];
  91259. /**
  91260. * Sets the meshes not impacted by this light.
  91261. */
  91262. set excludedMeshes(value: AbstractMesh[]);
  91263. private _excludeWithLayerMask;
  91264. /**
  91265. * Gets the layer id use to find what meshes are not impacted by the light.
  91266. * Inactive if 0
  91267. */
  91268. get excludeWithLayerMask(): number;
  91269. /**
  91270. * Sets the layer id use to find what meshes are not impacted by the light.
  91271. * Inactive if 0
  91272. */
  91273. set excludeWithLayerMask(value: number);
  91274. private _includeOnlyWithLayerMask;
  91275. /**
  91276. * Gets the layer id use to find what meshes are impacted by the light.
  91277. * Inactive if 0
  91278. */
  91279. get includeOnlyWithLayerMask(): number;
  91280. /**
  91281. * Sets the layer id use to find what meshes are impacted by the light.
  91282. * Inactive if 0
  91283. */
  91284. set includeOnlyWithLayerMask(value: number);
  91285. private _lightmapMode;
  91286. /**
  91287. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  91288. */
  91289. get lightmapMode(): number;
  91290. /**
  91291. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  91292. */
  91293. set lightmapMode(value: number);
  91294. /**
  91295. * Shadow generator associted to the light.
  91296. * @hidden Internal use only.
  91297. */
  91298. _shadowGenerator: Nullable<IShadowGenerator>;
  91299. /**
  91300. * @hidden Internal use only.
  91301. */
  91302. _excludedMeshesIds: string[];
  91303. /**
  91304. * @hidden Internal use only.
  91305. */
  91306. _includedOnlyMeshesIds: string[];
  91307. /**
  91308. * The current light unifom buffer.
  91309. * @hidden Internal use only.
  91310. */
  91311. _uniformBuffer: UniformBuffer;
  91312. /** @hidden */
  91313. _renderId: number;
  91314. /**
  91315. * Creates a Light object in the scene.
  91316. * Documentation : https://doc.babylonjs.com/babylon101/lights
  91317. * @param name The firendly name of the light
  91318. * @param scene The scene the light belongs too
  91319. */
  91320. constructor(name: string, scene: Scene);
  91321. protected abstract _buildUniformLayout(): void;
  91322. /**
  91323. * Sets the passed Effect "effect" with the Light information.
  91324. * @param effect The effect to update
  91325. * @param lightIndex The index of the light in the effect to update
  91326. * @returns The light
  91327. */
  91328. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  91329. /**
  91330. * Sets the passed Effect "effect" with the Light textures.
  91331. * @param effect The effect to update
  91332. * @param lightIndex The index of the light in the effect to update
  91333. * @returns The light
  91334. */
  91335. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  91336. /**
  91337. * Binds the lights information from the scene to the effect for the given mesh.
  91338. * @param lightIndex Light index
  91339. * @param scene The scene where the light belongs to
  91340. * @param effect The effect we are binding the data to
  91341. * @param useSpecular Defines if specular is supported
  91342. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  91343. */
  91344. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  91345. /**
  91346. * Sets the passed Effect "effect" with the Light information.
  91347. * @param effect The effect to update
  91348. * @param lightDataUniformName The uniform used to store light data (position or direction)
  91349. * @returns The light
  91350. */
  91351. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  91352. /**
  91353. * Returns the string "Light".
  91354. * @returns the class name
  91355. */
  91356. getClassName(): string;
  91357. /** @hidden */
  91358. readonly _isLight: boolean;
  91359. /**
  91360. * Converts the light information to a readable string for debug purpose.
  91361. * @param fullDetails Supports for multiple levels of logging within scene loading
  91362. * @returns the human readable light info
  91363. */
  91364. toString(fullDetails?: boolean): string;
  91365. /** @hidden */
  91366. protected _syncParentEnabledState(): void;
  91367. /**
  91368. * Set the enabled state of this node.
  91369. * @param value - the new enabled state
  91370. */
  91371. setEnabled(value: boolean): void;
  91372. /**
  91373. * Returns the Light associated shadow generator if any.
  91374. * @return the associated shadow generator.
  91375. */
  91376. getShadowGenerator(): Nullable<IShadowGenerator>;
  91377. /**
  91378. * Returns a Vector3, the absolute light position in the World.
  91379. * @returns the world space position of the light
  91380. */
  91381. getAbsolutePosition(): Vector3;
  91382. /**
  91383. * Specifies if the light will affect the passed mesh.
  91384. * @param mesh The mesh to test against the light
  91385. * @return true the mesh is affected otherwise, false.
  91386. */
  91387. canAffectMesh(mesh: AbstractMesh): boolean;
  91388. /**
  91389. * Sort function to order lights for rendering.
  91390. * @param a First Light object to compare to second.
  91391. * @param b Second Light object to compare first.
  91392. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  91393. */
  91394. static CompareLightsPriority(a: Light, b: Light): number;
  91395. /**
  91396. * Releases resources associated with this node.
  91397. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  91398. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  91399. */
  91400. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  91401. /**
  91402. * Returns the light type ID (integer).
  91403. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  91404. */
  91405. getTypeID(): number;
  91406. /**
  91407. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  91408. * @returns the scaled intensity in intensity mode unit
  91409. */
  91410. getScaledIntensity(): number;
  91411. /**
  91412. * Returns a new Light object, named "name", from the current one.
  91413. * @param name The name of the cloned light
  91414. * @returns the new created light
  91415. */
  91416. clone(name: string): Nullable<Light>;
  91417. /**
  91418. * Serializes the current light into a Serialization object.
  91419. * @returns the serialized object.
  91420. */
  91421. serialize(): any;
  91422. /**
  91423. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  91424. * This new light is named "name" and added to the passed scene.
  91425. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  91426. * @param name The friendly name of the light
  91427. * @param scene The scene the new light will belong to
  91428. * @returns the constructor function
  91429. */
  91430. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  91431. /**
  91432. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  91433. * @param parsedLight The JSON representation of the light
  91434. * @param scene The scene to create the parsed light in
  91435. * @returns the created light after parsing
  91436. */
  91437. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  91438. private _hookArrayForExcluded;
  91439. private _hookArrayForIncludedOnly;
  91440. private _resyncMeshes;
  91441. /**
  91442. * Forces the meshes to update their light related information in their rendering used effects
  91443. * @hidden Internal Use Only
  91444. */
  91445. _markMeshesAsLightDirty(): void;
  91446. /**
  91447. * Recomputes the cached photometric scale if needed.
  91448. */
  91449. private _computePhotometricScale;
  91450. /**
  91451. * Returns the Photometric Scale according to the light type and intensity mode.
  91452. */
  91453. private _getPhotometricScale;
  91454. /**
  91455. * Reorder the light in the scene according to their defined priority.
  91456. * @hidden Internal Use Only
  91457. */
  91458. _reorderLightsInScene(): void;
  91459. /**
  91460. * Prepares the list of defines specific to the light type.
  91461. * @param defines the list of defines
  91462. * @param lightIndex defines the index of the light for the effect
  91463. */
  91464. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  91465. }
  91466. }
  91467. declare module BABYLON {
  91468. /**
  91469. * Interface used to define Action
  91470. */
  91471. export interface IAction {
  91472. /**
  91473. * Trigger for the action
  91474. */
  91475. trigger: number;
  91476. /** Options of the trigger */
  91477. triggerOptions: any;
  91478. /**
  91479. * Gets the trigger parameters
  91480. * @returns the trigger parameters
  91481. */
  91482. getTriggerParameter(): any;
  91483. /**
  91484. * Internal only - executes current action event
  91485. * @hidden
  91486. */
  91487. _executeCurrent(evt?: ActionEvent): void;
  91488. /**
  91489. * Serialize placeholder for child classes
  91490. * @param parent of child
  91491. * @returns the serialized object
  91492. */
  91493. serialize(parent: any): any;
  91494. /**
  91495. * Internal only
  91496. * @hidden
  91497. */
  91498. _prepare(): void;
  91499. /**
  91500. * Internal only - manager for action
  91501. * @hidden
  91502. */
  91503. _actionManager: AbstractActionManager;
  91504. /**
  91505. * Adds action to chain of actions, may be a DoNothingAction
  91506. * @param action defines the next action to execute
  91507. * @returns The action passed in
  91508. * @see https://www.babylonjs-playground.com/#1T30HR#0
  91509. */
  91510. then(action: IAction): IAction;
  91511. }
  91512. /**
  91513. * The action to be carried out following a trigger
  91514. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  91515. */
  91516. export class Action implements IAction {
  91517. /** the trigger, with or without parameters, for the action */
  91518. triggerOptions: any;
  91519. /**
  91520. * Trigger for the action
  91521. */
  91522. trigger: number;
  91523. /**
  91524. * Internal only - manager for action
  91525. * @hidden
  91526. */
  91527. _actionManager: ActionManager;
  91528. private _nextActiveAction;
  91529. private _child;
  91530. private _condition?;
  91531. private _triggerParameter;
  91532. /**
  91533. * An event triggered prior to action being executed.
  91534. */
  91535. onBeforeExecuteObservable: Observable<Action>;
  91536. /**
  91537. * Creates a new Action
  91538. * @param triggerOptions the trigger, with or without parameters, for the action
  91539. * @param condition an optional determinant of action
  91540. */
  91541. constructor(
  91542. /** the trigger, with or without parameters, for the action */
  91543. triggerOptions: any, condition?: Condition);
  91544. /**
  91545. * Internal only
  91546. * @hidden
  91547. */
  91548. _prepare(): void;
  91549. /**
  91550. * Gets the trigger parameters
  91551. * @returns the trigger parameters
  91552. */
  91553. getTriggerParameter(): any;
  91554. /**
  91555. * Internal only - executes current action event
  91556. * @hidden
  91557. */
  91558. _executeCurrent(evt?: ActionEvent): void;
  91559. /**
  91560. * Execute placeholder for child classes
  91561. * @param evt optional action event
  91562. */
  91563. execute(evt?: ActionEvent): void;
  91564. /**
  91565. * Skips to next active action
  91566. */
  91567. skipToNextActiveAction(): void;
  91568. /**
  91569. * Adds action to chain of actions, may be a DoNothingAction
  91570. * @param action defines the next action to execute
  91571. * @returns The action passed in
  91572. * @see https://www.babylonjs-playground.com/#1T30HR#0
  91573. */
  91574. then(action: Action): Action;
  91575. /**
  91576. * Internal only
  91577. * @hidden
  91578. */
  91579. _getProperty(propertyPath: string): string;
  91580. /**
  91581. * Internal only
  91582. * @hidden
  91583. */
  91584. _getEffectiveTarget(target: any, propertyPath: string): any;
  91585. /**
  91586. * Serialize placeholder for child classes
  91587. * @param parent of child
  91588. * @returns the serialized object
  91589. */
  91590. serialize(parent: any): any;
  91591. /**
  91592. * Internal only called by serialize
  91593. * @hidden
  91594. */
  91595. protected _serialize(serializedAction: any, parent?: any): any;
  91596. /**
  91597. * Internal only
  91598. * @hidden
  91599. */
  91600. static _SerializeValueAsString: (value: any) => string;
  91601. /**
  91602. * Internal only
  91603. * @hidden
  91604. */
  91605. static _GetTargetProperty: (target: Node | Scene) => {
  91606. name: string;
  91607. targetType: string;
  91608. value: string;
  91609. };
  91610. }
  91611. }
  91612. declare module BABYLON {
  91613. /**
  91614. * A Condition applied to an Action
  91615. */
  91616. export class Condition {
  91617. /**
  91618. * Internal only - manager for action
  91619. * @hidden
  91620. */
  91621. _actionManager: ActionManager;
  91622. /**
  91623. * Internal only
  91624. * @hidden
  91625. */
  91626. _evaluationId: number;
  91627. /**
  91628. * Internal only
  91629. * @hidden
  91630. */
  91631. _currentResult: boolean;
  91632. /**
  91633. * Creates a new Condition
  91634. * @param actionManager the manager of the action the condition is applied to
  91635. */
  91636. constructor(actionManager: ActionManager);
  91637. /**
  91638. * Check if the current condition is valid
  91639. * @returns a boolean
  91640. */
  91641. isValid(): boolean;
  91642. /**
  91643. * Internal only
  91644. * @hidden
  91645. */
  91646. _getProperty(propertyPath: string): string;
  91647. /**
  91648. * Internal only
  91649. * @hidden
  91650. */
  91651. _getEffectiveTarget(target: any, propertyPath: string): any;
  91652. /**
  91653. * Serialize placeholder for child classes
  91654. * @returns the serialized object
  91655. */
  91656. serialize(): any;
  91657. /**
  91658. * Internal only
  91659. * @hidden
  91660. */
  91661. protected _serialize(serializedCondition: any): any;
  91662. }
  91663. /**
  91664. * Defines specific conditional operators as extensions of Condition
  91665. */
  91666. export class ValueCondition extends Condition {
  91667. /** path to specify the property of the target the conditional operator uses */
  91668. propertyPath: string;
  91669. /** the value compared by the conditional operator against the current value of the property */
  91670. value: any;
  91671. /** the conditional operator, default ValueCondition.IsEqual */
  91672. operator: number;
  91673. /**
  91674. * Internal only
  91675. * @hidden
  91676. */
  91677. private static _IsEqual;
  91678. /**
  91679. * Internal only
  91680. * @hidden
  91681. */
  91682. private static _IsDifferent;
  91683. /**
  91684. * Internal only
  91685. * @hidden
  91686. */
  91687. private static _IsGreater;
  91688. /**
  91689. * Internal only
  91690. * @hidden
  91691. */
  91692. private static _IsLesser;
  91693. /**
  91694. * returns the number for IsEqual
  91695. */
  91696. static get IsEqual(): number;
  91697. /**
  91698. * Returns the number for IsDifferent
  91699. */
  91700. static get IsDifferent(): number;
  91701. /**
  91702. * Returns the number for IsGreater
  91703. */
  91704. static get IsGreater(): number;
  91705. /**
  91706. * Returns the number for IsLesser
  91707. */
  91708. static get IsLesser(): number;
  91709. /**
  91710. * Internal only The action manager for the condition
  91711. * @hidden
  91712. */
  91713. _actionManager: ActionManager;
  91714. /**
  91715. * Internal only
  91716. * @hidden
  91717. */
  91718. private _target;
  91719. /**
  91720. * Internal only
  91721. * @hidden
  91722. */
  91723. private _effectiveTarget;
  91724. /**
  91725. * Internal only
  91726. * @hidden
  91727. */
  91728. private _property;
  91729. /**
  91730. * Creates a new ValueCondition
  91731. * @param actionManager manager for the action the condition applies to
  91732. * @param target for the action
  91733. * @param propertyPath path to specify the property of the target the conditional operator uses
  91734. * @param value the value compared by the conditional operator against the current value of the property
  91735. * @param operator the conditional operator, default ValueCondition.IsEqual
  91736. */
  91737. constructor(actionManager: ActionManager, target: any,
  91738. /** path to specify the property of the target the conditional operator uses */
  91739. propertyPath: string,
  91740. /** the value compared by the conditional operator against the current value of the property */
  91741. value: any,
  91742. /** the conditional operator, default ValueCondition.IsEqual */
  91743. operator?: number);
  91744. /**
  91745. * Compares the given value with the property value for the specified conditional operator
  91746. * @returns the result of the comparison
  91747. */
  91748. isValid(): boolean;
  91749. /**
  91750. * Serialize the ValueCondition into a JSON compatible object
  91751. * @returns serialization object
  91752. */
  91753. serialize(): any;
  91754. /**
  91755. * Gets the name of the conditional operator for the ValueCondition
  91756. * @param operator the conditional operator
  91757. * @returns the name
  91758. */
  91759. static GetOperatorName(operator: number): string;
  91760. }
  91761. /**
  91762. * Defines a predicate condition as an extension of Condition
  91763. */
  91764. export class PredicateCondition extends Condition {
  91765. /** defines the predicate function used to validate the condition */
  91766. predicate: () => boolean;
  91767. /**
  91768. * Internal only - manager for action
  91769. * @hidden
  91770. */
  91771. _actionManager: ActionManager;
  91772. /**
  91773. * Creates a new PredicateCondition
  91774. * @param actionManager manager for the action the condition applies to
  91775. * @param predicate defines the predicate function used to validate the condition
  91776. */
  91777. constructor(actionManager: ActionManager,
  91778. /** defines the predicate function used to validate the condition */
  91779. predicate: () => boolean);
  91780. /**
  91781. * @returns the validity of the predicate condition
  91782. */
  91783. isValid(): boolean;
  91784. }
  91785. /**
  91786. * Defines a state condition as an extension of Condition
  91787. */
  91788. export class StateCondition extends Condition {
  91789. /** Value to compare with target state */
  91790. value: string;
  91791. /**
  91792. * Internal only - manager for action
  91793. * @hidden
  91794. */
  91795. _actionManager: ActionManager;
  91796. /**
  91797. * Internal only
  91798. * @hidden
  91799. */
  91800. private _target;
  91801. /**
  91802. * Creates a new StateCondition
  91803. * @param actionManager manager for the action the condition applies to
  91804. * @param target of the condition
  91805. * @param value to compare with target state
  91806. */
  91807. constructor(actionManager: ActionManager, target: any,
  91808. /** Value to compare with target state */
  91809. value: string);
  91810. /**
  91811. * Gets a boolean indicating if the current condition is met
  91812. * @returns the validity of the state
  91813. */
  91814. isValid(): boolean;
  91815. /**
  91816. * Serialize the StateCondition into a JSON compatible object
  91817. * @returns serialization object
  91818. */
  91819. serialize(): any;
  91820. }
  91821. }
  91822. declare module BABYLON {
  91823. /**
  91824. * This defines an action responsible to toggle a boolean once triggered.
  91825. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  91826. */
  91827. export class SwitchBooleanAction extends Action {
  91828. /**
  91829. * The path to the boolean property in the target object
  91830. */
  91831. propertyPath: string;
  91832. private _target;
  91833. private _effectiveTarget;
  91834. private _property;
  91835. /**
  91836. * Instantiate the action
  91837. * @param triggerOptions defines the trigger options
  91838. * @param target defines the object containing the boolean
  91839. * @param propertyPath defines the path to the boolean property in the target object
  91840. * @param condition defines the trigger related conditions
  91841. */
  91842. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  91843. /** @hidden */
  91844. _prepare(): void;
  91845. /**
  91846. * Execute the action toggle the boolean value.
  91847. */
  91848. execute(): void;
  91849. /**
  91850. * Serializes the actions and its related information.
  91851. * @param parent defines the object to serialize in
  91852. * @returns the serialized object
  91853. */
  91854. serialize(parent: any): any;
  91855. }
  91856. /**
  91857. * This defines an action responsible to set a the state field of the target
  91858. * to a desired value once triggered.
  91859. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  91860. */
  91861. export class SetStateAction extends Action {
  91862. /**
  91863. * The value to store in the state field.
  91864. */
  91865. value: string;
  91866. private _target;
  91867. /**
  91868. * Instantiate the action
  91869. * @param triggerOptions defines the trigger options
  91870. * @param target defines the object containing the state property
  91871. * @param value defines the value to store in the state field
  91872. * @param condition defines the trigger related conditions
  91873. */
  91874. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  91875. /**
  91876. * Execute the action and store the value on the target state property.
  91877. */
  91878. execute(): void;
  91879. /**
  91880. * Serializes the actions and its related information.
  91881. * @param parent defines the object to serialize in
  91882. * @returns the serialized object
  91883. */
  91884. serialize(parent: any): any;
  91885. }
  91886. /**
  91887. * This defines an action responsible to set a property of the target
  91888. * to a desired value once triggered.
  91889. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  91890. */
  91891. export class SetValueAction extends Action {
  91892. /**
  91893. * The path of the property to set in the target.
  91894. */
  91895. propertyPath: string;
  91896. /**
  91897. * The value to set in the property
  91898. */
  91899. value: any;
  91900. private _target;
  91901. private _effectiveTarget;
  91902. private _property;
  91903. /**
  91904. * Instantiate the action
  91905. * @param triggerOptions defines the trigger options
  91906. * @param target defines the object containing the property
  91907. * @param propertyPath defines the path of the property to set in the target
  91908. * @param value defines the value to set in the property
  91909. * @param condition defines the trigger related conditions
  91910. */
  91911. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  91912. /** @hidden */
  91913. _prepare(): void;
  91914. /**
  91915. * Execute the action and set the targetted property to the desired value.
  91916. */
  91917. execute(): void;
  91918. /**
  91919. * Serializes the actions and its related information.
  91920. * @param parent defines the object to serialize in
  91921. * @returns the serialized object
  91922. */
  91923. serialize(parent: any): any;
  91924. }
  91925. /**
  91926. * This defines an action responsible to increment the target value
  91927. * to a desired value once triggered.
  91928. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  91929. */
  91930. export class IncrementValueAction extends Action {
  91931. /**
  91932. * The path of the property to increment in the target.
  91933. */
  91934. propertyPath: string;
  91935. /**
  91936. * The value we should increment the property by.
  91937. */
  91938. value: any;
  91939. private _target;
  91940. private _effectiveTarget;
  91941. private _property;
  91942. /**
  91943. * Instantiate the action
  91944. * @param triggerOptions defines the trigger options
  91945. * @param target defines the object containing the property
  91946. * @param propertyPath defines the path of the property to increment in the target
  91947. * @param value defines the value value we should increment the property by
  91948. * @param condition defines the trigger related conditions
  91949. */
  91950. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  91951. /** @hidden */
  91952. _prepare(): void;
  91953. /**
  91954. * Execute the action and increment the target of the value amount.
  91955. */
  91956. execute(): void;
  91957. /**
  91958. * Serializes the actions and its related information.
  91959. * @param parent defines the object to serialize in
  91960. * @returns the serialized object
  91961. */
  91962. serialize(parent: any): any;
  91963. }
  91964. /**
  91965. * This defines an action responsible to start an animation once triggered.
  91966. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  91967. */
  91968. export class PlayAnimationAction extends Action {
  91969. /**
  91970. * Where the animation should start (animation frame)
  91971. */
  91972. from: number;
  91973. /**
  91974. * Where the animation should stop (animation frame)
  91975. */
  91976. to: number;
  91977. /**
  91978. * Define if the animation should loop or stop after the first play.
  91979. */
  91980. loop?: boolean;
  91981. private _target;
  91982. /**
  91983. * Instantiate the action
  91984. * @param triggerOptions defines the trigger options
  91985. * @param target defines the target animation or animation name
  91986. * @param from defines from where the animation should start (animation frame)
  91987. * @param end defines where the animation should stop (animation frame)
  91988. * @param loop defines if the animation should loop or stop after the first play
  91989. * @param condition defines the trigger related conditions
  91990. */
  91991. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  91992. /** @hidden */
  91993. _prepare(): void;
  91994. /**
  91995. * Execute the action and play the animation.
  91996. */
  91997. execute(): void;
  91998. /**
  91999. * Serializes the actions and its related information.
  92000. * @param parent defines the object to serialize in
  92001. * @returns the serialized object
  92002. */
  92003. serialize(parent: any): any;
  92004. }
  92005. /**
  92006. * This defines an action responsible to stop an animation once triggered.
  92007. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  92008. */
  92009. export class StopAnimationAction extends Action {
  92010. private _target;
  92011. /**
  92012. * Instantiate the action
  92013. * @param triggerOptions defines the trigger options
  92014. * @param target defines the target animation or animation name
  92015. * @param condition defines the trigger related conditions
  92016. */
  92017. constructor(triggerOptions: any, target: any, condition?: Condition);
  92018. /** @hidden */
  92019. _prepare(): void;
  92020. /**
  92021. * Execute the action and stop the animation.
  92022. */
  92023. execute(): void;
  92024. /**
  92025. * Serializes the actions and its related information.
  92026. * @param parent defines the object to serialize in
  92027. * @returns the serialized object
  92028. */
  92029. serialize(parent: any): any;
  92030. }
  92031. /**
  92032. * This defines an action responsible that does nothing once triggered.
  92033. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  92034. */
  92035. export class DoNothingAction extends Action {
  92036. /**
  92037. * Instantiate the action
  92038. * @param triggerOptions defines the trigger options
  92039. * @param condition defines the trigger related conditions
  92040. */
  92041. constructor(triggerOptions?: any, condition?: Condition);
  92042. /**
  92043. * Execute the action and do nothing.
  92044. */
  92045. execute(): void;
  92046. /**
  92047. * Serializes the actions and its related information.
  92048. * @param parent defines the object to serialize in
  92049. * @returns the serialized object
  92050. */
  92051. serialize(parent: any): any;
  92052. }
  92053. /**
  92054. * This defines an action responsible to trigger several actions once triggered.
  92055. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  92056. */
  92057. export class CombineAction extends Action {
  92058. /**
  92059. * The list of aggregated animations to run.
  92060. */
  92061. children: Action[];
  92062. /**
  92063. * Instantiate the action
  92064. * @param triggerOptions defines the trigger options
  92065. * @param children defines the list of aggregated animations to run
  92066. * @param condition defines the trigger related conditions
  92067. */
  92068. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  92069. /** @hidden */
  92070. _prepare(): void;
  92071. /**
  92072. * Execute the action and executes all the aggregated actions.
  92073. */
  92074. execute(evt: ActionEvent): void;
  92075. /**
  92076. * Serializes the actions and its related information.
  92077. * @param parent defines the object to serialize in
  92078. * @returns the serialized object
  92079. */
  92080. serialize(parent: any): any;
  92081. }
  92082. /**
  92083. * This defines an action responsible to run code (external event) once triggered.
  92084. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  92085. */
  92086. export class ExecuteCodeAction extends Action {
  92087. /**
  92088. * The callback function to run.
  92089. */
  92090. func: (evt: ActionEvent) => void;
  92091. /**
  92092. * Instantiate the action
  92093. * @param triggerOptions defines the trigger options
  92094. * @param func defines the callback function to run
  92095. * @param condition defines the trigger related conditions
  92096. */
  92097. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  92098. /**
  92099. * Execute the action and run the attached code.
  92100. */
  92101. execute(evt: ActionEvent): void;
  92102. }
  92103. /**
  92104. * This defines an action responsible to set the parent property of the target once triggered.
  92105. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  92106. */
  92107. export class SetParentAction extends Action {
  92108. private _parent;
  92109. private _target;
  92110. /**
  92111. * Instantiate the action
  92112. * @param triggerOptions defines the trigger options
  92113. * @param target defines the target containing the parent property
  92114. * @param parent defines from where the animation should start (animation frame)
  92115. * @param condition defines the trigger related conditions
  92116. */
  92117. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  92118. /** @hidden */
  92119. _prepare(): void;
  92120. /**
  92121. * Execute the action and set the parent property.
  92122. */
  92123. execute(): void;
  92124. /**
  92125. * Serializes the actions and its related information.
  92126. * @param parent defines the object to serialize in
  92127. * @returns the serialized object
  92128. */
  92129. serialize(parent: any): any;
  92130. }
  92131. }
  92132. declare module BABYLON {
  92133. /**
  92134. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  92135. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  92136. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  92137. */
  92138. export class ActionManager extends AbstractActionManager {
  92139. /**
  92140. * Nothing
  92141. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  92142. */
  92143. static readonly NothingTrigger: number;
  92144. /**
  92145. * On pick
  92146. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  92147. */
  92148. static readonly OnPickTrigger: number;
  92149. /**
  92150. * On left pick
  92151. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  92152. */
  92153. static readonly OnLeftPickTrigger: number;
  92154. /**
  92155. * On right pick
  92156. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  92157. */
  92158. static readonly OnRightPickTrigger: number;
  92159. /**
  92160. * On center pick
  92161. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  92162. */
  92163. static readonly OnCenterPickTrigger: number;
  92164. /**
  92165. * On pick down
  92166. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  92167. */
  92168. static readonly OnPickDownTrigger: number;
  92169. /**
  92170. * On double pick
  92171. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  92172. */
  92173. static readonly OnDoublePickTrigger: number;
  92174. /**
  92175. * On pick up
  92176. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  92177. */
  92178. static readonly OnPickUpTrigger: number;
  92179. /**
  92180. * On pick out.
  92181. * This trigger will only be raised if you also declared a OnPickDown
  92182. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  92183. */
  92184. static readonly OnPickOutTrigger: number;
  92185. /**
  92186. * On long press
  92187. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  92188. */
  92189. static readonly OnLongPressTrigger: number;
  92190. /**
  92191. * On pointer over
  92192. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  92193. */
  92194. static readonly OnPointerOverTrigger: number;
  92195. /**
  92196. * On pointer out
  92197. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  92198. */
  92199. static readonly OnPointerOutTrigger: number;
  92200. /**
  92201. * On every frame
  92202. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  92203. */
  92204. static readonly OnEveryFrameTrigger: number;
  92205. /**
  92206. * On intersection enter
  92207. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  92208. */
  92209. static readonly OnIntersectionEnterTrigger: number;
  92210. /**
  92211. * On intersection exit
  92212. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  92213. */
  92214. static readonly OnIntersectionExitTrigger: number;
  92215. /**
  92216. * On key down
  92217. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  92218. */
  92219. static readonly OnKeyDownTrigger: number;
  92220. /**
  92221. * On key up
  92222. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  92223. */
  92224. static readonly OnKeyUpTrigger: number;
  92225. private _scene;
  92226. /**
  92227. * Creates a new action manager
  92228. * @param scene defines the hosting scene
  92229. */
  92230. constructor(scene: Scene);
  92231. /**
  92232. * Releases all associated resources
  92233. */
  92234. dispose(): void;
  92235. /**
  92236. * Gets hosting scene
  92237. * @returns the hosting scene
  92238. */
  92239. getScene(): Scene;
  92240. /**
  92241. * Does this action manager handles actions of any of the given triggers
  92242. * @param triggers defines the triggers to be tested
  92243. * @return a boolean indicating whether one (or more) of the triggers is handled
  92244. */
  92245. hasSpecificTriggers(triggers: number[]): boolean;
  92246. /**
  92247. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  92248. * speed.
  92249. * @param triggerA defines the trigger to be tested
  92250. * @param triggerB defines the trigger to be tested
  92251. * @return a boolean indicating whether one (or more) of the triggers is handled
  92252. */
  92253. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  92254. /**
  92255. * Does this action manager handles actions of a given trigger
  92256. * @param trigger defines the trigger to be tested
  92257. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  92258. * @return whether the trigger is handled
  92259. */
  92260. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  92261. /**
  92262. * Does this action manager has pointer triggers
  92263. */
  92264. get hasPointerTriggers(): boolean;
  92265. /**
  92266. * Does this action manager has pick triggers
  92267. */
  92268. get hasPickTriggers(): boolean;
  92269. /**
  92270. * Registers an action to this action manager
  92271. * @param action defines the action to be registered
  92272. * @return the action amended (prepared) after registration
  92273. */
  92274. registerAction(action: IAction): Nullable<IAction>;
  92275. /**
  92276. * Unregisters an action to this action manager
  92277. * @param action defines the action to be unregistered
  92278. * @return a boolean indicating whether the action has been unregistered
  92279. */
  92280. unregisterAction(action: IAction): Boolean;
  92281. /**
  92282. * Process a specific trigger
  92283. * @param trigger defines the trigger to process
  92284. * @param evt defines the event details to be processed
  92285. */
  92286. processTrigger(trigger: number, evt?: IActionEvent): void;
  92287. /** @hidden */
  92288. _getEffectiveTarget(target: any, propertyPath: string): any;
  92289. /** @hidden */
  92290. _getProperty(propertyPath: string): string;
  92291. /**
  92292. * Serialize this manager to a JSON object
  92293. * @param name defines the property name to store this manager
  92294. * @returns a JSON representation of this manager
  92295. */
  92296. serialize(name: string): any;
  92297. /**
  92298. * Creates a new ActionManager from a JSON data
  92299. * @param parsedActions defines the JSON data to read from
  92300. * @param object defines the hosting mesh
  92301. * @param scene defines the hosting scene
  92302. */
  92303. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  92304. /**
  92305. * Get a trigger name by index
  92306. * @param trigger defines the trigger index
  92307. * @returns a trigger name
  92308. */
  92309. static GetTriggerName(trigger: number): string;
  92310. }
  92311. }
  92312. declare module BABYLON {
  92313. /**
  92314. * Class used to represent a sprite
  92315. * @see http://doc.babylonjs.com/babylon101/sprites
  92316. */
  92317. export class Sprite {
  92318. /** defines the name */
  92319. name: string;
  92320. /** Gets or sets the current world position */
  92321. position: Vector3;
  92322. /** Gets or sets the main color */
  92323. color: Color4;
  92324. /** Gets or sets the width */
  92325. width: number;
  92326. /** Gets or sets the height */
  92327. height: number;
  92328. /** Gets or sets rotation angle */
  92329. angle: number;
  92330. /** Gets or sets the cell index in the sprite sheet */
  92331. cellIndex: number;
  92332. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  92333. cellRef: string;
  92334. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  92335. invertU: number;
  92336. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  92337. invertV: number;
  92338. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  92339. disposeWhenFinishedAnimating: boolean;
  92340. /** Gets the list of attached animations */
  92341. animations: Animation[];
  92342. /** Gets or sets a boolean indicating if the sprite can be picked */
  92343. isPickable: boolean;
  92344. /**
  92345. * Gets or sets the associated action manager
  92346. */
  92347. actionManager: Nullable<ActionManager>;
  92348. private _animationStarted;
  92349. private _loopAnimation;
  92350. private _fromIndex;
  92351. private _toIndex;
  92352. private _delay;
  92353. private _direction;
  92354. private _manager;
  92355. private _time;
  92356. private _onAnimationEnd;
  92357. /**
  92358. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  92359. */
  92360. isVisible: boolean;
  92361. /**
  92362. * Gets or sets the sprite size
  92363. */
  92364. get size(): number;
  92365. set size(value: number);
  92366. /**
  92367. * Creates a new Sprite
  92368. * @param name defines the name
  92369. * @param manager defines the manager
  92370. */
  92371. constructor(
  92372. /** defines the name */
  92373. name: string, manager: ISpriteManager);
  92374. /**
  92375. * Starts an animation
  92376. * @param from defines the initial key
  92377. * @param to defines the end key
  92378. * @param loop defines if the animation must loop
  92379. * @param delay defines the start delay (in ms)
  92380. * @param onAnimationEnd defines a callback to call when animation ends
  92381. */
  92382. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  92383. /** Stops current animation (if any) */
  92384. stopAnimation(): void;
  92385. /** @hidden */
  92386. _animate(deltaTime: number): void;
  92387. /** Release associated resources */
  92388. dispose(): void;
  92389. }
  92390. }
  92391. declare module BABYLON {
  92392. /**
  92393. * Information about the result of picking within a scene
  92394. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  92395. */
  92396. export class PickingInfo {
  92397. /** @hidden */
  92398. _pickingUnavailable: boolean;
  92399. /**
  92400. * If the pick collided with an object
  92401. */
  92402. hit: boolean;
  92403. /**
  92404. * Distance away where the pick collided
  92405. */
  92406. distance: number;
  92407. /**
  92408. * The location of pick collision
  92409. */
  92410. pickedPoint: Nullable<Vector3>;
  92411. /**
  92412. * The mesh corresponding the the pick collision
  92413. */
  92414. pickedMesh: Nullable<AbstractMesh>;
  92415. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  92416. bu: number;
  92417. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  92418. bv: number;
  92419. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  92420. faceId: number;
  92421. /** Id of the the submesh that was picked */
  92422. subMeshId: number;
  92423. /** If a sprite was picked, this will be the sprite the pick collided with */
  92424. pickedSprite: Nullable<Sprite>;
  92425. /**
  92426. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  92427. */
  92428. originMesh: Nullable<AbstractMesh>;
  92429. /**
  92430. * The ray that was used to perform the picking.
  92431. */
  92432. ray: Nullable<Ray>;
  92433. /**
  92434. * Gets the normal correspodning to the face the pick collided with
  92435. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  92436. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  92437. * @returns The normal correspodning to the face the pick collided with
  92438. */
  92439. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  92440. /**
  92441. * Gets the texture coordinates of where the pick occured
  92442. * @returns the vector containing the coordnates of the texture
  92443. */
  92444. getTextureCoordinates(): Nullable<Vector2>;
  92445. }
  92446. }
  92447. declare module BABYLON {
  92448. /**
  92449. * Gather the list of pointer event types as constants.
  92450. */
  92451. export class PointerEventTypes {
  92452. /**
  92453. * 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.
  92454. */
  92455. static readonly POINTERDOWN: number;
  92456. /**
  92457. * The pointerup event is fired when a pointer is no longer active.
  92458. */
  92459. static readonly POINTERUP: number;
  92460. /**
  92461. * The pointermove event is fired when a pointer changes coordinates.
  92462. */
  92463. static readonly POINTERMOVE: number;
  92464. /**
  92465. * The pointerwheel event is fired when a mouse wheel has been rotated.
  92466. */
  92467. static readonly POINTERWHEEL: number;
  92468. /**
  92469. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  92470. */
  92471. static readonly POINTERPICK: number;
  92472. /**
  92473. * The pointertap event is fired when a the object has been touched and released without drag.
  92474. */
  92475. static readonly POINTERTAP: number;
  92476. /**
  92477. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  92478. */
  92479. static readonly POINTERDOUBLETAP: number;
  92480. }
  92481. /**
  92482. * Base class of pointer info types.
  92483. */
  92484. export class PointerInfoBase {
  92485. /**
  92486. * Defines the type of event (PointerEventTypes)
  92487. */
  92488. type: number;
  92489. /**
  92490. * Defines the related dom event
  92491. */
  92492. event: PointerEvent | MouseWheelEvent;
  92493. /**
  92494. * Instantiates the base class of pointers info.
  92495. * @param type Defines the type of event (PointerEventTypes)
  92496. * @param event Defines the related dom event
  92497. */
  92498. constructor(
  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. /**
  92509. * This class is used to store pointer related info for the onPrePointerObservable event.
  92510. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  92511. */
  92512. export class PointerInfoPre extends PointerInfoBase {
  92513. /**
  92514. * Ray from a pointer if availible (eg. 6dof controller)
  92515. */
  92516. ray: Nullable<Ray>;
  92517. /**
  92518. * Defines the local position of the pointer on the canvas.
  92519. */
  92520. localPosition: Vector2;
  92521. /**
  92522. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  92523. */
  92524. skipOnPointerObservable: boolean;
  92525. /**
  92526. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  92527. * @param type Defines the type of event (PointerEventTypes)
  92528. * @param event Defines the related dom event
  92529. * @param localX Defines the local x coordinates of the pointer when the event occured
  92530. * @param localY Defines the local y coordinates of the pointer when the event occured
  92531. */
  92532. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  92533. }
  92534. /**
  92535. * This type contains all the data related to a pointer event in Babylon.js.
  92536. * 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.
  92537. */
  92538. export class PointerInfo extends PointerInfoBase {
  92539. /**
  92540. * Defines the picking info associated to the info (if any)\
  92541. */
  92542. pickInfo: Nullable<PickingInfo>;
  92543. /**
  92544. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  92545. * @param type Defines the type of event (PointerEventTypes)
  92546. * @param event Defines the related dom event
  92547. * @param pickInfo Defines the picking info associated to the info (if any)\
  92548. */
  92549. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  92550. /**
  92551. * Defines the picking info associated to the info (if any)\
  92552. */
  92553. pickInfo: Nullable<PickingInfo>);
  92554. }
  92555. /**
  92556. * Data relating to a touch event on the screen.
  92557. */
  92558. export interface PointerTouch {
  92559. /**
  92560. * X coordinate of touch.
  92561. */
  92562. x: number;
  92563. /**
  92564. * Y coordinate of touch.
  92565. */
  92566. y: number;
  92567. /**
  92568. * Id of touch. Unique for each finger.
  92569. */
  92570. pointerId: number;
  92571. /**
  92572. * Event type passed from DOM.
  92573. */
  92574. type: any;
  92575. }
  92576. }
  92577. declare module BABYLON {
  92578. /**
  92579. * Manage the mouse inputs to control the movement of a free camera.
  92580. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  92581. */
  92582. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  92583. /**
  92584. * Define if touch is enabled in the mouse input
  92585. */
  92586. touchEnabled: boolean;
  92587. /**
  92588. * Defines the camera the input is attached to.
  92589. */
  92590. camera: FreeCamera;
  92591. /**
  92592. * Defines the buttons associated with the input to handle camera move.
  92593. */
  92594. buttons: number[];
  92595. /**
  92596. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  92597. */
  92598. angularSensibility: number;
  92599. private _pointerInput;
  92600. private _onMouseMove;
  92601. private _observer;
  92602. private previousPosition;
  92603. /**
  92604. * Observable for when a pointer move event occurs containing the move offset
  92605. */
  92606. onPointerMovedObservable: Observable<{
  92607. offsetX: number;
  92608. offsetY: number;
  92609. }>;
  92610. /**
  92611. * @hidden
  92612. * If the camera should be rotated automatically based on pointer movement
  92613. */
  92614. _allowCameraRotation: boolean;
  92615. /**
  92616. * Manage the mouse inputs to control the movement of a free camera.
  92617. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  92618. * @param touchEnabled Defines if touch is enabled or not
  92619. */
  92620. constructor(
  92621. /**
  92622. * Define if touch is enabled in the mouse input
  92623. */
  92624. touchEnabled?: boolean);
  92625. /**
  92626. * Attach the input controls to a specific dom element to get the input from.
  92627. * @param element Defines the element the controls should be listened from
  92628. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  92629. */
  92630. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  92631. /**
  92632. * Called on JS contextmenu event.
  92633. * Override this method to provide functionality.
  92634. */
  92635. protected onContextMenu(evt: PointerEvent): void;
  92636. /**
  92637. * Detach the current controls from the specified dom element.
  92638. * @param element Defines the element to stop listening the inputs from
  92639. */
  92640. detachControl(element: Nullable<HTMLElement>): void;
  92641. /**
  92642. * Gets the class name of the current intput.
  92643. * @returns the class name
  92644. */
  92645. getClassName(): string;
  92646. /**
  92647. * Get the friendly name associated with the input class.
  92648. * @returns the input friendly name
  92649. */
  92650. getSimpleName(): string;
  92651. }
  92652. }
  92653. declare module BABYLON {
  92654. /**
  92655. * Manage the touch inputs to control the movement of a free camera.
  92656. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  92657. */
  92658. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  92659. /**
  92660. * Defines the camera the input is attached to.
  92661. */
  92662. camera: FreeCamera;
  92663. /**
  92664. * Defines the touch sensibility for rotation.
  92665. * The higher the faster.
  92666. */
  92667. touchAngularSensibility: number;
  92668. /**
  92669. * Defines the touch sensibility for move.
  92670. * The higher the faster.
  92671. */
  92672. touchMoveSensibility: number;
  92673. private _offsetX;
  92674. private _offsetY;
  92675. private _pointerPressed;
  92676. private _pointerInput;
  92677. private _observer;
  92678. private _onLostFocus;
  92679. /**
  92680. * Attach the input controls to a specific dom element to get the input from.
  92681. * @param element Defines the element the controls should be listened from
  92682. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  92683. */
  92684. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  92685. /**
  92686. * Detach the current controls from the specified dom element.
  92687. * @param element Defines the element to stop listening the inputs from
  92688. */
  92689. detachControl(element: Nullable<HTMLElement>): void;
  92690. /**
  92691. * Update the current camera state depending on the inputs that have been used this frame.
  92692. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  92693. */
  92694. checkInputs(): void;
  92695. /**
  92696. * Gets the class name of the current intput.
  92697. * @returns the class name
  92698. */
  92699. getClassName(): string;
  92700. /**
  92701. * Get the friendly name associated with the input class.
  92702. * @returns the input friendly name
  92703. */
  92704. getSimpleName(): string;
  92705. }
  92706. }
  92707. declare module BABYLON {
  92708. /**
  92709. * Default Inputs manager for the FreeCamera.
  92710. * It groups all the default supported inputs for ease of use.
  92711. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  92712. */
  92713. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  92714. /**
  92715. * @hidden
  92716. */
  92717. _mouseInput: Nullable<FreeCameraMouseInput>;
  92718. /**
  92719. * Instantiates a new FreeCameraInputsManager.
  92720. * @param camera Defines the camera the inputs belong to
  92721. */
  92722. constructor(camera: FreeCamera);
  92723. /**
  92724. * Add keyboard input support to the input manager.
  92725. * @returns the current input manager
  92726. */
  92727. addKeyboard(): FreeCameraInputsManager;
  92728. /**
  92729. * Add mouse input support to the input manager.
  92730. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  92731. * @returns the current input manager
  92732. */
  92733. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  92734. /**
  92735. * Removes the mouse input support from the manager
  92736. * @returns the current input manager
  92737. */
  92738. removeMouse(): FreeCameraInputsManager;
  92739. /**
  92740. * Add touch input support to the input manager.
  92741. * @returns the current input manager
  92742. */
  92743. addTouch(): FreeCameraInputsManager;
  92744. /**
  92745. * Remove all attached input methods from a camera
  92746. */
  92747. clear(): void;
  92748. }
  92749. }
  92750. declare module BABYLON {
  92751. /**
  92752. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  92753. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  92754. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  92755. */
  92756. export class FreeCamera extends TargetCamera {
  92757. /**
  92758. * Define the collision ellipsoid of the camera.
  92759. * This is helpful to simulate a camera body like the player body around the camera
  92760. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  92761. */
  92762. ellipsoid: Vector3;
  92763. /**
  92764. * Define an offset for the position of the ellipsoid around the camera.
  92765. * This can be helpful to determine the center of the body near the gravity center of the body
  92766. * instead of its head.
  92767. */
  92768. ellipsoidOffset: Vector3;
  92769. /**
  92770. * Enable or disable collisions of the camera with the rest of the scene objects.
  92771. */
  92772. checkCollisions: boolean;
  92773. /**
  92774. * Enable or disable gravity on the camera.
  92775. */
  92776. applyGravity: boolean;
  92777. /**
  92778. * Define the input manager associated to the camera.
  92779. */
  92780. inputs: FreeCameraInputsManager;
  92781. /**
  92782. * Gets the input sensibility for a mouse input. (default is 2000.0)
  92783. * Higher values reduce sensitivity.
  92784. */
  92785. get angularSensibility(): number;
  92786. /**
  92787. * Sets the input sensibility for a mouse input. (default is 2000.0)
  92788. * Higher values reduce sensitivity.
  92789. */
  92790. set angularSensibility(value: number);
  92791. /**
  92792. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  92793. */
  92794. get keysUp(): number[];
  92795. set keysUp(value: number[]);
  92796. /**
  92797. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  92798. */
  92799. get keysUpward(): number[];
  92800. set keysUpward(value: number[]);
  92801. /**
  92802. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  92803. */
  92804. get keysDown(): number[];
  92805. set keysDown(value: number[]);
  92806. /**
  92807. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  92808. */
  92809. get keysDownward(): number[];
  92810. set keysDownward(value: number[]);
  92811. /**
  92812. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  92813. */
  92814. get keysLeft(): number[];
  92815. set keysLeft(value: number[]);
  92816. /**
  92817. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  92818. */
  92819. get keysRight(): number[];
  92820. set keysRight(value: number[]);
  92821. /**
  92822. * Event raised when the camera collide with a mesh in the scene.
  92823. */
  92824. onCollide: (collidedMesh: AbstractMesh) => void;
  92825. private _collider;
  92826. private _needMoveForGravity;
  92827. private _oldPosition;
  92828. private _diffPosition;
  92829. private _newPosition;
  92830. /** @hidden */
  92831. _localDirection: Vector3;
  92832. /** @hidden */
  92833. _transformedDirection: Vector3;
  92834. /**
  92835. * Instantiates a Free Camera.
  92836. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  92837. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  92838. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  92839. * @param name Define the name of the camera in the scene
  92840. * @param position Define the start position of the camera in the scene
  92841. * @param scene Define the scene the camera belongs to
  92842. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  92843. */
  92844. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  92845. /**
  92846. * Attached controls to the current camera.
  92847. * @param element Defines the element the controls should be listened from
  92848. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  92849. */
  92850. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  92851. /**
  92852. * Detach the current controls from the camera.
  92853. * The camera will stop reacting to inputs.
  92854. * @param element Defines the element to stop listening the inputs from
  92855. */
  92856. detachControl(element: HTMLElement): void;
  92857. private _collisionMask;
  92858. /**
  92859. * Define a collision mask to limit the list of object the camera can collide with
  92860. */
  92861. get collisionMask(): number;
  92862. set collisionMask(mask: number);
  92863. /** @hidden */
  92864. _collideWithWorld(displacement: Vector3): void;
  92865. private _onCollisionPositionChange;
  92866. /** @hidden */
  92867. _checkInputs(): void;
  92868. /** @hidden */
  92869. _decideIfNeedsToMove(): boolean;
  92870. /** @hidden */
  92871. _updatePosition(): void;
  92872. /**
  92873. * Destroy the camera and release the current resources hold by it.
  92874. */
  92875. dispose(): void;
  92876. /**
  92877. * Gets the current object class name.
  92878. * @return the class name
  92879. */
  92880. getClassName(): string;
  92881. }
  92882. }
  92883. declare module BABYLON {
  92884. /**
  92885. * Represents a gamepad control stick position
  92886. */
  92887. export class StickValues {
  92888. /**
  92889. * The x component of the control stick
  92890. */
  92891. x: number;
  92892. /**
  92893. * The y component of the control stick
  92894. */
  92895. y: number;
  92896. /**
  92897. * Initializes the gamepad x and y control stick values
  92898. * @param x The x component of the gamepad control stick value
  92899. * @param y The y component of the gamepad control stick value
  92900. */
  92901. constructor(
  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. /**
  92912. * An interface which manages callbacks for gamepad button changes
  92913. */
  92914. export interface GamepadButtonChanges {
  92915. /**
  92916. * Called when a gamepad has been changed
  92917. */
  92918. changed: boolean;
  92919. /**
  92920. * Called when a gamepad press event has been triggered
  92921. */
  92922. pressChanged: boolean;
  92923. /**
  92924. * Called when a touch event has been triggered
  92925. */
  92926. touchChanged: boolean;
  92927. /**
  92928. * Called when a value has changed
  92929. */
  92930. valueChanged: boolean;
  92931. }
  92932. /**
  92933. * Represents a gamepad
  92934. */
  92935. export class Gamepad {
  92936. /**
  92937. * The id of the gamepad
  92938. */
  92939. id: string;
  92940. /**
  92941. * The index of the gamepad
  92942. */
  92943. index: number;
  92944. /**
  92945. * The browser gamepad
  92946. */
  92947. browserGamepad: any;
  92948. /**
  92949. * Specifies what type of gamepad this represents
  92950. */
  92951. type: number;
  92952. private _leftStick;
  92953. private _rightStick;
  92954. /** @hidden */
  92955. _isConnected: boolean;
  92956. private _leftStickAxisX;
  92957. private _leftStickAxisY;
  92958. private _rightStickAxisX;
  92959. private _rightStickAxisY;
  92960. /**
  92961. * Triggered when the left control stick has been changed
  92962. */
  92963. private _onleftstickchanged;
  92964. /**
  92965. * Triggered when the right control stick has been changed
  92966. */
  92967. private _onrightstickchanged;
  92968. /**
  92969. * Represents a gamepad controller
  92970. */
  92971. static GAMEPAD: number;
  92972. /**
  92973. * Represents a generic controller
  92974. */
  92975. static GENERIC: number;
  92976. /**
  92977. * Represents an XBox controller
  92978. */
  92979. static XBOX: number;
  92980. /**
  92981. * Represents a pose-enabled controller
  92982. */
  92983. static POSE_ENABLED: number;
  92984. /**
  92985. * Represents an Dual Shock controller
  92986. */
  92987. static DUALSHOCK: number;
  92988. /**
  92989. * Specifies whether the left control stick should be Y-inverted
  92990. */
  92991. protected _invertLeftStickY: boolean;
  92992. /**
  92993. * Specifies if the gamepad has been connected
  92994. */
  92995. get isConnected(): boolean;
  92996. /**
  92997. * Initializes the gamepad
  92998. * @param id The id of the gamepad
  92999. * @param index The index of the gamepad
  93000. * @param browserGamepad The browser gamepad
  93001. * @param leftStickX The x component of the left joystick
  93002. * @param leftStickY The y component of the left joystick
  93003. * @param rightStickX The x component of the right joystick
  93004. * @param rightStickY The y component of the right joystick
  93005. */
  93006. constructor(
  93007. /**
  93008. * The id of the gamepad
  93009. */
  93010. id: string,
  93011. /**
  93012. * The index of the gamepad
  93013. */
  93014. index: number,
  93015. /**
  93016. * The browser gamepad
  93017. */
  93018. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  93019. /**
  93020. * Callback triggered when the left joystick has changed
  93021. * @param callback
  93022. */
  93023. onleftstickchanged(callback: (values: StickValues) => void): void;
  93024. /**
  93025. * Callback triggered when the right joystick has changed
  93026. * @param callback
  93027. */
  93028. onrightstickchanged(callback: (values: StickValues) => void): void;
  93029. /**
  93030. * Gets the left joystick
  93031. */
  93032. get leftStick(): StickValues;
  93033. /**
  93034. * Sets the left joystick values
  93035. */
  93036. set leftStick(newValues: StickValues);
  93037. /**
  93038. * Gets the right joystick
  93039. */
  93040. get rightStick(): StickValues;
  93041. /**
  93042. * Sets the right joystick value
  93043. */
  93044. set rightStick(newValues: StickValues);
  93045. /**
  93046. * Updates the gamepad joystick positions
  93047. */
  93048. update(): void;
  93049. /**
  93050. * Disposes the gamepad
  93051. */
  93052. dispose(): void;
  93053. }
  93054. /**
  93055. * Represents a generic gamepad
  93056. */
  93057. export class GenericPad extends Gamepad {
  93058. private _buttons;
  93059. private _onbuttondown;
  93060. private _onbuttonup;
  93061. /**
  93062. * Observable triggered when a button has been pressed
  93063. */
  93064. onButtonDownObservable: Observable<number>;
  93065. /**
  93066. * Observable triggered when a button has been released
  93067. */
  93068. onButtonUpObservable: Observable<number>;
  93069. /**
  93070. * Callback triggered when a button has been pressed
  93071. * @param callback Called when a button has been pressed
  93072. */
  93073. onbuttondown(callback: (buttonPressed: number) => void): void;
  93074. /**
  93075. * Callback triggered when a button has been released
  93076. * @param callback Called when a button has been released
  93077. */
  93078. onbuttonup(callback: (buttonReleased: number) => void): void;
  93079. /**
  93080. * Initializes the generic gamepad
  93081. * @param id The id of the generic gamepad
  93082. * @param index The index of the generic gamepad
  93083. * @param browserGamepad The browser gamepad
  93084. */
  93085. constructor(id: string, index: number, browserGamepad: any);
  93086. private _setButtonValue;
  93087. /**
  93088. * Updates the generic gamepad
  93089. */
  93090. update(): void;
  93091. /**
  93092. * Disposes the generic gamepad
  93093. */
  93094. dispose(): void;
  93095. }
  93096. }
  93097. declare module BABYLON {
  93098. /**
  93099. * Defines the types of pose enabled controllers that are supported
  93100. */
  93101. export enum PoseEnabledControllerType {
  93102. /**
  93103. * HTC Vive
  93104. */
  93105. VIVE = 0,
  93106. /**
  93107. * Oculus Rift
  93108. */
  93109. OCULUS = 1,
  93110. /**
  93111. * Windows mixed reality
  93112. */
  93113. WINDOWS = 2,
  93114. /**
  93115. * Samsung gear VR
  93116. */
  93117. GEAR_VR = 3,
  93118. /**
  93119. * Google Daydream
  93120. */
  93121. DAYDREAM = 4,
  93122. /**
  93123. * Generic
  93124. */
  93125. GENERIC = 5
  93126. }
  93127. /**
  93128. * Defines the MutableGamepadButton interface for the state of a gamepad button
  93129. */
  93130. export interface MutableGamepadButton {
  93131. /**
  93132. * Value of the button/trigger
  93133. */
  93134. value: number;
  93135. /**
  93136. * If the button/trigger is currently touched
  93137. */
  93138. touched: boolean;
  93139. /**
  93140. * If the button/trigger is currently pressed
  93141. */
  93142. pressed: boolean;
  93143. }
  93144. /**
  93145. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  93146. * @hidden
  93147. */
  93148. export interface ExtendedGamepadButton extends GamepadButton {
  93149. /**
  93150. * If the button/trigger is currently pressed
  93151. */
  93152. readonly pressed: boolean;
  93153. /**
  93154. * If the button/trigger is currently touched
  93155. */
  93156. readonly touched: boolean;
  93157. /**
  93158. * Value of the button/trigger
  93159. */
  93160. readonly value: number;
  93161. }
  93162. /** @hidden */
  93163. export interface _GamePadFactory {
  93164. /**
  93165. * Returns whether or not the current gamepad can be created for this type of controller.
  93166. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  93167. * @returns true if it can be created, otherwise false
  93168. */
  93169. canCreate(gamepadInfo: any): boolean;
  93170. /**
  93171. * Creates a new instance of the Gamepad.
  93172. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  93173. * @returns the new gamepad instance
  93174. */
  93175. create(gamepadInfo: any): Gamepad;
  93176. }
  93177. /**
  93178. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  93179. */
  93180. export class PoseEnabledControllerHelper {
  93181. /** @hidden */
  93182. static _ControllerFactories: _GamePadFactory[];
  93183. /** @hidden */
  93184. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  93185. /**
  93186. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  93187. * @param vrGamepad the gamepad to initialized
  93188. * @returns a vr controller of the type the gamepad identified as
  93189. */
  93190. static InitiateController(vrGamepad: any): Gamepad;
  93191. }
  93192. /**
  93193. * Defines the PoseEnabledController object that contains state of a vr capable controller
  93194. */
  93195. export class PoseEnabledController extends Gamepad implements PoseControlled {
  93196. /**
  93197. * If the controller is used in a webXR session
  93198. */
  93199. isXR: boolean;
  93200. private _deviceRoomPosition;
  93201. private _deviceRoomRotationQuaternion;
  93202. /**
  93203. * The device position in babylon space
  93204. */
  93205. devicePosition: Vector3;
  93206. /**
  93207. * The device rotation in babylon space
  93208. */
  93209. deviceRotationQuaternion: Quaternion;
  93210. /**
  93211. * The scale factor of the device in babylon space
  93212. */
  93213. deviceScaleFactor: number;
  93214. /**
  93215. * (Likely devicePosition should be used instead) The device position in its room space
  93216. */
  93217. position: Vector3;
  93218. /**
  93219. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  93220. */
  93221. rotationQuaternion: Quaternion;
  93222. /**
  93223. * The type of controller (Eg. Windows mixed reality)
  93224. */
  93225. controllerType: PoseEnabledControllerType;
  93226. protected _calculatedPosition: Vector3;
  93227. private _calculatedRotation;
  93228. /**
  93229. * The raw pose from the device
  93230. */
  93231. rawPose: DevicePose;
  93232. private _trackPosition;
  93233. private _maxRotationDistFromHeadset;
  93234. private _draggedRoomRotation;
  93235. /**
  93236. * @hidden
  93237. */
  93238. _disableTrackPosition(fixedPosition: Vector3): void;
  93239. /**
  93240. * Internal, the mesh attached to the controller
  93241. * @hidden
  93242. */
  93243. _mesh: Nullable<AbstractMesh>;
  93244. private _poseControlledCamera;
  93245. private _leftHandSystemQuaternion;
  93246. /**
  93247. * Internal, matrix used to convert room space to babylon space
  93248. * @hidden
  93249. */
  93250. _deviceToWorld: Matrix;
  93251. /**
  93252. * Node to be used when casting a ray from the controller
  93253. * @hidden
  93254. */
  93255. _pointingPoseNode: Nullable<TransformNode>;
  93256. /**
  93257. * Name of the child mesh that can be used to cast a ray from the controller
  93258. */
  93259. static readonly POINTING_POSE: string;
  93260. /**
  93261. * Creates a new PoseEnabledController from a gamepad
  93262. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  93263. */
  93264. constructor(browserGamepad: any);
  93265. private _workingMatrix;
  93266. /**
  93267. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  93268. */
  93269. update(): void;
  93270. /**
  93271. * Updates only the pose device and mesh without doing any button event checking
  93272. */
  93273. protected _updatePoseAndMesh(): void;
  93274. /**
  93275. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  93276. * @param poseData raw pose fromthe device
  93277. */
  93278. updateFromDevice(poseData: DevicePose): void;
  93279. /**
  93280. * @hidden
  93281. */
  93282. _meshAttachedObservable: Observable<AbstractMesh>;
  93283. /**
  93284. * Attaches a mesh to the controller
  93285. * @param mesh the mesh to be attached
  93286. */
  93287. attachToMesh(mesh: AbstractMesh): void;
  93288. /**
  93289. * Attaches the controllers mesh to a camera
  93290. * @param camera the camera the mesh should be attached to
  93291. */
  93292. attachToPoseControlledCamera(camera: TargetCamera): void;
  93293. /**
  93294. * Disposes of the controller
  93295. */
  93296. dispose(): void;
  93297. /**
  93298. * The mesh that is attached to the controller
  93299. */
  93300. get mesh(): Nullable<AbstractMesh>;
  93301. /**
  93302. * Gets the ray of the controller in the direction the controller is pointing
  93303. * @param length the length the resulting ray should be
  93304. * @returns a ray in the direction the controller is pointing
  93305. */
  93306. getForwardRay(length?: number): Ray;
  93307. }
  93308. }
  93309. declare module BABYLON {
  93310. /**
  93311. * Defines the WebVRController object that represents controllers tracked in 3D space
  93312. */
  93313. export abstract class WebVRController extends PoseEnabledController {
  93314. /**
  93315. * Internal, the default controller model for the controller
  93316. */
  93317. protected _defaultModel: Nullable<AbstractMesh>;
  93318. /**
  93319. * Fired when the trigger state has changed
  93320. */
  93321. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  93322. /**
  93323. * Fired when the main button state has changed
  93324. */
  93325. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  93326. /**
  93327. * Fired when the secondary button state has changed
  93328. */
  93329. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  93330. /**
  93331. * Fired when the pad state has changed
  93332. */
  93333. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  93334. /**
  93335. * Fired when controllers stick values have changed
  93336. */
  93337. onPadValuesChangedObservable: Observable<StickValues>;
  93338. /**
  93339. * Array of button availible on the controller
  93340. */
  93341. protected _buttons: Array<MutableGamepadButton>;
  93342. private _onButtonStateChange;
  93343. /**
  93344. * Fired when a controller button's state has changed
  93345. * @param callback the callback containing the button that was modified
  93346. */
  93347. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  93348. /**
  93349. * X and Y axis corresponding to the controllers joystick
  93350. */
  93351. pad: StickValues;
  93352. /**
  93353. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  93354. */
  93355. hand: string;
  93356. /**
  93357. * The default controller model for the controller
  93358. */
  93359. get defaultModel(): Nullable<AbstractMesh>;
  93360. /**
  93361. * Creates a new WebVRController from a gamepad
  93362. * @param vrGamepad the gamepad that the WebVRController should be created from
  93363. */
  93364. constructor(vrGamepad: any);
  93365. /**
  93366. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  93367. */
  93368. update(): void;
  93369. /**
  93370. * Function to be called when a button is modified
  93371. */
  93372. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  93373. /**
  93374. * Loads a mesh and attaches it to the controller
  93375. * @param scene the scene the mesh should be added to
  93376. * @param meshLoaded callback for when the mesh has been loaded
  93377. */
  93378. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  93379. private _setButtonValue;
  93380. private _changes;
  93381. private _checkChanges;
  93382. /**
  93383. * Disposes of th webVRCOntroller
  93384. */
  93385. dispose(): void;
  93386. }
  93387. }
  93388. declare module BABYLON {
  93389. /**
  93390. * The HemisphericLight simulates the ambient environment light,
  93391. * so the passed direction is the light reflection direction, not the incoming direction.
  93392. */
  93393. export class HemisphericLight extends Light {
  93394. /**
  93395. * The groundColor is the light in the opposite direction to the one specified during creation.
  93396. * 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.
  93397. */
  93398. groundColor: Color3;
  93399. /**
  93400. * The light reflection direction, not the incoming direction.
  93401. */
  93402. direction: Vector3;
  93403. /**
  93404. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  93405. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  93406. * The HemisphericLight can't cast shadows.
  93407. * Documentation : https://doc.babylonjs.com/babylon101/lights
  93408. * @param name The friendly name of the light
  93409. * @param direction The direction of the light reflection
  93410. * @param scene The scene the light belongs to
  93411. */
  93412. constructor(name: string, direction: Vector3, scene: Scene);
  93413. protected _buildUniformLayout(): void;
  93414. /**
  93415. * Returns the string "HemisphericLight".
  93416. * @return The class name
  93417. */
  93418. getClassName(): string;
  93419. /**
  93420. * Sets the HemisphericLight direction towards the passed target (Vector3).
  93421. * Returns the updated direction.
  93422. * @param target The target the direction should point to
  93423. * @return The computed direction
  93424. */
  93425. setDirectionToTarget(target: Vector3): Vector3;
  93426. /**
  93427. * Returns the shadow generator associated to the light.
  93428. * @returns Always null for hemispheric lights because it does not support shadows.
  93429. */
  93430. getShadowGenerator(): Nullable<IShadowGenerator>;
  93431. /**
  93432. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  93433. * @param effect The effect to update
  93434. * @param lightIndex The index of the light in the effect to update
  93435. * @returns The hemispheric light
  93436. */
  93437. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  93438. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  93439. /**
  93440. * Computes the world matrix of the node
  93441. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  93442. * @param useWasUpdatedFlag defines a reserved property
  93443. * @returns the world matrix
  93444. */
  93445. computeWorldMatrix(): Matrix;
  93446. /**
  93447. * Returns the integer 3.
  93448. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  93449. */
  93450. getTypeID(): number;
  93451. /**
  93452. * Prepares the list of defines specific to the light type.
  93453. * @param defines the list of defines
  93454. * @param lightIndex defines the index of the light for the effect
  93455. */
  93456. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  93457. }
  93458. }
  93459. declare module BABYLON {
  93460. /** @hidden */
  93461. export var vrMultiviewToSingleviewPixelShader: {
  93462. name: string;
  93463. shader: string;
  93464. };
  93465. }
  93466. declare module BABYLON {
  93467. /**
  93468. * Renders to multiple views with a single draw call
  93469. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  93470. */
  93471. export class MultiviewRenderTarget extends RenderTargetTexture {
  93472. /**
  93473. * Creates a multiview render target
  93474. * @param scene scene used with the render target
  93475. * @param size the size of the render target (used for each view)
  93476. */
  93477. constructor(scene: Scene, size?: number | {
  93478. width: number;
  93479. height: number;
  93480. } | {
  93481. ratio: number;
  93482. });
  93483. /**
  93484. * @hidden
  93485. * @param faceIndex the face index, if its a cube texture
  93486. */
  93487. _bindFrameBuffer(faceIndex?: number): void;
  93488. /**
  93489. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  93490. * @returns the view count
  93491. */
  93492. getViewCount(): number;
  93493. }
  93494. }
  93495. declare module BABYLON {
  93496. /**
  93497. * Represents a camera frustum
  93498. */
  93499. export class Frustum {
  93500. /**
  93501. * Gets the planes representing the frustum
  93502. * @param transform matrix to be applied to the returned planes
  93503. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  93504. */
  93505. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  93506. /**
  93507. * Gets the near frustum plane transformed by the transform matrix
  93508. * @param transform transformation matrix to be applied to the resulting frustum plane
  93509. * @param frustumPlane the resuling frustum plane
  93510. */
  93511. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  93512. /**
  93513. * Gets the far frustum plane transformed by the transform matrix
  93514. * @param transform transformation matrix to be applied to the resulting frustum plane
  93515. * @param frustumPlane the resuling frustum plane
  93516. */
  93517. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  93518. /**
  93519. * Gets the left frustum plane transformed by the transform matrix
  93520. * @param transform transformation matrix to be applied to the resulting frustum plane
  93521. * @param frustumPlane the resuling frustum plane
  93522. */
  93523. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  93524. /**
  93525. * Gets the right frustum plane transformed by the transform matrix
  93526. * @param transform transformation matrix to be applied to the resulting frustum plane
  93527. * @param frustumPlane the resuling frustum plane
  93528. */
  93529. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  93530. /**
  93531. * Gets the top frustum plane transformed by the transform matrix
  93532. * @param transform transformation matrix to be applied to the resulting frustum plane
  93533. * @param frustumPlane the resuling frustum plane
  93534. */
  93535. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  93536. /**
  93537. * Gets the bottom frustum plane transformed by the transform matrix
  93538. * @param transform transformation matrix to be applied to the resulting frustum plane
  93539. * @param frustumPlane the resuling frustum plane
  93540. */
  93541. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  93542. /**
  93543. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  93544. * @param transform transformation matrix to be applied to the resulting frustum planes
  93545. * @param frustumPlanes the resuling frustum planes
  93546. */
  93547. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  93548. }
  93549. }
  93550. declare module BABYLON {
  93551. interface Engine {
  93552. /**
  93553. * Creates a new multiview render target
  93554. * @param width defines the width of the texture
  93555. * @param height defines the height of the texture
  93556. * @returns the created multiview texture
  93557. */
  93558. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  93559. /**
  93560. * Binds a multiview framebuffer to be drawn to
  93561. * @param multiviewTexture texture to bind
  93562. */
  93563. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  93564. }
  93565. interface Camera {
  93566. /**
  93567. * @hidden
  93568. * 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)
  93569. */
  93570. _useMultiviewToSingleView: boolean;
  93571. /**
  93572. * @hidden
  93573. * 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)
  93574. */
  93575. _multiviewTexture: Nullable<RenderTargetTexture>;
  93576. /**
  93577. * @hidden
  93578. * ensures the multiview texture of the camera exists and has the specified width/height
  93579. * @param width height to set on the multiview texture
  93580. * @param height width to set on the multiview texture
  93581. */
  93582. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  93583. }
  93584. interface Scene {
  93585. /** @hidden */
  93586. _transformMatrixR: Matrix;
  93587. /** @hidden */
  93588. _multiviewSceneUbo: Nullable<UniformBuffer>;
  93589. /** @hidden */
  93590. _createMultiviewUbo(): void;
  93591. /** @hidden */
  93592. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  93593. /** @hidden */
  93594. _renderMultiviewToSingleView(camera: Camera): void;
  93595. }
  93596. }
  93597. declare module BABYLON {
  93598. /**
  93599. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  93600. * This will not be used for webXR as it supports displaying texture arrays directly
  93601. */
  93602. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  93603. /**
  93604. * Initializes a VRMultiviewToSingleview
  93605. * @param name name of the post process
  93606. * @param camera camera to be applied to
  93607. * @param scaleFactor scaling factor to the size of the output texture
  93608. */
  93609. constructor(name: string, camera: Camera, scaleFactor: number);
  93610. }
  93611. }
  93612. declare module BABYLON {
  93613. /**
  93614. * Interface used to define additional presentation attributes
  93615. */
  93616. export interface IVRPresentationAttributes {
  93617. /**
  93618. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  93619. */
  93620. highRefreshRate: boolean;
  93621. /**
  93622. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  93623. */
  93624. foveationLevel: number;
  93625. }
  93626. interface Engine {
  93627. /** @hidden */
  93628. _vrDisplay: any;
  93629. /** @hidden */
  93630. _vrSupported: boolean;
  93631. /** @hidden */
  93632. _oldSize: Size;
  93633. /** @hidden */
  93634. _oldHardwareScaleFactor: number;
  93635. /** @hidden */
  93636. _vrExclusivePointerMode: boolean;
  93637. /** @hidden */
  93638. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  93639. /** @hidden */
  93640. _onVRDisplayPointerRestricted: () => void;
  93641. /** @hidden */
  93642. _onVRDisplayPointerUnrestricted: () => void;
  93643. /** @hidden */
  93644. _onVrDisplayConnect: Nullable<(display: any) => void>;
  93645. /** @hidden */
  93646. _onVrDisplayDisconnect: Nullable<() => void>;
  93647. /** @hidden */
  93648. _onVrDisplayPresentChange: Nullable<() => void>;
  93649. /**
  93650. * Observable signaled when VR display mode changes
  93651. */
  93652. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  93653. /**
  93654. * Observable signaled when VR request present is complete
  93655. */
  93656. onVRRequestPresentComplete: Observable<boolean>;
  93657. /**
  93658. * Observable signaled when VR request present starts
  93659. */
  93660. onVRRequestPresentStart: Observable<Engine>;
  93661. /**
  93662. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  93663. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  93664. */
  93665. isInVRExclusivePointerMode: boolean;
  93666. /**
  93667. * Gets a boolean indicating if a webVR device was detected
  93668. * @returns true if a webVR device was detected
  93669. */
  93670. isVRDevicePresent(): boolean;
  93671. /**
  93672. * Gets the current webVR device
  93673. * @returns the current webVR device (or null)
  93674. */
  93675. getVRDevice(): any;
  93676. /**
  93677. * Initializes a webVR display and starts listening to display change events
  93678. * The onVRDisplayChangedObservable will be notified upon these changes
  93679. * @returns A promise containing a VRDisplay and if vr is supported
  93680. */
  93681. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  93682. /** @hidden */
  93683. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  93684. /**
  93685. * Gets or sets the presentation attributes used to configure VR rendering
  93686. */
  93687. vrPresentationAttributes?: IVRPresentationAttributes;
  93688. /**
  93689. * Call this function to switch to webVR mode
  93690. * Will do nothing if webVR is not supported or if there is no webVR device
  93691. * @param options the webvr options provided to the camera. mainly used for multiview
  93692. * @see http://doc.babylonjs.com/how_to/webvr_camera
  93693. */
  93694. enableVR(options: WebVROptions): void;
  93695. /** @hidden */
  93696. _onVRFullScreenTriggered(): void;
  93697. }
  93698. }
  93699. declare module BABYLON {
  93700. /**
  93701. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  93702. * IMPORTANT!! The data is right-hand data.
  93703. * @export
  93704. * @interface DevicePose
  93705. */
  93706. export interface DevicePose {
  93707. /**
  93708. * The position of the device, values in array are [x,y,z].
  93709. */
  93710. readonly position: Nullable<Float32Array>;
  93711. /**
  93712. * The linearVelocity of the device, values in array are [x,y,z].
  93713. */
  93714. readonly linearVelocity: Nullable<Float32Array>;
  93715. /**
  93716. * The linearAcceleration of the device, values in array are [x,y,z].
  93717. */
  93718. readonly linearAcceleration: Nullable<Float32Array>;
  93719. /**
  93720. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  93721. */
  93722. readonly orientation: Nullable<Float32Array>;
  93723. /**
  93724. * The angularVelocity of the device, values in array are [x,y,z].
  93725. */
  93726. readonly angularVelocity: Nullable<Float32Array>;
  93727. /**
  93728. * The angularAcceleration of the device, values in array are [x,y,z].
  93729. */
  93730. readonly angularAcceleration: Nullable<Float32Array>;
  93731. }
  93732. /**
  93733. * Interface representing a pose controlled object in Babylon.
  93734. * A pose controlled object has both regular pose values as well as pose values
  93735. * from an external device such as a VR head mounted display
  93736. */
  93737. export interface PoseControlled {
  93738. /**
  93739. * The position of the object in babylon space.
  93740. */
  93741. position: Vector3;
  93742. /**
  93743. * The rotation quaternion of the object in babylon space.
  93744. */
  93745. rotationQuaternion: Quaternion;
  93746. /**
  93747. * The position of the device in babylon space.
  93748. */
  93749. devicePosition?: Vector3;
  93750. /**
  93751. * The rotation quaternion of the device in babylon space.
  93752. */
  93753. deviceRotationQuaternion: Quaternion;
  93754. /**
  93755. * The raw pose coming from the device.
  93756. */
  93757. rawPose: Nullable<DevicePose>;
  93758. /**
  93759. * The scale of the device to be used when translating from device space to babylon space.
  93760. */
  93761. deviceScaleFactor: number;
  93762. /**
  93763. * Updates the poseControlled values based on the input device pose.
  93764. * @param poseData the pose data to update the object with
  93765. */
  93766. updateFromDevice(poseData: DevicePose): void;
  93767. }
  93768. /**
  93769. * Set of options to customize the webVRCamera
  93770. */
  93771. export interface WebVROptions {
  93772. /**
  93773. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  93774. */
  93775. trackPosition?: boolean;
  93776. /**
  93777. * Sets the scale of the vrDevice in babylon space. (default: 1)
  93778. */
  93779. positionScale?: number;
  93780. /**
  93781. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  93782. */
  93783. displayName?: string;
  93784. /**
  93785. * Should the native controller meshes be initialized. (default: true)
  93786. */
  93787. controllerMeshes?: boolean;
  93788. /**
  93789. * Creating a default HemiLight only on controllers. (default: true)
  93790. */
  93791. defaultLightingOnControllers?: boolean;
  93792. /**
  93793. * If you don't want to use the default VR button of the helper. (default: false)
  93794. */
  93795. useCustomVRButton?: boolean;
  93796. /**
  93797. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  93798. */
  93799. customVRButton?: HTMLButtonElement;
  93800. /**
  93801. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  93802. */
  93803. rayLength?: number;
  93804. /**
  93805. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  93806. */
  93807. defaultHeight?: number;
  93808. /**
  93809. * If multiview should be used if availible (default: false)
  93810. */
  93811. useMultiview?: boolean;
  93812. }
  93813. /**
  93814. * This represents a WebVR camera.
  93815. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  93816. * @example http://doc.babylonjs.com/how_to/webvr_camera
  93817. */
  93818. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  93819. private webVROptions;
  93820. /**
  93821. * @hidden
  93822. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  93823. */
  93824. _vrDevice: any;
  93825. /**
  93826. * The rawPose of the vrDevice.
  93827. */
  93828. rawPose: Nullable<DevicePose>;
  93829. private _onVREnabled;
  93830. private _specsVersion;
  93831. private _attached;
  93832. private _frameData;
  93833. protected _descendants: Array<Node>;
  93834. private _deviceRoomPosition;
  93835. /** @hidden */
  93836. _deviceRoomRotationQuaternion: Quaternion;
  93837. private _standingMatrix;
  93838. /**
  93839. * Represents device position in babylon space.
  93840. */
  93841. devicePosition: Vector3;
  93842. /**
  93843. * Represents device rotation in babylon space.
  93844. */
  93845. deviceRotationQuaternion: Quaternion;
  93846. /**
  93847. * The scale of the device to be used when translating from device space to babylon space.
  93848. */
  93849. deviceScaleFactor: number;
  93850. private _deviceToWorld;
  93851. private _worldToDevice;
  93852. /**
  93853. * References to the webVR controllers for the vrDevice.
  93854. */
  93855. controllers: Array<WebVRController>;
  93856. /**
  93857. * Emits an event when a controller is attached.
  93858. */
  93859. onControllersAttachedObservable: Observable<WebVRController[]>;
  93860. /**
  93861. * Emits an event when a controller's mesh has been loaded;
  93862. */
  93863. onControllerMeshLoadedObservable: Observable<WebVRController>;
  93864. /**
  93865. * Emits an event when the HMD's pose has been updated.
  93866. */
  93867. onPoseUpdatedFromDeviceObservable: Observable<any>;
  93868. private _poseSet;
  93869. /**
  93870. * If the rig cameras be used as parent instead of this camera.
  93871. */
  93872. rigParenting: boolean;
  93873. private _lightOnControllers;
  93874. private _defaultHeight?;
  93875. /**
  93876. * Instantiates a WebVRFreeCamera.
  93877. * @param name The name of the WebVRFreeCamera
  93878. * @param position The starting anchor position for the camera
  93879. * @param scene The scene the camera belongs to
  93880. * @param webVROptions a set of customizable options for the webVRCamera
  93881. */
  93882. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  93883. /**
  93884. * Gets the device distance from the ground in meters.
  93885. * @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.
  93886. */
  93887. deviceDistanceToRoomGround(): number;
  93888. /**
  93889. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  93890. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  93891. */
  93892. useStandingMatrix(callback?: (bool: boolean) => void): void;
  93893. /**
  93894. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  93895. * @returns A promise with a boolean set to if the standing matrix is supported.
  93896. */
  93897. useStandingMatrixAsync(): Promise<boolean>;
  93898. /**
  93899. * Disposes the camera
  93900. */
  93901. dispose(): void;
  93902. /**
  93903. * Gets a vrController by name.
  93904. * @param name The name of the controller to retreive
  93905. * @returns the controller matching the name specified or null if not found
  93906. */
  93907. getControllerByName(name: string): Nullable<WebVRController>;
  93908. private _leftController;
  93909. /**
  93910. * The controller corresponding to the users left hand.
  93911. */
  93912. get leftController(): Nullable<WebVRController>;
  93913. private _rightController;
  93914. /**
  93915. * The controller corresponding to the users right hand.
  93916. */
  93917. get rightController(): Nullable<WebVRController>;
  93918. /**
  93919. * Casts a ray forward from the vrCamera's gaze.
  93920. * @param length Length of the ray (default: 100)
  93921. * @returns the ray corresponding to the gaze
  93922. */
  93923. getForwardRay(length?: number): Ray;
  93924. /**
  93925. * @hidden
  93926. * Updates the camera based on device's frame data
  93927. */
  93928. _checkInputs(): void;
  93929. /**
  93930. * Updates the poseControlled values based on the input device pose.
  93931. * @param poseData Pose coming from the device
  93932. */
  93933. updateFromDevice(poseData: DevicePose): void;
  93934. private _htmlElementAttached;
  93935. private _detachIfAttached;
  93936. /**
  93937. * WebVR's attach control will start broadcasting frames to the device.
  93938. * Note that in certain browsers (chrome for example) this function must be called
  93939. * within a user-interaction callback. Example:
  93940. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  93941. *
  93942. * @param element html element to attach the vrDevice to
  93943. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  93944. */
  93945. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  93946. /**
  93947. * Detaches the camera from the html element and disables VR
  93948. *
  93949. * @param element html element to detach from
  93950. */
  93951. detachControl(element: HTMLElement): void;
  93952. /**
  93953. * @returns the name of this class
  93954. */
  93955. getClassName(): string;
  93956. /**
  93957. * Calls resetPose on the vrDisplay
  93958. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  93959. */
  93960. resetToCurrentRotation(): void;
  93961. /**
  93962. * @hidden
  93963. * Updates the rig cameras (left and right eye)
  93964. */
  93965. _updateRigCameras(): void;
  93966. private _workingVector;
  93967. private _oneVector;
  93968. private _workingMatrix;
  93969. private updateCacheCalled;
  93970. private _correctPositionIfNotTrackPosition;
  93971. /**
  93972. * @hidden
  93973. * Updates the cached values of the camera
  93974. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  93975. */
  93976. _updateCache(ignoreParentClass?: boolean): void;
  93977. /**
  93978. * @hidden
  93979. * Get current device position in babylon world
  93980. */
  93981. _computeDevicePosition(): void;
  93982. /**
  93983. * Updates the current device position and rotation in the babylon world
  93984. */
  93985. update(): void;
  93986. /**
  93987. * @hidden
  93988. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  93989. * @returns an identity matrix
  93990. */
  93991. _getViewMatrix(): Matrix;
  93992. private _tmpMatrix;
  93993. /**
  93994. * This function is called by the two RIG cameras.
  93995. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  93996. * @hidden
  93997. */
  93998. _getWebVRViewMatrix(): Matrix;
  93999. /** @hidden */
  94000. _getWebVRProjectionMatrix(): Matrix;
  94001. private _onGamepadConnectedObserver;
  94002. private _onGamepadDisconnectedObserver;
  94003. private _updateCacheWhenTrackingDisabledObserver;
  94004. /**
  94005. * Initializes the controllers and their meshes
  94006. */
  94007. initControllers(): void;
  94008. }
  94009. }
  94010. declare module BABYLON {
  94011. /**
  94012. * Size options for a post process
  94013. */
  94014. export type PostProcessOptions = {
  94015. width: number;
  94016. height: number;
  94017. };
  94018. /**
  94019. * PostProcess can be used to apply a shader to a texture after it has been rendered
  94020. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  94021. */
  94022. export class PostProcess {
  94023. /** Name of the PostProcess. */
  94024. name: string;
  94025. /**
  94026. * Gets or sets the unique id of the post process
  94027. */
  94028. uniqueId: number;
  94029. /**
  94030. * Width of the texture to apply the post process on
  94031. */
  94032. width: number;
  94033. /**
  94034. * Height of the texture to apply the post process on
  94035. */
  94036. height: number;
  94037. /**
  94038. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  94039. * @hidden
  94040. */
  94041. _outputTexture: Nullable<InternalTexture>;
  94042. /**
  94043. * Sampling mode used by the shader
  94044. * See https://doc.babylonjs.com/classes/3.1/texture
  94045. */
  94046. renderTargetSamplingMode: number;
  94047. /**
  94048. * Clear color to use when screen clearing
  94049. */
  94050. clearColor: Color4;
  94051. /**
  94052. * If the buffer needs to be cleared before applying the post process. (default: true)
  94053. * Should be set to false if shader will overwrite all previous pixels.
  94054. */
  94055. autoClear: boolean;
  94056. /**
  94057. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  94058. */
  94059. alphaMode: number;
  94060. /**
  94061. * Sets the setAlphaBlendConstants of the babylon engine
  94062. */
  94063. alphaConstants: Color4;
  94064. /**
  94065. * Animations to be used for the post processing
  94066. */
  94067. animations: Animation[];
  94068. /**
  94069. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  94070. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  94071. */
  94072. enablePixelPerfectMode: boolean;
  94073. /**
  94074. * Force the postprocess to be applied without taking in account viewport
  94075. */
  94076. forceFullscreenViewport: boolean;
  94077. /**
  94078. * List of inspectable custom properties (used by the Inspector)
  94079. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  94080. */
  94081. inspectableCustomProperties: IInspectable[];
  94082. /**
  94083. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  94084. *
  94085. * | Value | Type | Description |
  94086. * | ----- | ----------------------------------- | ----------- |
  94087. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  94088. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  94089. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  94090. *
  94091. */
  94092. scaleMode: number;
  94093. /**
  94094. * Force textures to be a power of two (default: false)
  94095. */
  94096. alwaysForcePOT: boolean;
  94097. private _samples;
  94098. /**
  94099. * Number of sample textures (default: 1)
  94100. */
  94101. get samples(): number;
  94102. set samples(n: number);
  94103. /**
  94104. * Modify the scale of the post process to be the same as the viewport (default: false)
  94105. */
  94106. adaptScaleToCurrentViewport: boolean;
  94107. private _camera;
  94108. private _scene;
  94109. private _engine;
  94110. private _options;
  94111. private _reusable;
  94112. private _textureType;
  94113. private _textureFormat;
  94114. /**
  94115. * Smart array of input and output textures for the post process.
  94116. * @hidden
  94117. */
  94118. _textures: SmartArray<InternalTexture>;
  94119. /**
  94120. * The index in _textures that corresponds to the output texture.
  94121. * @hidden
  94122. */
  94123. _currentRenderTextureInd: number;
  94124. private _effect;
  94125. private _samplers;
  94126. private _fragmentUrl;
  94127. private _vertexUrl;
  94128. private _parameters;
  94129. private _scaleRatio;
  94130. protected _indexParameters: any;
  94131. private _shareOutputWithPostProcess;
  94132. private _texelSize;
  94133. private _forcedOutputTexture;
  94134. /**
  94135. * Returns the fragment url or shader name used in the post process.
  94136. * @returns the fragment url or name in the shader store.
  94137. */
  94138. getEffectName(): string;
  94139. /**
  94140. * An event triggered when the postprocess is activated.
  94141. */
  94142. onActivateObservable: Observable<Camera>;
  94143. private _onActivateObserver;
  94144. /**
  94145. * A function that is added to the onActivateObservable
  94146. */
  94147. set onActivate(callback: Nullable<(camera: Camera) => void>);
  94148. /**
  94149. * An event triggered when the postprocess changes its size.
  94150. */
  94151. onSizeChangedObservable: Observable<PostProcess>;
  94152. private _onSizeChangedObserver;
  94153. /**
  94154. * A function that is added to the onSizeChangedObservable
  94155. */
  94156. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  94157. /**
  94158. * An event triggered when the postprocess applies its effect.
  94159. */
  94160. onApplyObservable: Observable<Effect>;
  94161. private _onApplyObserver;
  94162. /**
  94163. * A function that is added to the onApplyObservable
  94164. */
  94165. set onApply(callback: (effect: Effect) => void);
  94166. /**
  94167. * An event triggered before rendering the postprocess
  94168. */
  94169. onBeforeRenderObservable: Observable<Effect>;
  94170. private _onBeforeRenderObserver;
  94171. /**
  94172. * A function that is added to the onBeforeRenderObservable
  94173. */
  94174. set onBeforeRender(callback: (effect: Effect) => void);
  94175. /**
  94176. * An event triggered after rendering the postprocess
  94177. */
  94178. onAfterRenderObservable: Observable<Effect>;
  94179. private _onAfterRenderObserver;
  94180. /**
  94181. * A function that is added to the onAfterRenderObservable
  94182. */
  94183. set onAfterRender(callback: (efect: Effect) => void);
  94184. /**
  94185. * 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
  94186. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  94187. */
  94188. get inputTexture(): InternalTexture;
  94189. set inputTexture(value: InternalTexture);
  94190. /**
  94191. * Gets the camera which post process is applied to.
  94192. * @returns The camera the post process is applied to.
  94193. */
  94194. getCamera(): Camera;
  94195. /**
  94196. * Gets the texel size of the postprocess.
  94197. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  94198. */
  94199. get texelSize(): Vector2;
  94200. /**
  94201. * Creates a new instance PostProcess
  94202. * @param name The name of the PostProcess.
  94203. * @param fragmentUrl The url of the fragment shader to be used.
  94204. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  94205. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  94206. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  94207. * @param camera The camera to apply the render pass to.
  94208. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  94209. * @param engine The engine which the post process will be applied. (default: current engine)
  94210. * @param reusable If the post process can be reused on the same frame. (default: false)
  94211. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  94212. * @param textureType Type of textures used when performing the post process. (default: 0)
  94213. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  94214. * @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
  94215. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  94216. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  94217. */
  94218. constructor(
  94219. /** Name of the PostProcess. */
  94220. 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);
  94221. /**
  94222. * Gets a string idenfifying the name of the class
  94223. * @returns "PostProcess" string
  94224. */
  94225. getClassName(): string;
  94226. /**
  94227. * Gets the engine which this post process belongs to.
  94228. * @returns The engine the post process was enabled with.
  94229. */
  94230. getEngine(): Engine;
  94231. /**
  94232. * The effect that is created when initializing the post process.
  94233. * @returns The created effect corresponding the the postprocess.
  94234. */
  94235. getEffect(): Effect;
  94236. /**
  94237. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  94238. * @param postProcess The post process to share the output with.
  94239. * @returns This post process.
  94240. */
  94241. shareOutputWith(postProcess: PostProcess): PostProcess;
  94242. /**
  94243. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  94244. * This should be called if the post process that shares output with this post process is disabled/disposed.
  94245. */
  94246. useOwnOutput(): void;
  94247. /**
  94248. * Updates the effect with the current post process compile time values and recompiles the shader.
  94249. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  94250. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  94251. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  94252. * @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
  94253. * @param onCompiled Called when the shader has been compiled.
  94254. * @param onError Called if there is an error when compiling a shader.
  94255. */
  94256. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  94257. /**
  94258. * The post process is reusable if it can be used multiple times within one frame.
  94259. * @returns If the post process is reusable
  94260. */
  94261. isReusable(): boolean;
  94262. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  94263. markTextureDirty(): void;
  94264. /**
  94265. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  94266. * 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.
  94267. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  94268. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  94269. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  94270. * @returns The target texture that was bound to be written to.
  94271. */
  94272. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  94273. /**
  94274. * If the post process is supported.
  94275. */
  94276. get isSupported(): boolean;
  94277. /**
  94278. * The aspect ratio of the output texture.
  94279. */
  94280. get aspectRatio(): number;
  94281. /**
  94282. * Get a value indicating if the post-process is ready to be used
  94283. * @returns true if the post-process is ready (shader is compiled)
  94284. */
  94285. isReady(): boolean;
  94286. /**
  94287. * Binds all textures and uniforms to the shader, this will be run on every pass.
  94288. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  94289. */
  94290. apply(): Nullable<Effect>;
  94291. private _disposeTextures;
  94292. /**
  94293. * Disposes the post process.
  94294. * @param camera The camera to dispose the post process on.
  94295. */
  94296. dispose(camera?: Camera): void;
  94297. }
  94298. }
  94299. declare module BABYLON {
  94300. /** @hidden */
  94301. export var kernelBlurVaryingDeclaration: {
  94302. name: string;
  94303. shader: string;
  94304. };
  94305. }
  94306. declare module BABYLON {
  94307. /** @hidden */
  94308. export var kernelBlurFragment: {
  94309. name: string;
  94310. shader: string;
  94311. };
  94312. }
  94313. declare module BABYLON {
  94314. /** @hidden */
  94315. export var kernelBlurFragment2: {
  94316. name: string;
  94317. shader: string;
  94318. };
  94319. }
  94320. declare module BABYLON {
  94321. /** @hidden */
  94322. export var kernelBlurPixelShader: {
  94323. name: string;
  94324. shader: string;
  94325. };
  94326. }
  94327. declare module BABYLON {
  94328. /** @hidden */
  94329. export var kernelBlurVertex: {
  94330. name: string;
  94331. shader: string;
  94332. };
  94333. }
  94334. declare module BABYLON {
  94335. /** @hidden */
  94336. export var kernelBlurVertexShader: {
  94337. name: string;
  94338. shader: string;
  94339. };
  94340. }
  94341. declare module BABYLON {
  94342. /**
  94343. * The Blur Post Process which blurs an image based on a kernel and direction.
  94344. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  94345. */
  94346. export class BlurPostProcess extends PostProcess {
  94347. /** The direction in which to blur the image. */
  94348. direction: Vector2;
  94349. private blockCompilation;
  94350. protected _kernel: number;
  94351. protected _idealKernel: number;
  94352. protected _packedFloat: boolean;
  94353. private _staticDefines;
  94354. /**
  94355. * Sets the length in pixels of the blur sample region
  94356. */
  94357. set kernel(v: number);
  94358. /**
  94359. * Gets the length in pixels of the blur sample region
  94360. */
  94361. get kernel(): number;
  94362. /**
  94363. * Sets wether or not the blur needs to unpack/repack floats
  94364. */
  94365. set packedFloat(v: boolean);
  94366. /**
  94367. * Gets wether or not the blur is unpacking/repacking floats
  94368. */
  94369. get packedFloat(): boolean;
  94370. /**
  94371. * Creates a new instance BlurPostProcess
  94372. * @param name The name of the effect.
  94373. * @param direction The direction in which to blur the image.
  94374. * @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.
  94375. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  94376. * @param camera The camera to apply the render pass to.
  94377. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  94378. * @param engine The engine which the post process will be applied. (default: current engine)
  94379. * @param reusable If the post process can be reused on the same frame. (default: false)
  94380. * @param textureType Type of textures used when performing the post process. (default: 0)
  94381. * @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)
  94382. */
  94383. constructor(name: string,
  94384. /** The direction in which to blur the image. */
  94385. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  94386. /**
  94387. * Updates the effect with the current post process compile time values and recompiles the shader.
  94388. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  94389. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  94390. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  94391. * @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
  94392. * @param onCompiled Called when the shader has been compiled.
  94393. * @param onError Called if there is an error when compiling a shader.
  94394. */
  94395. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  94396. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  94397. /**
  94398. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  94399. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  94400. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  94401. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  94402. * The gaps between physical kernels are compensated for in the weighting of the samples
  94403. * @param idealKernel Ideal blur kernel.
  94404. * @return Nearest best kernel.
  94405. */
  94406. protected _nearestBestKernel(idealKernel: number): number;
  94407. /**
  94408. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  94409. * @param x The point on the Gaussian distribution to sample.
  94410. * @return the value of the Gaussian function at x.
  94411. */
  94412. protected _gaussianWeight(x: number): number;
  94413. /**
  94414. * Generates a string that can be used as a floating point number in GLSL.
  94415. * @param x Value to print.
  94416. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  94417. * @return GLSL float string.
  94418. */
  94419. protected _glslFloat(x: number, decimalFigures?: number): string;
  94420. }
  94421. }
  94422. declare module BABYLON {
  94423. /**
  94424. * Mirror texture can be used to simulate the view from a mirror in a scene.
  94425. * It will dynamically be rendered every frame to adapt to the camera point of view.
  94426. * You can then easily use it as a reflectionTexture on a flat surface.
  94427. * In case the surface is not a plane, please consider relying on reflection probes.
  94428. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  94429. */
  94430. export class MirrorTexture extends RenderTargetTexture {
  94431. private scene;
  94432. /**
  94433. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  94434. * 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.
  94435. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  94436. */
  94437. mirrorPlane: Plane;
  94438. /**
  94439. * Define the blur ratio used to blur the reflection if needed.
  94440. */
  94441. set blurRatio(value: number);
  94442. get blurRatio(): number;
  94443. /**
  94444. * Define the adaptive blur kernel used to blur the reflection if needed.
  94445. * This will autocompute the closest best match for the `blurKernel`
  94446. */
  94447. set adaptiveBlurKernel(value: number);
  94448. /**
  94449. * Define the blur kernel used to blur the reflection if needed.
  94450. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  94451. */
  94452. set blurKernel(value: number);
  94453. /**
  94454. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  94455. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  94456. */
  94457. set blurKernelX(value: number);
  94458. get blurKernelX(): number;
  94459. /**
  94460. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  94461. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  94462. */
  94463. set blurKernelY(value: number);
  94464. get blurKernelY(): number;
  94465. private _autoComputeBlurKernel;
  94466. protected _onRatioRescale(): void;
  94467. private _updateGammaSpace;
  94468. private _imageProcessingConfigChangeObserver;
  94469. private _transformMatrix;
  94470. private _mirrorMatrix;
  94471. private _savedViewMatrix;
  94472. private _blurX;
  94473. private _blurY;
  94474. private _adaptiveBlurKernel;
  94475. private _blurKernelX;
  94476. private _blurKernelY;
  94477. private _blurRatio;
  94478. /**
  94479. * Instantiates a Mirror Texture.
  94480. * Mirror texture can be used to simulate the view from a mirror in a scene.
  94481. * It will dynamically be rendered every frame to adapt to the camera point of view.
  94482. * You can then easily use it as a reflectionTexture on a flat surface.
  94483. * In case the surface is not a plane, please consider relying on reflection probes.
  94484. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  94485. * @param name
  94486. * @param size
  94487. * @param scene
  94488. * @param generateMipMaps
  94489. * @param type
  94490. * @param samplingMode
  94491. * @param generateDepthBuffer
  94492. */
  94493. constructor(name: string, size: number | {
  94494. width: number;
  94495. height: number;
  94496. } | {
  94497. ratio: number;
  94498. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  94499. private _preparePostProcesses;
  94500. /**
  94501. * Clone the mirror texture.
  94502. * @returns the cloned texture
  94503. */
  94504. clone(): MirrorTexture;
  94505. /**
  94506. * Serialize the texture to a JSON representation you could use in Parse later on
  94507. * @returns the serialized JSON representation
  94508. */
  94509. serialize(): any;
  94510. /**
  94511. * Dispose the texture and release its associated resources.
  94512. */
  94513. dispose(): void;
  94514. }
  94515. }
  94516. declare module BABYLON {
  94517. /**
  94518. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  94519. * @see http://doc.babylonjs.com/babylon101/materials#texture
  94520. */
  94521. export class Texture extends BaseTexture {
  94522. /**
  94523. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  94524. */
  94525. static SerializeBuffers: boolean;
  94526. /** @hidden */
  94527. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  94528. /** @hidden */
  94529. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  94530. /** @hidden */
  94531. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  94532. /** nearest is mag = nearest and min = nearest and mip = linear */
  94533. static readonly NEAREST_SAMPLINGMODE: number;
  94534. /** nearest is mag = nearest and min = nearest and mip = linear */
  94535. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  94536. /** Bilinear is mag = linear and min = linear and mip = nearest */
  94537. static readonly BILINEAR_SAMPLINGMODE: number;
  94538. /** Bilinear is mag = linear and min = linear and mip = nearest */
  94539. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  94540. /** Trilinear is mag = linear and min = linear and mip = linear */
  94541. static readonly TRILINEAR_SAMPLINGMODE: number;
  94542. /** Trilinear is mag = linear and min = linear and mip = linear */
  94543. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  94544. /** mag = nearest and min = nearest and mip = nearest */
  94545. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  94546. /** mag = nearest and min = linear and mip = nearest */
  94547. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  94548. /** mag = nearest and min = linear and mip = linear */
  94549. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  94550. /** mag = nearest and min = linear and mip = none */
  94551. static readonly NEAREST_LINEAR: number;
  94552. /** mag = nearest and min = nearest and mip = none */
  94553. static readonly NEAREST_NEAREST: number;
  94554. /** mag = linear and min = nearest and mip = nearest */
  94555. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  94556. /** mag = linear and min = nearest and mip = linear */
  94557. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  94558. /** mag = linear and min = linear and mip = none */
  94559. static readonly LINEAR_LINEAR: number;
  94560. /** mag = linear and min = nearest and mip = none */
  94561. static readonly LINEAR_NEAREST: number;
  94562. /** Explicit coordinates mode */
  94563. static readonly EXPLICIT_MODE: number;
  94564. /** Spherical coordinates mode */
  94565. static readonly SPHERICAL_MODE: number;
  94566. /** Planar coordinates mode */
  94567. static readonly PLANAR_MODE: number;
  94568. /** Cubic coordinates mode */
  94569. static readonly CUBIC_MODE: number;
  94570. /** Projection coordinates mode */
  94571. static readonly PROJECTION_MODE: number;
  94572. /** Inverse Cubic coordinates mode */
  94573. static readonly SKYBOX_MODE: number;
  94574. /** Inverse Cubic coordinates mode */
  94575. static readonly INVCUBIC_MODE: number;
  94576. /** Equirectangular coordinates mode */
  94577. static readonly EQUIRECTANGULAR_MODE: number;
  94578. /** Equirectangular Fixed coordinates mode */
  94579. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  94580. /** Equirectangular Fixed Mirrored coordinates mode */
  94581. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  94582. /** Texture is not repeating outside of 0..1 UVs */
  94583. static readonly CLAMP_ADDRESSMODE: number;
  94584. /** Texture is repeating outside of 0..1 UVs */
  94585. static readonly WRAP_ADDRESSMODE: number;
  94586. /** Texture is repeating and mirrored */
  94587. static readonly MIRROR_ADDRESSMODE: number;
  94588. /**
  94589. * 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
  94590. */
  94591. static UseSerializedUrlIfAny: boolean;
  94592. /**
  94593. * Define the url of the texture.
  94594. */
  94595. url: Nullable<string>;
  94596. /**
  94597. * Define an offset on the texture to offset the u coordinates of the UVs
  94598. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  94599. */
  94600. uOffset: number;
  94601. /**
  94602. * Define an offset on the texture to offset the v coordinates of the UVs
  94603. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  94604. */
  94605. vOffset: number;
  94606. /**
  94607. * Define an offset on the texture to scale the u coordinates of the UVs
  94608. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  94609. */
  94610. uScale: number;
  94611. /**
  94612. * Define an offset on the texture to scale the v coordinates of the UVs
  94613. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  94614. */
  94615. vScale: number;
  94616. /**
  94617. * Define an offset on the texture to rotate around the u coordinates of the UVs
  94618. * @see http://doc.babylonjs.com/how_to/more_materials
  94619. */
  94620. uAng: number;
  94621. /**
  94622. * Define an offset on the texture to rotate around the v coordinates of the UVs
  94623. * @see http://doc.babylonjs.com/how_to/more_materials
  94624. */
  94625. vAng: number;
  94626. /**
  94627. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  94628. * @see http://doc.babylonjs.com/how_to/more_materials
  94629. */
  94630. wAng: number;
  94631. /**
  94632. * Defines the center of rotation (U)
  94633. */
  94634. uRotationCenter: number;
  94635. /**
  94636. * Defines the center of rotation (V)
  94637. */
  94638. vRotationCenter: number;
  94639. /**
  94640. * Defines the center of rotation (W)
  94641. */
  94642. wRotationCenter: number;
  94643. /**
  94644. * Are mip maps generated for this texture or not.
  94645. */
  94646. get noMipmap(): boolean;
  94647. /**
  94648. * List of inspectable custom properties (used by the Inspector)
  94649. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  94650. */
  94651. inspectableCustomProperties: Nullable<IInspectable[]>;
  94652. private _noMipmap;
  94653. /** @hidden */
  94654. _invertY: boolean;
  94655. private _rowGenerationMatrix;
  94656. private _cachedTextureMatrix;
  94657. private _projectionModeMatrix;
  94658. private _t0;
  94659. private _t1;
  94660. private _t2;
  94661. private _cachedUOffset;
  94662. private _cachedVOffset;
  94663. private _cachedUScale;
  94664. private _cachedVScale;
  94665. private _cachedUAng;
  94666. private _cachedVAng;
  94667. private _cachedWAng;
  94668. private _cachedProjectionMatrixId;
  94669. private _cachedCoordinatesMode;
  94670. /** @hidden */
  94671. protected _initialSamplingMode: number;
  94672. /** @hidden */
  94673. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  94674. private _deleteBuffer;
  94675. protected _format: Nullable<number>;
  94676. private _delayedOnLoad;
  94677. private _delayedOnError;
  94678. private _mimeType?;
  94679. /**
  94680. * Observable triggered once the texture has been loaded.
  94681. */
  94682. onLoadObservable: Observable<Texture>;
  94683. protected _isBlocking: boolean;
  94684. /**
  94685. * Is the texture preventing material to render while loading.
  94686. * If false, a default texture will be used instead of the loading one during the preparation step.
  94687. */
  94688. set isBlocking(value: boolean);
  94689. get isBlocking(): boolean;
  94690. /**
  94691. * Get the current sampling mode associated with the texture.
  94692. */
  94693. get samplingMode(): number;
  94694. /**
  94695. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  94696. */
  94697. get invertY(): boolean;
  94698. /**
  94699. * Instantiates a new texture.
  94700. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  94701. * @see http://doc.babylonjs.com/babylon101/materials#texture
  94702. * @param url defines the url of the picture to load as a texture
  94703. * @param scene defines the scene or engine the texture will belong to
  94704. * @param noMipmap defines if the texture will require mip maps or not
  94705. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  94706. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  94707. * @param onLoad defines a callback triggered when the texture has been loaded
  94708. * @param onError defines a callback triggered when an error occurred during the loading session
  94709. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  94710. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  94711. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  94712. * @param mimeType defines an optional mime type information
  94713. */
  94714. 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);
  94715. /**
  94716. * Update the url (and optional buffer) of this texture if url was null during construction.
  94717. * @param url the url of the texture
  94718. * @param buffer the buffer of the texture (defaults to null)
  94719. * @param onLoad callback called when the texture is loaded (defaults to null)
  94720. */
  94721. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  94722. /**
  94723. * Finish the loading sequence of a texture flagged as delayed load.
  94724. * @hidden
  94725. */
  94726. delayLoad(): void;
  94727. private _prepareRowForTextureGeneration;
  94728. /**
  94729. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  94730. * @returns the transform matrix of the texture.
  94731. */
  94732. getTextureMatrix(uBase?: number): Matrix;
  94733. /**
  94734. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  94735. * @returns The reflection texture transform
  94736. */
  94737. getReflectionTextureMatrix(): Matrix;
  94738. /**
  94739. * Clones the texture.
  94740. * @returns the cloned texture
  94741. */
  94742. clone(): Texture;
  94743. /**
  94744. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  94745. * @returns The JSON representation of the texture
  94746. */
  94747. serialize(): any;
  94748. /**
  94749. * Get the current class name of the texture useful for serialization or dynamic coding.
  94750. * @returns "Texture"
  94751. */
  94752. getClassName(): string;
  94753. /**
  94754. * Dispose the texture and release its associated resources.
  94755. */
  94756. dispose(): void;
  94757. /**
  94758. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  94759. * @param parsedTexture Define the JSON representation of the texture
  94760. * @param scene Define the scene the parsed texture should be instantiated in
  94761. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  94762. * @returns The parsed texture if successful
  94763. */
  94764. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  94765. /**
  94766. * Creates a texture from its base 64 representation.
  94767. * @param data Define the base64 payload without the data: prefix
  94768. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  94769. * @param scene Define the scene the texture should belong to
  94770. * @param noMipmap Forces the texture to not create mip map information if true
  94771. * @param invertY define if the texture needs to be inverted on the y axis during loading
  94772. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  94773. * @param onLoad define a callback triggered when the texture has been loaded
  94774. * @param onError define a callback triggered when an error occurred during the loading session
  94775. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  94776. * @returns the created texture
  94777. */
  94778. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  94779. /**
  94780. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  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 buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  94784. * @param scene Define the scene the texture should belong to
  94785. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  94786. * @param noMipmap Forces the texture to not create mip map information if true
  94787. * @param invertY define if the texture needs to be inverted on the y axis during loading
  94788. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  94789. * @param onLoad define a callback triggered when the texture has been loaded
  94790. * @param onError define a callback triggered when an error occurred during the loading session
  94791. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  94792. * @returns the created texture
  94793. */
  94794. 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;
  94795. }
  94796. }
  94797. declare module BABYLON {
  94798. /**
  94799. * PostProcessManager is used to manage one or more post processes or post process pipelines
  94800. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  94801. */
  94802. export class PostProcessManager {
  94803. private _scene;
  94804. private _indexBuffer;
  94805. private _vertexBuffers;
  94806. /**
  94807. * Creates a new instance PostProcess
  94808. * @param scene The scene that the post process is associated with.
  94809. */
  94810. constructor(scene: Scene);
  94811. private _prepareBuffers;
  94812. private _buildIndexBuffer;
  94813. /**
  94814. * Rebuilds the vertex buffers of the manager.
  94815. * @hidden
  94816. */
  94817. _rebuild(): void;
  94818. /**
  94819. * Prepares a frame to be run through a post process.
  94820. * @param sourceTexture The input texture to the post procesess. (default: null)
  94821. * @param postProcesses An array of post processes to be run. (default: null)
  94822. * @returns True if the post processes were able to be run.
  94823. * @hidden
  94824. */
  94825. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  94826. /**
  94827. * Manually render a set of post processes to a texture.
  94828. * @param postProcesses An array of post processes to be run.
  94829. * @param targetTexture The target texture to render to.
  94830. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  94831. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  94832. * @param lodLevel defines which lod of the texture to render to
  94833. */
  94834. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  94835. /**
  94836. * Finalize the result of the output of the postprocesses.
  94837. * @param doNotPresent If true the result will not be displayed to the screen.
  94838. * @param targetTexture The target texture to render to.
  94839. * @param faceIndex The index of the face to bind the target texture to.
  94840. * @param postProcesses The array of post processes to render.
  94841. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  94842. * @hidden
  94843. */
  94844. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  94845. /**
  94846. * Disposes of the post process manager.
  94847. */
  94848. dispose(): void;
  94849. }
  94850. }
  94851. declare module BABYLON {
  94852. /**
  94853. * This Helps creating a texture that will be created from a camera in your scene.
  94854. * It is basically a dynamic texture that could be used to create special effects for instance.
  94855. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  94856. */
  94857. export class RenderTargetTexture extends Texture {
  94858. isCube: boolean;
  94859. /**
  94860. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  94861. */
  94862. static readonly REFRESHRATE_RENDER_ONCE: number;
  94863. /**
  94864. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  94865. */
  94866. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  94867. /**
  94868. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  94869. * the central point of your effect and can save a lot of performances.
  94870. */
  94871. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  94872. /**
  94873. * Use this predicate to dynamically define the list of mesh you want to render.
  94874. * If set, the renderList property will be overwritten.
  94875. */
  94876. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  94877. private _renderList;
  94878. /**
  94879. * Use this list to define the list of mesh you want to render.
  94880. */
  94881. get renderList(): Nullable<Array<AbstractMesh>>;
  94882. set renderList(value: Nullable<Array<AbstractMesh>>);
  94883. /**
  94884. * Use this function to overload the renderList array at rendering time.
  94885. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  94886. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  94887. * the cube (if the RTT is a cube, else layerOrFace=0).
  94888. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  94889. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  94890. * hold dummy elements!
  94891. */
  94892. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  94893. private _hookArray;
  94894. /**
  94895. * Define if particles should be rendered in your texture.
  94896. */
  94897. renderParticles: boolean;
  94898. /**
  94899. * Define if sprites should be rendered in your texture.
  94900. */
  94901. renderSprites: boolean;
  94902. /**
  94903. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  94904. */
  94905. coordinatesMode: number;
  94906. /**
  94907. * Define the camera used to render the texture.
  94908. */
  94909. activeCamera: Nullable<Camera>;
  94910. /**
  94911. * Override the mesh isReady function with your own one.
  94912. */
  94913. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  94914. /**
  94915. * Override the render function of the texture with your own one.
  94916. */
  94917. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  94918. /**
  94919. * Define if camera post processes should be use while rendering the texture.
  94920. */
  94921. useCameraPostProcesses: boolean;
  94922. /**
  94923. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  94924. */
  94925. ignoreCameraViewport: boolean;
  94926. private _postProcessManager;
  94927. private _postProcesses;
  94928. private _resizeObserver;
  94929. /**
  94930. * An event triggered when the texture is unbind.
  94931. */
  94932. onBeforeBindObservable: Observable<RenderTargetTexture>;
  94933. /**
  94934. * An event triggered when the texture is unbind.
  94935. */
  94936. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  94937. private _onAfterUnbindObserver;
  94938. /**
  94939. * Set a after unbind callback in the texture.
  94940. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  94941. */
  94942. set onAfterUnbind(callback: () => void);
  94943. /**
  94944. * An event triggered before rendering the texture
  94945. */
  94946. onBeforeRenderObservable: Observable<number>;
  94947. private _onBeforeRenderObserver;
  94948. /**
  94949. * Set a before render callback in the texture.
  94950. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  94951. */
  94952. set onBeforeRender(callback: (faceIndex: number) => void);
  94953. /**
  94954. * An event triggered after rendering the texture
  94955. */
  94956. onAfterRenderObservable: Observable<number>;
  94957. private _onAfterRenderObserver;
  94958. /**
  94959. * Set a after render callback in the texture.
  94960. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  94961. */
  94962. set onAfterRender(callback: (faceIndex: number) => void);
  94963. /**
  94964. * An event triggered after the texture clear
  94965. */
  94966. onClearObservable: Observable<Engine>;
  94967. private _onClearObserver;
  94968. /**
  94969. * Set a clear callback in the texture.
  94970. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  94971. */
  94972. set onClear(callback: (Engine: Engine) => void);
  94973. /**
  94974. * An event triggered when the texture is resized.
  94975. */
  94976. onResizeObservable: Observable<RenderTargetTexture>;
  94977. /**
  94978. * Define the clear color of the Render Target if it should be different from the scene.
  94979. */
  94980. clearColor: Color4;
  94981. protected _size: number | {
  94982. width: number;
  94983. height: number;
  94984. layers?: number;
  94985. };
  94986. protected _initialSizeParameter: number | {
  94987. width: number;
  94988. height: number;
  94989. } | {
  94990. ratio: number;
  94991. };
  94992. protected _sizeRatio: Nullable<number>;
  94993. /** @hidden */
  94994. _generateMipMaps: boolean;
  94995. protected _renderingManager: RenderingManager;
  94996. /** @hidden */
  94997. _waitingRenderList: string[];
  94998. protected _doNotChangeAspectRatio: boolean;
  94999. protected _currentRefreshId: number;
  95000. protected _refreshRate: number;
  95001. protected _textureMatrix: Matrix;
  95002. protected _samples: number;
  95003. protected _renderTargetOptions: RenderTargetCreationOptions;
  95004. /**
  95005. * Gets render target creation options that were used.
  95006. */
  95007. get renderTargetOptions(): RenderTargetCreationOptions;
  95008. protected _engine: Engine;
  95009. protected _onRatioRescale(): void;
  95010. /**
  95011. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  95012. * It must define where the camera used to render the texture is set
  95013. */
  95014. boundingBoxPosition: Vector3;
  95015. private _boundingBoxSize;
  95016. /**
  95017. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  95018. * When defined, the cubemap will switch to local mode
  95019. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  95020. * @example https://www.babylonjs-playground.com/#RNASML
  95021. */
  95022. set boundingBoxSize(value: Vector3);
  95023. get boundingBoxSize(): Vector3;
  95024. /**
  95025. * In case the RTT has been created with a depth texture, get the associated
  95026. * depth texture.
  95027. * Otherwise, return null.
  95028. */
  95029. get depthStencilTexture(): Nullable<InternalTexture>;
  95030. /**
  95031. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  95032. * or used a shadow, depth texture...
  95033. * @param name The friendly name of the texture
  95034. * @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)
  95035. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  95036. * @param generateMipMaps True if mip maps need to be generated after render.
  95037. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  95038. * @param type The type of the buffer in the RTT (int, half float, float...)
  95039. * @param isCube True if a cube texture needs to be created
  95040. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  95041. * @param generateDepthBuffer True to generate a depth buffer
  95042. * @param generateStencilBuffer True to generate a stencil buffer
  95043. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  95044. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  95045. * @param delayAllocation if the texture allocation should be delayed (default: false)
  95046. */
  95047. constructor(name: string, size: number | {
  95048. width: number;
  95049. height: number;
  95050. layers?: number;
  95051. } | {
  95052. ratio: number;
  95053. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  95054. /**
  95055. * Creates a depth stencil texture.
  95056. * This is only available in WebGL 2 or with the depth texture extension available.
  95057. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  95058. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  95059. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  95060. */
  95061. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  95062. private _processSizeParameter;
  95063. /**
  95064. * Define the number of samples to use in case of MSAA.
  95065. * It defaults to one meaning no MSAA has been enabled.
  95066. */
  95067. get samples(): number;
  95068. set samples(value: number);
  95069. /**
  95070. * Resets the refresh counter of the texture and start bak from scratch.
  95071. * Could be useful to regenerate the texture if it is setup to render only once.
  95072. */
  95073. resetRefreshCounter(): void;
  95074. /**
  95075. * Define the refresh rate of the texture or the rendering frequency.
  95076. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  95077. */
  95078. get refreshRate(): number;
  95079. set refreshRate(value: number);
  95080. /**
  95081. * Adds a post process to the render target rendering passes.
  95082. * @param postProcess define the post process to add
  95083. */
  95084. addPostProcess(postProcess: PostProcess): void;
  95085. /**
  95086. * Clear all the post processes attached to the render target
  95087. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  95088. */
  95089. clearPostProcesses(dispose?: boolean): void;
  95090. /**
  95091. * Remove one of the post process from the list of attached post processes to the texture
  95092. * @param postProcess define the post process to remove from the list
  95093. */
  95094. removePostProcess(postProcess: PostProcess): void;
  95095. /** @hidden */
  95096. _shouldRender(): boolean;
  95097. /**
  95098. * Gets the actual render size of the texture.
  95099. * @returns the width of the render size
  95100. */
  95101. getRenderSize(): number;
  95102. /**
  95103. * Gets the actual render width of the texture.
  95104. * @returns the width of the render size
  95105. */
  95106. getRenderWidth(): number;
  95107. /**
  95108. * Gets the actual render height of the texture.
  95109. * @returns the height of the render size
  95110. */
  95111. getRenderHeight(): number;
  95112. /**
  95113. * Gets the actual number of layers of the texture.
  95114. * @returns the number of layers
  95115. */
  95116. getRenderLayers(): number;
  95117. /**
  95118. * Get if the texture can be rescaled or not.
  95119. */
  95120. get canRescale(): boolean;
  95121. /**
  95122. * Resize the texture using a ratio.
  95123. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  95124. */
  95125. scale(ratio: number): void;
  95126. /**
  95127. * Get the texture reflection matrix used to rotate/transform the reflection.
  95128. * @returns the reflection matrix
  95129. */
  95130. getReflectionTextureMatrix(): Matrix;
  95131. /**
  95132. * Resize the texture to a new desired size.
  95133. * Be carrefull as it will recreate all the data in the new texture.
  95134. * @param size Define the new size. It can be:
  95135. * - a number for squared texture,
  95136. * - an object containing { width: number, height: number }
  95137. * - or an object containing a ratio { ratio: number }
  95138. */
  95139. resize(size: number | {
  95140. width: number;
  95141. height: number;
  95142. } | {
  95143. ratio: number;
  95144. }): void;
  95145. private _defaultRenderListPrepared;
  95146. /**
  95147. * Renders all the objects from the render list into the texture.
  95148. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  95149. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  95150. */
  95151. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  95152. private _bestReflectionRenderTargetDimension;
  95153. private _prepareRenderingManager;
  95154. /**
  95155. * @hidden
  95156. * @param faceIndex face index to bind to if this is a cubetexture
  95157. * @param layer defines the index of the texture to bind in the array
  95158. */
  95159. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  95160. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  95161. private renderToTarget;
  95162. /**
  95163. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  95164. * This allowed control for front to back rendering or reversly depending of the special needs.
  95165. *
  95166. * @param renderingGroupId The rendering group id corresponding to its index
  95167. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  95168. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  95169. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  95170. */
  95171. 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;
  95172. /**
  95173. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  95174. *
  95175. * @param renderingGroupId The rendering group id corresponding to its index
  95176. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  95177. */
  95178. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  95179. /**
  95180. * Clones the texture.
  95181. * @returns the cloned texture
  95182. */
  95183. clone(): RenderTargetTexture;
  95184. /**
  95185. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  95186. * @returns The JSON representation of the texture
  95187. */
  95188. serialize(): any;
  95189. /**
  95190. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  95191. */
  95192. disposeFramebufferObjects(): void;
  95193. /**
  95194. * Dispose the texture and release its associated resources.
  95195. */
  95196. dispose(): void;
  95197. /** @hidden */
  95198. _rebuild(): void;
  95199. /**
  95200. * Clear the info related to rendering groups preventing retention point in material dispose.
  95201. */
  95202. freeRenderingGroups(): void;
  95203. /**
  95204. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  95205. * @returns the view count
  95206. */
  95207. getViewCount(): number;
  95208. }
  95209. }
  95210. declare module BABYLON {
  95211. /**
  95212. * Options for compiling materials.
  95213. */
  95214. export interface IMaterialCompilationOptions {
  95215. /**
  95216. * Defines whether clip planes are enabled.
  95217. */
  95218. clipPlane: boolean;
  95219. /**
  95220. * Defines whether instances are enabled.
  95221. */
  95222. useInstances: boolean;
  95223. }
  95224. /**
  95225. * Base class for the main features of a material in Babylon.js
  95226. */
  95227. export class Material implements IAnimatable {
  95228. /**
  95229. * Returns the triangle fill mode
  95230. */
  95231. static readonly TriangleFillMode: number;
  95232. /**
  95233. * Returns the wireframe mode
  95234. */
  95235. static readonly WireFrameFillMode: number;
  95236. /**
  95237. * Returns the point fill mode
  95238. */
  95239. static readonly PointFillMode: number;
  95240. /**
  95241. * Returns the point list draw mode
  95242. */
  95243. static readonly PointListDrawMode: number;
  95244. /**
  95245. * Returns the line list draw mode
  95246. */
  95247. static readonly LineListDrawMode: number;
  95248. /**
  95249. * Returns the line loop draw mode
  95250. */
  95251. static readonly LineLoopDrawMode: number;
  95252. /**
  95253. * Returns the line strip draw mode
  95254. */
  95255. static readonly LineStripDrawMode: number;
  95256. /**
  95257. * Returns the triangle strip draw mode
  95258. */
  95259. static readonly TriangleStripDrawMode: number;
  95260. /**
  95261. * Returns the triangle fan draw mode
  95262. */
  95263. static readonly TriangleFanDrawMode: number;
  95264. /**
  95265. * Stores the clock-wise side orientation
  95266. */
  95267. static readonly ClockWiseSideOrientation: number;
  95268. /**
  95269. * Stores the counter clock-wise side orientation
  95270. */
  95271. static readonly CounterClockWiseSideOrientation: number;
  95272. /**
  95273. * The dirty texture flag value
  95274. */
  95275. static readonly TextureDirtyFlag: number;
  95276. /**
  95277. * The dirty light flag value
  95278. */
  95279. static readonly LightDirtyFlag: number;
  95280. /**
  95281. * The dirty fresnel flag value
  95282. */
  95283. static readonly FresnelDirtyFlag: number;
  95284. /**
  95285. * The dirty attribute flag value
  95286. */
  95287. static readonly AttributesDirtyFlag: number;
  95288. /**
  95289. * The dirty misc flag value
  95290. */
  95291. static readonly MiscDirtyFlag: number;
  95292. /**
  95293. * The all dirty flag value
  95294. */
  95295. static readonly AllDirtyFlag: number;
  95296. /**
  95297. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  95298. */
  95299. static readonly MATERIAL_OPAQUE: number;
  95300. /**
  95301. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  95302. */
  95303. static readonly MATERIAL_ALPHATEST: number;
  95304. /**
  95305. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  95306. */
  95307. static readonly MATERIAL_ALPHABLEND: number;
  95308. /**
  95309. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  95310. * They are also discarded below the alpha cutoff threshold to improve performances.
  95311. */
  95312. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  95313. /**
  95314. * The ID of the material
  95315. */
  95316. id: string;
  95317. /**
  95318. * Gets or sets the unique id of the material
  95319. */
  95320. uniqueId: number;
  95321. /**
  95322. * The name of the material
  95323. */
  95324. name: string;
  95325. /**
  95326. * Gets or sets user defined metadata
  95327. */
  95328. metadata: any;
  95329. /**
  95330. * For internal use only. Please do not use.
  95331. */
  95332. reservedDataStore: any;
  95333. /**
  95334. * Specifies if the ready state should be checked on each call
  95335. */
  95336. checkReadyOnEveryCall: boolean;
  95337. /**
  95338. * Specifies if the ready state should be checked once
  95339. */
  95340. checkReadyOnlyOnce: boolean;
  95341. /**
  95342. * The state of the material
  95343. */
  95344. state: string;
  95345. /**
  95346. * The alpha value of the material
  95347. */
  95348. protected _alpha: number;
  95349. /**
  95350. * List of inspectable custom properties (used by the Inspector)
  95351. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  95352. */
  95353. inspectableCustomProperties: IInspectable[];
  95354. /**
  95355. * Sets the alpha value of the material
  95356. */
  95357. set alpha(value: number);
  95358. /**
  95359. * Gets the alpha value of the material
  95360. */
  95361. get alpha(): number;
  95362. /**
  95363. * Specifies if back face culling is enabled
  95364. */
  95365. protected _backFaceCulling: boolean;
  95366. /**
  95367. * Sets the back-face culling state
  95368. */
  95369. set backFaceCulling(value: boolean);
  95370. /**
  95371. * Gets the back-face culling state
  95372. */
  95373. get backFaceCulling(): boolean;
  95374. /**
  95375. * Stores the value for side orientation
  95376. */
  95377. sideOrientation: number;
  95378. /**
  95379. * Callback triggered when the material is compiled
  95380. */
  95381. onCompiled: Nullable<(effect: Effect) => void>;
  95382. /**
  95383. * Callback triggered when an error occurs
  95384. */
  95385. onError: Nullable<(effect: Effect, errors: string) => void>;
  95386. /**
  95387. * Callback triggered to get the render target textures
  95388. */
  95389. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  95390. /**
  95391. * Gets a boolean indicating that current material needs to register RTT
  95392. */
  95393. get hasRenderTargetTextures(): boolean;
  95394. /**
  95395. * Specifies if the material should be serialized
  95396. */
  95397. doNotSerialize: boolean;
  95398. /**
  95399. * @hidden
  95400. */
  95401. _storeEffectOnSubMeshes: boolean;
  95402. /**
  95403. * Stores the animations for the material
  95404. */
  95405. animations: Nullable<Array<Animation>>;
  95406. /**
  95407. * An event triggered when the material is disposed
  95408. */
  95409. onDisposeObservable: Observable<Material>;
  95410. /**
  95411. * An observer which watches for dispose events
  95412. */
  95413. private _onDisposeObserver;
  95414. private _onUnBindObservable;
  95415. /**
  95416. * Called during a dispose event
  95417. */
  95418. set onDispose(callback: () => void);
  95419. private _onBindObservable;
  95420. /**
  95421. * An event triggered when the material is bound
  95422. */
  95423. get onBindObservable(): Observable<AbstractMesh>;
  95424. /**
  95425. * An observer which watches for bind events
  95426. */
  95427. private _onBindObserver;
  95428. /**
  95429. * Called during a bind event
  95430. */
  95431. set onBind(callback: (Mesh: AbstractMesh) => void);
  95432. /**
  95433. * An event triggered when the material is unbound
  95434. */
  95435. get onUnBindObservable(): Observable<Material>;
  95436. /**
  95437. * Stores the value of the alpha mode
  95438. */
  95439. private _alphaMode;
  95440. /**
  95441. * Sets the value of the alpha mode.
  95442. *
  95443. * | Value | Type | Description |
  95444. * | --- | --- | --- |
  95445. * | 0 | ALPHA_DISABLE | |
  95446. * | 1 | ALPHA_ADD | |
  95447. * | 2 | ALPHA_COMBINE | |
  95448. * | 3 | ALPHA_SUBTRACT | |
  95449. * | 4 | ALPHA_MULTIPLY | |
  95450. * | 5 | ALPHA_MAXIMIZED | |
  95451. * | 6 | ALPHA_ONEONE | |
  95452. * | 7 | ALPHA_PREMULTIPLIED | |
  95453. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  95454. * | 9 | ALPHA_INTERPOLATE | |
  95455. * | 10 | ALPHA_SCREENMODE | |
  95456. *
  95457. */
  95458. set alphaMode(value: number);
  95459. /**
  95460. * Gets the value of the alpha mode
  95461. */
  95462. get alphaMode(): number;
  95463. /**
  95464. * Stores the state of the need depth pre-pass value
  95465. */
  95466. private _needDepthPrePass;
  95467. /**
  95468. * Sets the need depth pre-pass value
  95469. */
  95470. set needDepthPrePass(value: boolean);
  95471. /**
  95472. * Gets the depth pre-pass value
  95473. */
  95474. get needDepthPrePass(): boolean;
  95475. /**
  95476. * Specifies if depth writing should be disabled
  95477. */
  95478. disableDepthWrite: boolean;
  95479. /**
  95480. * Specifies if depth writing should be forced
  95481. */
  95482. forceDepthWrite: boolean;
  95483. /**
  95484. * Specifies the depth function that should be used. 0 means the default engine function
  95485. */
  95486. depthFunction: number;
  95487. /**
  95488. * Specifies if there should be a separate pass for culling
  95489. */
  95490. separateCullingPass: boolean;
  95491. /**
  95492. * Stores the state specifing if fog should be enabled
  95493. */
  95494. private _fogEnabled;
  95495. /**
  95496. * Sets the state for enabling fog
  95497. */
  95498. set fogEnabled(value: boolean);
  95499. /**
  95500. * Gets the value of the fog enabled state
  95501. */
  95502. get fogEnabled(): boolean;
  95503. /**
  95504. * Stores the size of points
  95505. */
  95506. pointSize: number;
  95507. /**
  95508. * Stores the z offset value
  95509. */
  95510. zOffset: number;
  95511. /**
  95512. * Gets a value specifying if wireframe mode is enabled
  95513. */
  95514. get wireframe(): boolean;
  95515. /**
  95516. * Sets the state of wireframe mode
  95517. */
  95518. set wireframe(value: boolean);
  95519. /**
  95520. * Gets the value specifying if point clouds are enabled
  95521. */
  95522. get pointsCloud(): boolean;
  95523. /**
  95524. * Sets the state of point cloud mode
  95525. */
  95526. set pointsCloud(value: boolean);
  95527. /**
  95528. * Gets the material fill mode
  95529. */
  95530. get fillMode(): number;
  95531. /**
  95532. * Sets the material fill mode
  95533. */
  95534. set fillMode(value: number);
  95535. /**
  95536. * @hidden
  95537. * Stores the effects for the material
  95538. */
  95539. _effect: Nullable<Effect>;
  95540. /**
  95541. * Specifies if uniform buffers should be used
  95542. */
  95543. private _useUBO;
  95544. /**
  95545. * Stores a reference to the scene
  95546. */
  95547. private _scene;
  95548. /**
  95549. * Stores the fill mode state
  95550. */
  95551. private _fillMode;
  95552. /**
  95553. * Specifies if the depth write state should be cached
  95554. */
  95555. private _cachedDepthWriteState;
  95556. /**
  95557. * Specifies if the depth function state should be cached
  95558. */
  95559. private _cachedDepthFunctionState;
  95560. /**
  95561. * Stores the uniform buffer
  95562. */
  95563. protected _uniformBuffer: UniformBuffer;
  95564. /** @hidden */
  95565. _indexInSceneMaterialArray: number;
  95566. /** @hidden */
  95567. meshMap: Nullable<{
  95568. [id: string]: AbstractMesh | undefined;
  95569. }>;
  95570. /**
  95571. * Creates a material instance
  95572. * @param name defines the name of the material
  95573. * @param scene defines the scene to reference
  95574. * @param doNotAdd specifies if the material should be added to the scene
  95575. */
  95576. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  95577. /**
  95578. * Returns a string representation of the current material
  95579. * @param fullDetails defines a boolean indicating which levels of logging is desired
  95580. * @returns a string with material information
  95581. */
  95582. toString(fullDetails?: boolean): string;
  95583. /**
  95584. * Gets the class name of the material
  95585. * @returns a string with the class name of the material
  95586. */
  95587. getClassName(): string;
  95588. /**
  95589. * Specifies if updates for the material been locked
  95590. */
  95591. get isFrozen(): boolean;
  95592. /**
  95593. * Locks updates for the material
  95594. */
  95595. freeze(): void;
  95596. /**
  95597. * Unlocks updates for the material
  95598. */
  95599. unfreeze(): void;
  95600. /**
  95601. * Specifies if the material is ready to be used
  95602. * @param mesh defines the mesh to check
  95603. * @param useInstances specifies if instances should be used
  95604. * @returns a boolean indicating if the material is ready to be used
  95605. */
  95606. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  95607. /**
  95608. * Specifies that the submesh is ready to be used
  95609. * @param mesh defines the mesh to check
  95610. * @param subMesh defines which submesh to check
  95611. * @param useInstances specifies that instances should be used
  95612. * @returns a boolean indicating that the submesh is ready or not
  95613. */
  95614. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  95615. /**
  95616. * Returns the material effect
  95617. * @returns the effect associated with the material
  95618. */
  95619. getEffect(): Nullable<Effect>;
  95620. /**
  95621. * Returns the current scene
  95622. * @returns a Scene
  95623. */
  95624. getScene(): Scene;
  95625. /**
  95626. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  95627. */
  95628. protected _forceAlphaTest: boolean;
  95629. /**
  95630. * The transparency mode of the material.
  95631. */
  95632. protected _transparencyMode: Nullable<number>;
  95633. /**
  95634. * Gets the current transparency mode.
  95635. */
  95636. get transparencyMode(): Nullable<number>;
  95637. /**
  95638. * Sets the transparency mode of the material.
  95639. *
  95640. * | Value | Type | Description |
  95641. * | ----- | ----------------------------------- | ----------- |
  95642. * | 0 | OPAQUE | |
  95643. * | 1 | ALPHATEST | |
  95644. * | 2 | ALPHABLEND | |
  95645. * | 3 | ALPHATESTANDBLEND | |
  95646. *
  95647. */
  95648. set transparencyMode(value: Nullable<number>);
  95649. /**
  95650. * Returns true if alpha blending should be disabled.
  95651. */
  95652. protected get _disableAlphaBlending(): boolean;
  95653. /**
  95654. * Specifies whether or not this material should be rendered in alpha blend mode.
  95655. * @returns a boolean specifying if alpha blending is needed
  95656. */
  95657. needAlphaBlending(): boolean;
  95658. /**
  95659. * Specifies if the mesh will require alpha blending
  95660. * @param mesh defines the mesh to check
  95661. * @returns a boolean specifying if alpha blending is needed for the mesh
  95662. */
  95663. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  95664. /**
  95665. * Specifies whether or not this material should be rendered in alpha test mode.
  95666. * @returns a boolean specifying if an alpha test is needed.
  95667. */
  95668. needAlphaTesting(): boolean;
  95669. /**
  95670. * Specifies if material alpha testing should be turned on for the mesh
  95671. * @param mesh defines the mesh to check
  95672. */
  95673. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  95674. /**
  95675. * Gets the texture used for the alpha test
  95676. * @returns the texture to use for alpha testing
  95677. */
  95678. getAlphaTestTexture(): Nullable<BaseTexture>;
  95679. /**
  95680. * Marks the material to indicate that it needs to be re-calculated
  95681. */
  95682. markDirty(): void;
  95683. /** @hidden */
  95684. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  95685. /**
  95686. * Binds the material to the mesh
  95687. * @param world defines the world transformation matrix
  95688. * @param mesh defines the mesh to bind the material to
  95689. */
  95690. bind(world: Matrix, mesh?: Mesh): void;
  95691. /**
  95692. * Binds the submesh to the material
  95693. * @param world defines the world transformation matrix
  95694. * @param mesh defines the mesh containing the submesh
  95695. * @param subMesh defines the submesh to bind the material to
  95696. */
  95697. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  95698. /**
  95699. * Binds the world matrix to the material
  95700. * @param world defines the world transformation matrix
  95701. */
  95702. bindOnlyWorldMatrix(world: Matrix): void;
  95703. /**
  95704. * Binds the scene's uniform buffer to the effect.
  95705. * @param effect defines the effect to bind to the scene uniform buffer
  95706. * @param sceneUbo defines the uniform buffer storing scene data
  95707. */
  95708. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  95709. /**
  95710. * Binds the view matrix to the effect
  95711. * @param effect defines the effect to bind the view matrix to
  95712. */
  95713. bindView(effect: Effect): void;
  95714. /**
  95715. * Binds the view projection matrix to the effect
  95716. * @param effect defines the effect to bind the view projection matrix to
  95717. */
  95718. bindViewProjection(effect: Effect): void;
  95719. /**
  95720. * Processes to execute after binding the material to a mesh
  95721. * @param mesh defines the rendered mesh
  95722. */
  95723. protected _afterBind(mesh?: Mesh): void;
  95724. /**
  95725. * Unbinds the material from the mesh
  95726. */
  95727. unbind(): void;
  95728. /**
  95729. * Gets the active textures from the material
  95730. * @returns an array of textures
  95731. */
  95732. getActiveTextures(): BaseTexture[];
  95733. /**
  95734. * Specifies if the material uses a texture
  95735. * @param texture defines the texture to check against the material
  95736. * @returns a boolean specifying if the material uses the texture
  95737. */
  95738. hasTexture(texture: BaseTexture): boolean;
  95739. /**
  95740. * Makes a duplicate of the material, and gives it a new name
  95741. * @param name defines the new name for the duplicated material
  95742. * @returns the cloned material
  95743. */
  95744. clone(name: string): Nullable<Material>;
  95745. /**
  95746. * Gets the meshes bound to the material
  95747. * @returns an array of meshes bound to the material
  95748. */
  95749. getBindedMeshes(): AbstractMesh[];
  95750. /**
  95751. * Force shader compilation
  95752. * @param mesh defines the mesh associated with this material
  95753. * @param onCompiled defines a function to execute once the material is compiled
  95754. * @param options defines the options to configure the compilation
  95755. * @param onError defines a function to execute if the material fails compiling
  95756. */
  95757. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  95758. /**
  95759. * Force shader compilation
  95760. * @param mesh defines the mesh that will use this material
  95761. * @param options defines additional options for compiling the shaders
  95762. * @returns a promise that resolves when the compilation completes
  95763. */
  95764. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  95765. private static readonly _AllDirtyCallBack;
  95766. private static readonly _ImageProcessingDirtyCallBack;
  95767. private static readonly _TextureDirtyCallBack;
  95768. private static readonly _FresnelDirtyCallBack;
  95769. private static readonly _MiscDirtyCallBack;
  95770. private static readonly _LightsDirtyCallBack;
  95771. private static readonly _AttributeDirtyCallBack;
  95772. private static _FresnelAndMiscDirtyCallBack;
  95773. private static _TextureAndMiscDirtyCallBack;
  95774. private static readonly _DirtyCallbackArray;
  95775. private static readonly _RunDirtyCallBacks;
  95776. /**
  95777. * Marks a define in the material to indicate that it needs to be re-computed
  95778. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  95779. */
  95780. markAsDirty(flag: number): void;
  95781. /**
  95782. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  95783. * @param func defines a function which checks material defines against the submeshes
  95784. */
  95785. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  95786. /**
  95787. * Indicates that we need to re-calculated for all submeshes
  95788. */
  95789. protected _markAllSubMeshesAsAllDirty(): void;
  95790. /**
  95791. * Indicates that image processing needs to be re-calculated for all submeshes
  95792. */
  95793. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  95794. /**
  95795. * Indicates that textures need to be re-calculated for all submeshes
  95796. */
  95797. protected _markAllSubMeshesAsTexturesDirty(): void;
  95798. /**
  95799. * Indicates that fresnel needs to be re-calculated for all submeshes
  95800. */
  95801. protected _markAllSubMeshesAsFresnelDirty(): void;
  95802. /**
  95803. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  95804. */
  95805. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  95806. /**
  95807. * Indicates that lights need to be re-calculated for all submeshes
  95808. */
  95809. protected _markAllSubMeshesAsLightsDirty(): void;
  95810. /**
  95811. * Indicates that attributes need to be re-calculated for all submeshes
  95812. */
  95813. protected _markAllSubMeshesAsAttributesDirty(): void;
  95814. /**
  95815. * Indicates that misc needs to be re-calculated for all submeshes
  95816. */
  95817. protected _markAllSubMeshesAsMiscDirty(): void;
  95818. /**
  95819. * Indicates that textures and misc need to be re-calculated for all submeshes
  95820. */
  95821. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  95822. /**
  95823. * Disposes the material
  95824. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  95825. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  95826. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  95827. */
  95828. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  95829. /** @hidden */
  95830. private releaseVertexArrayObject;
  95831. /**
  95832. * Serializes this material
  95833. * @returns the serialized material object
  95834. */
  95835. serialize(): any;
  95836. /**
  95837. * Creates a material from parsed material data
  95838. * @param parsedMaterial defines parsed material data
  95839. * @param scene defines the hosting scene
  95840. * @param rootUrl defines the root URL to use to load textures
  95841. * @returns a new material
  95842. */
  95843. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  95844. }
  95845. }
  95846. declare module BABYLON {
  95847. /**
  95848. * A multi-material is used to apply different materials to different parts of the same object without the need of
  95849. * separate meshes. This can be use to improve performances.
  95850. * @see http://doc.babylonjs.com/how_to/multi_materials
  95851. */
  95852. export class MultiMaterial extends Material {
  95853. private _subMaterials;
  95854. /**
  95855. * Gets or Sets the list of Materials used within the multi material.
  95856. * They need to be ordered according to the submeshes order in the associated mesh
  95857. */
  95858. get subMaterials(): Nullable<Material>[];
  95859. set subMaterials(value: Nullable<Material>[]);
  95860. /**
  95861. * Function used to align with Node.getChildren()
  95862. * @returns the list of Materials used within the multi material
  95863. */
  95864. getChildren(): Nullable<Material>[];
  95865. /**
  95866. * Instantiates a new Multi Material
  95867. * A multi-material is used to apply different materials to different parts of the same object without the need of
  95868. * separate meshes. This can be use to improve performances.
  95869. * @see http://doc.babylonjs.com/how_to/multi_materials
  95870. * @param name Define the name in the scene
  95871. * @param scene Define the scene the material belongs to
  95872. */
  95873. constructor(name: string, scene: Scene);
  95874. private _hookArray;
  95875. /**
  95876. * Get one of the submaterial by its index in the submaterials array
  95877. * @param index The index to look the sub material at
  95878. * @returns The Material if the index has been defined
  95879. */
  95880. getSubMaterial(index: number): Nullable<Material>;
  95881. /**
  95882. * Get the list of active textures for the whole sub materials list.
  95883. * @returns All the textures that will be used during the rendering
  95884. */
  95885. getActiveTextures(): BaseTexture[];
  95886. /**
  95887. * Gets the current class name of the material e.g. "MultiMaterial"
  95888. * Mainly use in serialization.
  95889. * @returns the class name
  95890. */
  95891. getClassName(): string;
  95892. /**
  95893. * Checks if the material is ready to render the requested sub mesh
  95894. * @param mesh Define the mesh the submesh belongs to
  95895. * @param subMesh Define the sub mesh to look readyness for
  95896. * @param useInstances Define whether or not the material is used with instances
  95897. * @returns true if ready, otherwise false
  95898. */
  95899. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  95900. /**
  95901. * Clones the current material and its related sub materials
  95902. * @param name Define the name of the newly cloned material
  95903. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  95904. * @returns the cloned material
  95905. */
  95906. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  95907. /**
  95908. * Serializes the materials into a JSON representation.
  95909. * @returns the JSON representation
  95910. */
  95911. serialize(): any;
  95912. /**
  95913. * Dispose the material and release its associated resources
  95914. * @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)
  95915. * @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)
  95916. * @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)
  95917. */
  95918. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  95919. /**
  95920. * Creates a MultiMaterial from parsed MultiMaterial data.
  95921. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  95922. * @param scene defines the hosting scene
  95923. * @returns a new MultiMaterial
  95924. */
  95925. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  95926. }
  95927. }
  95928. declare module BABYLON {
  95929. /**
  95930. * Base class for submeshes
  95931. */
  95932. export class BaseSubMesh {
  95933. /** @hidden */
  95934. _materialDefines: Nullable<MaterialDefines>;
  95935. /** @hidden */
  95936. _materialEffect: Nullable<Effect>;
  95937. /**
  95938. * Gets material defines used by the effect associated to the sub mesh
  95939. */
  95940. get materialDefines(): Nullable<MaterialDefines>;
  95941. /**
  95942. * Sets material defines used by the effect associated to the sub mesh
  95943. */
  95944. set materialDefines(defines: Nullable<MaterialDefines>);
  95945. /**
  95946. * Gets associated effect
  95947. */
  95948. get effect(): Nullable<Effect>;
  95949. /**
  95950. * Sets associated effect (effect used to render this submesh)
  95951. * @param effect defines the effect to associate with
  95952. * @param defines defines the set of defines used to compile this effect
  95953. */
  95954. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  95955. }
  95956. /**
  95957. * Defines a subdivision inside a mesh
  95958. */
  95959. export class SubMesh extends BaseSubMesh implements ICullable {
  95960. /** the material index to use */
  95961. materialIndex: number;
  95962. /** vertex index start */
  95963. verticesStart: number;
  95964. /** vertices count */
  95965. verticesCount: number;
  95966. /** index start */
  95967. indexStart: number;
  95968. /** indices count */
  95969. indexCount: number;
  95970. /** @hidden */
  95971. _linesIndexCount: number;
  95972. private _mesh;
  95973. private _renderingMesh;
  95974. private _boundingInfo;
  95975. private _linesIndexBuffer;
  95976. /** @hidden */
  95977. _lastColliderWorldVertices: Nullable<Vector3[]>;
  95978. /** @hidden */
  95979. _trianglePlanes: Plane[];
  95980. /** @hidden */
  95981. _lastColliderTransformMatrix: Nullable<Matrix>;
  95982. /** @hidden */
  95983. _renderId: number;
  95984. /** @hidden */
  95985. _alphaIndex: number;
  95986. /** @hidden */
  95987. _distanceToCamera: number;
  95988. /** @hidden */
  95989. _id: number;
  95990. private _currentMaterial;
  95991. /**
  95992. * Add a new submesh to a mesh
  95993. * @param materialIndex defines the material index to use
  95994. * @param verticesStart defines vertex index start
  95995. * @param verticesCount defines vertices count
  95996. * @param indexStart defines index start
  95997. * @param indexCount defines indices count
  95998. * @param mesh defines the parent mesh
  95999. * @param renderingMesh defines an optional rendering mesh
  96000. * @param createBoundingBox defines if bounding box should be created for this submesh
  96001. * @returns the new submesh
  96002. */
  96003. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  96004. /**
  96005. * Creates a new submesh
  96006. * @param materialIndex defines the material index to use
  96007. * @param verticesStart defines vertex index start
  96008. * @param verticesCount defines vertices count
  96009. * @param indexStart defines index start
  96010. * @param indexCount defines indices count
  96011. * @param mesh defines the parent mesh
  96012. * @param renderingMesh defines an optional rendering mesh
  96013. * @param createBoundingBox defines if bounding box should be created for this submesh
  96014. */
  96015. constructor(
  96016. /** the material index to use */
  96017. materialIndex: number,
  96018. /** vertex index start */
  96019. verticesStart: number,
  96020. /** vertices count */
  96021. verticesCount: number,
  96022. /** index start */
  96023. indexStart: number,
  96024. /** indices count */
  96025. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  96026. /**
  96027. * Returns true if this submesh covers the entire parent mesh
  96028. * @ignorenaming
  96029. */
  96030. get IsGlobal(): boolean;
  96031. /**
  96032. * Returns the submesh BoudingInfo object
  96033. * @returns current bounding info (or mesh's one if the submesh is global)
  96034. */
  96035. getBoundingInfo(): BoundingInfo;
  96036. /**
  96037. * Sets the submesh BoundingInfo
  96038. * @param boundingInfo defines the new bounding info to use
  96039. * @returns the SubMesh
  96040. */
  96041. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  96042. /**
  96043. * Returns the mesh of the current submesh
  96044. * @return the parent mesh
  96045. */
  96046. getMesh(): AbstractMesh;
  96047. /**
  96048. * Returns the rendering mesh of the submesh
  96049. * @returns the rendering mesh (could be different from parent mesh)
  96050. */
  96051. getRenderingMesh(): Mesh;
  96052. /**
  96053. * Returns the submesh material
  96054. * @returns null or the current material
  96055. */
  96056. getMaterial(): Nullable<Material>;
  96057. /**
  96058. * Sets a new updated BoundingInfo object to the submesh
  96059. * @param data defines an optional position array to use to determine the bounding info
  96060. * @returns the SubMesh
  96061. */
  96062. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  96063. /** @hidden */
  96064. _checkCollision(collider: Collider): boolean;
  96065. /**
  96066. * Updates the submesh BoundingInfo
  96067. * @param world defines the world matrix to use to update the bounding info
  96068. * @returns the submesh
  96069. */
  96070. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  96071. /**
  96072. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  96073. * @param frustumPlanes defines the frustum planes
  96074. * @returns true if the submesh is intersecting with the frustum
  96075. */
  96076. isInFrustum(frustumPlanes: Plane[]): boolean;
  96077. /**
  96078. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  96079. * @param frustumPlanes defines the frustum planes
  96080. * @returns true if the submesh is inside the frustum
  96081. */
  96082. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  96083. /**
  96084. * Renders the submesh
  96085. * @param enableAlphaMode defines if alpha needs to be used
  96086. * @returns the submesh
  96087. */
  96088. render(enableAlphaMode: boolean): SubMesh;
  96089. /**
  96090. * @hidden
  96091. */
  96092. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  96093. /**
  96094. * Checks if the submesh intersects with a ray
  96095. * @param ray defines the ray to test
  96096. * @returns true is the passed ray intersects the submesh bounding box
  96097. */
  96098. canIntersects(ray: Ray): boolean;
  96099. /**
  96100. * Intersects current submesh with a ray
  96101. * @param ray defines the ray to test
  96102. * @param positions defines mesh's positions array
  96103. * @param indices defines mesh's indices array
  96104. * @param fastCheck defines if only bounding info should be used
  96105. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  96106. * @returns intersection info or null if no intersection
  96107. */
  96108. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  96109. /** @hidden */
  96110. private _intersectLines;
  96111. /** @hidden */
  96112. private _intersectUnIndexedLines;
  96113. /** @hidden */
  96114. private _intersectTriangles;
  96115. /** @hidden */
  96116. private _intersectUnIndexedTriangles;
  96117. /** @hidden */
  96118. _rebuild(): void;
  96119. /**
  96120. * Creates a new submesh from the passed mesh
  96121. * @param newMesh defines the new hosting mesh
  96122. * @param newRenderingMesh defines an optional rendering mesh
  96123. * @returns the new submesh
  96124. */
  96125. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  96126. /**
  96127. * Release associated resources
  96128. */
  96129. dispose(): void;
  96130. /**
  96131. * Gets the class name
  96132. * @returns the string "SubMesh".
  96133. */
  96134. getClassName(): string;
  96135. /**
  96136. * Creates a new submesh from indices data
  96137. * @param materialIndex the index of the main mesh material
  96138. * @param startIndex the index where to start the copy in the mesh indices array
  96139. * @param indexCount the number of indices to copy then from the startIndex
  96140. * @param mesh the main mesh to create the submesh from
  96141. * @param renderingMesh the optional rendering mesh
  96142. * @returns a new submesh
  96143. */
  96144. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  96145. }
  96146. }
  96147. declare module BABYLON {
  96148. /**
  96149. * Class used to represent data loading progression
  96150. */
  96151. export class SceneLoaderFlags {
  96152. private static _ForceFullSceneLoadingForIncremental;
  96153. private static _ShowLoadingScreen;
  96154. private static _CleanBoneMatrixWeights;
  96155. private static _loggingLevel;
  96156. /**
  96157. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  96158. */
  96159. static get ForceFullSceneLoadingForIncremental(): boolean;
  96160. static set ForceFullSceneLoadingForIncremental(value: boolean);
  96161. /**
  96162. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  96163. */
  96164. static get ShowLoadingScreen(): boolean;
  96165. static set ShowLoadingScreen(value: boolean);
  96166. /**
  96167. * Defines the current logging level (while loading the scene)
  96168. * @ignorenaming
  96169. */
  96170. static get loggingLevel(): number;
  96171. static set loggingLevel(value: number);
  96172. /**
  96173. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  96174. */
  96175. static get CleanBoneMatrixWeights(): boolean;
  96176. static set CleanBoneMatrixWeights(value: boolean);
  96177. }
  96178. }
  96179. declare module BABYLON {
  96180. /**
  96181. * Class used to store geometry data (vertex buffers + index buffer)
  96182. */
  96183. export class Geometry implements IGetSetVerticesData {
  96184. /**
  96185. * Gets or sets the ID of the geometry
  96186. */
  96187. id: string;
  96188. /**
  96189. * Gets or sets the unique ID of the geometry
  96190. */
  96191. uniqueId: number;
  96192. /**
  96193. * Gets the delay loading state of the geometry (none by default which means not delayed)
  96194. */
  96195. delayLoadState: number;
  96196. /**
  96197. * Gets the file containing the data to load when running in delay load state
  96198. */
  96199. delayLoadingFile: Nullable<string>;
  96200. /**
  96201. * Callback called when the geometry is updated
  96202. */
  96203. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  96204. private _scene;
  96205. private _engine;
  96206. private _meshes;
  96207. private _totalVertices;
  96208. /** @hidden */
  96209. _indices: IndicesArray;
  96210. /** @hidden */
  96211. _vertexBuffers: {
  96212. [key: string]: VertexBuffer;
  96213. };
  96214. private _isDisposed;
  96215. private _extend;
  96216. private _boundingBias;
  96217. /** @hidden */
  96218. _delayInfo: Array<string>;
  96219. private _indexBuffer;
  96220. private _indexBufferIsUpdatable;
  96221. /** @hidden */
  96222. _boundingInfo: Nullable<BoundingInfo>;
  96223. /** @hidden */
  96224. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  96225. /** @hidden */
  96226. _softwareSkinningFrameId: number;
  96227. private _vertexArrayObjects;
  96228. private _updatable;
  96229. /** @hidden */
  96230. _positions: Nullable<Vector3[]>;
  96231. /**
  96232. * 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
  96233. */
  96234. get boundingBias(): Vector2;
  96235. /**
  96236. * 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
  96237. */
  96238. set boundingBias(value: Vector2);
  96239. /**
  96240. * Static function used to attach a new empty geometry to a mesh
  96241. * @param mesh defines the mesh to attach the geometry to
  96242. * @returns the new Geometry
  96243. */
  96244. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  96245. /**
  96246. * Creates a new geometry
  96247. * @param id defines the unique ID
  96248. * @param scene defines the hosting scene
  96249. * @param vertexData defines the VertexData used to get geometry data
  96250. * @param updatable defines if geometry must be updatable (false by default)
  96251. * @param mesh defines the mesh that will be associated with the geometry
  96252. */
  96253. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  96254. /**
  96255. * Gets the current extend of the geometry
  96256. */
  96257. get extend(): {
  96258. minimum: Vector3;
  96259. maximum: Vector3;
  96260. };
  96261. /**
  96262. * Gets the hosting scene
  96263. * @returns the hosting Scene
  96264. */
  96265. getScene(): Scene;
  96266. /**
  96267. * Gets the hosting engine
  96268. * @returns the hosting Engine
  96269. */
  96270. getEngine(): Engine;
  96271. /**
  96272. * Defines if the geometry is ready to use
  96273. * @returns true if the geometry is ready to be used
  96274. */
  96275. isReady(): boolean;
  96276. /**
  96277. * Gets a value indicating that the geometry should not be serialized
  96278. */
  96279. get doNotSerialize(): boolean;
  96280. /** @hidden */
  96281. _rebuild(): void;
  96282. /**
  96283. * Affects all geometry data in one call
  96284. * @param vertexData defines the geometry data
  96285. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  96286. */
  96287. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  96288. /**
  96289. * Set specific vertex data
  96290. * @param kind defines the data kind (Position, normal, etc...)
  96291. * @param data defines the vertex data to use
  96292. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  96293. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  96294. */
  96295. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  96296. /**
  96297. * Removes a specific vertex data
  96298. * @param kind defines the data kind (Position, normal, etc...)
  96299. */
  96300. removeVerticesData(kind: string): void;
  96301. /**
  96302. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  96303. * @param buffer defines the vertex buffer to use
  96304. * @param totalVertices defines the total number of vertices for position kind (could be null)
  96305. */
  96306. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  96307. /**
  96308. * Update a specific vertex buffer
  96309. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  96310. * It will do nothing if the buffer is not updatable
  96311. * @param kind defines the data kind (Position, normal, etc...)
  96312. * @param data defines the data to use
  96313. * @param offset defines the offset in the target buffer where to store the data
  96314. * @param useBytes set to true if the offset is in bytes
  96315. */
  96316. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  96317. /**
  96318. * Update a specific vertex buffer
  96319. * This function will create a new buffer if the current one is not updatable
  96320. * @param kind defines the data kind (Position, normal, etc...)
  96321. * @param data defines the data to use
  96322. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  96323. */
  96324. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  96325. private _updateBoundingInfo;
  96326. /** @hidden */
  96327. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  96328. /**
  96329. * Gets total number of vertices
  96330. * @returns the total number of vertices
  96331. */
  96332. getTotalVertices(): number;
  96333. /**
  96334. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  96335. * @param kind defines the data kind (Position, normal, etc...)
  96336. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  96337. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  96338. * @returns a float array containing vertex data
  96339. */
  96340. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  96341. /**
  96342. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  96343. * @param kind defines the data kind (Position, normal, etc...)
  96344. * @returns true if the vertex buffer with the specified kind is updatable
  96345. */
  96346. isVertexBufferUpdatable(kind: string): boolean;
  96347. /**
  96348. * Gets a specific vertex buffer
  96349. * @param kind defines the data kind (Position, normal, etc...)
  96350. * @returns a VertexBuffer
  96351. */
  96352. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  96353. /**
  96354. * Returns all vertex buffers
  96355. * @return an object holding all vertex buffers indexed by kind
  96356. */
  96357. getVertexBuffers(): Nullable<{
  96358. [key: string]: VertexBuffer;
  96359. }>;
  96360. /**
  96361. * Gets a boolean indicating if specific vertex buffer is present
  96362. * @param kind defines the data kind (Position, normal, etc...)
  96363. * @returns true if data is present
  96364. */
  96365. isVerticesDataPresent(kind: string): boolean;
  96366. /**
  96367. * Gets a list of all attached data kinds (Position, normal, etc...)
  96368. * @returns a list of string containing all kinds
  96369. */
  96370. getVerticesDataKinds(): string[];
  96371. /**
  96372. * Update index buffer
  96373. * @param indices defines the indices to store in the index buffer
  96374. * @param offset defines the offset in the target buffer where to store the data
  96375. * @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)
  96376. */
  96377. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  96378. /**
  96379. * Creates a new index buffer
  96380. * @param indices defines the indices to store in the index buffer
  96381. * @param totalVertices defines the total number of vertices (could be null)
  96382. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  96383. */
  96384. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  96385. /**
  96386. * Return the total number of indices
  96387. * @returns the total number of indices
  96388. */
  96389. getTotalIndices(): number;
  96390. /**
  96391. * Gets the index buffer array
  96392. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  96393. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  96394. * @returns the index buffer array
  96395. */
  96396. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  96397. /**
  96398. * Gets the index buffer
  96399. * @return the index buffer
  96400. */
  96401. getIndexBuffer(): Nullable<DataBuffer>;
  96402. /** @hidden */
  96403. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  96404. /**
  96405. * Release the associated resources for a specific mesh
  96406. * @param mesh defines the source mesh
  96407. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  96408. */
  96409. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  96410. /**
  96411. * Apply current geometry to a given mesh
  96412. * @param mesh defines the mesh to apply geometry to
  96413. */
  96414. applyToMesh(mesh: Mesh): void;
  96415. private _updateExtend;
  96416. private _applyToMesh;
  96417. private notifyUpdate;
  96418. /**
  96419. * Load the geometry if it was flagged as delay loaded
  96420. * @param scene defines the hosting scene
  96421. * @param onLoaded defines a callback called when the geometry is loaded
  96422. */
  96423. load(scene: Scene, onLoaded?: () => void): void;
  96424. private _queueLoad;
  96425. /**
  96426. * Invert the geometry to move from a right handed system to a left handed one.
  96427. */
  96428. toLeftHanded(): void;
  96429. /** @hidden */
  96430. _resetPointsArrayCache(): void;
  96431. /** @hidden */
  96432. _generatePointsArray(): boolean;
  96433. /**
  96434. * Gets a value indicating if the geometry is disposed
  96435. * @returns true if the geometry was disposed
  96436. */
  96437. isDisposed(): boolean;
  96438. private _disposeVertexArrayObjects;
  96439. /**
  96440. * Free all associated resources
  96441. */
  96442. dispose(): void;
  96443. /**
  96444. * Clone the current geometry into a new geometry
  96445. * @param id defines the unique ID of the new geometry
  96446. * @returns a new geometry object
  96447. */
  96448. copy(id: string): Geometry;
  96449. /**
  96450. * Serialize the current geometry info (and not the vertices data) into a JSON object
  96451. * @return a JSON representation of the current geometry data (without the vertices data)
  96452. */
  96453. serialize(): any;
  96454. private toNumberArray;
  96455. /**
  96456. * Serialize all vertices data into a JSON oject
  96457. * @returns a JSON representation of the current geometry data
  96458. */
  96459. serializeVerticeData(): any;
  96460. /**
  96461. * Extracts a clone of a mesh geometry
  96462. * @param mesh defines the source mesh
  96463. * @param id defines the unique ID of the new geometry object
  96464. * @returns the new geometry object
  96465. */
  96466. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  96467. /**
  96468. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  96469. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  96470. * Be aware Math.random() could cause collisions, but:
  96471. * "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"
  96472. * @returns a string containing a new GUID
  96473. */
  96474. static RandomId(): string;
  96475. /** @hidden */
  96476. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  96477. private static _CleanMatricesWeights;
  96478. /**
  96479. * Create a new geometry from persisted data (Using .babylon file format)
  96480. * @param parsedVertexData defines the persisted data
  96481. * @param scene defines the hosting scene
  96482. * @param rootUrl defines the root url to use to load assets (like delayed data)
  96483. * @returns the new geometry object
  96484. */
  96485. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  96486. }
  96487. }
  96488. declare module BABYLON {
  96489. /**
  96490. * Define an interface for all classes that will get and set the data on vertices
  96491. */
  96492. export interface IGetSetVerticesData {
  96493. /**
  96494. * Gets a boolean indicating if specific vertex data is present
  96495. * @param kind defines the vertex data kind to use
  96496. * @returns true is data kind is present
  96497. */
  96498. isVerticesDataPresent(kind: string): boolean;
  96499. /**
  96500. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  96501. * @param kind defines the data kind (Position, normal, etc...)
  96502. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  96503. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  96504. * @returns a float array containing vertex data
  96505. */
  96506. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  96507. /**
  96508. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  96509. * @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.
  96510. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  96511. * @returns the indices array or an empty array if the mesh has no geometry
  96512. */
  96513. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  96514. /**
  96515. * Set specific vertex data
  96516. * @param kind defines the data kind (Position, normal, etc...)
  96517. * @param data defines the vertex data to use
  96518. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  96519. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  96520. */
  96521. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  96522. /**
  96523. * Update a specific associated vertex buffer
  96524. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  96525. * - VertexBuffer.PositionKind
  96526. * - VertexBuffer.UVKind
  96527. * - VertexBuffer.UV2Kind
  96528. * - VertexBuffer.UV3Kind
  96529. * - VertexBuffer.UV4Kind
  96530. * - VertexBuffer.UV5Kind
  96531. * - VertexBuffer.UV6Kind
  96532. * - VertexBuffer.ColorKind
  96533. * - VertexBuffer.MatricesIndicesKind
  96534. * - VertexBuffer.MatricesIndicesExtraKind
  96535. * - VertexBuffer.MatricesWeightsKind
  96536. * - VertexBuffer.MatricesWeightsExtraKind
  96537. * @param data defines the data source
  96538. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  96539. * @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)
  96540. */
  96541. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  96542. /**
  96543. * Creates a new index buffer
  96544. * @param indices defines the indices to store in the index buffer
  96545. * @param totalVertices defines the total number of vertices (could be null)
  96546. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  96547. */
  96548. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  96549. }
  96550. /**
  96551. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  96552. */
  96553. export class VertexData {
  96554. /**
  96555. * Mesh side orientation : usually the external or front surface
  96556. */
  96557. static readonly FRONTSIDE: number;
  96558. /**
  96559. * Mesh side orientation : usually the internal or back surface
  96560. */
  96561. static readonly BACKSIDE: number;
  96562. /**
  96563. * Mesh side orientation : both internal and external or front and back surfaces
  96564. */
  96565. static readonly DOUBLESIDE: number;
  96566. /**
  96567. * Mesh side orientation : by default, `FRONTSIDE`
  96568. */
  96569. static readonly DEFAULTSIDE: number;
  96570. /**
  96571. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  96572. */
  96573. positions: Nullable<FloatArray>;
  96574. /**
  96575. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  96576. */
  96577. normals: Nullable<FloatArray>;
  96578. /**
  96579. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  96580. */
  96581. tangents: Nullable<FloatArray>;
  96582. /**
  96583. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  96584. */
  96585. uvs: Nullable<FloatArray>;
  96586. /**
  96587. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  96588. */
  96589. uvs2: Nullable<FloatArray>;
  96590. /**
  96591. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  96592. */
  96593. uvs3: Nullable<FloatArray>;
  96594. /**
  96595. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  96596. */
  96597. uvs4: Nullable<FloatArray>;
  96598. /**
  96599. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  96600. */
  96601. uvs5: Nullable<FloatArray>;
  96602. /**
  96603. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  96604. */
  96605. uvs6: Nullable<FloatArray>;
  96606. /**
  96607. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  96608. */
  96609. colors: Nullable<FloatArray>;
  96610. /**
  96611. * 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).
  96612. */
  96613. matricesIndices: Nullable<FloatArray>;
  96614. /**
  96615. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  96616. */
  96617. matricesWeights: Nullable<FloatArray>;
  96618. /**
  96619. * An array extending the number of possible indices
  96620. */
  96621. matricesIndicesExtra: Nullable<FloatArray>;
  96622. /**
  96623. * An array extending the number of possible weights when the number of indices is extended
  96624. */
  96625. matricesWeightsExtra: Nullable<FloatArray>;
  96626. /**
  96627. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  96628. */
  96629. indices: Nullable<IndicesArray>;
  96630. /**
  96631. * Uses the passed data array to set the set the values for the specified kind of data
  96632. * @param data a linear array of floating numbers
  96633. * @param kind the type of data that is being set, eg positions, colors etc
  96634. */
  96635. set(data: FloatArray, kind: string): void;
  96636. /**
  96637. * Associates the vertexData to the passed Mesh.
  96638. * Sets it as updatable or not (default `false`)
  96639. * @param mesh the mesh the vertexData is applied to
  96640. * @param updatable when used and having the value true allows new data to update the vertexData
  96641. * @returns the VertexData
  96642. */
  96643. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  96644. /**
  96645. * Associates the vertexData to the passed Geometry.
  96646. * Sets it as updatable or not (default `false`)
  96647. * @param geometry the geometry the vertexData is applied to
  96648. * @param updatable when used and having the value true allows new data to update the vertexData
  96649. * @returns VertexData
  96650. */
  96651. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  96652. /**
  96653. * Updates the associated mesh
  96654. * @param mesh the mesh to be updated
  96655. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  96656. * @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
  96657. * @returns VertexData
  96658. */
  96659. updateMesh(mesh: Mesh): VertexData;
  96660. /**
  96661. * Updates the associated geometry
  96662. * @param geometry the geometry to be updated
  96663. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  96664. * @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
  96665. * @returns VertexData.
  96666. */
  96667. updateGeometry(geometry: Geometry): VertexData;
  96668. private _applyTo;
  96669. private _update;
  96670. /**
  96671. * Transforms each position and each normal of the vertexData according to the passed Matrix
  96672. * @param matrix the transforming matrix
  96673. * @returns the VertexData
  96674. */
  96675. transform(matrix: Matrix): VertexData;
  96676. /**
  96677. * Merges the passed VertexData into the current one
  96678. * @param other the VertexData to be merged into the current one
  96679. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  96680. * @returns the modified VertexData
  96681. */
  96682. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  96683. private _mergeElement;
  96684. private _validate;
  96685. /**
  96686. * Serializes the VertexData
  96687. * @returns a serialized object
  96688. */
  96689. serialize(): any;
  96690. /**
  96691. * Extracts the vertexData from a mesh
  96692. * @param mesh the mesh from which to extract the VertexData
  96693. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  96694. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  96695. * @returns the object VertexData associated to the passed mesh
  96696. */
  96697. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  96698. /**
  96699. * Extracts the vertexData from the geometry
  96700. * @param geometry the geometry from which to extract the VertexData
  96701. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  96702. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  96703. * @returns the object VertexData associated to the passed mesh
  96704. */
  96705. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  96706. private static _ExtractFrom;
  96707. /**
  96708. * Creates the VertexData for a Ribbon
  96709. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  96710. * * pathArray array of paths, each of which an array of successive Vector3
  96711. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  96712. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  96713. * * 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
  96714. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  96715. * * 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)
  96716. * * 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)
  96717. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  96718. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  96719. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  96720. * @returns the VertexData of the ribbon
  96721. */
  96722. static CreateRibbon(options: {
  96723. pathArray: Vector3[][];
  96724. closeArray?: boolean;
  96725. closePath?: boolean;
  96726. offset?: number;
  96727. sideOrientation?: number;
  96728. frontUVs?: Vector4;
  96729. backUVs?: Vector4;
  96730. invertUV?: boolean;
  96731. uvs?: Vector2[];
  96732. colors?: Color4[];
  96733. }): VertexData;
  96734. /**
  96735. * Creates the VertexData for a box
  96736. * @param options an object used to set the following optional parameters for the box, required but can be empty
  96737. * * size sets the width, height and depth of the box to the value of size, optional default 1
  96738. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  96739. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  96740. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  96741. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  96742. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  96743. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  96744. * * 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)
  96745. * * 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)
  96746. * @returns the VertexData of the box
  96747. */
  96748. static CreateBox(options: {
  96749. size?: number;
  96750. width?: number;
  96751. height?: number;
  96752. depth?: number;
  96753. faceUV?: Vector4[];
  96754. faceColors?: Color4[];
  96755. sideOrientation?: number;
  96756. frontUVs?: Vector4;
  96757. backUVs?: Vector4;
  96758. }): VertexData;
  96759. /**
  96760. * Creates the VertexData for a tiled box
  96761. * @param options an object used to set the following optional parameters for the box, required but can be empty
  96762. * * faceTiles sets the pattern, tile size and number of tiles for a face
  96763. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  96764. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  96765. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  96766. * @returns the VertexData of the box
  96767. */
  96768. static CreateTiledBox(options: {
  96769. pattern?: number;
  96770. width?: number;
  96771. height?: number;
  96772. depth?: number;
  96773. tileSize?: number;
  96774. tileWidth?: number;
  96775. tileHeight?: number;
  96776. alignHorizontal?: number;
  96777. alignVertical?: number;
  96778. faceUV?: Vector4[];
  96779. faceColors?: Color4[];
  96780. sideOrientation?: number;
  96781. }): VertexData;
  96782. /**
  96783. * Creates the VertexData for a tiled plane
  96784. * @param options an object used to set the following optional parameters for the box, required but can be empty
  96785. * * pattern a limited pattern arrangement depending on the number
  96786. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  96787. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  96788. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  96789. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  96790. * * 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)
  96791. * * 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)
  96792. * @returns the VertexData of the tiled plane
  96793. */
  96794. static CreateTiledPlane(options: {
  96795. pattern?: number;
  96796. tileSize?: number;
  96797. tileWidth?: number;
  96798. tileHeight?: number;
  96799. size?: number;
  96800. width?: number;
  96801. height?: number;
  96802. alignHorizontal?: number;
  96803. alignVertical?: number;
  96804. sideOrientation?: number;
  96805. frontUVs?: Vector4;
  96806. backUVs?: Vector4;
  96807. }): VertexData;
  96808. /**
  96809. * Creates the VertexData for an ellipsoid, defaults to a sphere
  96810. * @param options an object used to set the following optional parameters for the box, required but can be empty
  96811. * * segments sets the number of horizontal strips optional, default 32
  96812. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  96813. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  96814. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  96815. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  96816. * * 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
  96817. * * 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
  96818. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  96819. * * 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)
  96820. * * 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)
  96821. * @returns the VertexData of the ellipsoid
  96822. */
  96823. static CreateSphere(options: {
  96824. segments?: number;
  96825. diameter?: number;
  96826. diameterX?: number;
  96827. diameterY?: number;
  96828. diameterZ?: number;
  96829. arc?: number;
  96830. slice?: number;
  96831. sideOrientation?: number;
  96832. frontUVs?: Vector4;
  96833. backUVs?: Vector4;
  96834. }): VertexData;
  96835. /**
  96836. * Creates the VertexData for a cylinder, cone or prism
  96837. * @param options an object used to set the following optional parameters for the box, required but can be empty
  96838. * * height sets the height (y direction) of the cylinder, optional, default 2
  96839. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  96840. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  96841. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  96842. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  96843. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  96844. * * 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
  96845. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  96846. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  96847. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  96848. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  96849. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  96850. * * 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)
  96851. * * 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)
  96852. * @returns the VertexData of the cylinder, cone or prism
  96853. */
  96854. static CreateCylinder(options: {
  96855. height?: number;
  96856. diameterTop?: number;
  96857. diameterBottom?: number;
  96858. diameter?: number;
  96859. tessellation?: number;
  96860. subdivisions?: number;
  96861. arc?: number;
  96862. faceColors?: Color4[];
  96863. faceUV?: Vector4[];
  96864. hasRings?: boolean;
  96865. enclose?: boolean;
  96866. sideOrientation?: number;
  96867. frontUVs?: Vector4;
  96868. backUVs?: Vector4;
  96869. }): VertexData;
  96870. /**
  96871. * Creates the VertexData for a torus
  96872. * @param options an object used to set the following optional parameters for the box, required but can be empty
  96873. * * diameter the diameter of the torus, optional default 1
  96874. * * thickness the diameter of the tube forming the torus, optional default 0.5
  96875. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  96876. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  96877. * * 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)
  96878. * * 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)
  96879. * @returns the VertexData of the torus
  96880. */
  96881. static CreateTorus(options: {
  96882. diameter?: number;
  96883. thickness?: number;
  96884. tessellation?: number;
  96885. sideOrientation?: number;
  96886. frontUVs?: Vector4;
  96887. backUVs?: Vector4;
  96888. }): VertexData;
  96889. /**
  96890. * Creates the VertexData of the LineSystem
  96891. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  96892. * - lines an array of lines, each line being an array of successive Vector3
  96893. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  96894. * @returns the VertexData of the LineSystem
  96895. */
  96896. static CreateLineSystem(options: {
  96897. lines: Vector3[][];
  96898. colors?: Nullable<Color4[][]>;
  96899. }): VertexData;
  96900. /**
  96901. * Create the VertexData for a DashedLines
  96902. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  96903. * - points an array successive Vector3
  96904. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  96905. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  96906. * - dashNb the intended total number of dashes, optional, default 200
  96907. * @returns the VertexData for the DashedLines
  96908. */
  96909. static CreateDashedLines(options: {
  96910. points: Vector3[];
  96911. dashSize?: number;
  96912. gapSize?: number;
  96913. dashNb?: number;
  96914. }): VertexData;
  96915. /**
  96916. * Creates the VertexData for a Ground
  96917. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  96918. * - width the width (x direction) of the ground, optional, default 1
  96919. * - height the height (z direction) of the ground, optional, default 1
  96920. * - subdivisions the number of subdivisions per side, optional, default 1
  96921. * @returns the VertexData of the Ground
  96922. */
  96923. static CreateGround(options: {
  96924. width?: number;
  96925. height?: number;
  96926. subdivisions?: number;
  96927. subdivisionsX?: number;
  96928. subdivisionsY?: number;
  96929. }): VertexData;
  96930. /**
  96931. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  96932. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  96933. * * xmin the ground minimum X coordinate, optional, default -1
  96934. * * zmin the ground minimum Z coordinate, optional, default -1
  96935. * * xmax the ground maximum X coordinate, optional, default 1
  96936. * * zmax the ground maximum Z coordinate, optional, default 1
  96937. * * 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}
  96938. * * 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}
  96939. * @returns the VertexData of the TiledGround
  96940. */
  96941. static CreateTiledGround(options: {
  96942. xmin: number;
  96943. zmin: number;
  96944. xmax: number;
  96945. zmax: number;
  96946. subdivisions?: {
  96947. w: number;
  96948. h: number;
  96949. };
  96950. precision?: {
  96951. w: number;
  96952. h: number;
  96953. };
  96954. }): VertexData;
  96955. /**
  96956. * Creates the VertexData of the Ground designed from a heightmap
  96957. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  96958. * * width the width (x direction) of the ground
  96959. * * height the height (z direction) of the ground
  96960. * * subdivisions the number of subdivisions per side
  96961. * * minHeight the minimum altitude on the ground, optional, default 0
  96962. * * maxHeight the maximum altitude on the ground, optional default 1
  96963. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  96964. * * buffer the array holding the image color data
  96965. * * bufferWidth the width of image
  96966. * * bufferHeight the height of image
  96967. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  96968. * @returns the VertexData of the Ground designed from a heightmap
  96969. */
  96970. static CreateGroundFromHeightMap(options: {
  96971. width: number;
  96972. height: number;
  96973. subdivisions: number;
  96974. minHeight: number;
  96975. maxHeight: number;
  96976. colorFilter: Color3;
  96977. buffer: Uint8Array;
  96978. bufferWidth: number;
  96979. bufferHeight: number;
  96980. alphaFilter: number;
  96981. }): VertexData;
  96982. /**
  96983. * Creates the VertexData for a Plane
  96984. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  96985. * * size sets the width and height of the plane to the value of size, optional default 1
  96986. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  96987. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  96988. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  96989. * * 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)
  96990. * * 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)
  96991. * @returns the VertexData of the box
  96992. */
  96993. static CreatePlane(options: {
  96994. size?: number;
  96995. width?: number;
  96996. height?: number;
  96997. sideOrientation?: number;
  96998. frontUVs?: Vector4;
  96999. backUVs?: Vector4;
  97000. }): VertexData;
  97001. /**
  97002. * Creates the VertexData of the Disc or regular Polygon
  97003. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  97004. * * radius the radius of the disc, optional default 0.5
  97005. * * tessellation the number of polygon sides, optional, default 64
  97006. * * 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
  97007. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  97008. * * 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)
  97009. * * 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)
  97010. * @returns the VertexData of the box
  97011. */
  97012. static CreateDisc(options: {
  97013. radius?: number;
  97014. tessellation?: number;
  97015. arc?: number;
  97016. sideOrientation?: number;
  97017. frontUVs?: Vector4;
  97018. backUVs?: Vector4;
  97019. }): VertexData;
  97020. /**
  97021. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  97022. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  97023. * @param polygon a mesh built from polygonTriangulation.build()
  97024. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  97025. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  97026. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  97027. * @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)
  97028. * @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)
  97029. * @returns the VertexData of the Polygon
  97030. */
  97031. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  97032. /**
  97033. * Creates the VertexData of the IcoSphere
  97034. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  97035. * * radius the radius of the IcoSphere, optional default 1
  97036. * * radiusX allows stretching in the x direction, optional, default radius
  97037. * * radiusY allows stretching in the y direction, optional, default radius
  97038. * * radiusZ allows stretching in the z direction, optional, default radius
  97039. * * flat when true creates a flat shaded mesh, optional, default true
  97040. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  97041. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  97042. * * 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)
  97043. * * 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)
  97044. * @returns the VertexData of the IcoSphere
  97045. */
  97046. static CreateIcoSphere(options: {
  97047. radius?: number;
  97048. radiusX?: number;
  97049. radiusY?: number;
  97050. radiusZ?: number;
  97051. flat?: boolean;
  97052. subdivisions?: number;
  97053. sideOrientation?: number;
  97054. frontUVs?: Vector4;
  97055. backUVs?: Vector4;
  97056. }): VertexData;
  97057. /**
  97058. * Creates the VertexData for a Polyhedron
  97059. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  97060. * * type provided types are:
  97061. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  97062. * * 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)
  97063. * * size the size of the IcoSphere, optional default 1
  97064. * * sizeX allows stretching in the x direction, optional, default size
  97065. * * sizeY allows stretching in the y direction, optional, default size
  97066. * * sizeZ allows stretching in the z direction, optional, default size
  97067. * * 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
  97068. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  97069. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  97070. * * flat when true creates a flat shaded mesh, optional, default true
  97071. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  97072. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  97073. * * 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)
  97074. * * 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)
  97075. * @returns the VertexData of the Polyhedron
  97076. */
  97077. static CreatePolyhedron(options: {
  97078. type?: number;
  97079. size?: number;
  97080. sizeX?: number;
  97081. sizeY?: number;
  97082. sizeZ?: number;
  97083. custom?: any;
  97084. faceUV?: Vector4[];
  97085. faceColors?: Color4[];
  97086. flat?: boolean;
  97087. sideOrientation?: number;
  97088. frontUVs?: Vector4;
  97089. backUVs?: Vector4;
  97090. }): VertexData;
  97091. /**
  97092. * Creates the VertexData for a TorusKnot
  97093. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  97094. * * radius the radius of the torus knot, optional, default 2
  97095. * * tube the thickness of the tube, optional, default 0.5
  97096. * * radialSegments the number of sides on each tube segments, optional, default 32
  97097. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  97098. * * p the number of windings around the z axis, optional, default 2
  97099. * * q the number of windings around the x axis, optional, default 3
  97100. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  97101. * * 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)
  97102. * * 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)
  97103. * @returns the VertexData of the Torus Knot
  97104. */
  97105. static CreateTorusKnot(options: {
  97106. radius?: number;
  97107. tube?: number;
  97108. radialSegments?: number;
  97109. tubularSegments?: number;
  97110. p?: number;
  97111. q?: number;
  97112. sideOrientation?: number;
  97113. frontUVs?: Vector4;
  97114. backUVs?: Vector4;
  97115. }): VertexData;
  97116. /**
  97117. * Compute normals for given positions and indices
  97118. * @param positions an array of vertex positions, [...., x, y, z, ......]
  97119. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  97120. * @param normals an array of vertex normals, [...., x, y, z, ......]
  97121. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  97122. * * facetNormals : optional array of facet normals (vector3)
  97123. * * facetPositions : optional array of facet positions (vector3)
  97124. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  97125. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  97126. * * bInfo : optional bounding info, required for facetPartitioning computation
  97127. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  97128. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  97129. * * useRightHandedSystem: optional boolean to for right handed system computation
  97130. * * depthSort : optional boolean to enable the facet depth sort computation
  97131. * * distanceTo : optional Vector3 to compute the facet depth from this location
  97132. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  97133. */
  97134. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  97135. facetNormals?: any;
  97136. facetPositions?: any;
  97137. facetPartitioning?: any;
  97138. ratio?: number;
  97139. bInfo?: any;
  97140. bbSize?: Vector3;
  97141. subDiv?: any;
  97142. useRightHandedSystem?: boolean;
  97143. depthSort?: boolean;
  97144. distanceTo?: Vector3;
  97145. depthSortedFacets?: any;
  97146. }): void;
  97147. /** @hidden */
  97148. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  97149. /**
  97150. * Applies VertexData created from the imported parameters to the geometry
  97151. * @param parsedVertexData the parsed data from an imported file
  97152. * @param geometry the geometry to apply the VertexData to
  97153. */
  97154. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  97155. }
  97156. }
  97157. declare module BABYLON {
  97158. /**
  97159. * Defines a target to use with MorphTargetManager
  97160. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  97161. */
  97162. export class MorphTarget implements IAnimatable {
  97163. /** defines the name of the target */
  97164. name: string;
  97165. /**
  97166. * Gets or sets the list of animations
  97167. */
  97168. animations: Animation[];
  97169. private _scene;
  97170. private _positions;
  97171. private _normals;
  97172. private _tangents;
  97173. private _uvs;
  97174. private _influence;
  97175. private _uniqueId;
  97176. /**
  97177. * Observable raised when the influence changes
  97178. */
  97179. onInfluenceChanged: Observable<boolean>;
  97180. /** @hidden */
  97181. _onDataLayoutChanged: Observable<void>;
  97182. /**
  97183. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  97184. */
  97185. get influence(): number;
  97186. set influence(influence: number);
  97187. /**
  97188. * Gets or sets the id of the morph Target
  97189. */
  97190. id: string;
  97191. private _animationPropertiesOverride;
  97192. /**
  97193. * Gets or sets the animation properties override
  97194. */
  97195. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  97196. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  97197. /**
  97198. * Creates a new MorphTarget
  97199. * @param name defines the name of the target
  97200. * @param influence defines the influence to use
  97201. * @param scene defines the scene the morphtarget belongs to
  97202. */
  97203. constructor(
  97204. /** defines the name of the target */
  97205. name: string, influence?: number, scene?: Nullable<Scene>);
  97206. /**
  97207. * Gets the unique ID of this manager
  97208. */
  97209. get uniqueId(): number;
  97210. /**
  97211. * Gets a boolean defining if the target contains position data
  97212. */
  97213. get hasPositions(): boolean;
  97214. /**
  97215. * Gets a boolean defining if the target contains normal data
  97216. */
  97217. get hasNormals(): boolean;
  97218. /**
  97219. * Gets a boolean defining if the target contains tangent data
  97220. */
  97221. get hasTangents(): boolean;
  97222. /**
  97223. * Gets a boolean defining if the target contains texture coordinates data
  97224. */
  97225. get hasUVs(): boolean;
  97226. /**
  97227. * Affects position data to this target
  97228. * @param data defines the position data to use
  97229. */
  97230. setPositions(data: Nullable<FloatArray>): void;
  97231. /**
  97232. * Gets the position data stored in this target
  97233. * @returns a FloatArray containing the position data (or null if not present)
  97234. */
  97235. getPositions(): Nullable<FloatArray>;
  97236. /**
  97237. * Affects normal data to this target
  97238. * @param data defines the normal data to use
  97239. */
  97240. setNormals(data: Nullable<FloatArray>): void;
  97241. /**
  97242. * Gets the normal data stored in this target
  97243. * @returns a FloatArray containing the normal data (or null if not present)
  97244. */
  97245. getNormals(): Nullable<FloatArray>;
  97246. /**
  97247. * Affects tangent data to this target
  97248. * @param data defines the tangent data to use
  97249. */
  97250. setTangents(data: Nullable<FloatArray>): void;
  97251. /**
  97252. * Gets the tangent data stored in this target
  97253. * @returns a FloatArray containing the tangent data (or null if not present)
  97254. */
  97255. getTangents(): Nullable<FloatArray>;
  97256. /**
  97257. * Affects texture coordinates data to this target
  97258. * @param data defines the texture coordinates data to use
  97259. */
  97260. setUVs(data: Nullable<FloatArray>): void;
  97261. /**
  97262. * Gets the texture coordinates data stored in this target
  97263. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  97264. */
  97265. getUVs(): Nullable<FloatArray>;
  97266. /**
  97267. * Clone the current target
  97268. * @returns a new MorphTarget
  97269. */
  97270. clone(): MorphTarget;
  97271. /**
  97272. * Serializes the current target into a Serialization object
  97273. * @returns the serialized object
  97274. */
  97275. serialize(): any;
  97276. /**
  97277. * Returns the string "MorphTarget"
  97278. * @returns "MorphTarget"
  97279. */
  97280. getClassName(): string;
  97281. /**
  97282. * Creates a new target from serialized data
  97283. * @param serializationObject defines the serialized data to use
  97284. * @returns a new MorphTarget
  97285. */
  97286. static Parse(serializationObject: any): MorphTarget;
  97287. /**
  97288. * Creates a MorphTarget from mesh data
  97289. * @param mesh defines the source mesh
  97290. * @param name defines the name to use for the new target
  97291. * @param influence defines the influence to attach to the target
  97292. * @returns a new MorphTarget
  97293. */
  97294. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  97295. }
  97296. }
  97297. declare module BABYLON {
  97298. /**
  97299. * This class is used to deform meshes using morphing between different targets
  97300. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  97301. */
  97302. export class MorphTargetManager {
  97303. private _targets;
  97304. private _targetInfluenceChangedObservers;
  97305. private _targetDataLayoutChangedObservers;
  97306. private _activeTargets;
  97307. private _scene;
  97308. private _influences;
  97309. private _supportsNormals;
  97310. private _supportsTangents;
  97311. private _supportsUVs;
  97312. private _vertexCount;
  97313. private _uniqueId;
  97314. private _tempInfluences;
  97315. /**
  97316. * Gets or sets a boolean indicating if normals must be morphed
  97317. */
  97318. enableNormalMorphing: boolean;
  97319. /**
  97320. * Gets or sets a boolean indicating if tangents must be morphed
  97321. */
  97322. enableTangentMorphing: boolean;
  97323. /**
  97324. * Gets or sets a boolean indicating if UV must be morphed
  97325. */
  97326. enableUVMorphing: boolean;
  97327. /**
  97328. * Creates a new MorphTargetManager
  97329. * @param scene defines the current scene
  97330. */
  97331. constructor(scene?: Nullable<Scene>);
  97332. /**
  97333. * Gets the unique ID of this manager
  97334. */
  97335. get uniqueId(): number;
  97336. /**
  97337. * Gets the number of vertices handled by this manager
  97338. */
  97339. get vertexCount(): number;
  97340. /**
  97341. * Gets a boolean indicating if this manager supports morphing of normals
  97342. */
  97343. get supportsNormals(): boolean;
  97344. /**
  97345. * Gets a boolean indicating if this manager supports morphing of tangents
  97346. */
  97347. get supportsTangents(): boolean;
  97348. /**
  97349. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  97350. */
  97351. get supportsUVs(): boolean;
  97352. /**
  97353. * Gets the number of targets stored in this manager
  97354. */
  97355. get numTargets(): number;
  97356. /**
  97357. * Gets the number of influencers (ie. the number of targets with influences > 0)
  97358. */
  97359. get numInfluencers(): number;
  97360. /**
  97361. * Gets the list of influences (one per target)
  97362. */
  97363. get influences(): Float32Array;
  97364. /**
  97365. * Gets the active target at specified index. An active target is a target with an influence > 0
  97366. * @param index defines the index to check
  97367. * @returns the requested target
  97368. */
  97369. getActiveTarget(index: number): MorphTarget;
  97370. /**
  97371. * Gets the target at specified index
  97372. * @param index defines the index to check
  97373. * @returns the requested target
  97374. */
  97375. getTarget(index: number): MorphTarget;
  97376. /**
  97377. * Add a new target to this manager
  97378. * @param target defines the target to add
  97379. */
  97380. addTarget(target: MorphTarget): void;
  97381. /**
  97382. * Removes a target from the manager
  97383. * @param target defines the target to remove
  97384. */
  97385. removeTarget(target: MorphTarget): void;
  97386. /**
  97387. * Clone the current manager
  97388. * @returns a new MorphTargetManager
  97389. */
  97390. clone(): MorphTargetManager;
  97391. /**
  97392. * Serializes the current manager into a Serialization object
  97393. * @returns the serialized object
  97394. */
  97395. serialize(): any;
  97396. private _syncActiveTargets;
  97397. /**
  97398. * Syncrhonize the targets with all the meshes using this morph target manager
  97399. */
  97400. synchronize(): void;
  97401. /**
  97402. * Creates a new MorphTargetManager from serialized data
  97403. * @param serializationObject defines the serialized data
  97404. * @param scene defines the hosting scene
  97405. * @returns the new MorphTargetManager
  97406. */
  97407. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  97408. }
  97409. }
  97410. declare module BABYLON {
  97411. /**
  97412. * Class used to represent a specific level of detail of a mesh
  97413. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  97414. */
  97415. export class MeshLODLevel {
  97416. /** Defines the distance where this level should start being displayed */
  97417. distance: number;
  97418. /** Defines the mesh to use to render this level */
  97419. mesh: Nullable<Mesh>;
  97420. /**
  97421. * Creates a new LOD level
  97422. * @param distance defines the distance where this level should star being displayed
  97423. * @param mesh defines the mesh to use to render this level
  97424. */
  97425. constructor(
  97426. /** Defines the distance where this level should start being displayed */
  97427. distance: number,
  97428. /** Defines the mesh to use to render this level */
  97429. mesh: Nullable<Mesh>);
  97430. }
  97431. }
  97432. declare module BABYLON {
  97433. /**
  97434. * Mesh representing the gorund
  97435. */
  97436. export class GroundMesh extends Mesh {
  97437. /** If octree should be generated */
  97438. generateOctree: boolean;
  97439. private _heightQuads;
  97440. /** @hidden */
  97441. _subdivisionsX: number;
  97442. /** @hidden */
  97443. _subdivisionsY: number;
  97444. /** @hidden */
  97445. _width: number;
  97446. /** @hidden */
  97447. _height: number;
  97448. /** @hidden */
  97449. _minX: number;
  97450. /** @hidden */
  97451. _maxX: number;
  97452. /** @hidden */
  97453. _minZ: number;
  97454. /** @hidden */
  97455. _maxZ: number;
  97456. constructor(name: string, scene: Scene);
  97457. /**
  97458. * "GroundMesh"
  97459. * @returns "GroundMesh"
  97460. */
  97461. getClassName(): string;
  97462. /**
  97463. * The minimum of x and y subdivisions
  97464. */
  97465. get subdivisions(): number;
  97466. /**
  97467. * X subdivisions
  97468. */
  97469. get subdivisionsX(): number;
  97470. /**
  97471. * Y subdivisions
  97472. */
  97473. get subdivisionsY(): number;
  97474. /**
  97475. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  97476. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  97477. * @param chunksCount the number of subdivisions for x and y
  97478. * @param octreeBlocksSize (Default: 32)
  97479. */
  97480. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  97481. /**
  97482. * Returns a height (y) value in the Worl system :
  97483. * the ground altitude at the coordinates (x, z) expressed in the World system.
  97484. * @param x x coordinate
  97485. * @param z z coordinate
  97486. * @returns the ground y position if (x, z) are outside the ground surface.
  97487. */
  97488. getHeightAtCoordinates(x: number, z: number): number;
  97489. /**
  97490. * Returns a normalized vector (Vector3) orthogonal to the ground
  97491. * at the ground coordinates (x, z) expressed in the World system.
  97492. * @param x x coordinate
  97493. * @param z z coordinate
  97494. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  97495. */
  97496. getNormalAtCoordinates(x: number, z: number): Vector3;
  97497. /**
  97498. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  97499. * at the ground coordinates (x, z) expressed in the World system.
  97500. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  97501. * @param x x coordinate
  97502. * @param z z coordinate
  97503. * @param ref vector to store the result
  97504. * @returns the GroundMesh.
  97505. */
  97506. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  97507. /**
  97508. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  97509. * if the ground has been updated.
  97510. * This can be used in the render loop.
  97511. * @returns the GroundMesh.
  97512. */
  97513. updateCoordinateHeights(): GroundMesh;
  97514. private _getFacetAt;
  97515. private _initHeightQuads;
  97516. private _computeHeightQuads;
  97517. /**
  97518. * Serializes this ground mesh
  97519. * @param serializationObject object to write serialization to
  97520. */
  97521. serialize(serializationObject: any): void;
  97522. /**
  97523. * Parses a serialized ground mesh
  97524. * @param parsedMesh the serialized mesh
  97525. * @param scene the scene to create the ground mesh in
  97526. * @returns the created ground mesh
  97527. */
  97528. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  97529. }
  97530. }
  97531. declare module BABYLON {
  97532. /**
  97533. * Interface for Physics-Joint data
  97534. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  97535. */
  97536. export interface PhysicsJointData {
  97537. /**
  97538. * The main pivot of the joint
  97539. */
  97540. mainPivot?: Vector3;
  97541. /**
  97542. * The connected pivot of the joint
  97543. */
  97544. connectedPivot?: Vector3;
  97545. /**
  97546. * The main axis of the joint
  97547. */
  97548. mainAxis?: Vector3;
  97549. /**
  97550. * The connected axis of the joint
  97551. */
  97552. connectedAxis?: Vector3;
  97553. /**
  97554. * The collision of the joint
  97555. */
  97556. collision?: boolean;
  97557. /**
  97558. * Native Oimo/Cannon/Energy data
  97559. */
  97560. nativeParams?: any;
  97561. }
  97562. /**
  97563. * This is a holder class for the physics joint created by the physics plugin
  97564. * It holds a set of functions to control the underlying joint
  97565. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  97566. */
  97567. export class PhysicsJoint {
  97568. /**
  97569. * The type of the physics joint
  97570. */
  97571. type: number;
  97572. /**
  97573. * The data for the physics joint
  97574. */
  97575. jointData: PhysicsJointData;
  97576. private _physicsJoint;
  97577. protected _physicsPlugin: IPhysicsEnginePlugin;
  97578. /**
  97579. * Initializes the physics joint
  97580. * @param type The type of the physics joint
  97581. * @param jointData The data for the physics joint
  97582. */
  97583. constructor(
  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. /**
  97593. * Gets the physics joint
  97594. */
  97595. get physicsJoint(): any;
  97596. /**
  97597. * Sets the physics joint
  97598. */
  97599. set physicsJoint(newJoint: any);
  97600. /**
  97601. * Sets the physics plugin
  97602. */
  97603. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  97604. /**
  97605. * Execute a function that is physics-plugin specific.
  97606. * @param {Function} func the function that will be executed.
  97607. * It accepts two parameters: the physics world and the physics joint
  97608. */
  97609. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  97610. /**
  97611. * Distance-Joint type
  97612. */
  97613. static DistanceJoint: number;
  97614. /**
  97615. * Hinge-Joint type
  97616. */
  97617. static HingeJoint: number;
  97618. /**
  97619. * Ball-and-Socket joint type
  97620. */
  97621. static BallAndSocketJoint: number;
  97622. /**
  97623. * Wheel-Joint type
  97624. */
  97625. static WheelJoint: number;
  97626. /**
  97627. * Slider-Joint type
  97628. */
  97629. static SliderJoint: number;
  97630. /**
  97631. * Prismatic-Joint type
  97632. */
  97633. static PrismaticJoint: number;
  97634. /**
  97635. * Universal-Joint type
  97636. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  97637. */
  97638. static UniversalJoint: number;
  97639. /**
  97640. * Hinge-Joint 2 type
  97641. */
  97642. static Hinge2Joint: number;
  97643. /**
  97644. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  97645. */
  97646. static PointToPointJoint: number;
  97647. /**
  97648. * Spring-Joint type
  97649. */
  97650. static SpringJoint: number;
  97651. /**
  97652. * Lock-Joint type
  97653. */
  97654. static LockJoint: number;
  97655. }
  97656. /**
  97657. * A class representing a physics distance joint
  97658. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  97659. */
  97660. export class DistanceJoint extends PhysicsJoint {
  97661. /**
  97662. *
  97663. * @param jointData The data for the Distance-Joint
  97664. */
  97665. constructor(jointData: DistanceJointData);
  97666. /**
  97667. * Update the predefined distance.
  97668. * @param maxDistance The maximum preferred distance
  97669. * @param minDistance The minimum preferred distance
  97670. */
  97671. updateDistance(maxDistance: number, minDistance?: number): void;
  97672. }
  97673. /**
  97674. * Represents a Motor-Enabled Joint
  97675. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  97676. */
  97677. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  97678. /**
  97679. * Initializes the Motor-Enabled Joint
  97680. * @param type The type of the joint
  97681. * @param jointData The physica joint data for the joint
  97682. */
  97683. constructor(type: number, jointData: PhysicsJointData);
  97684. /**
  97685. * Set the motor values.
  97686. * Attention, this function is plugin specific. Engines won't react 100% the same.
  97687. * @param force the force to apply
  97688. * @param maxForce max force for this motor.
  97689. */
  97690. setMotor(force?: number, maxForce?: number): void;
  97691. /**
  97692. * Set the motor's limits.
  97693. * Attention, this function is plugin specific. Engines won't react 100% the same.
  97694. * @param upperLimit The upper limit of the motor
  97695. * @param lowerLimit The lower limit of the motor
  97696. */
  97697. setLimit(upperLimit: number, lowerLimit?: number): void;
  97698. }
  97699. /**
  97700. * This class represents a single physics Hinge-Joint
  97701. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  97702. */
  97703. export class HingeJoint extends MotorEnabledJoint {
  97704. /**
  97705. * Initializes the Hinge-Joint
  97706. * @param jointData The joint data for the Hinge-Joint
  97707. */
  97708. constructor(jointData: PhysicsJointData);
  97709. /**
  97710. * Set the motor values.
  97711. * Attention, this function is plugin specific. Engines won't react 100% the same.
  97712. * @param {number} force the force to apply
  97713. * @param {number} maxForce max force for this motor.
  97714. */
  97715. setMotor(force?: number, maxForce?: number): void;
  97716. /**
  97717. * Set the motor's limits.
  97718. * Attention, this function is plugin specific. Engines won't react 100% the same.
  97719. * @param upperLimit The upper limit of the motor
  97720. * @param lowerLimit The lower limit of the motor
  97721. */
  97722. setLimit(upperLimit: number, lowerLimit?: number): void;
  97723. }
  97724. /**
  97725. * This class represents a dual hinge physics joint (same as wheel joint)
  97726. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  97727. */
  97728. export class Hinge2Joint extends MotorEnabledJoint {
  97729. /**
  97730. * Initializes the Hinge2-Joint
  97731. * @param jointData The joint data for the Hinge2-Joint
  97732. */
  97733. constructor(jointData: PhysicsJointData);
  97734. /**
  97735. * Set the motor values.
  97736. * Attention, this function is plugin specific. Engines won't react 100% the same.
  97737. * @param {number} targetSpeed the speed the motor is to reach
  97738. * @param {number} maxForce max force for this motor.
  97739. * @param {motorIndex} the motor's index, 0 or 1.
  97740. */
  97741. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  97742. /**
  97743. * Set the motor limits.
  97744. * Attention, this function is plugin specific. Engines won't react 100% the same.
  97745. * @param {number} upperLimit the upper limit
  97746. * @param {number} lowerLimit lower limit
  97747. * @param {motorIndex} the motor's index, 0 or 1.
  97748. */
  97749. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  97750. }
  97751. /**
  97752. * Interface for a motor enabled joint
  97753. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  97754. */
  97755. export interface IMotorEnabledJoint {
  97756. /**
  97757. * Physics joint
  97758. */
  97759. physicsJoint: any;
  97760. /**
  97761. * Sets the motor of the motor-enabled joint
  97762. * @param force The force of the motor
  97763. * @param maxForce The maximum force of the motor
  97764. * @param motorIndex The index of the motor
  97765. */
  97766. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  97767. /**
  97768. * Sets the limit of the motor
  97769. * @param upperLimit The upper limit of the motor
  97770. * @param lowerLimit The lower limit of the motor
  97771. * @param motorIndex The index of the motor
  97772. */
  97773. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  97774. }
  97775. /**
  97776. * Joint data for a Distance-Joint
  97777. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  97778. */
  97779. export interface DistanceJointData extends PhysicsJointData {
  97780. /**
  97781. * Max distance the 2 joint objects can be apart
  97782. */
  97783. maxDistance: number;
  97784. }
  97785. /**
  97786. * Joint data from a spring joint
  97787. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  97788. */
  97789. export interface SpringJointData extends PhysicsJointData {
  97790. /**
  97791. * Length of the spring
  97792. */
  97793. length: number;
  97794. /**
  97795. * Stiffness of the spring
  97796. */
  97797. stiffness: number;
  97798. /**
  97799. * Damping of the spring
  97800. */
  97801. damping: number;
  97802. /** this callback will be called when applying the force to the impostors. */
  97803. forceApplicationCallback: () => void;
  97804. }
  97805. }
  97806. declare module BABYLON {
  97807. /**
  97808. * Holds the data for the raycast result
  97809. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  97810. */
  97811. export class PhysicsRaycastResult {
  97812. private _hasHit;
  97813. private _hitDistance;
  97814. private _hitNormalWorld;
  97815. private _hitPointWorld;
  97816. private _rayFromWorld;
  97817. private _rayToWorld;
  97818. /**
  97819. * Gets if there was a hit
  97820. */
  97821. get hasHit(): boolean;
  97822. /**
  97823. * Gets the distance from the hit
  97824. */
  97825. get hitDistance(): number;
  97826. /**
  97827. * Gets the hit normal/direction in the world
  97828. */
  97829. get hitNormalWorld(): Vector3;
  97830. /**
  97831. * Gets the hit point in the world
  97832. */
  97833. get hitPointWorld(): Vector3;
  97834. /**
  97835. * Gets the ray "start point" of the ray in the world
  97836. */
  97837. get rayFromWorld(): Vector3;
  97838. /**
  97839. * Gets the ray "end point" of the ray in the world
  97840. */
  97841. get rayToWorld(): Vector3;
  97842. /**
  97843. * Sets the hit data (normal & point in world space)
  97844. * @param hitNormalWorld defines the normal in world space
  97845. * @param hitPointWorld defines the point in world space
  97846. */
  97847. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  97848. /**
  97849. * Sets the distance from the start point to the hit point
  97850. * @param distance
  97851. */
  97852. setHitDistance(distance: number): void;
  97853. /**
  97854. * Calculates the distance manually
  97855. */
  97856. calculateHitDistance(): void;
  97857. /**
  97858. * Resets all the values to default
  97859. * @param from The from point on world space
  97860. * @param to The to point on world space
  97861. */
  97862. reset(from?: Vector3, to?: Vector3): void;
  97863. }
  97864. /**
  97865. * Interface for the size containing width and height
  97866. */
  97867. interface IXYZ {
  97868. /**
  97869. * X
  97870. */
  97871. x: number;
  97872. /**
  97873. * Y
  97874. */
  97875. y: number;
  97876. /**
  97877. * Z
  97878. */
  97879. z: number;
  97880. }
  97881. }
  97882. declare module BABYLON {
  97883. /**
  97884. * Interface used to describe a physics joint
  97885. */
  97886. export interface PhysicsImpostorJoint {
  97887. /** Defines the main impostor to which the joint is linked */
  97888. mainImpostor: PhysicsImpostor;
  97889. /** Defines the impostor that is connected to the main impostor using this joint */
  97890. connectedImpostor: PhysicsImpostor;
  97891. /** Defines the joint itself */
  97892. joint: PhysicsJoint;
  97893. }
  97894. /** @hidden */
  97895. export interface IPhysicsEnginePlugin {
  97896. world: any;
  97897. name: string;
  97898. setGravity(gravity: Vector3): void;
  97899. setTimeStep(timeStep: number): void;
  97900. getTimeStep(): number;
  97901. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  97902. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  97903. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  97904. generatePhysicsBody(impostor: PhysicsImpostor): void;
  97905. removePhysicsBody(impostor: PhysicsImpostor): void;
  97906. generateJoint(joint: PhysicsImpostorJoint): void;
  97907. removeJoint(joint: PhysicsImpostorJoint): void;
  97908. isSupported(): boolean;
  97909. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  97910. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  97911. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  97912. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  97913. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  97914. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  97915. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  97916. getBodyMass(impostor: PhysicsImpostor): number;
  97917. getBodyFriction(impostor: PhysicsImpostor): number;
  97918. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  97919. getBodyRestitution(impostor: PhysicsImpostor): number;
  97920. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  97921. getBodyPressure?(impostor: PhysicsImpostor): number;
  97922. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  97923. getBodyStiffness?(impostor: PhysicsImpostor): number;
  97924. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  97925. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  97926. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  97927. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  97928. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  97929. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  97930. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  97931. sleepBody(impostor: PhysicsImpostor): void;
  97932. wakeUpBody(impostor: PhysicsImpostor): void;
  97933. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  97934. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  97935. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  97936. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  97937. getRadius(impostor: PhysicsImpostor): number;
  97938. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  97939. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  97940. dispose(): void;
  97941. }
  97942. /**
  97943. * Interface used to define a physics engine
  97944. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  97945. */
  97946. export interface IPhysicsEngine {
  97947. /**
  97948. * Gets the gravity vector used by the simulation
  97949. */
  97950. gravity: Vector3;
  97951. /**
  97952. * Sets the gravity vector used by the simulation
  97953. * @param gravity defines the gravity vector to use
  97954. */
  97955. setGravity(gravity: Vector3): void;
  97956. /**
  97957. * Set the time step of the physics engine.
  97958. * Default is 1/60.
  97959. * To slow it down, enter 1/600 for example.
  97960. * To speed it up, 1/30
  97961. * @param newTimeStep the new timestep to apply to this world.
  97962. */
  97963. setTimeStep(newTimeStep: number): void;
  97964. /**
  97965. * Get the time step of the physics engine.
  97966. * @returns the current time step
  97967. */
  97968. getTimeStep(): number;
  97969. /**
  97970. * Set the sub time step of the physics engine.
  97971. * Default is 0 meaning there is no sub steps
  97972. * To increase physics resolution precision, set a small value (like 1 ms)
  97973. * @param subTimeStep defines the new sub timestep used for physics resolution.
  97974. */
  97975. setSubTimeStep(subTimeStep: number): void;
  97976. /**
  97977. * Get the sub time step of the physics engine.
  97978. * @returns the current sub time step
  97979. */
  97980. getSubTimeStep(): number;
  97981. /**
  97982. * Release all resources
  97983. */
  97984. dispose(): void;
  97985. /**
  97986. * Gets the name of the current physics plugin
  97987. * @returns the name of the plugin
  97988. */
  97989. getPhysicsPluginName(): string;
  97990. /**
  97991. * Adding a new impostor for the impostor tracking.
  97992. * This will be done by the impostor itself.
  97993. * @param impostor the impostor to add
  97994. */
  97995. addImpostor(impostor: PhysicsImpostor): void;
  97996. /**
  97997. * Remove an impostor from the engine.
  97998. * This impostor and its mesh will not longer be updated by the physics engine.
  97999. * @param impostor the impostor to remove
  98000. */
  98001. removeImpostor(impostor: PhysicsImpostor): void;
  98002. /**
  98003. * Add a joint to the physics engine
  98004. * @param mainImpostor defines the main impostor to which the joint is added.
  98005. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  98006. * @param joint defines the joint that will connect both impostors.
  98007. */
  98008. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  98009. /**
  98010. * Removes a joint from the simulation
  98011. * @param mainImpostor defines the impostor used with the joint
  98012. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  98013. * @param joint defines the joint to remove
  98014. */
  98015. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  98016. /**
  98017. * Gets the current plugin used to run the simulation
  98018. * @returns current plugin
  98019. */
  98020. getPhysicsPlugin(): IPhysicsEnginePlugin;
  98021. /**
  98022. * Gets the list of physic impostors
  98023. * @returns an array of PhysicsImpostor
  98024. */
  98025. getImpostors(): Array<PhysicsImpostor>;
  98026. /**
  98027. * Gets the impostor for a physics enabled object
  98028. * @param object defines the object impersonated by the impostor
  98029. * @returns the PhysicsImpostor or null if not found
  98030. */
  98031. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  98032. /**
  98033. * Gets the impostor for a physics body object
  98034. * @param body defines physics body used by the impostor
  98035. * @returns the PhysicsImpostor or null if not found
  98036. */
  98037. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  98038. /**
  98039. * Does a raycast in the physics world
  98040. * @param from when should the ray start?
  98041. * @param to when should the ray end?
  98042. * @returns PhysicsRaycastResult
  98043. */
  98044. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  98045. /**
  98046. * Called by the scene. No need to call it.
  98047. * @param delta defines the timespam between frames
  98048. */
  98049. _step(delta: number): void;
  98050. }
  98051. }
  98052. declare module BABYLON {
  98053. /**
  98054. * The interface for the physics imposter parameters
  98055. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  98056. */
  98057. export interface PhysicsImpostorParameters {
  98058. /**
  98059. * The mass of the physics imposter
  98060. */
  98061. mass: number;
  98062. /**
  98063. * The friction of the physics imposter
  98064. */
  98065. friction?: number;
  98066. /**
  98067. * The coefficient of restitution of the physics imposter
  98068. */
  98069. restitution?: number;
  98070. /**
  98071. * The native options of the physics imposter
  98072. */
  98073. nativeOptions?: any;
  98074. /**
  98075. * Specifies if the parent should be ignored
  98076. */
  98077. ignoreParent?: boolean;
  98078. /**
  98079. * Specifies if bi-directional transformations should be disabled
  98080. */
  98081. disableBidirectionalTransformation?: boolean;
  98082. /**
  98083. * The pressure inside the physics imposter, soft object only
  98084. */
  98085. pressure?: number;
  98086. /**
  98087. * The stiffness the physics imposter, soft object only
  98088. */
  98089. stiffness?: number;
  98090. /**
  98091. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  98092. */
  98093. velocityIterations?: number;
  98094. /**
  98095. * The number of iterations used in maintaining consistent vertex positions, soft object only
  98096. */
  98097. positionIterations?: number;
  98098. /**
  98099. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  98100. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  98101. * Add to fix multiple points
  98102. */
  98103. fixedPoints?: number;
  98104. /**
  98105. * The collision margin around a soft object
  98106. */
  98107. margin?: number;
  98108. /**
  98109. * The collision margin around a soft object
  98110. */
  98111. damping?: number;
  98112. /**
  98113. * The path for a rope based on an extrusion
  98114. */
  98115. path?: any;
  98116. /**
  98117. * The shape of an extrusion used for a rope based on an extrusion
  98118. */
  98119. shape?: any;
  98120. }
  98121. /**
  98122. * Interface for a physics-enabled object
  98123. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  98124. */
  98125. export interface IPhysicsEnabledObject {
  98126. /**
  98127. * The position of the physics-enabled object
  98128. */
  98129. position: Vector3;
  98130. /**
  98131. * The rotation of the physics-enabled object
  98132. */
  98133. rotationQuaternion: Nullable<Quaternion>;
  98134. /**
  98135. * The scale of the physics-enabled object
  98136. */
  98137. scaling: Vector3;
  98138. /**
  98139. * The rotation of the physics-enabled object
  98140. */
  98141. rotation?: Vector3;
  98142. /**
  98143. * The parent of the physics-enabled object
  98144. */
  98145. parent?: any;
  98146. /**
  98147. * The bounding info of the physics-enabled object
  98148. * @returns The bounding info of the physics-enabled object
  98149. */
  98150. getBoundingInfo(): BoundingInfo;
  98151. /**
  98152. * Computes the world matrix
  98153. * @param force Specifies if the world matrix should be computed by force
  98154. * @returns A world matrix
  98155. */
  98156. computeWorldMatrix(force: boolean): Matrix;
  98157. /**
  98158. * Gets the world matrix
  98159. * @returns A world matrix
  98160. */
  98161. getWorldMatrix?(): Matrix;
  98162. /**
  98163. * Gets the child meshes
  98164. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  98165. * @returns An array of abstract meshes
  98166. */
  98167. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  98168. /**
  98169. * Gets the vertex data
  98170. * @param kind The type of vertex data
  98171. * @returns A nullable array of numbers, or a float32 array
  98172. */
  98173. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  98174. /**
  98175. * Gets the indices from the mesh
  98176. * @returns A nullable array of index arrays
  98177. */
  98178. getIndices?(): Nullable<IndicesArray>;
  98179. /**
  98180. * Gets the scene from the mesh
  98181. * @returns the indices array or null
  98182. */
  98183. getScene?(): Scene;
  98184. /**
  98185. * Gets the absolute position from the mesh
  98186. * @returns the absolute position
  98187. */
  98188. getAbsolutePosition(): Vector3;
  98189. /**
  98190. * Gets the absolute pivot point from the mesh
  98191. * @returns the absolute pivot point
  98192. */
  98193. getAbsolutePivotPoint(): Vector3;
  98194. /**
  98195. * Rotates the mesh
  98196. * @param axis The axis of rotation
  98197. * @param amount The amount of rotation
  98198. * @param space The space of the rotation
  98199. * @returns The rotation transform node
  98200. */
  98201. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  98202. /**
  98203. * Translates the mesh
  98204. * @param axis The axis of translation
  98205. * @param distance The distance of translation
  98206. * @param space The space of the translation
  98207. * @returns The transform node
  98208. */
  98209. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  98210. /**
  98211. * Sets the absolute position of the mesh
  98212. * @param absolutePosition The absolute position of the mesh
  98213. * @returns The transform node
  98214. */
  98215. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  98216. /**
  98217. * Gets the class name of the mesh
  98218. * @returns The class name
  98219. */
  98220. getClassName(): string;
  98221. }
  98222. /**
  98223. * Represents a physics imposter
  98224. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  98225. */
  98226. export class PhysicsImpostor {
  98227. /**
  98228. * The physics-enabled object used as the physics imposter
  98229. */
  98230. object: IPhysicsEnabledObject;
  98231. /**
  98232. * The type of the physics imposter
  98233. */
  98234. type: number;
  98235. private _options;
  98236. private _scene?;
  98237. /**
  98238. * The default object size of the imposter
  98239. */
  98240. static DEFAULT_OBJECT_SIZE: Vector3;
  98241. /**
  98242. * The identity quaternion of the imposter
  98243. */
  98244. static IDENTITY_QUATERNION: Quaternion;
  98245. /** @hidden */
  98246. _pluginData: any;
  98247. private _physicsEngine;
  98248. private _physicsBody;
  98249. private _bodyUpdateRequired;
  98250. private _onBeforePhysicsStepCallbacks;
  98251. private _onAfterPhysicsStepCallbacks;
  98252. /** @hidden */
  98253. _onPhysicsCollideCallbacks: Array<{
  98254. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  98255. otherImpostors: Array<PhysicsImpostor>;
  98256. }>;
  98257. private _deltaPosition;
  98258. private _deltaRotation;
  98259. private _deltaRotationConjugated;
  98260. /** @hidden */
  98261. _isFromLine: boolean;
  98262. private _parent;
  98263. private _isDisposed;
  98264. private static _tmpVecs;
  98265. private static _tmpQuat;
  98266. /**
  98267. * Specifies if the physics imposter is disposed
  98268. */
  98269. get isDisposed(): boolean;
  98270. /**
  98271. * Gets the mass of the physics imposter
  98272. */
  98273. get mass(): number;
  98274. set mass(value: number);
  98275. /**
  98276. * Gets the coefficient of friction
  98277. */
  98278. get friction(): number;
  98279. /**
  98280. * Sets the coefficient of friction
  98281. */
  98282. set friction(value: number);
  98283. /**
  98284. * Gets the coefficient of restitution
  98285. */
  98286. get restitution(): number;
  98287. /**
  98288. * Sets the coefficient of restitution
  98289. */
  98290. set restitution(value: number);
  98291. /**
  98292. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  98293. */
  98294. get pressure(): number;
  98295. /**
  98296. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  98297. */
  98298. set pressure(value: number);
  98299. /**
  98300. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  98301. */
  98302. get stiffness(): number;
  98303. /**
  98304. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  98305. */
  98306. set stiffness(value: number);
  98307. /**
  98308. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  98309. */
  98310. get velocityIterations(): number;
  98311. /**
  98312. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  98313. */
  98314. set velocityIterations(value: number);
  98315. /**
  98316. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  98317. */
  98318. get positionIterations(): number;
  98319. /**
  98320. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  98321. */
  98322. set positionIterations(value: number);
  98323. /**
  98324. * The unique id of the physics imposter
  98325. * set by the physics engine when adding this impostor to the array
  98326. */
  98327. uniqueId: number;
  98328. /**
  98329. * @hidden
  98330. */
  98331. soft: boolean;
  98332. /**
  98333. * @hidden
  98334. */
  98335. segments: number;
  98336. private _joints;
  98337. /**
  98338. * Initializes the physics imposter
  98339. * @param object The physics-enabled object used as the physics imposter
  98340. * @param type The type of the physics imposter
  98341. * @param _options The options for the physics imposter
  98342. * @param _scene The Babylon scene
  98343. */
  98344. constructor(
  98345. /**
  98346. * The physics-enabled object used as the physics imposter
  98347. */
  98348. object: IPhysicsEnabledObject,
  98349. /**
  98350. * The type of the physics imposter
  98351. */
  98352. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  98353. /**
  98354. * This function will completly initialize this impostor.
  98355. * It will create a new body - but only if this mesh has no parent.
  98356. * If it has, this impostor will not be used other than to define the impostor
  98357. * of the child mesh.
  98358. * @hidden
  98359. */
  98360. _init(): void;
  98361. private _getPhysicsParent;
  98362. /**
  98363. * Should a new body be generated.
  98364. * @returns boolean specifying if body initialization is required
  98365. */
  98366. isBodyInitRequired(): boolean;
  98367. /**
  98368. * Sets the updated scaling
  98369. * @param updated Specifies if the scaling is updated
  98370. */
  98371. setScalingUpdated(): void;
  98372. /**
  98373. * Force a regeneration of this or the parent's impostor's body.
  98374. * Use under cautious - This will remove all joints already implemented.
  98375. */
  98376. forceUpdate(): void;
  98377. /**
  98378. * Gets the body that holds this impostor. Either its own, or its parent.
  98379. */
  98380. get physicsBody(): any;
  98381. /**
  98382. * Get the parent of the physics imposter
  98383. * @returns Physics imposter or null
  98384. */
  98385. get parent(): Nullable<PhysicsImpostor>;
  98386. /**
  98387. * Sets the parent of the physics imposter
  98388. */
  98389. set parent(value: Nullable<PhysicsImpostor>);
  98390. /**
  98391. * Set the physics body. Used mainly by the physics engine/plugin
  98392. */
  98393. set physicsBody(physicsBody: any);
  98394. /**
  98395. * Resets the update flags
  98396. */
  98397. resetUpdateFlags(): void;
  98398. /**
  98399. * Gets the object extend size
  98400. * @returns the object extend size
  98401. */
  98402. getObjectExtendSize(): Vector3;
  98403. /**
  98404. * Gets the object center
  98405. * @returns The object center
  98406. */
  98407. getObjectCenter(): Vector3;
  98408. /**
  98409. * Get a specific parameter from the options parameters
  98410. * @param paramName The object parameter name
  98411. * @returns The object parameter
  98412. */
  98413. getParam(paramName: string): any;
  98414. /**
  98415. * Sets a specific parameter in the options given to the physics plugin
  98416. * @param paramName The parameter name
  98417. * @param value The value of the parameter
  98418. */
  98419. setParam(paramName: string, value: number): void;
  98420. /**
  98421. * Specifically change the body's mass option. Won't recreate the physics body object
  98422. * @param mass The mass of the physics imposter
  98423. */
  98424. setMass(mass: number): void;
  98425. /**
  98426. * Gets the linear velocity
  98427. * @returns linear velocity or null
  98428. */
  98429. getLinearVelocity(): Nullable<Vector3>;
  98430. /**
  98431. * Sets the linear velocity
  98432. * @param velocity linear velocity or null
  98433. */
  98434. setLinearVelocity(velocity: Nullable<Vector3>): void;
  98435. /**
  98436. * Gets the angular velocity
  98437. * @returns angular velocity or null
  98438. */
  98439. getAngularVelocity(): Nullable<Vector3>;
  98440. /**
  98441. * Sets the angular velocity
  98442. * @param velocity The velocity or null
  98443. */
  98444. setAngularVelocity(velocity: Nullable<Vector3>): void;
  98445. /**
  98446. * Execute a function with the physics plugin native code
  98447. * Provide a function the will have two variables - the world object and the physics body object
  98448. * @param func The function to execute with the physics plugin native code
  98449. */
  98450. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  98451. /**
  98452. * Register a function that will be executed before the physics world is stepping forward
  98453. * @param func The function to execute before the physics world is stepped forward
  98454. */
  98455. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  98456. /**
  98457. * Unregister a function that will be executed before the physics world is stepping forward
  98458. * @param func The function to execute before the physics world is stepped forward
  98459. */
  98460. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  98461. /**
  98462. * Register a function that will be executed after the physics step
  98463. * @param func The function to execute after physics step
  98464. */
  98465. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  98466. /**
  98467. * Unregisters a function that will be executed after the physics step
  98468. * @param func The function to execute after physics step
  98469. */
  98470. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  98471. /**
  98472. * register a function that will be executed when this impostor collides against a different body
  98473. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  98474. * @param func Callback that is executed on collision
  98475. */
  98476. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  98477. /**
  98478. * Unregisters the physics imposter on contact
  98479. * @param collideAgainst The physics object to collide against
  98480. * @param func Callback to execute on collision
  98481. */
  98482. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  98483. private _tmpQuat;
  98484. private _tmpQuat2;
  98485. /**
  98486. * Get the parent rotation
  98487. * @returns The parent rotation
  98488. */
  98489. getParentsRotation(): Quaternion;
  98490. /**
  98491. * this function is executed by the physics engine.
  98492. */
  98493. beforeStep: () => void;
  98494. /**
  98495. * this function is executed by the physics engine
  98496. */
  98497. afterStep: () => void;
  98498. /**
  98499. * Legacy collision detection event support
  98500. */
  98501. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  98502. /**
  98503. * event and body object due to cannon's event-based architecture.
  98504. */
  98505. onCollide: (e: {
  98506. body: any;
  98507. }) => void;
  98508. /**
  98509. * Apply a force
  98510. * @param force The force to apply
  98511. * @param contactPoint The contact point for the force
  98512. * @returns The physics imposter
  98513. */
  98514. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  98515. /**
  98516. * Apply an impulse
  98517. * @param force The impulse force
  98518. * @param contactPoint The contact point for the impulse force
  98519. * @returns The physics imposter
  98520. */
  98521. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  98522. /**
  98523. * A help function to create a joint
  98524. * @param otherImpostor A physics imposter used to create a joint
  98525. * @param jointType The type of joint
  98526. * @param jointData The data for the joint
  98527. * @returns The physics imposter
  98528. */
  98529. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  98530. /**
  98531. * Add a joint to this impostor with a different impostor
  98532. * @param otherImpostor A physics imposter used to add a joint
  98533. * @param joint The joint to add
  98534. * @returns The physics imposter
  98535. */
  98536. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  98537. /**
  98538. * Add an anchor to a cloth impostor
  98539. * @param otherImpostor rigid impostor to anchor to
  98540. * @param width ratio across width from 0 to 1
  98541. * @param height ratio up height from 0 to 1
  98542. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  98543. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  98544. * @returns impostor the soft imposter
  98545. */
  98546. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  98547. /**
  98548. * Add a hook to a rope impostor
  98549. * @param otherImpostor rigid impostor to anchor to
  98550. * @param length ratio across rope from 0 to 1
  98551. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  98552. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  98553. * @returns impostor the rope imposter
  98554. */
  98555. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  98556. /**
  98557. * Will keep this body still, in a sleep mode.
  98558. * @returns the physics imposter
  98559. */
  98560. sleep(): PhysicsImpostor;
  98561. /**
  98562. * Wake the body up.
  98563. * @returns The physics imposter
  98564. */
  98565. wakeUp(): PhysicsImpostor;
  98566. /**
  98567. * Clones the physics imposter
  98568. * @param newObject The physics imposter clones to this physics-enabled object
  98569. * @returns A nullable physics imposter
  98570. */
  98571. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  98572. /**
  98573. * Disposes the physics imposter
  98574. */
  98575. dispose(): void;
  98576. /**
  98577. * Sets the delta position
  98578. * @param position The delta position amount
  98579. */
  98580. setDeltaPosition(position: Vector3): void;
  98581. /**
  98582. * Sets the delta rotation
  98583. * @param rotation The delta rotation amount
  98584. */
  98585. setDeltaRotation(rotation: Quaternion): void;
  98586. /**
  98587. * Gets the box size of the physics imposter and stores the result in the input parameter
  98588. * @param result Stores the box size
  98589. * @returns The physics imposter
  98590. */
  98591. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  98592. /**
  98593. * Gets the radius of the physics imposter
  98594. * @returns Radius of the physics imposter
  98595. */
  98596. getRadius(): number;
  98597. /**
  98598. * Sync a bone with this impostor
  98599. * @param bone The bone to sync to the impostor.
  98600. * @param boneMesh The mesh that the bone is influencing.
  98601. * @param jointPivot The pivot of the joint / bone in local space.
  98602. * @param distToJoint Optional distance from the impostor to the joint.
  98603. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  98604. */
  98605. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  98606. /**
  98607. * Sync impostor to a bone
  98608. * @param bone The bone that the impostor will be synced to.
  98609. * @param boneMesh The mesh that the bone is influencing.
  98610. * @param jointPivot The pivot of the joint / bone in local space.
  98611. * @param distToJoint Optional distance from the impostor to the joint.
  98612. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  98613. * @param boneAxis Optional vector3 axis the bone is aligned with
  98614. */
  98615. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  98616. /**
  98617. * No-Imposter type
  98618. */
  98619. static NoImpostor: number;
  98620. /**
  98621. * Sphere-Imposter type
  98622. */
  98623. static SphereImpostor: number;
  98624. /**
  98625. * Box-Imposter type
  98626. */
  98627. static BoxImpostor: number;
  98628. /**
  98629. * Plane-Imposter type
  98630. */
  98631. static PlaneImpostor: number;
  98632. /**
  98633. * Mesh-imposter type
  98634. */
  98635. static MeshImpostor: number;
  98636. /**
  98637. * Capsule-Impostor type (Ammo.js plugin only)
  98638. */
  98639. static CapsuleImpostor: number;
  98640. /**
  98641. * Cylinder-Imposter type
  98642. */
  98643. static CylinderImpostor: number;
  98644. /**
  98645. * Particle-Imposter type
  98646. */
  98647. static ParticleImpostor: number;
  98648. /**
  98649. * Heightmap-Imposter type
  98650. */
  98651. static HeightmapImpostor: number;
  98652. /**
  98653. * ConvexHull-Impostor type (Ammo.js plugin only)
  98654. */
  98655. static ConvexHullImpostor: number;
  98656. /**
  98657. * Custom-Imposter type (Ammo.js plugin only)
  98658. */
  98659. static CustomImpostor: number;
  98660. /**
  98661. * Rope-Imposter type
  98662. */
  98663. static RopeImpostor: number;
  98664. /**
  98665. * Cloth-Imposter type
  98666. */
  98667. static ClothImpostor: number;
  98668. /**
  98669. * Softbody-Imposter type
  98670. */
  98671. static SoftbodyImpostor: number;
  98672. }
  98673. }
  98674. declare module BABYLON {
  98675. /**
  98676. * @hidden
  98677. **/
  98678. export class _CreationDataStorage {
  98679. closePath?: boolean;
  98680. closeArray?: boolean;
  98681. idx: number[];
  98682. dashSize: number;
  98683. gapSize: number;
  98684. path3D: Path3D;
  98685. pathArray: Vector3[][];
  98686. arc: number;
  98687. radius: number;
  98688. cap: number;
  98689. tessellation: number;
  98690. }
  98691. /**
  98692. * @hidden
  98693. **/
  98694. class _InstanceDataStorage {
  98695. visibleInstances: any;
  98696. batchCache: _InstancesBatch;
  98697. instancesBufferSize: number;
  98698. instancesBuffer: Nullable<Buffer>;
  98699. instancesData: Float32Array;
  98700. overridenInstanceCount: number;
  98701. isFrozen: boolean;
  98702. previousBatch: Nullable<_InstancesBatch>;
  98703. hardwareInstancedRendering: boolean;
  98704. sideOrientation: number;
  98705. manualUpdate: boolean;
  98706. }
  98707. /**
  98708. * @hidden
  98709. **/
  98710. export class _InstancesBatch {
  98711. mustReturn: boolean;
  98712. visibleInstances: Nullable<InstancedMesh[]>[];
  98713. renderSelf: boolean[];
  98714. hardwareInstancedRendering: boolean[];
  98715. }
  98716. /**
  98717. * Class used to represent renderable models
  98718. */
  98719. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  98720. /**
  98721. * Mesh side orientation : usually the external or front surface
  98722. */
  98723. static readonly FRONTSIDE: number;
  98724. /**
  98725. * Mesh side orientation : usually the internal or back surface
  98726. */
  98727. static readonly BACKSIDE: number;
  98728. /**
  98729. * Mesh side orientation : both internal and external or front and back surfaces
  98730. */
  98731. static readonly DOUBLESIDE: number;
  98732. /**
  98733. * Mesh side orientation : by default, `FRONTSIDE`
  98734. */
  98735. static readonly DEFAULTSIDE: number;
  98736. /**
  98737. * Mesh cap setting : no cap
  98738. */
  98739. static readonly NO_CAP: number;
  98740. /**
  98741. * Mesh cap setting : one cap at the beginning of the mesh
  98742. */
  98743. static readonly CAP_START: number;
  98744. /**
  98745. * Mesh cap setting : one cap at the end of the mesh
  98746. */
  98747. static readonly CAP_END: number;
  98748. /**
  98749. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  98750. */
  98751. static readonly CAP_ALL: number;
  98752. /**
  98753. * Mesh pattern setting : no flip or rotate
  98754. */
  98755. static readonly NO_FLIP: number;
  98756. /**
  98757. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  98758. */
  98759. static readonly FLIP_TILE: number;
  98760. /**
  98761. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  98762. */
  98763. static readonly ROTATE_TILE: number;
  98764. /**
  98765. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  98766. */
  98767. static readonly FLIP_ROW: number;
  98768. /**
  98769. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  98770. */
  98771. static readonly ROTATE_ROW: number;
  98772. /**
  98773. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  98774. */
  98775. static readonly FLIP_N_ROTATE_TILE: number;
  98776. /**
  98777. * Mesh pattern setting : rotate pattern and rotate
  98778. */
  98779. static readonly FLIP_N_ROTATE_ROW: number;
  98780. /**
  98781. * Mesh tile positioning : part tiles same on left/right or top/bottom
  98782. */
  98783. static readonly CENTER: number;
  98784. /**
  98785. * Mesh tile positioning : part tiles on left
  98786. */
  98787. static readonly LEFT: number;
  98788. /**
  98789. * Mesh tile positioning : part tiles on right
  98790. */
  98791. static readonly RIGHT: number;
  98792. /**
  98793. * Mesh tile positioning : part tiles on top
  98794. */
  98795. static readonly TOP: number;
  98796. /**
  98797. * Mesh tile positioning : part tiles on bottom
  98798. */
  98799. static readonly BOTTOM: number;
  98800. /**
  98801. * Gets the default side orientation.
  98802. * @param orientation the orientation to value to attempt to get
  98803. * @returns the default orientation
  98804. * @hidden
  98805. */
  98806. static _GetDefaultSideOrientation(orientation?: number): number;
  98807. private _internalMeshDataInfo;
  98808. /**
  98809. * An event triggered before rendering the mesh
  98810. */
  98811. get onBeforeRenderObservable(): Observable<Mesh>;
  98812. /**
  98813. * An event triggered before binding the mesh
  98814. */
  98815. get onBeforeBindObservable(): Observable<Mesh>;
  98816. /**
  98817. * An event triggered after rendering the mesh
  98818. */
  98819. get onAfterRenderObservable(): Observable<Mesh>;
  98820. /**
  98821. * An event triggered before drawing the mesh
  98822. */
  98823. get onBeforeDrawObservable(): Observable<Mesh>;
  98824. private _onBeforeDrawObserver;
  98825. /**
  98826. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  98827. */
  98828. set onBeforeDraw(callback: () => void);
  98829. get hasInstances(): boolean;
  98830. /**
  98831. * Gets the delay loading state of the mesh (when delay loading is turned on)
  98832. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  98833. */
  98834. delayLoadState: number;
  98835. /**
  98836. * Gets the list of instances created from this mesh
  98837. * it is not supposed to be modified manually.
  98838. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  98839. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  98840. */
  98841. instances: InstancedMesh[];
  98842. /**
  98843. * Gets the file containing delay loading data for this mesh
  98844. */
  98845. delayLoadingFile: string;
  98846. /** @hidden */
  98847. _binaryInfo: any;
  98848. /**
  98849. * User defined function used to change how LOD level selection is done
  98850. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  98851. */
  98852. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  98853. /**
  98854. * Gets or sets the morph target manager
  98855. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  98856. */
  98857. get morphTargetManager(): Nullable<MorphTargetManager>;
  98858. set morphTargetManager(value: Nullable<MorphTargetManager>);
  98859. /** @hidden */
  98860. _creationDataStorage: Nullable<_CreationDataStorage>;
  98861. /** @hidden */
  98862. _geometry: Nullable<Geometry>;
  98863. /** @hidden */
  98864. _delayInfo: Array<string>;
  98865. /** @hidden */
  98866. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  98867. /** @hidden */
  98868. _instanceDataStorage: _InstanceDataStorage;
  98869. private _effectiveMaterial;
  98870. /** @hidden */
  98871. _shouldGenerateFlatShading: boolean;
  98872. /** @hidden */
  98873. _originalBuilderSideOrientation: number;
  98874. /**
  98875. * Use this property to change the original side orientation defined at construction time
  98876. */
  98877. overrideMaterialSideOrientation: Nullable<number>;
  98878. /**
  98879. * Gets the source mesh (the one used to clone this one from)
  98880. */
  98881. get source(): Nullable<Mesh>;
  98882. /**
  98883. * Gets or sets a boolean indicating that this mesh does not use index buffer
  98884. */
  98885. get isUnIndexed(): boolean;
  98886. set isUnIndexed(value: boolean);
  98887. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  98888. get worldMatrixInstancedBuffer(): Float32Array;
  98889. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  98890. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  98891. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  98892. /**
  98893. * @constructor
  98894. * @param name The value used by scene.getMeshByName() to do a lookup.
  98895. * @param scene The scene to add this mesh to.
  98896. * @param parent The parent of this mesh, if it has one
  98897. * @param source An optional Mesh from which geometry is shared, cloned.
  98898. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  98899. * When false, achieved by calling a clone(), also passing False.
  98900. * This will make creation of children, recursive.
  98901. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  98902. */
  98903. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  98904. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  98905. doNotInstantiate: boolean;
  98906. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  98907. /**
  98908. * Gets the class name
  98909. * @returns the string "Mesh".
  98910. */
  98911. getClassName(): string;
  98912. /** @hidden */
  98913. get _isMesh(): boolean;
  98914. /**
  98915. * Returns a description of this mesh
  98916. * @param fullDetails define if full details about this mesh must be used
  98917. * @returns a descriptive string representing this mesh
  98918. */
  98919. toString(fullDetails?: boolean): string;
  98920. /** @hidden */
  98921. _unBindEffect(): void;
  98922. /**
  98923. * Gets a boolean indicating if this mesh has LOD
  98924. */
  98925. get hasLODLevels(): boolean;
  98926. /**
  98927. * Gets the list of MeshLODLevel associated with the current mesh
  98928. * @returns an array of MeshLODLevel
  98929. */
  98930. getLODLevels(): MeshLODLevel[];
  98931. private _sortLODLevels;
  98932. /**
  98933. * Add a mesh as LOD level triggered at the given distance.
  98934. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  98935. * @param distance The distance from the center of the object to show this level
  98936. * @param mesh The mesh to be added as LOD level (can be null)
  98937. * @return This mesh (for chaining)
  98938. */
  98939. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  98940. /**
  98941. * Returns the LOD level mesh at the passed distance or null if not found.
  98942. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  98943. * @param distance The distance from the center of the object to show this level
  98944. * @returns a Mesh or `null`
  98945. */
  98946. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  98947. /**
  98948. * Remove a mesh from the LOD array
  98949. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  98950. * @param mesh defines the mesh to be removed
  98951. * @return This mesh (for chaining)
  98952. */
  98953. removeLODLevel(mesh: Mesh): Mesh;
  98954. /**
  98955. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  98956. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  98957. * @param camera defines the camera to use to compute distance
  98958. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  98959. * @return This mesh (for chaining)
  98960. */
  98961. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  98962. /**
  98963. * Gets the mesh internal Geometry object
  98964. */
  98965. get geometry(): Nullable<Geometry>;
  98966. /**
  98967. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  98968. * @returns the total number of vertices
  98969. */
  98970. getTotalVertices(): number;
  98971. /**
  98972. * Returns the content of an associated vertex buffer
  98973. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  98974. * - VertexBuffer.PositionKind
  98975. * - VertexBuffer.UVKind
  98976. * - VertexBuffer.UV2Kind
  98977. * - VertexBuffer.UV3Kind
  98978. * - VertexBuffer.UV4Kind
  98979. * - VertexBuffer.UV5Kind
  98980. * - VertexBuffer.UV6Kind
  98981. * - VertexBuffer.ColorKind
  98982. * - VertexBuffer.MatricesIndicesKind
  98983. * - VertexBuffer.MatricesIndicesExtraKind
  98984. * - VertexBuffer.MatricesWeightsKind
  98985. * - VertexBuffer.MatricesWeightsExtraKind
  98986. * @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
  98987. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  98988. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  98989. */
  98990. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  98991. /**
  98992. * Returns the mesh VertexBuffer object from the requested `kind`
  98993. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  98994. * - VertexBuffer.PositionKind
  98995. * - VertexBuffer.NormalKind
  98996. * - VertexBuffer.UVKind
  98997. * - VertexBuffer.UV2Kind
  98998. * - VertexBuffer.UV3Kind
  98999. * - VertexBuffer.UV4Kind
  99000. * - VertexBuffer.UV5Kind
  99001. * - VertexBuffer.UV6Kind
  99002. * - VertexBuffer.ColorKind
  99003. * - VertexBuffer.MatricesIndicesKind
  99004. * - VertexBuffer.MatricesIndicesExtraKind
  99005. * - VertexBuffer.MatricesWeightsKind
  99006. * - VertexBuffer.MatricesWeightsExtraKind
  99007. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  99008. */
  99009. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  99010. /**
  99011. * Tests if a specific vertex buffer is associated with this mesh
  99012. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  99013. * - VertexBuffer.PositionKind
  99014. * - VertexBuffer.NormalKind
  99015. * - VertexBuffer.UVKind
  99016. * - VertexBuffer.UV2Kind
  99017. * - VertexBuffer.UV3Kind
  99018. * - VertexBuffer.UV4Kind
  99019. * - VertexBuffer.UV5Kind
  99020. * - VertexBuffer.UV6Kind
  99021. * - VertexBuffer.ColorKind
  99022. * - VertexBuffer.MatricesIndicesKind
  99023. * - VertexBuffer.MatricesIndicesExtraKind
  99024. * - VertexBuffer.MatricesWeightsKind
  99025. * - VertexBuffer.MatricesWeightsExtraKind
  99026. * @returns a boolean
  99027. */
  99028. isVerticesDataPresent(kind: string): boolean;
  99029. /**
  99030. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  99031. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  99032. * - VertexBuffer.PositionKind
  99033. * - VertexBuffer.UVKind
  99034. * - VertexBuffer.UV2Kind
  99035. * - VertexBuffer.UV3Kind
  99036. * - VertexBuffer.UV4Kind
  99037. * - VertexBuffer.UV5Kind
  99038. * - VertexBuffer.UV6Kind
  99039. * - VertexBuffer.ColorKind
  99040. * - VertexBuffer.MatricesIndicesKind
  99041. * - VertexBuffer.MatricesIndicesExtraKind
  99042. * - VertexBuffer.MatricesWeightsKind
  99043. * - VertexBuffer.MatricesWeightsExtraKind
  99044. * @returns a boolean
  99045. */
  99046. isVertexBufferUpdatable(kind: string): boolean;
  99047. /**
  99048. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  99049. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  99050. * - VertexBuffer.PositionKind
  99051. * - VertexBuffer.NormalKind
  99052. * - VertexBuffer.UVKind
  99053. * - VertexBuffer.UV2Kind
  99054. * - VertexBuffer.UV3Kind
  99055. * - VertexBuffer.UV4Kind
  99056. * - VertexBuffer.UV5Kind
  99057. * - VertexBuffer.UV6Kind
  99058. * - VertexBuffer.ColorKind
  99059. * - VertexBuffer.MatricesIndicesKind
  99060. * - VertexBuffer.MatricesIndicesExtraKind
  99061. * - VertexBuffer.MatricesWeightsKind
  99062. * - VertexBuffer.MatricesWeightsExtraKind
  99063. * @returns an array of strings
  99064. */
  99065. getVerticesDataKinds(): string[];
  99066. /**
  99067. * Returns a positive integer : the total number of indices in this mesh geometry.
  99068. * @returns the numner of indices or zero if the mesh has no geometry.
  99069. */
  99070. getTotalIndices(): number;
  99071. /**
  99072. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  99073. * @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.
  99074. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  99075. * @returns the indices array or an empty array if the mesh has no geometry
  99076. */
  99077. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  99078. get isBlocked(): boolean;
  99079. /**
  99080. * Determine if the current mesh is ready to be rendered
  99081. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  99082. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  99083. * @returns true if all associated assets are ready (material, textures, shaders)
  99084. */
  99085. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  99086. /**
  99087. * 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.
  99088. */
  99089. get areNormalsFrozen(): boolean;
  99090. /**
  99091. * 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.
  99092. * @returns the current mesh
  99093. */
  99094. freezeNormals(): Mesh;
  99095. /**
  99096. * 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
  99097. * @returns the current mesh
  99098. */
  99099. unfreezeNormals(): Mesh;
  99100. /**
  99101. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  99102. */
  99103. set overridenInstanceCount(count: number);
  99104. /** @hidden */
  99105. _preActivate(): Mesh;
  99106. /** @hidden */
  99107. _preActivateForIntermediateRendering(renderId: number): Mesh;
  99108. /** @hidden */
  99109. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  99110. /**
  99111. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  99112. * This means the mesh underlying bounding box and sphere are recomputed.
  99113. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  99114. * @returns the current mesh
  99115. */
  99116. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  99117. /** @hidden */
  99118. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  99119. /**
  99120. * This function will subdivide the mesh into multiple submeshes
  99121. * @param count defines the expected number of submeshes
  99122. */
  99123. subdivide(count: number): void;
  99124. /**
  99125. * Copy a FloatArray into a specific associated vertex buffer
  99126. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  99127. * - VertexBuffer.PositionKind
  99128. * - VertexBuffer.UVKind
  99129. * - VertexBuffer.UV2Kind
  99130. * - VertexBuffer.UV3Kind
  99131. * - VertexBuffer.UV4Kind
  99132. * - VertexBuffer.UV5Kind
  99133. * - VertexBuffer.UV6Kind
  99134. * - VertexBuffer.ColorKind
  99135. * - VertexBuffer.MatricesIndicesKind
  99136. * - VertexBuffer.MatricesIndicesExtraKind
  99137. * - VertexBuffer.MatricesWeightsKind
  99138. * - VertexBuffer.MatricesWeightsExtraKind
  99139. * @param data defines the data source
  99140. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  99141. * @param stride defines the data stride size (can be null)
  99142. * @returns the current mesh
  99143. */
  99144. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  99145. /**
  99146. * Delete a vertex buffer associated with this mesh
  99147. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  99148. * - VertexBuffer.PositionKind
  99149. * - VertexBuffer.UVKind
  99150. * - VertexBuffer.UV2Kind
  99151. * - VertexBuffer.UV3Kind
  99152. * - VertexBuffer.UV4Kind
  99153. * - VertexBuffer.UV5Kind
  99154. * - VertexBuffer.UV6Kind
  99155. * - VertexBuffer.ColorKind
  99156. * - VertexBuffer.MatricesIndicesKind
  99157. * - VertexBuffer.MatricesIndicesExtraKind
  99158. * - VertexBuffer.MatricesWeightsKind
  99159. * - VertexBuffer.MatricesWeightsExtraKind
  99160. */
  99161. removeVerticesData(kind: string): void;
  99162. /**
  99163. * Flags an associated vertex buffer as updatable
  99164. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  99165. * - VertexBuffer.PositionKind
  99166. * - VertexBuffer.UVKind
  99167. * - VertexBuffer.UV2Kind
  99168. * - VertexBuffer.UV3Kind
  99169. * - VertexBuffer.UV4Kind
  99170. * - VertexBuffer.UV5Kind
  99171. * - VertexBuffer.UV6Kind
  99172. * - VertexBuffer.ColorKind
  99173. * - VertexBuffer.MatricesIndicesKind
  99174. * - VertexBuffer.MatricesIndicesExtraKind
  99175. * - VertexBuffer.MatricesWeightsKind
  99176. * - VertexBuffer.MatricesWeightsExtraKind
  99177. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  99178. */
  99179. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  99180. /**
  99181. * Sets the mesh global Vertex Buffer
  99182. * @param buffer defines the buffer to use
  99183. * @returns the current mesh
  99184. */
  99185. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  99186. /**
  99187. * Update a specific associated vertex buffer
  99188. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  99189. * - VertexBuffer.PositionKind
  99190. * - VertexBuffer.UVKind
  99191. * - VertexBuffer.UV2Kind
  99192. * - VertexBuffer.UV3Kind
  99193. * - VertexBuffer.UV4Kind
  99194. * - VertexBuffer.UV5Kind
  99195. * - VertexBuffer.UV6Kind
  99196. * - VertexBuffer.ColorKind
  99197. * - VertexBuffer.MatricesIndicesKind
  99198. * - VertexBuffer.MatricesIndicesExtraKind
  99199. * - VertexBuffer.MatricesWeightsKind
  99200. * - VertexBuffer.MatricesWeightsExtraKind
  99201. * @param data defines the data source
  99202. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  99203. * @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)
  99204. * @returns the current mesh
  99205. */
  99206. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  99207. /**
  99208. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  99209. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  99210. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  99211. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  99212. * @returns the current mesh
  99213. */
  99214. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  99215. /**
  99216. * Creates a un-shared specific occurence of the geometry for the mesh.
  99217. * @returns the current mesh
  99218. */
  99219. makeGeometryUnique(): Mesh;
  99220. /**
  99221. * Set the index buffer of this mesh
  99222. * @param indices defines the source data
  99223. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  99224. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  99225. * @returns the current mesh
  99226. */
  99227. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  99228. /**
  99229. * Update the current index buffer
  99230. * @param indices defines the source data
  99231. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  99232. * @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)
  99233. * @returns the current mesh
  99234. */
  99235. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  99236. /**
  99237. * Invert the geometry to move from a right handed system to a left handed one.
  99238. * @returns the current mesh
  99239. */
  99240. toLeftHanded(): Mesh;
  99241. /** @hidden */
  99242. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  99243. /** @hidden */
  99244. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  99245. /**
  99246. * Registers for this mesh a javascript function called just before the rendering process
  99247. * @param func defines the function to call before rendering this mesh
  99248. * @returns the current mesh
  99249. */
  99250. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  99251. /**
  99252. * Disposes a previously registered javascript function called before the rendering
  99253. * @param func defines the function to remove
  99254. * @returns the current mesh
  99255. */
  99256. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  99257. /**
  99258. * Registers for this mesh a javascript function called just after the rendering is complete
  99259. * @param func defines the function to call after rendering this mesh
  99260. * @returns the current mesh
  99261. */
  99262. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  99263. /**
  99264. * Disposes a previously registered javascript function called after the rendering.
  99265. * @param func defines the function to remove
  99266. * @returns the current mesh
  99267. */
  99268. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  99269. /** @hidden */
  99270. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  99271. /** @hidden */
  99272. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  99273. /** @hidden */
  99274. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  99275. /** @hidden */
  99276. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  99277. /** @hidden */
  99278. _rebuild(): void;
  99279. /** @hidden */
  99280. _freeze(): void;
  99281. /** @hidden */
  99282. _unFreeze(): void;
  99283. /**
  99284. * 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
  99285. * @param subMesh defines the subMesh to render
  99286. * @param enableAlphaMode defines if alpha mode can be changed
  99287. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  99288. * @returns the current mesh
  99289. */
  99290. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  99291. private _onBeforeDraw;
  99292. /**
  99293. * Renormalize the mesh and patch it up if there are no weights
  99294. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  99295. * However in the case of zero weights then we set just a single influence to 1.
  99296. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  99297. */
  99298. cleanMatrixWeights(): void;
  99299. private normalizeSkinFourWeights;
  99300. private normalizeSkinWeightsAndExtra;
  99301. /**
  99302. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  99303. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  99304. * the user know there was an issue with importing the mesh
  99305. * @returns a validation object with skinned, valid and report string
  99306. */
  99307. validateSkinning(): {
  99308. skinned: boolean;
  99309. valid: boolean;
  99310. report: string;
  99311. };
  99312. /** @hidden */
  99313. _checkDelayState(): Mesh;
  99314. private _queueLoad;
  99315. /**
  99316. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  99317. * A mesh is in the frustum if its bounding box intersects the frustum
  99318. * @param frustumPlanes defines the frustum to test
  99319. * @returns true if the mesh is in the frustum planes
  99320. */
  99321. isInFrustum(frustumPlanes: Plane[]): boolean;
  99322. /**
  99323. * Sets the mesh material by the material or multiMaterial `id` property
  99324. * @param id is a string identifying the material or the multiMaterial
  99325. * @returns the current mesh
  99326. */
  99327. setMaterialByID(id: string): Mesh;
  99328. /**
  99329. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  99330. * @returns an array of IAnimatable
  99331. */
  99332. getAnimatables(): IAnimatable[];
  99333. /**
  99334. * Modifies the mesh geometry according to the passed transformation matrix.
  99335. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  99336. * The mesh normals are modified using the same transformation.
  99337. * Note that, under the hood, this method sets a new VertexBuffer each call.
  99338. * @param transform defines the transform matrix to use
  99339. * @see http://doc.babylonjs.com/resources/baking_transformations
  99340. * @returns the current mesh
  99341. */
  99342. bakeTransformIntoVertices(transform: Matrix): Mesh;
  99343. /**
  99344. * Modifies the mesh geometry according to its own current World Matrix.
  99345. * The mesh World Matrix is then reset.
  99346. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  99347. * Note that, under the hood, this method sets a new VertexBuffer each call.
  99348. * @see http://doc.babylonjs.com/resources/baking_transformations
  99349. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  99350. * @returns the current mesh
  99351. */
  99352. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  99353. /** @hidden */
  99354. get _positions(): Nullable<Vector3[]>;
  99355. /** @hidden */
  99356. _resetPointsArrayCache(): Mesh;
  99357. /** @hidden */
  99358. _generatePointsArray(): boolean;
  99359. /**
  99360. * Returns a new Mesh object generated from the current mesh properties.
  99361. * This method must not get confused with createInstance()
  99362. * @param name is a string, the name given to the new mesh
  99363. * @param newParent can be any Node object (default `null`)
  99364. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  99365. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  99366. * @returns a new mesh
  99367. */
  99368. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  99369. /**
  99370. * Releases resources associated with this mesh.
  99371. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  99372. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  99373. */
  99374. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  99375. /** @hidden */
  99376. _disposeInstanceSpecificData(): void;
  99377. /**
  99378. * Modifies the mesh geometry according to a displacement map.
  99379. * 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.
  99380. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  99381. * @param url is a string, the URL from the image file is to be downloaded.
  99382. * @param minHeight is the lower limit of the displacement.
  99383. * @param maxHeight is the upper limit of the displacement.
  99384. * @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.
  99385. * @param uvOffset is an optional vector2 used to offset UV.
  99386. * @param uvScale is an optional vector2 used to scale UV.
  99387. * @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.
  99388. * @returns the Mesh.
  99389. */
  99390. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  99391. /**
  99392. * Modifies the mesh geometry according to a displacementMap buffer.
  99393. * A displacement map is a colored image. Each pixel color value (actually a gradient computed from red, green, blue values) will give the displacement to apply to each mesh vertex.
  99394. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  99395. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  99396. * @param heightMapWidth is the width of the buffer image.
  99397. * @param heightMapHeight is the height of the buffer image.
  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. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  99407. /**
  99408. * Modify the mesh to get a flat shading rendering.
  99409. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  99410. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  99411. * @returns current mesh
  99412. */
  99413. convertToFlatShadedMesh(): Mesh;
  99414. /**
  99415. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  99416. * In other words, more vertices, no more indices and a single bigger VBO.
  99417. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  99418. * @returns current mesh
  99419. */
  99420. convertToUnIndexedMesh(): Mesh;
  99421. /**
  99422. * Inverses facet orientations.
  99423. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  99424. * @param flipNormals will also inverts the normals
  99425. * @returns current mesh
  99426. */
  99427. flipFaces(flipNormals?: boolean): Mesh;
  99428. /**
  99429. * Increase the number of facets and hence vertices in a mesh
  99430. * Vertex normals are interpolated from existing vertex normals
  99431. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  99432. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  99433. */
  99434. increaseVertices(numberPerEdge: number): void;
  99435. /**
  99436. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  99437. * This will undo any application of covertToFlatShadedMesh
  99438. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  99439. */
  99440. forceSharedVertices(): void;
  99441. /** @hidden */
  99442. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  99443. /** @hidden */
  99444. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  99445. /**
  99446. * Creates a new InstancedMesh object from the mesh model.
  99447. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  99448. * @param name defines the name of the new instance
  99449. * @returns a new InstancedMesh
  99450. */
  99451. createInstance(name: string): InstancedMesh;
  99452. /**
  99453. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  99454. * After this call, all the mesh instances have the same submeshes than the current mesh.
  99455. * @returns the current mesh
  99456. */
  99457. synchronizeInstances(): Mesh;
  99458. /**
  99459. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  99460. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  99461. * This should be used together with the simplification to avoid disappearing triangles.
  99462. * @param successCallback an optional success callback to be called after the optimization finished.
  99463. * @returns the current mesh
  99464. */
  99465. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  99466. /**
  99467. * Serialize current mesh
  99468. * @param serializationObject defines the object which will receive the serialization data
  99469. */
  99470. serialize(serializationObject: any): void;
  99471. /** @hidden */
  99472. _syncGeometryWithMorphTargetManager(): void;
  99473. /** @hidden */
  99474. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  99475. /**
  99476. * Returns a new Mesh object parsed from the source provided.
  99477. * @param parsedMesh is the source
  99478. * @param scene defines the hosting scene
  99479. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  99480. * @returns a new Mesh
  99481. */
  99482. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  99483. /**
  99484. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  99485. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  99486. * @param name defines the name of the mesh to create
  99487. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  99488. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  99489. * @param closePath creates a seam between the first and the last points of each path of the path array
  99490. * @param offset is taken in account only if the `pathArray` is containing a single path
  99491. * @param scene defines the hosting scene
  99492. * @param updatable defines if the mesh must be flagged as updatable
  99493. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  99494. * @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)
  99495. * @returns a new Mesh
  99496. */
  99497. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  99498. /**
  99499. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  99500. * @param name defines the name of the mesh to create
  99501. * @param radius sets the radius size (float) of the polygon (default 0.5)
  99502. * @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
  99503. * @param scene defines the hosting scene
  99504. * @param updatable defines if the mesh must be flagged as updatable
  99505. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  99506. * @returns a new Mesh
  99507. */
  99508. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  99509. /**
  99510. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  99511. * @param name defines the name of the mesh to create
  99512. * @param size sets the size (float) of each box side (default 1)
  99513. * @param scene defines the hosting scene
  99514. * @param updatable defines if the mesh must be flagged as updatable
  99515. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  99516. * @returns a new Mesh
  99517. */
  99518. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  99519. /**
  99520. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  99521. * @param name defines the name of the mesh to create
  99522. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  99523. * @param diameter sets the diameter size (float) of the sphere (default 1)
  99524. * @param scene defines the hosting scene
  99525. * @param updatable defines if the mesh must be flagged as updatable
  99526. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  99527. * @returns a new Mesh
  99528. */
  99529. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  99530. /**
  99531. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  99532. * @param name defines the name of the mesh to create
  99533. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  99534. * @param diameter sets the diameter size (float) of the sphere (default 1)
  99535. * @param scene defines the hosting scene
  99536. * @returns a new Mesh
  99537. */
  99538. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  99539. /**
  99540. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  99541. * @param name defines the name of the mesh to create
  99542. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  99543. * @param diameterTop set the top cap diameter (floats, default 1)
  99544. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  99545. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  99546. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  99547. * @param scene defines the hosting scene
  99548. * @param updatable defines if the mesh must be flagged as updatable
  99549. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  99550. * @returns a new Mesh
  99551. */
  99552. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  99553. /**
  99554. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  99555. * @param name defines the name of the mesh to create
  99556. * @param diameter sets the diameter size (float) of the torus (default 1)
  99557. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  99558. * @param tessellation sets the number of torus sides (postive integer, default 16)
  99559. * @param scene defines the hosting scene
  99560. * @param updatable defines if the mesh must be flagged as updatable
  99561. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  99562. * @returns a new Mesh
  99563. */
  99564. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  99565. /**
  99566. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  99567. * @param name defines the name of the mesh to create
  99568. * @param radius sets the global radius size (float) of the torus knot (default 2)
  99569. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  99570. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  99571. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  99572. * @param p the number of windings on X axis (positive integers, default 2)
  99573. * @param q the number of windings on Y axis (positive integers, default 3)
  99574. * @param scene defines the hosting scene
  99575. * @param updatable defines if the mesh must be flagged as updatable
  99576. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  99577. * @returns a new Mesh
  99578. */
  99579. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  99580. /**
  99581. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  99582. * @param name defines the name of the mesh to create
  99583. * @param points is an array successive Vector3
  99584. * @param scene defines the hosting scene
  99585. * @param updatable defines if the mesh must be flagged as updatable
  99586. * @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).
  99587. * @returns a new Mesh
  99588. */
  99589. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  99590. /**
  99591. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  99592. * @param name defines the name of the mesh to create
  99593. * @param points is an array successive Vector3
  99594. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  99595. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  99596. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  99597. * @param scene defines the hosting scene
  99598. * @param updatable defines if the mesh must be flagged as updatable
  99599. * @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)
  99600. * @returns a new Mesh
  99601. */
  99602. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  99603. /**
  99604. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  99605. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  99606. * 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.
  99607. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  99608. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  99609. * Remember you can only change the shape positions, not their number when updating a polygon.
  99610. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  99611. * @param name defines the name of the mesh to create
  99612. * @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
  99613. * @param scene defines the hosting scene
  99614. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  99615. * @param updatable defines if the mesh must be flagged as updatable
  99616. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  99617. * @param earcutInjection can be used to inject your own earcut reference
  99618. * @returns a new Mesh
  99619. */
  99620. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  99621. /**
  99622. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  99623. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  99624. * @param name defines the name of the mesh to create
  99625. * @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
  99626. * @param depth defines the height of extrusion
  99627. * @param scene defines the hosting scene
  99628. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  99629. * @param updatable defines if the mesh must be flagged as updatable
  99630. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  99631. * @param earcutInjection can be used to inject your own earcut reference
  99632. * @returns a new Mesh
  99633. */
  99634. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  99635. /**
  99636. * Creates an extruded shape mesh.
  99637. * 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
  99638. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  99639. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  99640. * @param name defines the name of the mesh to create
  99641. * @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
  99642. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  99643. * @param scale is the value to scale the shape
  99644. * @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
  99645. * @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
  99646. * @param scene defines the hosting scene
  99647. * @param updatable defines if the mesh must be flagged as updatable
  99648. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  99649. * @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)
  99650. * @returns a new Mesh
  99651. */
  99652. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  99653. /**
  99654. * Creates an custom extruded shape mesh.
  99655. * The custom extrusion is a parametric shape.
  99656. * It has no predefined shape. Its final shape will depend on the input parameters.
  99657. * Please consider using the same method from the MeshBuilder class instead
  99658. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  99659. * @param name defines the name of the mesh to create
  99660. * @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
  99661. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  99662. * @param scaleFunction is a custom Javascript function called on each path point
  99663. * @param rotationFunction is a custom Javascript function called on each path point
  99664. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  99665. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  99666. * @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
  99667. * @param scene defines the hosting scene
  99668. * @param updatable defines if the mesh must be flagged as updatable
  99669. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  99670. * @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)
  99671. * @returns a new Mesh
  99672. */
  99673. 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;
  99674. /**
  99675. * Creates lathe mesh.
  99676. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  99677. * Please consider using the same method from the MeshBuilder class instead
  99678. * @param name defines the name of the mesh to create
  99679. * @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
  99680. * @param radius is the radius value of the lathe
  99681. * @param tessellation is the side number of the lathe.
  99682. * @param scene defines the hosting scene
  99683. * @param updatable defines if the mesh must be flagged as updatable
  99684. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  99685. * @returns a new Mesh
  99686. */
  99687. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  99688. /**
  99689. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  99690. * @param name defines the name of the mesh to create
  99691. * @param size sets the size (float) of both sides of the plane at once (default 1)
  99692. * @param scene defines the hosting scene
  99693. * @param updatable defines if the mesh must be flagged as updatable
  99694. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  99695. * @returns a new Mesh
  99696. */
  99697. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  99698. /**
  99699. * Creates a ground mesh.
  99700. * Please consider using the same method from the MeshBuilder class instead
  99701. * @param name defines the name of the mesh to create
  99702. * @param width set the width of the ground
  99703. * @param height set the height of the ground
  99704. * @param subdivisions sets the number of subdivisions per side
  99705. * @param scene defines the hosting scene
  99706. * @param updatable defines if the mesh must be flagged as updatable
  99707. * @returns a new Mesh
  99708. */
  99709. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  99710. /**
  99711. * Creates a tiled ground mesh.
  99712. * Please consider using the same method from the MeshBuilder class instead
  99713. * @param name defines the name of the mesh to create
  99714. * @param xmin set the ground minimum X coordinate
  99715. * @param zmin set the ground minimum Y coordinate
  99716. * @param xmax set the ground maximum X coordinate
  99717. * @param zmax set the ground maximum Z coordinate
  99718. * @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
  99719. * @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
  99720. * @param scene defines the hosting scene
  99721. * @param updatable defines if the mesh must be flagged as updatable
  99722. * @returns a new Mesh
  99723. */
  99724. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  99725. w: number;
  99726. h: number;
  99727. }, precision: {
  99728. w: number;
  99729. h: number;
  99730. }, scene: Scene, updatable?: boolean): Mesh;
  99731. /**
  99732. * Creates a ground mesh from a height map.
  99733. * Please consider using the same method from the MeshBuilder class instead
  99734. * @see http://doc.babylonjs.com/babylon101/height_map
  99735. * @param name defines the name of the mesh to create
  99736. * @param url sets the URL of the height map image resource
  99737. * @param width set the ground width size
  99738. * @param height set the ground height size
  99739. * @param subdivisions sets the number of subdivision per side
  99740. * @param minHeight is the minimum altitude on the ground
  99741. * @param maxHeight is the maximum altitude on the ground
  99742. * @param scene defines the hosting scene
  99743. * @param updatable defines if the mesh must be flagged as updatable
  99744. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  99745. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  99746. * @returns a new Mesh
  99747. */
  99748. 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;
  99749. /**
  99750. * Creates a tube mesh.
  99751. * The tube is a parametric shape.
  99752. * It has no predefined shape. Its final shape will depend on the input parameters.
  99753. * Please consider using the same method from the MeshBuilder class instead
  99754. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  99755. * @param name defines the name of the mesh to create
  99756. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  99757. * @param radius sets the tube radius size
  99758. * @param tessellation is the number of sides on the tubular surface
  99759. * @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
  99760. * @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
  99761. * @param scene defines the hosting scene
  99762. * @param updatable defines if the mesh must be flagged as updatable
  99763. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  99764. * @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)
  99765. * @returns a new Mesh
  99766. */
  99767. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  99768. (i: number, distance: number): number;
  99769. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  99770. /**
  99771. * Creates a polyhedron mesh.
  99772. * Please consider using the same method from the MeshBuilder class instead.
  99773. * * 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
  99774. * * The parameter `size` (positive float, default 1) sets the polygon size
  99775. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  99776. * * 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`
  99777. * * 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
  99778. * * 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)`)
  99779. * * 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
  99780. * * 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
  99781. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  99782. * * If you create a double-sided mesh, you can choose what parts of 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
  99783. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  99784. * @param name defines the name of the mesh to create
  99785. * @param options defines the options used to create the mesh
  99786. * @param scene defines the hosting scene
  99787. * @returns a new Mesh
  99788. */
  99789. static CreatePolyhedron(name: string, options: {
  99790. type?: number;
  99791. size?: number;
  99792. sizeX?: number;
  99793. sizeY?: number;
  99794. sizeZ?: number;
  99795. custom?: any;
  99796. faceUV?: Vector4[];
  99797. faceColors?: Color4[];
  99798. updatable?: boolean;
  99799. sideOrientation?: number;
  99800. }, scene: Scene): Mesh;
  99801. /**
  99802. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  99803. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  99804. * * 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`)
  99805. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  99806. * * 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
  99807. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  99808. * * If you create a double-sided mesh, you can choose what parts of 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
  99809. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  99810. * @param name defines the name of the mesh
  99811. * @param options defines the options used to create the mesh
  99812. * @param scene defines the hosting scene
  99813. * @returns a new Mesh
  99814. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  99815. */
  99816. static CreateIcoSphere(name: string, options: {
  99817. radius?: number;
  99818. flat?: boolean;
  99819. subdivisions?: number;
  99820. sideOrientation?: number;
  99821. updatable?: boolean;
  99822. }, scene: Scene): Mesh;
  99823. /**
  99824. * Creates a decal mesh.
  99825. * Please consider using the same method from the MeshBuilder class instead.
  99826. * A decal is a mesh usually applied as a model onto the surface of another mesh
  99827. * @param name defines the name of the mesh
  99828. * @param sourceMesh defines the mesh receiving the decal
  99829. * @param position sets the position of the decal in world coordinates
  99830. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  99831. * @param size sets the decal scaling
  99832. * @param angle sets the angle to rotate the decal
  99833. * @returns a new Mesh
  99834. */
  99835. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  99836. /**
  99837. * Prepare internal position array for software CPU skinning
  99838. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  99839. */
  99840. setPositionsForCPUSkinning(): Float32Array;
  99841. /**
  99842. * Prepare internal normal array for software CPU skinning
  99843. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  99844. */
  99845. setNormalsForCPUSkinning(): Float32Array;
  99846. /**
  99847. * Updates the vertex buffer by applying transformation from the bones
  99848. * @param skeleton defines the skeleton to apply to current mesh
  99849. * @returns the current mesh
  99850. */
  99851. applySkeleton(skeleton: Skeleton): Mesh;
  99852. /**
  99853. * 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
  99854. * @param meshes defines the list of meshes to scan
  99855. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  99856. */
  99857. static MinMax(meshes: AbstractMesh[]): {
  99858. min: Vector3;
  99859. max: Vector3;
  99860. };
  99861. /**
  99862. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  99863. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  99864. * @returns a vector3
  99865. */
  99866. static Center(meshesOrMinMaxVector: {
  99867. min: Vector3;
  99868. max: Vector3;
  99869. } | AbstractMesh[]): Vector3;
  99870. /**
  99871. * Merge the array of meshes into a single mesh for performance reasons.
  99872. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  99873. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  99874. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  99875. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  99876. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  99877. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  99878. * @returns a new mesh
  99879. */
  99880. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  99881. /** @hidden */
  99882. addInstance(instance: InstancedMesh): void;
  99883. /** @hidden */
  99884. removeInstance(instance: InstancedMesh): void;
  99885. }
  99886. }
  99887. declare module BABYLON {
  99888. /**
  99889. * This is the base class of all the camera used in the application.
  99890. * @see http://doc.babylonjs.com/features/cameras
  99891. */
  99892. export class Camera extends Node {
  99893. /** @hidden */
  99894. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  99895. /**
  99896. * This is the default projection mode used by the cameras.
  99897. * It helps recreating a feeling of perspective and better appreciate depth.
  99898. * This is the best way to simulate real life cameras.
  99899. */
  99900. static readonly PERSPECTIVE_CAMERA: number;
  99901. /**
  99902. * This helps creating camera with an orthographic mode.
  99903. * 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.
  99904. */
  99905. static readonly ORTHOGRAPHIC_CAMERA: number;
  99906. /**
  99907. * This is the default FOV mode for perspective cameras.
  99908. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  99909. */
  99910. static readonly FOVMODE_VERTICAL_FIXED: number;
  99911. /**
  99912. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  99913. */
  99914. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  99915. /**
  99916. * This specifies ther is no need for a camera rig.
  99917. * Basically only one eye is rendered corresponding to the camera.
  99918. */
  99919. static readonly RIG_MODE_NONE: number;
  99920. /**
  99921. * Simulates a camera Rig with one blue eye and one red eye.
  99922. * This can be use with 3d blue and red glasses.
  99923. */
  99924. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  99925. /**
  99926. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  99927. */
  99928. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  99929. /**
  99930. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  99931. */
  99932. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  99933. /**
  99934. * Defines that both eyes of the camera will be rendered over under each other.
  99935. */
  99936. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  99937. /**
  99938. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  99939. */
  99940. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  99941. /**
  99942. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  99943. */
  99944. static readonly RIG_MODE_VR: number;
  99945. /**
  99946. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  99947. */
  99948. static readonly RIG_MODE_WEBVR: number;
  99949. /**
  99950. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  99951. */
  99952. static readonly RIG_MODE_CUSTOM: number;
  99953. /**
  99954. * Defines if by default attaching controls should prevent the default javascript event to continue.
  99955. */
  99956. static ForceAttachControlToAlwaysPreventDefault: boolean;
  99957. /**
  99958. * Define the input manager associated with the camera.
  99959. */
  99960. inputs: CameraInputsManager<Camera>;
  99961. /** @hidden */
  99962. _position: Vector3;
  99963. /**
  99964. * Define the current local position of the camera in the scene
  99965. */
  99966. get position(): Vector3;
  99967. set position(newPosition: Vector3);
  99968. /**
  99969. * The vector the camera should consider as up.
  99970. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  99971. */
  99972. upVector: Vector3;
  99973. /**
  99974. * Define the current limit on the left side for an orthographic camera
  99975. * In scene unit
  99976. */
  99977. orthoLeft: Nullable<number>;
  99978. /**
  99979. * Define the current limit on the right side for an orthographic camera
  99980. * In scene unit
  99981. */
  99982. orthoRight: Nullable<number>;
  99983. /**
  99984. * Define the current limit on the bottom side for an orthographic camera
  99985. * In scene unit
  99986. */
  99987. orthoBottom: Nullable<number>;
  99988. /**
  99989. * Define the current limit on the top side for an orthographic camera
  99990. * In scene unit
  99991. */
  99992. orthoTop: Nullable<number>;
  99993. /**
  99994. * Field Of View is set in Radians. (default is 0.8)
  99995. */
  99996. fov: number;
  99997. /**
  99998. * Define the minimum distance the camera can see from.
  99999. * This is important to note that the depth buffer are not infinite and the closer it starts
  100000. * the more your scene might encounter depth fighting issue.
  100001. */
  100002. minZ: number;
  100003. /**
  100004. * Define the maximum distance the camera can see to.
  100005. * This is important to note that the depth buffer are not infinite and the further it end
  100006. * the more your scene might encounter depth fighting issue.
  100007. */
  100008. maxZ: number;
  100009. /**
  100010. * Define the default inertia of the camera.
  100011. * This helps giving a smooth feeling to the camera movement.
  100012. */
  100013. inertia: number;
  100014. /**
  100015. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  100016. */
  100017. mode: number;
  100018. /**
  100019. * Define whether the camera is intermediate.
  100020. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  100021. */
  100022. isIntermediate: boolean;
  100023. /**
  100024. * Define the viewport of the camera.
  100025. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  100026. */
  100027. viewport: Viewport;
  100028. /**
  100029. * Restricts the camera to viewing objects with the same layerMask.
  100030. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  100031. */
  100032. layerMask: number;
  100033. /**
  100034. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  100035. */
  100036. fovMode: number;
  100037. /**
  100038. * Rig mode of the camera.
  100039. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  100040. * This is normally controlled byt the camera themselves as internal use.
  100041. */
  100042. cameraRigMode: number;
  100043. /**
  100044. * Defines the distance between both "eyes" in case of a RIG
  100045. */
  100046. interaxialDistance: number;
  100047. /**
  100048. * Defines if stereoscopic rendering is done side by side or over under.
  100049. */
  100050. isStereoscopicSideBySide: boolean;
  100051. /**
  100052. * 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
  100053. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  100054. * else in the scene. (Eg. security camera)
  100055. *
  100056. * 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)
  100057. */
  100058. customRenderTargets: RenderTargetTexture[];
  100059. /**
  100060. * When set, the camera will render to this render target instead of the default canvas
  100061. *
  100062. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  100063. */
  100064. outputRenderTarget: Nullable<RenderTargetTexture>;
  100065. /**
  100066. * Observable triggered when the camera view matrix has changed.
  100067. */
  100068. onViewMatrixChangedObservable: Observable<Camera>;
  100069. /**
  100070. * Observable triggered when the camera Projection matrix has changed.
  100071. */
  100072. onProjectionMatrixChangedObservable: Observable<Camera>;
  100073. /**
  100074. * Observable triggered when the inputs have been processed.
  100075. */
  100076. onAfterCheckInputsObservable: Observable<Camera>;
  100077. /**
  100078. * Observable triggered when reset has been called and applied to the camera.
  100079. */
  100080. onRestoreStateObservable: Observable<Camera>;
  100081. /**
  100082. * Is this camera a part of a rig system?
  100083. */
  100084. isRigCamera: boolean;
  100085. /**
  100086. * If isRigCamera set to true this will be set with the parent camera.
  100087. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  100088. */
  100089. rigParent?: Camera;
  100090. /** @hidden */
  100091. _cameraRigParams: any;
  100092. /** @hidden */
  100093. _rigCameras: Camera[];
  100094. /** @hidden */
  100095. _rigPostProcess: Nullable<PostProcess>;
  100096. protected _webvrViewMatrix: Matrix;
  100097. /** @hidden */
  100098. _skipRendering: boolean;
  100099. /** @hidden */
  100100. _projectionMatrix: Matrix;
  100101. /** @hidden */
  100102. _postProcesses: Nullable<PostProcess>[];
  100103. /** @hidden */
  100104. _activeMeshes: SmartArray<AbstractMesh>;
  100105. protected _globalPosition: Vector3;
  100106. /** @hidden */
  100107. _computedViewMatrix: Matrix;
  100108. private _doNotComputeProjectionMatrix;
  100109. private _transformMatrix;
  100110. private _frustumPlanes;
  100111. private _refreshFrustumPlanes;
  100112. private _storedFov;
  100113. private _stateStored;
  100114. /**
  100115. * Instantiates a new camera object.
  100116. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  100117. * @see http://doc.babylonjs.com/features/cameras
  100118. * @param name Defines the name of the camera in the scene
  100119. * @param position Defines the position of the camera
  100120. * @param scene Defines the scene the camera belongs too
  100121. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  100122. */
  100123. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  100124. /**
  100125. * Store current camera state (fov, position, etc..)
  100126. * @returns the camera
  100127. */
  100128. storeState(): Camera;
  100129. /**
  100130. * Restores the camera state values if it has been stored. You must call storeState() first
  100131. */
  100132. protected _restoreStateValues(): boolean;
  100133. /**
  100134. * Restored camera state. You must call storeState() first.
  100135. * @returns true if restored and false otherwise
  100136. */
  100137. restoreState(): boolean;
  100138. /**
  100139. * Gets the class name of the camera.
  100140. * @returns the class name
  100141. */
  100142. getClassName(): string;
  100143. /** @hidden */
  100144. readonly _isCamera: boolean;
  100145. /**
  100146. * Gets a string representation of the camera useful for debug purpose.
  100147. * @param fullDetails Defines that a more verboe level of logging is required
  100148. * @returns the string representation
  100149. */
  100150. toString(fullDetails?: boolean): string;
  100151. /**
  100152. * Gets the current world space position of the camera.
  100153. */
  100154. get globalPosition(): Vector3;
  100155. /**
  100156. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  100157. * @returns the active meshe list
  100158. */
  100159. getActiveMeshes(): SmartArray<AbstractMesh>;
  100160. /**
  100161. * Check whether a mesh is part of the current active mesh list of the camera
  100162. * @param mesh Defines the mesh to check
  100163. * @returns true if active, false otherwise
  100164. */
  100165. isActiveMesh(mesh: Mesh): boolean;
  100166. /**
  100167. * Is this camera ready to be used/rendered
  100168. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  100169. * @return true if the camera is ready
  100170. */
  100171. isReady(completeCheck?: boolean): boolean;
  100172. /** @hidden */
  100173. _initCache(): void;
  100174. /** @hidden */
  100175. _updateCache(ignoreParentClass?: boolean): void;
  100176. /** @hidden */
  100177. _isSynchronized(): boolean;
  100178. /** @hidden */
  100179. _isSynchronizedViewMatrix(): boolean;
  100180. /** @hidden */
  100181. _isSynchronizedProjectionMatrix(): boolean;
  100182. /**
  100183. * Attach the input controls to a specific dom element to get the input from.
  100184. * @param element Defines the element the controls should be listened from
  100185. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  100186. */
  100187. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  100188. /**
  100189. * Detach the current controls from the specified dom element.
  100190. * @param element Defines the element to stop listening the inputs from
  100191. */
  100192. detachControl(element: HTMLElement): void;
  100193. /**
  100194. * Update the camera state according to the different inputs gathered during the frame.
  100195. */
  100196. update(): void;
  100197. /** @hidden */
  100198. _checkInputs(): void;
  100199. /** @hidden */
  100200. get rigCameras(): Camera[];
  100201. /**
  100202. * Gets the post process used by the rig cameras
  100203. */
  100204. get rigPostProcess(): Nullable<PostProcess>;
  100205. /**
  100206. * Internal, gets the first post proces.
  100207. * @returns the first post process to be run on this camera.
  100208. */
  100209. _getFirstPostProcess(): Nullable<PostProcess>;
  100210. private _cascadePostProcessesToRigCams;
  100211. /**
  100212. * Attach a post process to the camera.
  100213. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  100214. * @param postProcess The post process to attach to the camera
  100215. * @param insertAt The position of the post process in case several of them are in use in the scene
  100216. * @returns the position the post process has been inserted at
  100217. */
  100218. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  100219. /**
  100220. * Detach a post process to the camera.
  100221. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  100222. * @param postProcess The post process to detach from the camera
  100223. */
  100224. detachPostProcess(postProcess: PostProcess): void;
  100225. /**
  100226. * Gets the current world matrix of the camera
  100227. */
  100228. getWorldMatrix(): Matrix;
  100229. /** @hidden */
  100230. _getViewMatrix(): Matrix;
  100231. /**
  100232. * Gets the current view matrix of the camera.
  100233. * @param force forces the camera to recompute the matrix without looking at the cached state
  100234. * @returns the view matrix
  100235. */
  100236. getViewMatrix(force?: boolean): Matrix;
  100237. /**
  100238. * Freeze the projection matrix.
  100239. * It will prevent the cache check of the camera projection compute and can speed up perf
  100240. * if no parameter of the camera are meant to change
  100241. * @param projection Defines manually a projection if necessary
  100242. */
  100243. freezeProjectionMatrix(projection?: Matrix): void;
  100244. /**
  100245. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  100246. */
  100247. unfreezeProjectionMatrix(): void;
  100248. /**
  100249. * Gets the current projection matrix of the camera.
  100250. * @param force forces the camera to recompute the matrix without looking at the cached state
  100251. * @returns the projection matrix
  100252. */
  100253. getProjectionMatrix(force?: boolean): Matrix;
  100254. /**
  100255. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  100256. * @returns a Matrix
  100257. */
  100258. getTransformationMatrix(): Matrix;
  100259. private _updateFrustumPlanes;
  100260. /**
  100261. * Checks if a cullable object (mesh...) is in the camera frustum
  100262. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  100263. * @param target The object to check
  100264. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  100265. * @returns true if the object is in frustum otherwise false
  100266. */
  100267. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  100268. /**
  100269. * Checks if a cullable object (mesh...) is in the camera frustum
  100270. * Unlike isInFrustum this cheks the full bounding box
  100271. * @param target The object to check
  100272. * @returns true if the object is in frustum otherwise false
  100273. */
  100274. isCompletelyInFrustum(target: ICullable): boolean;
  100275. /**
  100276. * Gets a ray in the forward direction from the camera.
  100277. * @param length Defines the length of the ray to create
  100278. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  100279. * @param origin Defines the start point of the ray which defaults to the camera position
  100280. * @returns the forward ray
  100281. */
  100282. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  100283. /**
  100284. * Releases resources associated with this node.
  100285. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  100286. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  100287. */
  100288. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  100289. /** @hidden */
  100290. _isLeftCamera: boolean;
  100291. /**
  100292. * Gets the left camera of a rig setup in case of Rigged Camera
  100293. */
  100294. get isLeftCamera(): boolean;
  100295. /** @hidden */
  100296. _isRightCamera: boolean;
  100297. /**
  100298. * Gets the right camera of a rig setup in case of Rigged Camera
  100299. */
  100300. get isRightCamera(): boolean;
  100301. /**
  100302. * Gets the left camera of a rig setup in case of Rigged Camera
  100303. */
  100304. get leftCamera(): Nullable<FreeCamera>;
  100305. /**
  100306. * Gets the right camera of a rig setup in case of Rigged Camera
  100307. */
  100308. get rightCamera(): Nullable<FreeCamera>;
  100309. /**
  100310. * Gets the left camera target of a rig setup in case of Rigged Camera
  100311. * @returns the target position
  100312. */
  100313. getLeftTarget(): Nullable<Vector3>;
  100314. /**
  100315. * Gets the right camera target of a rig setup in case of Rigged Camera
  100316. * @returns the target position
  100317. */
  100318. getRightTarget(): Nullable<Vector3>;
  100319. /**
  100320. * @hidden
  100321. */
  100322. setCameraRigMode(mode: number, rigParams: any): void;
  100323. /** @hidden */
  100324. static _setStereoscopicRigMode(camera: Camera): void;
  100325. /** @hidden */
  100326. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  100327. /** @hidden */
  100328. static _setVRRigMode(camera: Camera, rigParams: any): void;
  100329. /** @hidden */
  100330. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  100331. /** @hidden */
  100332. _getVRProjectionMatrix(): Matrix;
  100333. protected _updateCameraRotationMatrix(): void;
  100334. protected _updateWebVRCameraRotationMatrix(): void;
  100335. /**
  100336. * This function MUST be overwritten by the different WebVR cameras available.
  100337. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  100338. * @hidden
  100339. */
  100340. _getWebVRProjectionMatrix(): Matrix;
  100341. /**
  100342. * This function MUST be overwritten by the different WebVR cameras available.
  100343. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  100344. * @hidden
  100345. */
  100346. _getWebVRViewMatrix(): Matrix;
  100347. /** @hidden */
  100348. setCameraRigParameter(name: string, value: any): void;
  100349. /**
  100350. * needs to be overridden by children so sub has required properties to be copied
  100351. * @hidden
  100352. */
  100353. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  100354. /**
  100355. * May need to be overridden by children
  100356. * @hidden
  100357. */
  100358. _updateRigCameras(): void;
  100359. /** @hidden */
  100360. _setupInputs(): void;
  100361. /**
  100362. * Serialiaze the camera setup to a json represention
  100363. * @returns the JSON representation
  100364. */
  100365. serialize(): any;
  100366. /**
  100367. * Clones the current camera.
  100368. * @param name The cloned camera name
  100369. * @returns the cloned camera
  100370. */
  100371. clone(name: string): Camera;
  100372. /**
  100373. * Gets the direction of the camera relative to a given local axis.
  100374. * @param localAxis Defines the reference axis to provide a relative direction.
  100375. * @return the direction
  100376. */
  100377. getDirection(localAxis: Vector3): Vector3;
  100378. /**
  100379. * Returns the current camera absolute rotation
  100380. */
  100381. get absoluteRotation(): Quaternion;
  100382. /**
  100383. * Gets the direction of the camera relative to a given local axis into a passed vector.
  100384. * @param localAxis Defines the reference axis to provide a relative direction.
  100385. * @param result Defines the vector to store the result in
  100386. */
  100387. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  100388. /**
  100389. * Gets a camera constructor for a given camera type
  100390. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  100391. * @param name The name of the camera the result will be able to instantiate
  100392. * @param scene The scene the result will construct the camera in
  100393. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  100394. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  100395. * @returns a factory method to construc the camera
  100396. */
  100397. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  100398. /**
  100399. * Compute the world matrix of the camera.
  100400. * @returns the camera world matrix
  100401. */
  100402. computeWorldMatrix(): Matrix;
  100403. /**
  100404. * Parse a JSON and creates the camera from the parsed information
  100405. * @param parsedCamera The JSON to parse
  100406. * @param scene The scene to instantiate the camera in
  100407. * @returns the newly constructed camera
  100408. */
  100409. static Parse(parsedCamera: any, scene: Scene): Camera;
  100410. }
  100411. }
  100412. declare module BABYLON {
  100413. /**
  100414. * Class containing static functions to help procedurally build meshes
  100415. */
  100416. export class DiscBuilder {
  100417. /**
  100418. * Creates a plane polygonal mesh. By default, this is a disc
  100419. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  100420. * * 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
  100421. * * 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
  100422. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  100423. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  100424. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  100425. * @param name defines the name of the mesh
  100426. * @param options defines the options used to create the mesh
  100427. * @param scene defines the hosting scene
  100428. * @returns the plane polygonal mesh
  100429. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  100430. */
  100431. static CreateDisc(name: string, options: {
  100432. radius?: number;
  100433. tessellation?: number;
  100434. arc?: number;
  100435. updatable?: boolean;
  100436. sideOrientation?: number;
  100437. frontUVs?: Vector4;
  100438. backUVs?: Vector4;
  100439. }, scene?: Nullable<Scene>): Mesh;
  100440. }
  100441. }
  100442. declare module BABYLON {
  100443. /**
  100444. * Options to be used when creating a FresnelParameters.
  100445. */
  100446. export type IFresnelParametersCreationOptions = {
  100447. /**
  100448. * Define the color used on edges (grazing angle)
  100449. */
  100450. leftColor?: Color3;
  100451. /**
  100452. * Define the color used on center
  100453. */
  100454. rightColor?: Color3;
  100455. /**
  100456. * Define bias applied to computed fresnel term
  100457. */
  100458. bias?: number;
  100459. /**
  100460. * Defined the power exponent applied to fresnel term
  100461. */
  100462. power?: number;
  100463. /**
  100464. * Define if the fresnel effect is enable or not.
  100465. */
  100466. isEnabled?: boolean;
  100467. };
  100468. /**
  100469. * Serialized format for FresnelParameters.
  100470. */
  100471. export type IFresnelParametersSerialized = {
  100472. /**
  100473. * Define the color used on edges (grazing angle) [as an array]
  100474. */
  100475. leftColor: number[];
  100476. /**
  100477. * Define the color used on center [as an array]
  100478. */
  100479. rightColor: number[];
  100480. /**
  100481. * Define bias applied to computed fresnel term
  100482. */
  100483. bias: number;
  100484. /**
  100485. * Defined the power exponent applied to fresnel term
  100486. */
  100487. power?: number;
  100488. /**
  100489. * Define if the fresnel effect is enable or not.
  100490. */
  100491. isEnabled: boolean;
  100492. };
  100493. /**
  100494. * This represents all the required information to add a fresnel effect on a material:
  100495. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  100496. */
  100497. export class FresnelParameters {
  100498. private _isEnabled;
  100499. /**
  100500. * Define if the fresnel effect is enable or not.
  100501. */
  100502. get isEnabled(): boolean;
  100503. set isEnabled(value: boolean);
  100504. /**
  100505. * Define the color used on edges (grazing angle)
  100506. */
  100507. leftColor: Color3;
  100508. /**
  100509. * Define the color used on center
  100510. */
  100511. rightColor: Color3;
  100512. /**
  100513. * Define bias applied to computed fresnel term
  100514. */
  100515. bias: number;
  100516. /**
  100517. * Defined the power exponent applied to fresnel term
  100518. */
  100519. power: number;
  100520. /**
  100521. * Creates a new FresnelParameters object.
  100522. *
  100523. * @param options provide your own settings to optionally to override defaults
  100524. */
  100525. constructor(options?: IFresnelParametersCreationOptions);
  100526. /**
  100527. * Clones the current fresnel and its valuues
  100528. * @returns a clone fresnel configuration
  100529. */
  100530. clone(): FresnelParameters;
  100531. /**
  100532. * Determines equality between FresnelParameters objects
  100533. * @param otherFresnelParameters defines the second operand
  100534. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  100535. */
  100536. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  100537. /**
  100538. * Serializes the current fresnel parameters to a JSON representation.
  100539. * @return the JSON serialization
  100540. */
  100541. serialize(): IFresnelParametersSerialized;
  100542. /**
  100543. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  100544. * @param parsedFresnelParameters Define the JSON representation
  100545. * @returns the parsed parameters
  100546. */
  100547. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  100548. }
  100549. }
  100550. declare module BABYLON {
  100551. /**
  100552. * Base class of materials working in push mode in babylon JS
  100553. * @hidden
  100554. */
  100555. export class PushMaterial extends Material {
  100556. protected _activeEffect: Effect;
  100557. protected _normalMatrix: Matrix;
  100558. /**
  100559. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  100560. * This means that the material can keep using a previous shader while a new one is being compiled.
  100561. * This is mostly used when shader parallel compilation is supported (true by default)
  100562. */
  100563. allowShaderHotSwapping: boolean;
  100564. constructor(name: string, scene: Scene);
  100565. getEffect(): Effect;
  100566. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  100567. /**
  100568. * Binds the given world matrix to the active effect
  100569. *
  100570. * @param world the matrix to bind
  100571. */
  100572. bindOnlyWorldMatrix(world: Matrix): void;
  100573. /**
  100574. * Binds the given normal matrix to the active effect
  100575. *
  100576. * @param normalMatrix the matrix to bind
  100577. */
  100578. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  100579. bind(world: Matrix, mesh?: Mesh): void;
  100580. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  100581. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  100582. }
  100583. }
  100584. declare module BABYLON {
  100585. /**
  100586. * This groups all the flags used to control the materials channel.
  100587. */
  100588. export class MaterialFlags {
  100589. private static _DiffuseTextureEnabled;
  100590. /**
  100591. * Are diffuse textures enabled in the application.
  100592. */
  100593. static get DiffuseTextureEnabled(): boolean;
  100594. static set DiffuseTextureEnabled(value: boolean);
  100595. private static _AmbientTextureEnabled;
  100596. /**
  100597. * Are ambient textures enabled in the application.
  100598. */
  100599. static get AmbientTextureEnabled(): boolean;
  100600. static set AmbientTextureEnabled(value: boolean);
  100601. private static _OpacityTextureEnabled;
  100602. /**
  100603. * Are opacity textures enabled in the application.
  100604. */
  100605. static get OpacityTextureEnabled(): boolean;
  100606. static set OpacityTextureEnabled(value: boolean);
  100607. private static _ReflectionTextureEnabled;
  100608. /**
  100609. * Are reflection textures enabled in the application.
  100610. */
  100611. static get ReflectionTextureEnabled(): boolean;
  100612. static set ReflectionTextureEnabled(value: boolean);
  100613. private static _EmissiveTextureEnabled;
  100614. /**
  100615. * Are emissive textures enabled in the application.
  100616. */
  100617. static get EmissiveTextureEnabled(): boolean;
  100618. static set EmissiveTextureEnabled(value: boolean);
  100619. private static _SpecularTextureEnabled;
  100620. /**
  100621. * Are specular textures enabled in the application.
  100622. */
  100623. static get SpecularTextureEnabled(): boolean;
  100624. static set SpecularTextureEnabled(value: boolean);
  100625. private static _BumpTextureEnabled;
  100626. /**
  100627. * Are bump textures enabled in the application.
  100628. */
  100629. static get BumpTextureEnabled(): boolean;
  100630. static set BumpTextureEnabled(value: boolean);
  100631. private static _LightmapTextureEnabled;
  100632. /**
  100633. * Are lightmap textures enabled in the application.
  100634. */
  100635. static get LightmapTextureEnabled(): boolean;
  100636. static set LightmapTextureEnabled(value: boolean);
  100637. private static _RefractionTextureEnabled;
  100638. /**
  100639. * Are refraction textures enabled in the application.
  100640. */
  100641. static get RefractionTextureEnabled(): boolean;
  100642. static set RefractionTextureEnabled(value: boolean);
  100643. private static _ColorGradingTextureEnabled;
  100644. /**
  100645. * Are color grading textures enabled in the application.
  100646. */
  100647. static get ColorGradingTextureEnabled(): boolean;
  100648. static set ColorGradingTextureEnabled(value: boolean);
  100649. private static _FresnelEnabled;
  100650. /**
  100651. * Are fresnels enabled in the application.
  100652. */
  100653. static get FresnelEnabled(): boolean;
  100654. static set FresnelEnabled(value: boolean);
  100655. private static _ClearCoatTextureEnabled;
  100656. /**
  100657. * Are clear coat textures enabled in the application.
  100658. */
  100659. static get ClearCoatTextureEnabled(): boolean;
  100660. static set ClearCoatTextureEnabled(value: boolean);
  100661. private static _ClearCoatBumpTextureEnabled;
  100662. /**
  100663. * Are clear coat bump textures enabled in the application.
  100664. */
  100665. static get ClearCoatBumpTextureEnabled(): boolean;
  100666. static set ClearCoatBumpTextureEnabled(value: boolean);
  100667. private static _ClearCoatTintTextureEnabled;
  100668. /**
  100669. * Are clear coat tint textures enabled in the application.
  100670. */
  100671. static get ClearCoatTintTextureEnabled(): boolean;
  100672. static set ClearCoatTintTextureEnabled(value: boolean);
  100673. private static _SheenTextureEnabled;
  100674. /**
  100675. * Are sheen textures enabled in the application.
  100676. */
  100677. static get SheenTextureEnabled(): boolean;
  100678. static set SheenTextureEnabled(value: boolean);
  100679. private static _AnisotropicTextureEnabled;
  100680. /**
  100681. * Are anisotropic textures enabled in the application.
  100682. */
  100683. static get AnisotropicTextureEnabled(): boolean;
  100684. static set AnisotropicTextureEnabled(value: boolean);
  100685. private static _ThicknessTextureEnabled;
  100686. /**
  100687. * Are thickness textures enabled in the application.
  100688. */
  100689. static get ThicknessTextureEnabled(): boolean;
  100690. static set ThicknessTextureEnabled(value: boolean);
  100691. }
  100692. }
  100693. declare module BABYLON {
  100694. /** @hidden */
  100695. export var defaultFragmentDeclaration: {
  100696. name: string;
  100697. shader: string;
  100698. };
  100699. }
  100700. declare module BABYLON {
  100701. /** @hidden */
  100702. export var defaultUboDeclaration: {
  100703. name: string;
  100704. shader: string;
  100705. };
  100706. }
  100707. declare module BABYLON {
  100708. /** @hidden */
  100709. export var lightFragmentDeclaration: {
  100710. name: string;
  100711. shader: string;
  100712. };
  100713. }
  100714. declare module BABYLON {
  100715. /** @hidden */
  100716. export var lightUboDeclaration: {
  100717. name: string;
  100718. shader: string;
  100719. };
  100720. }
  100721. declare module BABYLON {
  100722. /** @hidden */
  100723. export var lightsFragmentFunctions: {
  100724. name: string;
  100725. shader: string;
  100726. };
  100727. }
  100728. declare module BABYLON {
  100729. /** @hidden */
  100730. export var shadowsFragmentFunctions: {
  100731. name: string;
  100732. shader: string;
  100733. };
  100734. }
  100735. declare module BABYLON {
  100736. /** @hidden */
  100737. export var fresnelFunction: {
  100738. name: string;
  100739. shader: string;
  100740. };
  100741. }
  100742. declare module BABYLON {
  100743. /** @hidden */
  100744. export var reflectionFunction: {
  100745. name: string;
  100746. shader: string;
  100747. };
  100748. }
  100749. declare module BABYLON {
  100750. /** @hidden */
  100751. export var bumpFragmentFunctions: {
  100752. name: string;
  100753. shader: string;
  100754. };
  100755. }
  100756. declare module BABYLON {
  100757. /** @hidden */
  100758. export var logDepthDeclaration: {
  100759. name: string;
  100760. shader: string;
  100761. };
  100762. }
  100763. declare module BABYLON {
  100764. /** @hidden */
  100765. export var bumpFragment: {
  100766. name: string;
  100767. shader: string;
  100768. };
  100769. }
  100770. declare module BABYLON {
  100771. /** @hidden */
  100772. export var depthPrePass: {
  100773. name: string;
  100774. shader: string;
  100775. };
  100776. }
  100777. declare module BABYLON {
  100778. /** @hidden */
  100779. export var lightFragment: {
  100780. name: string;
  100781. shader: string;
  100782. };
  100783. }
  100784. declare module BABYLON {
  100785. /** @hidden */
  100786. export var logDepthFragment: {
  100787. name: string;
  100788. shader: string;
  100789. };
  100790. }
  100791. declare module BABYLON {
  100792. /** @hidden */
  100793. export var defaultPixelShader: {
  100794. name: string;
  100795. shader: string;
  100796. };
  100797. }
  100798. declare module BABYLON {
  100799. /** @hidden */
  100800. export var defaultVertexDeclaration: {
  100801. name: string;
  100802. shader: string;
  100803. };
  100804. }
  100805. declare module BABYLON {
  100806. /** @hidden */
  100807. export var bumpVertexDeclaration: {
  100808. name: string;
  100809. shader: string;
  100810. };
  100811. }
  100812. declare module BABYLON {
  100813. /** @hidden */
  100814. export var bumpVertex: {
  100815. name: string;
  100816. shader: string;
  100817. };
  100818. }
  100819. declare module BABYLON {
  100820. /** @hidden */
  100821. export var fogVertex: {
  100822. name: string;
  100823. shader: string;
  100824. };
  100825. }
  100826. declare module BABYLON {
  100827. /** @hidden */
  100828. export var shadowsVertex: {
  100829. name: string;
  100830. shader: string;
  100831. };
  100832. }
  100833. declare module BABYLON {
  100834. /** @hidden */
  100835. export var pointCloudVertex: {
  100836. name: string;
  100837. shader: string;
  100838. };
  100839. }
  100840. declare module BABYLON {
  100841. /** @hidden */
  100842. export var logDepthVertex: {
  100843. name: string;
  100844. shader: string;
  100845. };
  100846. }
  100847. declare module BABYLON {
  100848. /** @hidden */
  100849. export var defaultVertexShader: {
  100850. name: string;
  100851. shader: string;
  100852. };
  100853. }
  100854. declare module BABYLON {
  100855. /** @hidden */
  100856. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  100857. MAINUV1: boolean;
  100858. MAINUV2: boolean;
  100859. DIFFUSE: boolean;
  100860. DIFFUSEDIRECTUV: number;
  100861. AMBIENT: boolean;
  100862. AMBIENTDIRECTUV: number;
  100863. OPACITY: boolean;
  100864. OPACITYDIRECTUV: number;
  100865. OPACITYRGB: boolean;
  100866. REFLECTION: boolean;
  100867. EMISSIVE: boolean;
  100868. EMISSIVEDIRECTUV: number;
  100869. SPECULAR: boolean;
  100870. SPECULARDIRECTUV: number;
  100871. BUMP: boolean;
  100872. BUMPDIRECTUV: number;
  100873. PARALLAX: boolean;
  100874. PARALLAXOCCLUSION: boolean;
  100875. SPECULAROVERALPHA: boolean;
  100876. CLIPPLANE: boolean;
  100877. CLIPPLANE2: boolean;
  100878. CLIPPLANE3: boolean;
  100879. CLIPPLANE4: boolean;
  100880. CLIPPLANE5: boolean;
  100881. CLIPPLANE6: boolean;
  100882. ALPHATEST: boolean;
  100883. DEPTHPREPASS: boolean;
  100884. ALPHAFROMDIFFUSE: boolean;
  100885. POINTSIZE: boolean;
  100886. FOG: boolean;
  100887. SPECULARTERM: boolean;
  100888. DIFFUSEFRESNEL: boolean;
  100889. OPACITYFRESNEL: boolean;
  100890. REFLECTIONFRESNEL: boolean;
  100891. REFRACTIONFRESNEL: boolean;
  100892. EMISSIVEFRESNEL: boolean;
  100893. FRESNEL: boolean;
  100894. NORMAL: boolean;
  100895. UV1: boolean;
  100896. UV2: boolean;
  100897. VERTEXCOLOR: boolean;
  100898. VERTEXALPHA: boolean;
  100899. NUM_BONE_INFLUENCERS: number;
  100900. BonesPerMesh: number;
  100901. BONETEXTURE: boolean;
  100902. INSTANCES: boolean;
  100903. GLOSSINESS: boolean;
  100904. ROUGHNESS: boolean;
  100905. EMISSIVEASILLUMINATION: boolean;
  100906. LINKEMISSIVEWITHDIFFUSE: boolean;
  100907. REFLECTIONFRESNELFROMSPECULAR: boolean;
  100908. LIGHTMAP: boolean;
  100909. LIGHTMAPDIRECTUV: number;
  100910. OBJECTSPACE_NORMALMAP: boolean;
  100911. USELIGHTMAPASSHADOWMAP: boolean;
  100912. REFLECTIONMAP_3D: boolean;
  100913. REFLECTIONMAP_SPHERICAL: boolean;
  100914. REFLECTIONMAP_PLANAR: boolean;
  100915. REFLECTIONMAP_CUBIC: boolean;
  100916. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  100917. REFLECTIONMAP_PROJECTION: boolean;
  100918. REFLECTIONMAP_SKYBOX: boolean;
  100919. REFLECTIONMAP_EXPLICIT: boolean;
  100920. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  100921. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  100922. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  100923. INVERTCUBICMAP: boolean;
  100924. LOGARITHMICDEPTH: boolean;
  100925. REFRACTION: boolean;
  100926. REFRACTIONMAP_3D: boolean;
  100927. REFLECTIONOVERALPHA: boolean;
  100928. TWOSIDEDLIGHTING: boolean;
  100929. SHADOWFLOAT: boolean;
  100930. MORPHTARGETS: boolean;
  100931. MORPHTARGETS_NORMAL: boolean;
  100932. MORPHTARGETS_TANGENT: boolean;
  100933. MORPHTARGETS_UV: boolean;
  100934. NUM_MORPH_INFLUENCERS: number;
  100935. NONUNIFORMSCALING: boolean;
  100936. PREMULTIPLYALPHA: boolean;
  100937. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  100938. ALPHABLEND: boolean;
  100939. IMAGEPROCESSING: boolean;
  100940. VIGNETTE: boolean;
  100941. VIGNETTEBLENDMODEMULTIPLY: boolean;
  100942. VIGNETTEBLENDMODEOPAQUE: boolean;
  100943. TONEMAPPING: boolean;
  100944. TONEMAPPING_ACES: boolean;
  100945. CONTRAST: boolean;
  100946. COLORCURVES: boolean;
  100947. COLORGRADING: boolean;
  100948. COLORGRADING3D: boolean;
  100949. SAMPLER3DGREENDEPTH: boolean;
  100950. SAMPLER3DBGRMAP: boolean;
  100951. IMAGEPROCESSINGPOSTPROCESS: boolean;
  100952. MULTIVIEW: boolean;
  100953. /**
  100954. * If the reflection texture on this material is in linear color space
  100955. * @hidden
  100956. */
  100957. IS_REFLECTION_LINEAR: boolean;
  100958. /**
  100959. * If the refraction texture on this material is in linear color space
  100960. * @hidden
  100961. */
  100962. IS_REFRACTION_LINEAR: boolean;
  100963. EXPOSURE: boolean;
  100964. constructor();
  100965. setReflectionMode(modeToEnable: string): void;
  100966. }
  100967. /**
  100968. * This is the default material used in Babylon. It is the best trade off between quality
  100969. * and performances.
  100970. * @see http://doc.babylonjs.com/babylon101/materials
  100971. */
  100972. export class StandardMaterial extends PushMaterial {
  100973. private _diffuseTexture;
  100974. /**
  100975. * The basic texture of the material as viewed under a light.
  100976. */
  100977. diffuseTexture: Nullable<BaseTexture>;
  100978. private _ambientTexture;
  100979. /**
  100980. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  100981. */
  100982. ambientTexture: Nullable<BaseTexture>;
  100983. private _opacityTexture;
  100984. /**
  100985. * Define the transparency of the material from a texture.
  100986. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  100987. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  100988. */
  100989. opacityTexture: Nullable<BaseTexture>;
  100990. private _reflectionTexture;
  100991. /**
  100992. * Define the texture used to display the reflection.
  100993. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  100994. */
  100995. reflectionTexture: Nullable<BaseTexture>;
  100996. private _emissiveTexture;
  100997. /**
  100998. * Define texture of the material as if self lit.
  100999. * This will be mixed in the final result even in the absence of light.
  101000. */
  101001. emissiveTexture: Nullable<BaseTexture>;
  101002. private _specularTexture;
  101003. /**
  101004. * Define how the color and intensity of the highlight given by the light in the material.
  101005. */
  101006. specularTexture: Nullable<BaseTexture>;
  101007. private _bumpTexture;
  101008. /**
  101009. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  101010. * 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.
  101011. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  101012. */
  101013. bumpTexture: Nullable<BaseTexture>;
  101014. private _lightmapTexture;
  101015. /**
  101016. * Complex lighting can be computationally expensive to compute at runtime.
  101017. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  101018. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  101019. */
  101020. lightmapTexture: Nullable<BaseTexture>;
  101021. private _refractionTexture;
  101022. /**
  101023. * Define the texture used to display the refraction.
  101024. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  101025. */
  101026. refractionTexture: Nullable<BaseTexture>;
  101027. /**
  101028. * The color of the material lit by the environmental background lighting.
  101029. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  101030. */
  101031. ambientColor: Color3;
  101032. /**
  101033. * The basic color of the material as viewed under a light.
  101034. */
  101035. diffuseColor: Color3;
  101036. /**
  101037. * Define how the color and intensity of the highlight given by the light in the material.
  101038. */
  101039. specularColor: Color3;
  101040. /**
  101041. * Define the color of the material as if self lit.
  101042. * This will be mixed in the final result even in the absence of light.
  101043. */
  101044. emissiveColor: Color3;
  101045. /**
  101046. * Defines how sharp are the highlights in the material.
  101047. * The bigger the value the sharper giving a more glossy feeling to the result.
  101048. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  101049. */
  101050. specularPower: number;
  101051. private _useAlphaFromDiffuseTexture;
  101052. /**
  101053. * Does the transparency come from the diffuse texture alpha channel.
  101054. */
  101055. useAlphaFromDiffuseTexture: boolean;
  101056. private _useEmissiveAsIllumination;
  101057. /**
  101058. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  101059. */
  101060. useEmissiveAsIllumination: boolean;
  101061. private _linkEmissiveWithDiffuse;
  101062. /**
  101063. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  101064. * the emissive level when the final color is close to one.
  101065. */
  101066. linkEmissiveWithDiffuse: boolean;
  101067. private _useSpecularOverAlpha;
  101068. /**
  101069. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  101070. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  101071. */
  101072. useSpecularOverAlpha: boolean;
  101073. private _useReflectionOverAlpha;
  101074. /**
  101075. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  101076. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  101077. */
  101078. useReflectionOverAlpha: boolean;
  101079. private _disableLighting;
  101080. /**
  101081. * Does lights from the scene impacts this material.
  101082. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  101083. */
  101084. disableLighting: boolean;
  101085. private _useObjectSpaceNormalMap;
  101086. /**
  101087. * Allows using an object space normal map (instead of tangent space).
  101088. */
  101089. useObjectSpaceNormalMap: boolean;
  101090. private _useParallax;
  101091. /**
  101092. * Is parallax enabled or not.
  101093. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  101094. */
  101095. useParallax: boolean;
  101096. private _useParallaxOcclusion;
  101097. /**
  101098. * Is parallax occlusion enabled or not.
  101099. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  101100. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  101101. */
  101102. useParallaxOcclusion: boolean;
  101103. /**
  101104. * 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.
  101105. */
  101106. parallaxScaleBias: number;
  101107. private _roughness;
  101108. /**
  101109. * Helps to define how blurry the reflections should appears in the material.
  101110. */
  101111. roughness: number;
  101112. /**
  101113. * In case of refraction, define the value of the index of refraction.
  101114. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  101115. */
  101116. indexOfRefraction: number;
  101117. /**
  101118. * Invert the refraction texture alongside the y axis.
  101119. * It can be useful with procedural textures or probe for instance.
  101120. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  101121. */
  101122. invertRefractionY: boolean;
  101123. /**
  101124. * Defines the alpha limits in alpha test mode.
  101125. */
  101126. alphaCutOff: number;
  101127. private _useLightmapAsShadowmap;
  101128. /**
  101129. * In case of light mapping, define whether the map contains light or shadow informations.
  101130. */
  101131. useLightmapAsShadowmap: boolean;
  101132. private _diffuseFresnelParameters;
  101133. /**
  101134. * Define the diffuse fresnel parameters of the material.
  101135. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  101136. */
  101137. diffuseFresnelParameters: FresnelParameters;
  101138. private _opacityFresnelParameters;
  101139. /**
  101140. * Define the opacity fresnel parameters of the material.
  101141. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  101142. */
  101143. opacityFresnelParameters: FresnelParameters;
  101144. private _reflectionFresnelParameters;
  101145. /**
  101146. * Define the reflection fresnel parameters of the material.
  101147. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  101148. */
  101149. reflectionFresnelParameters: FresnelParameters;
  101150. private _refractionFresnelParameters;
  101151. /**
  101152. * Define the refraction fresnel parameters of the material.
  101153. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  101154. */
  101155. refractionFresnelParameters: FresnelParameters;
  101156. private _emissiveFresnelParameters;
  101157. /**
  101158. * Define the emissive fresnel parameters of the material.
  101159. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  101160. */
  101161. emissiveFresnelParameters: FresnelParameters;
  101162. private _useReflectionFresnelFromSpecular;
  101163. /**
  101164. * If true automatically deducts the fresnels values from the material specularity.
  101165. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  101166. */
  101167. useReflectionFresnelFromSpecular: boolean;
  101168. private _useGlossinessFromSpecularMapAlpha;
  101169. /**
  101170. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  101171. */
  101172. useGlossinessFromSpecularMapAlpha: boolean;
  101173. private _maxSimultaneousLights;
  101174. /**
  101175. * Defines the maximum number of lights that can be used in the material
  101176. */
  101177. maxSimultaneousLights: number;
  101178. private _invertNormalMapX;
  101179. /**
  101180. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  101181. */
  101182. invertNormalMapX: boolean;
  101183. private _invertNormalMapY;
  101184. /**
  101185. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  101186. */
  101187. invertNormalMapY: boolean;
  101188. private _twoSidedLighting;
  101189. /**
  101190. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  101191. */
  101192. twoSidedLighting: boolean;
  101193. /**
  101194. * Default configuration related to image processing available in the standard Material.
  101195. */
  101196. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  101197. /**
  101198. * Gets the image processing configuration used either in this material.
  101199. */
  101200. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  101201. /**
  101202. * Sets the Default image processing configuration used either in the this material.
  101203. *
  101204. * If sets to null, the scene one is in use.
  101205. */
  101206. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  101207. /**
  101208. * Keep track of the image processing observer to allow dispose and replace.
  101209. */
  101210. private _imageProcessingObserver;
  101211. /**
  101212. * Attaches a new image processing configuration to the Standard Material.
  101213. * @param configuration
  101214. */
  101215. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  101216. /**
  101217. * Gets wether the color curves effect is enabled.
  101218. */
  101219. get cameraColorCurvesEnabled(): boolean;
  101220. /**
  101221. * Sets wether the color curves effect is enabled.
  101222. */
  101223. set cameraColorCurvesEnabled(value: boolean);
  101224. /**
  101225. * Gets wether the color grading effect is enabled.
  101226. */
  101227. get cameraColorGradingEnabled(): boolean;
  101228. /**
  101229. * Gets wether the color grading effect is enabled.
  101230. */
  101231. set cameraColorGradingEnabled(value: boolean);
  101232. /**
  101233. * Gets wether tonemapping is enabled or not.
  101234. */
  101235. get cameraToneMappingEnabled(): boolean;
  101236. /**
  101237. * Sets wether tonemapping is enabled or not
  101238. */
  101239. set cameraToneMappingEnabled(value: boolean);
  101240. /**
  101241. * The camera exposure used on this material.
  101242. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  101243. * This corresponds to a photographic exposure.
  101244. */
  101245. get cameraExposure(): number;
  101246. /**
  101247. * The camera exposure used on this material.
  101248. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  101249. * This corresponds to a photographic exposure.
  101250. */
  101251. set cameraExposure(value: number);
  101252. /**
  101253. * Gets The camera contrast used on this material.
  101254. */
  101255. get cameraContrast(): number;
  101256. /**
  101257. * Sets The camera contrast used on this material.
  101258. */
  101259. set cameraContrast(value: number);
  101260. /**
  101261. * Gets the Color Grading 2D Lookup Texture.
  101262. */
  101263. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  101264. /**
  101265. * Sets the Color Grading 2D Lookup Texture.
  101266. */
  101267. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  101268. /**
  101269. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  101270. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  101271. * 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;
  101272. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  101273. */
  101274. get cameraColorCurves(): Nullable<ColorCurves>;
  101275. /**
  101276. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  101277. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  101278. * 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;
  101279. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  101280. */
  101281. set cameraColorCurves(value: Nullable<ColorCurves>);
  101282. /**
  101283. * Custom callback helping to override the default shader used in the material.
  101284. */
  101285. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines, attributes?: string[]) => string;
  101286. protected _renderTargets: SmartArray<RenderTargetTexture>;
  101287. protected _worldViewProjectionMatrix: Matrix;
  101288. protected _globalAmbientColor: Color3;
  101289. protected _useLogarithmicDepth: boolean;
  101290. protected _rebuildInParallel: boolean;
  101291. /**
  101292. * Instantiates a new standard material.
  101293. * This is the default material used in Babylon. It is the best trade off between quality
  101294. * and performances.
  101295. * @see http://doc.babylonjs.com/babylon101/materials
  101296. * @param name Define the name of the material in the scene
  101297. * @param scene Define the scene the material belong to
  101298. */
  101299. constructor(name: string, scene: Scene);
  101300. /**
  101301. * Gets a boolean indicating that current material needs to register RTT
  101302. */
  101303. get hasRenderTargetTextures(): boolean;
  101304. /**
  101305. * Gets the current class name of the material e.g. "StandardMaterial"
  101306. * Mainly use in serialization.
  101307. * @returns the class name
  101308. */
  101309. getClassName(): string;
  101310. /**
  101311. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  101312. * You can try switching to logarithmic depth.
  101313. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  101314. */
  101315. get useLogarithmicDepth(): boolean;
  101316. set useLogarithmicDepth(value: boolean);
  101317. /**
  101318. * Specifies if the material will require alpha blending
  101319. * @returns a boolean specifying if alpha blending is needed
  101320. */
  101321. needAlphaBlending(): boolean;
  101322. /**
  101323. * Specifies if this material should be rendered in alpha test mode
  101324. * @returns a boolean specifying if an alpha test is needed.
  101325. */
  101326. needAlphaTesting(): boolean;
  101327. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  101328. /**
  101329. * Get the texture used for alpha test purpose.
  101330. * @returns the diffuse texture in case of the standard material.
  101331. */
  101332. getAlphaTestTexture(): Nullable<BaseTexture>;
  101333. /**
  101334. * Get if the submesh is ready to be used and all its information available.
  101335. * Child classes can use it to update shaders
  101336. * @param mesh defines the mesh to check
  101337. * @param subMesh defines which submesh to check
  101338. * @param useInstances specifies that instances should be used
  101339. * @returns a boolean indicating that the submesh is ready or not
  101340. */
  101341. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  101342. /**
  101343. * Builds the material UBO layouts.
  101344. * Used internally during the effect preparation.
  101345. */
  101346. buildUniformLayout(): void;
  101347. /**
  101348. * Unbinds the material from the mesh
  101349. */
  101350. unbind(): void;
  101351. /**
  101352. * Binds the submesh to this material by preparing the effect and shader to draw
  101353. * @param world defines the world transformation matrix
  101354. * @param mesh defines the mesh containing the submesh
  101355. * @param subMesh defines the submesh to bind the material to
  101356. */
  101357. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  101358. /**
  101359. * Get the list of animatables in the material.
  101360. * @returns the list of animatables object used in the material
  101361. */
  101362. getAnimatables(): IAnimatable[];
  101363. /**
  101364. * Gets the active textures from the material
  101365. * @returns an array of textures
  101366. */
  101367. getActiveTextures(): BaseTexture[];
  101368. /**
  101369. * Specifies if the material uses a texture
  101370. * @param texture defines the texture to check against the material
  101371. * @returns a boolean specifying if the material uses the texture
  101372. */
  101373. hasTexture(texture: BaseTexture): boolean;
  101374. /**
  101375. * Disposes the material
  101376. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  101377. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  101378. */
  101379. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  101380. /**
  101381. * Makes a duplicate of the material, and gives it a new name
  101382. * @param name defines the new name for the duplicated material
  101383. * @returns the cloned material
  101384. */
  101385. clone(name: string): StandardMaterial;
  101386. /**
  101387. * Serializes this material in a JSON representation
  101388. * @returns the serialized material object
  101389. */
  101390. serialize(): any;
  101391. /**
  101392. * Creates a standard material from parsed material data
  101393. * @param source defines the JSON representation of the material
  101394. * @param scene defines the hosting scene
  101395. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  101396. * @returns a new standard material
  101397. */
  101398. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  101399. /**
  101400. * Are diffuse textures enabled in the application.
  101401. */
  101402. static get DiffuseTextureEnabled(): boolean;
  101403. static set DiffuseTextureEnabled(value: boolean);
  101404. /**
  101405. * Are ambient textures enabled in the application.
  101406. */
  101407. static get AmbientTextureEnabled(): boolean;
  101408. static set AmbientTextureEnabled(value: boolean);
  101409. /**
  101410. * Are opacity textures enabled in the application.
  101411. */
  101412. static get OpacityTextureEnabled(): boolean;
  101413. static set OpacityTextureEnabled(value: boolean);
  101414. /**
  101415. * Are reflection textures enabled in the application.
  101416. */
  101417. static get ReflectionTextureEnabled(): boolean;
  101418. static set ReflectionTextureEnabled(value: boolean);
  101419. /**
  101420. * Are emissive textures enabled in the application.
  101421. */
  101422. static get EmissiveTextureEnabled(): boolean;
  101423. static set EmissiveTextureEnabled(value: boolean);
  101424. /**
  101425. * Are specular textures enabled in the application.
  101426. */
  101427. static get SpecularTextureEnabled(): boolean;
  101428. static set SpecularTextureEnabled(value: boolean);
  101429. /**
  101430. * Are bump textures enabled in the application.
  101431. */
  101432. static get BumpTextureEnabled(): boolean;
  101433. static set BumpTextureEnabled(value: boolean);
  101434. /**
  101435. * Are lightmap textures enabled in the application.
  101436. */
  101437. static get LightmapTextureEnabled(): boolean;
  101438. static set LightmapTextureEnabled(value: boolean);
  101439. /**
  101440. * Are refraction textures enabled in the application.
  101441. */
  101442. static get RefractionTextureEnabled(): boolean;
  101443. static set RefractionTextureEnabled(value: boolean);
  101444. /**
  101445. * Are color grading textures enabled in the application.
  101446. */
  101447. static get ColorGradingTextureEnabled(): boolean;
  101448. static set ColorGradingTextureEnabled(value: boolean);
  101449. /**
  101450. * Are fresnels enabled in the application.
  101451. */
  101452. static get FresnelEnabled(): boolean;
  101453. static set FresnelEnabled(value: boolean);
  101454. }
  101455. }
  101456. declare module BABYLON {
  101457. /**
  101458. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  101459. *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.
  101460. * The SPS is also a particle system. It provides some methods to manage the particles.
  101461. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  101462. *
  101463. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  101464. */
  101465. export class SolidParticleSystem implements IDisposable {
  101466. /**
  101467. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  101468. * Example : var p = SPS.particles[i];
  101469. */
  101470. particles: SolidParticle[];
  101471. /**
  101472. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  101473. */
  101474. nbParticles: number;
  101475. /**
  101476. * If the particles must ever face the camera (default false). Useful for planar particles.
  101477. */
  101478. billboard: boolean;
  101479. /**
  101480. * Recompute normals when adding a shape
  101481. */
  101482. recomputeNormals: boolean;
  101483. /**
  101484. * This a counter ofr your own usage. It's not set by any SPS functions.
  101485. */
  101486. counter: number;
  101487. /**
  101488. * The SPS name. This name is also given to the underlying mesh.
  101489. */
  101490. name: string;
  101491. /**
  101492. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  101493. */
  101494. mesh: Mesh;
  101495. /**
  101496. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  101497. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  101498. */
  101499. vars: any;
  101500. /**
  101501. * This array is populated when the SPS is set as 'pickable'.
  101502. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  101503. * Each element of this array is an object `{idx: int, faceId: int}`.
  101504. * `idx` is the picked particle index in the `SPS.particles` array
  101505. * `faceId` is the picked face index counted within this particle.
  101506. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  101507. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  101508. * Use the method SPS.pickedParticle(pickingInfo) instead.
  101509. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  101510. */
  101511. pickedParticles: {
  101512. idx: number;
  101513. faceId: number;
  101514. }[];
  101515. /**
  101516. * This array is populated when the SPS is set as 'pickable'
  101517. * Each key of this array is a submesh index.
  101518. * Each element of this array is a second array defined like this :
  101519. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  101520. * Each element of this second 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. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  101524. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  101525. */
  101526. pickedBySubMesh: {
  101527. idx: number;
  101528. faceId: number;
  101529. }[][];
  101530. /**
  101531. * This array is populated when `enableDepthSort` is set to true.
  101532. * Each element of this array is an instance of the class DepthSortedParticle.
  101533. */
  101534. depthSortedParticles: DepthSortedParticle[];
  101535. /**
  101536. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  101537. * @hidden
  101538. */
  101539. _bSphereOnly: boolean;
  101540. /**
  101541. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  101542. * @hidden
  101543. */
  101544. _bSphereRadiusFactor: number;
  101545. private _scene;
  101546. private _positions;
  101547. private _indices;
  101548. private _normals;
  101549. private _colors;
  101550. private _uvs;
  101551. private _indices32;
  101552. private _positions32;
  101553. private _normals32;
  101554. private _fixedNormal32;
  101555. private _colors32;
  101556. private _uvs32;
  101557. private _index;
  101558. private _updatable;
  101559. private _pickable;
  101560. private _isVisibilityBoxLocked;
  101561. private _alwaysVisible;
  101562. private _depthSort;
  101563. private _expandable;
  101564. private _shapeCounter;
  101565. private _copy;
  101566. private _color;
  101567. private _computeParticleColor;
  101568. private _computeParticleTexture;
  101569. private _computeParticleRotation;
  101570. private _computeParticleVertex;
  101571. private _computeBoundingBox;
  101572. private _depthSortParticles;
  101573. private _camera;
  101574. private _mustUnrotateFixedNormals;
  101575. private _particlesIntersect;
  101576. private _needs32Bits;
  101577. private _isNotBuilt;
  101578. private _lastParticleId;
  101579. private _idxOfId;
  101580. private _multimaterialEnabled;
  101581. private _useModelMaterial;
  101582. private _indicesByMaterial;
  101583. private _materialIndexes;
  101584. private _depthSortFunction;
  101585. private _materialSortFunction;
  101586. private _materials;
  101587. private _multimaterial;
  101588. private _materialIndexesById;
  101589. private _defaultMaterial;
  101590. private _autoUpdateSubMeshes;
  101591. /**
  101592. * Creates a SPS (Solid Particle System) object.
  101593. * @param name (String) is the SPS name, this will be the underlying mesh name.
  101594. * @param scene (Scene) is the scene in which the SPS is added.
  101595. * @param options defines the options of the sps e.g.
  101596. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  101597. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  101598. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  101599. * * 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.
  101600. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  101601. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  101602. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  101603. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  101604. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  101605. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  101606. */
  101607. constructor(name: string, scene: Scene, options?: {
  101608. updatable?: boolean;
  101609. isPickable?: boolean;
  101610. enableDepthSort?: boolean;
  101611. particleIntersection?: boolean;
  101612. boundingSphereOnly?: boolean;
  101613. bSphereRadiusFactor?: number;
  101614. expandable?: boolean;
  101615. useModelMaterial?: boolean;
  101616. enableMultiMaterial?: boolean;
  101617. });
  101618. /**
  101619. * Builds the SPS underlying mesh. Returns a standard Mesh.
  101620. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  101621. * @returns the created mesh
  101622. */
  101623. buildMesh(): Mesh;
  101624. /**
  101625. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  101626. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  101627. * Thus the particles generated from `digest()` have their property `position` set yet.
  101628. * @param mesh ( Mesh ) is the mesh to be digested
  101629. * @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
  101630. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  101631. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  101632. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  101633. * @returns the current SPS
  101634. */
  101635. digest(mesh: Mesh, options?: {
  101636. facetNb?: number;
  101637. number?: number;
  101638. delta?: number;
  101639. storage?: [];
  101640. }): SolidParticleSystem;
  101641. /**
  101642. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  101643. * @hidden
  101644. */
  101645. private _unrotateFixedNormals;
  101646. /**
  101647. * Resets the temporary working copy particle
  101648. * @hidden
  101649. */
  101650. private _resetCopy;
  101651. /**
  101652. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  101653. * @param p the current index in the positions array to be updated
  101654. * @param ind the current index in the indices array
  101655. * @param shape a Vector3 array, the shape geometry
  101656. * @param positions the positions array to be updated
  101657. * @param meshInd the shape indices array
  101658. * @param indices the indices array to be updated
  101659. * @param meshUV the shape uv array
  101660. * @param uvs the uv array to be updated
  101661. * @param meshCol the shape color array
  101662. * @param colors the color array to be updated
  101663. * @param meshNor the shape normals array
  101664. * @param normals the normals array to be updated
  101665. * @param idx the particle index
  101666. * @param idxInShape the particle index in its shape
  101667. * @param options the addShape() method passed options
  101668. * @model the particle model
  101669. * @hidden
  101670. */
  101671. private _meshBuilder;
  101672. /**
  101673. * Returns a shape Vector3 array from positions float array
  101674. * @param positions float array
  101675. * @returns a vector3 array
  101676. * @hidden
  101677. */
  101678. private _posToShape;
  101679. /**
  101680. * Returns a shapeUV array from a float uvs (array deep copy)
  101681. * @param uvs as a float array
  101682. * @returns a shapeUV array
  101683. * @hidden
  101684. */
  101685. private _uvsToShapeUV;
  101686. /**
  101687. * Adds a new particle object in the particles array
  101688. * @param idx particle index in particles array
  101689. * @param id particle id
  101690. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  101691. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  101692. * @param model particle ModelShape object
  101693. * @param shapeId model shape identifier
  101694. * @param idxInShape index of the particle in the current model
  101695. * @param bInfo model bounding info object
  101696. * @param storage target storage array, if any
  101697. * @hidden
  101698. */
  101699. private _addParticle;
  101700. /**
  101701. * Adds some particles to the SPS from the model shape. Returns the shape id.
  101702. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  101703. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  101704. * @param nb (positive integer) the number of particles to be created from this model
  101705. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  101706. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  101707. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  101708. * @returns the number of shapes in the system
  101709. */
  101710. addShape(mesh: Mesh, nb: number, options?: {
  101711. positionFunction?: any;
  101712. vertexFunction?: any;
  101713. storage?: [];
  101714. }): number;
  101715. /**
  101716. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  101717. * @hidden
  101718. */
  101719. private _rebuildParticle;
  101720. /**
  101721. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  101722. * @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.
  101723. * @returns the SPS.
  101724. */
  101725. rebuildMesh(reset?: boolean): SolidParticleSystem;
  101726. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  101727. * Returns an array with the removed particles.
  101728. * 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.
  101729. * The SPS can't be empty so at least one particle needs to remain in place.
  101730. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  101731. * @param start index of the first particle to remove
  101732. * @param end index of the last particle to remove (included)
  101733. * @returns an array populated with the removed particles
  101734. */
  101735. removeParticles(start: number, end: number): SolidParticle[];
  101736. /**
  101737. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  101738. * @param solidParticleArray an array populated with Solid Particles objects
  101739. * @returns the SPS
  101740. */
  101741. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  101742. /**
  101743. * Creates a new particle and modifies the SPS mesh geometry :
  101744. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  101745. * - calls _addParticle() to populate the particle array
  101746. * factorized code from addShape() and insertParticlesFromArray()
  101747. * @param idx particle index in the particles array
  101748. * @param i particle index in its shape
  101749. * @param modelShape particle ModelShape object
  101750. * @param shape shape vertex array
  101751. * @param meshInd shape indices array
  101752. * @param meshUV shape uv array
  101753. * @param meshCol shape color array
  101754. * @param meshNor shape normals array
  101755. * @param bbInfo shape bounding info
  101756. * @param storage target particle storage
  101757. * @options addShape() passed options
  101758. * @hidden
  101759. */
  101760. private _insertNewParticle;
  101761. /**
  101762. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  101763. * This method calls `updateParticle()` for each particle of the SPS.
  101764. * For an animated SPS, it is usually called within the render loop.
  101765. * 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.
  101766. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  101767. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  101768. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  101769. * @returns the SPS.
  101770. */
  101771. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  101772. /**
  101773. * Disposes the SPS.
  101774. */
  101775. dispose(): void;
  101776. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  101777. * idx is the particle index in the SPS
  101778. * faceId is the picked face index counted within this particle.
  101779. * Returns null if the pickInfo can't identify a picked particle.
  101780. * @param pickingInfo (PickingInfo object)
  101781. * @returns {idx: number, faceId: number} or null
  101782. */
  101783. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  101784. idx: number;
  101785. faceId: number;
  101786. }>;
  101787. /**
  101788. * Returns a SolidParticle object from its identifier : particle.id
  101789. * @param id (integer) the particle Id
  101790. * @returns the searched particle or null if not found in the SPS.
  101791. */
  101792. getParticleById(id: number): Nullable<SolidParticle>;
  101793. /**
  101794. * Returns a new array populated with the particles having the passed shapeId.
  101795. * @param shapeId (integer) the shape identifier
  101796. * @returns a new solid particle array
  101797. */
  101798. getParticlesByShapeId(shapeId: number): SolidParticle[];
  101799. /**
  101800. * Populates the passed array "ref" with the particles having the passed shapeId.
  101801. * @param shapeId the shape identifier
  101802. * @returns the SPS
  101803. * @param ref
  101804. */
  101805. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  101806. /**
  101807. * Computes the required SubMeshes according the materials assigned to the particles.
  101808. * @returns the solid particle system.
  101809. * Does nothing if called before the SPS mesh is built.
  101810. */
  101811. computeSubMeshes(): SolidParticleSystem;
  101812. /**
  101813. * Sorts the solid particles by material when MultiMaterial is enabled.
  101814. * Updates the indices32 array.
  101815. * Updates the indicesByMaterial array.
  101816. * Updates the mesh indices array.
  101817. * @returns the SPS
  101818. * @hidden
  101819. */
  101820. private _sortParticlesByMaterial;
  101821. /**
  101822. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  101823. * @hidden
  101824. */
  101825. private _setMaterialIndexesById;
  101826. /**
  101827. * Returns an array with unique values of Materials from the passed array
  101828. * @param array the material array to be checked and filtered
  101829. * @hidden
  101830. */
  101831. private _filterUniqueMaterialId;
  101832. /**
  101833. * Sets a new Standard Material as _defaultMaterial if not already set.
  101834. * @hidden
  101835. */
  101836. private _setDefaultMaterial;
  101837. /**
  101838. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  101839. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  101840. * @returns the SPS.
  101841. */
  101842. refreshVisibleSize(): SolidParticleSystem;
  101843. /**
  101844. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  101845. * @param size the size (float) of the visibility box
  101846. * note : this doesn't lock the SPS mesh bounding box.
  101847. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  101848. */
  101849. setVisibilityBox(size: number): void;
  101850. /**
  101851. * Gets whether the SPS as always visible or not
  101852. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  101853. */
  101854. get isAlwaysVisible(): boolean;
  101855. /**
  101856. * Sets the SPS as always visible or not
  101857. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  101858. */
  101859. set isAlwaysVisible(val: boolean);
  101860. /**
  101861. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  101862. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  101863. */
  101864. set isVisibilityBoxLocked(val: boolean);
  101865. /**
  101866. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  101867. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  101868. */
  101869. get isVisibilityBoxLocked(): boolean;
  101870. /**
  101871. * Tells to `setParticles()` to compute the particle rotations or not.
  101872. * Default value : true. The SPS is faster when it's set to false.
  101873. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  101874. */
  101875. set computeParticleRotation(val: boolean);
  101876. /**
  101877. * Tells to `setParticles()` to compute the particle colors or not.
  101878. * Default value : true. The SPS is faster when it's set to false.
  101879. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  101880. */
  101881. set computeParticleColor(val: boolean);
  101882. set computeParticleTexture(val: boolean);
  101883. /**
  101884. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  101885. * Default value : false. The SPS is faster when it's set to false.
  101886. * Note : the particle custom vertex positions aren't stored values.
  101887. */
  101888. set computeParticleVertex(val: boolean);
  101889. /**
  101890. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  101891. */
  101892. set computeBoundingBox(val: boolean);
  101893. /**
  101894. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  101895. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  101896. * Default : `true`
  101897. */
  101898. set depthSortParticles(val: boolean);
  101899. /**
  101900. * Gets if `setParticles()` computes the particle rotations or not.
  101901. * Default value : true. The SPS is faster when it's set to false.
  101902. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  101903. */
  101904. get computeParticleRotation(): boolean;
  101905. /**
  101906. * Gets if `setParticles()` computes the particle colors or not.
  101907. * Default value : true. The SPS is faster when it's set to false.
  101908. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  101909. */
  101910. get computeParticleColor(): boolean;
  101911. /**
  101912. * Gets if `setParticles()` computes the particle textures or not.
  101913. * Default value : true. The SPS is faster when it's set to false.
  101914. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  101915. */
  101916. get computeParticleTexture(): boolean;
  101917. /**
  101918. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  101919. * Default value : false. The SPS is faster when it's set to false.
  101920. * Note : the particle custom vertex positions aren't stored values.
  101921. */
  101922. get computeParticleVertex(): boolean;
  101923. /**
  101924. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  101925. */
  101926. get computeBoundingBox(): boolean;
  101927. /**
  101928. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  101929. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  101930. * Default : `true`
  101931. */
  101932. get depthSortParticles(): boolean;
  101933. /**
  101934. * Gets if the SPS is created as expandable at construction time.
  101935. * Default : `false`
  101936. */
  101937. get expandable(): boolean;
  101938. /**
  101939. * Gets if the SPS supports the Multi Materials
  101940. */
  101941. get multimaterialEnabled(): boolean;
  101942. /**
  101943. * Gets if the SPS uses the model materials for its own multimaterial.
  101944. */
  101945. get useModelMaterial(): boolean;
  101946. /**
  101947. * The SPS used material array.
  101948. */
  101949. get materials(): Material[];
  101950. /**
  101951. * Sets the SPS MultiMaterial from the passed materials.
  101952. * Note : the passed array is internally copied and not used then by reference.
  101953. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  101954. */
  101955. setMultiMaterial(materials: Material[]): void;
  101956. /**
  101957. * The SPS computed multimaterial object
  101958. */
  101959. get multimaterial(): MultiMaterial;
  101960. set multimaterial(mm: MultiMaterial);
  101961. /**
  101962. * If the subMeshes must be updated on the next call to setParticles()
  101963. */
  101964. get autoUpdateSubMeshes(): boolean;
  101965. set autoUpdateSubMeshes(val: boolean);
  101966. /**
  101967. * This function does nothing. It may be overwritten to set all the particle first values.
  101968. * The SPS doesn't call this function, you may have to call it by your own.
  101969. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  101970. */
  101971. initParticles(): void;
  101972. /**
  101973. * This function does nothing. It may be overwritten to recycle a particle.
  101974. * The SPS doesn't call this function, you may have to call it by your own.
  101975. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  101976. * @param particle The particle to recycle
  101977. * @returns the recycled particle
  101978. */
  101979. recycleParticle(particle: SolidParticle): SolidParticle;
  101980. /**
  101981. * Updates a particle : this function should be overwritten by the user.
  101982. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  101983. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  101984. * @example : just set a particle position or velocity and recycle conditions
  101985. * @param particle The particle to update
  101986. * @returns the updated particle
  101987. */
  101988. updateParticle(particle: SolidParticle): SolidParticle;
  101989. /**
  101990. * Updates a vertex of a particle : it can be overwritten by the user.
  101991. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  101992. * @param particle the current particle
  101993. * @param vertex the current index of the current particle
  101994. * @param pt the index of the current vertex in the particle shape
  101995. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  101996. * @example : just set a vertex particle position
  101997. * @returns the updated vertex
  101998. */
  101999. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  102000. /**
  102001. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  102002. * This does nothing and may be overwritten by the user.
  102003. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  102004. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  102005. * @param update the boolean update value actually passed to setParticles()
  102006. */
  102007. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  102008. /**
  102009. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  102010. * This will be passed three parameters.
  102011. * This does nothing and may be overwritten by the user.
  102012. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  102013. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  102014. * @param update the boolean update value actually passed to setParticles()
  102015. */
  102016. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  102017. }
  102018. }
  102019. declare module BABYLON {
  102020. /**
  102021. * Represents one particle of a solid particle system.
  102022. */
  102023. export class SolidParticle {
  102024. /**
  102025. * particle global index
  102026. */
  102027. idx: number;
  102028. /**
  102029. * particle identifier
  102030. */
  102031. id: number;
  102032. /**
  102033. * The color of the particle
  102034. */
  102035. color: Nullable<Color4>;
  102036. /**
  102037. * The world space position of the particle.
  102038. */
  102039. position: Vector3;
  102040. /**
  102041. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  102042. */
  102043. rotation: Vector3;
  102044. /**
  102045. * The world space rotation quaternion of the particle.
  102046. */
  102047. rotationQuaternion: Nullable<Quaternion>;
  102048. /**
  102049. * The scaling of the particle.
  102050. */
  102051. scaling: Vector3;
  102052. /**
  102053. * The uvs of the particle.
  102054. */
  102055. uvs: Vector4;
  102056. /**
  102057. * The current speed of the particle.
  102058. */
  102059. velocity: Vector3;
  102060. /**
  102061. * The pivot point in the particle local space.
  102062. */
  102063. pivot: Vector3;
  102064. /**
  102065. * Must the particle be translated from its pivot point in its local space ?
  102066. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  102067. * Default : false
  102068. */
  102069. translateFromPivot: boolean;
  102070. /**
  102071. * Is the particle active or not ?
  102072. */
  102073. alive: boolean;
  102074. /**
  102075. * Is the particle visible or not ?
  102076. */
  102077. isVisible: boolean;
  102078. /**
  102079. * Index of this particle in the global "positions" array (Internal use)
  102080. * @hidden
  102081. */
  102082. _pos: number;
  102083. /**
  102084. * @hidden Index of this particle in the global "indices" array (Internal use)
  102085. */
  102086. _ind: number;
  102087. /**
  102088. * @hidden ModelShape of this particle (Internal use)
  102089. */
  102090. _model: ModelShape;
  102091. /**
  102092. * ModelShape id of this particle
  102093. */
  102094. shapeId: number;
  102095. /**
  102096. * Index of the particle in its shape id
  102097. */
  102098. idxInShape: number;
  102099. /**
  102100. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  102101. */
  102102. _modelBoundingInfo: BoundingInfo;
  102103. /**
  102104. * @hidden Particle BoundingInfo object (Internal use)
  102105. */
  102106. _boundingInfo: BoundingInfo;
  102107. /**
  102108. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  102109. */
  102110. _sps: SolidParticleSystem;
  102111. /**
  102112. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  102113. */
  102114. _stillInvisible: boolean;
  102115. /**
  102116. * @hidden Last computed particle rotation matrix
  102117. */
  102118. _rotationMatrix: number[];
  102119. /**
  102120. * Parent particle Id, if any.
  102121. * Default null.
  102122. */
  102123. parentId: Nullable<number>;
  102124. /**
  102125. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  102126. */
  102127. materialIndex: Nullable<number>;
  102128. /**
  102129. * Custom object or properties.
  102130. */
  102131. props: Nullable<any>;
  102132. /**
  102133. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  102134. * The possible values are :
  102135. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  102136. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  102137. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  102138. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  102139. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  102140. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  102141. * */
  102142. cullingStrategy: number;
  102143. /**
  102144. * @hidden Internal global position in the SPS.
  102145. */
  102146. _globalPosition: Vector3;
  102147. /**
  102148. * Creates a Solid Particle object.
  102149. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  102150. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  102151. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  102152. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  102153. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  102154. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  102155. * @param shapeId (integer) is the model shape identifier in the SPS.
  102156. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  102157. * @param sps defines the sps it is associated to
  102158. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  102159. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  102160. */
  102161. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  102162. /**
  102163. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  102164. * @param target the particle target
  102165. * @returns the current particle
  102166. */
  102167. copyToRef(target: SolidParticle): SolidParticle;
  102168. /**
  102169. * Legacy support, changed scale to scaling
  102170. */
  102171. get scale(): Vector3;
  102172. /**
  102173. * Legacy support, changed scale to scaling
  102174. */
  102175. set scale(scale: Vector3);
  102176. /**
  102177. * Legacy support, changed quaternion to rotationQuaternion
  102178. */
  102179. get quaternion(): Nullable<Quaternion>;
  102180. /**
  102181. * Legacy support, changed quaternion to rotationQuaternion
  102182. */
  102183. set quaternion(q: Nullable<Quaternion>);
  102184. /**
  102185. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  102186. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  102187. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  102188. * @returns true if it intersects
  102189. */
  102190. intersectsMesh(target: Mesh | SolidParticle): boolean;
  102191. /**
  102192. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  102193. * A particle is in the frustum if its bounding box intersects the frustum
  102194. * @param frustumPlanes defines the frustum to test
  102195. * @returns true if the particle is in the frustum planes
  102196. */
  102197. isInFrustum(frustumPlanes: Plane[]): boolean;
  102198. /**
  102199. * get the rotation matrix of the particle
  102200. * @hidden
  102201. */
  102202. getRotationMatrix(m: Matrix): void;
  102203. }
  102204. /**
  102205. * Represents the shape of the model used by one particle of a solid particle system.
  102206. * SPS internal tool, don't use it manually.
  102207. */
  102208. export class ModelShape {
  102209. /**
  102210. * The shape id
  102211. * @hidden
  102212. */
  102213. shapeID: number;
  102214. /**
  102215. * flat array of model positions (internal use)
  102216. * @hidden
  102217. */
  102218. _shape: Vector3[];
  102219. /**
  102220. * flat array of model UVs (internal use)
  102221. * @hidden
  102222. */
  102223. _shapeUV: number[];
  102224. /**
  102225. * color array of the model
  102226. * @hidden
  102227. */
  102228. _shapeColors: number[];
  102229. /**
  102230. * indices array of the model
  102231. * @hidden
  102232. */
  102233. _indices: number[];
  102234. /**
  102235. * normals array of the model
  102236. * @hidden
  102237. */
  102238. _normals: number[];
  102239. /**
  102240. * length of the shape in the model indices array (internal use)
  102241. * @hidden
  102242. */
  102243. _indicesLength: number;
  102244. /**
  102245. * Custom position function (internal use)
  102246. * @hidden
  102247. */
  102248. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  102249. /**
  102250. * Custom vertex function (internal use)
  102251. * @hidden
  102252. */
  102253. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  102254. /**
  102255. * Model material (internal use)
  102256. * @hidden
  102257. */
  102258. _material: Nullable<Material>;
  102259. /**
  102260. * 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.
  102261. * SPS internal tool, don't use it manually.
  102262. * @hidden
  102263. */
  102264. 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>);
  102265. }
  102266. /**
  102267. * Represents a Depth Sorted Particle in the solid particle system.
  102268. * @hidden
  102269. */
  102270. export class DepthSortedParticle {
  102271. /**
  102272. * Particle index
  102273. */
  102274. idx: number;
  102275. /**
  102276. * Index of the particle in the "indices" array
  102277. */
  102278. ind: number;
  102279. /**
  102280. * Length of the particle shape in the "indices" array
  102281. */
  102282. indicesLength: number;
  102283. /**
  102284. * Squared distance from the particle to the camera
  102285. */
  102286. sqDistance: number;
  102287. /**
  102288. * Material index when used with MultiMaterials
  102289. */
  102290. materialIndex: number;
  102291. /**
  102292. * Creates a new sorted particle
  102293. * @param materialIndex
  102294. */
  102295. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  102296. }
  102297. }
  102298. declare module BABYLON {
  102299. /**
  102300. * @hidden
  102301. */
  102302. export class _MeshCollisionData {
  102303. _checkCollisions: boolean;
  102304. _collisionMask: number;
  102305. _collisionGroup: number;
  102306. _surroundingMeshes: Nullable<AbstractMesh[]>;
  102307. _collider: Nullable<Collider>;
  102308. _oldPositionForCollisions: Vector3;
  102309. _diffPositionForCollisions: Vector3;
  102310. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  102311. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  102312. }
  102313. }
  102314. declare module BABYLON {
  102315. /** @hidden */
  102316. class _FacetDataStorage {
  102317. facetPositions: Vector3[];
  102318. facetNormals: Vector3[];
  102319. facetPartitioning: number[][];
  102320. facetNb: number;
  102321. partitioningSubdivisions: number;
  102322. partitioningBBoxRatio: number;
  102323. facetDataEnabled: boolean;
  102324. facetParameters: any;
  102325. bbSize: Vector3;
  102326. subDiv: {
  102327. max: number;
  102328. X: number;
  102329. Y: number;
  102330. Z: number;
  102331. };
  102332. facetDepthSort: boolean;
  102333. facetDepthSortEnabled: boolean;
  102334. depthSortedIndices: IndicesArray;
  102335. depthSortedFacets: {
  102336. ind: number;
  102337. sqDistance: number;
  102338. }[];
  102339. facetDepthSortFunction: (f1: {
  102340. ind: number;
  102341. sqDistance: number;
  102342. }, f2: {
  102343. ind: number;
  102344. sqDistance: number;
  102345. }) => number;
  102346. facetDepthSortFrom: Vector3;
  102347. facetDepthSortOrigin: Vector3;
  102348. invertedMatrix: Matrix;
  102349. }
  102350. /**
  102351. * @hidden
  102352. **/
  102353. class _InternalAbstractMeshDataInfo {
  102354. _hasVertexAlpha: boolean;
  102355. _useVertexColors: boolean;
  102356. _numBoneInfluencers: number;
  102357. _applyFog: boolean;
  102358. _receiveShadows: boolean;
  102359. _facetData: _FacetDataStorage;
  102360. _visibility: number;
  102361. _skeleton: Nullable<Skeleton>;
  102362. _layerMask: number;
  102363. _computeBonesUsingShaders: boolean;
  102364. _isActive: boolean;
  102365. _onlyForInstances: boolean;
  102366. _isActiveIntermediate: boolean;
  102367. _onlyForInstancesIntermediate: boolean;
  102368. _actAsRegularMesh: boolean;
  102369. }
  102370. /**
  102371. * Class used to store all common mesh properties
  102372. */
  102373. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  102374. /** No occlusion */
  102375. static OCCLUSION_TYPE_NONE: number;
  102376. /** Occlusion set to optimisitic */
  102377. static OCCLUSION_TYPE_OPTIMISTIC: number;
  102378. /** Occlusion set to strict */
  102379. static OCCLUSION_TYPE_STRICT: number;
  102380. /** Use an accurante occlusion algorithm */
  102381. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  102382. /** Use a conservative occlusion algorithm */
  102383. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  102384. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  102385. * Test order :
  102386. * Is the bounding sphere outside the frustum ?
  102387. * If not, are the bounding box vertices outside the frustum ?
  102388. * It not, then the cullable object is in the frustum.
  102389. */
  102390. static readonly CULLINGSTRATEGY_STANDARD: number;
  102391. /** Culling strategy : Bounding Sphere Only.
  102392. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  102393. * It's also less accurate than the standard because some not visible objects can still be selected.
  102394. * Test : is the bounding sphere outside the frustum ?
  102395. * If not, then the cullable object is in the frustum.
  102396. */
  102397. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  102398. /** Culling strategy : Optimistic Inclusion.
  102399. * This in an inclusion test first, then the standard exclusion test.
  102400. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  102401. * 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.
  102402. * Anyway, it's as accurate as the standard strategy.
  102403. * Test :
  102404. * Is the cullable object bounding sphere center in the frustum ?
  102405. * If not, apply the default culling strategy.
  102406. */
  102407. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  102408. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  102409. * This in an inclusion test first, then the bounding sphere only exclusion test.
  102410. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  102411. * 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.
  102412. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  102413. * Test :
  102414. * Is the cullable object bounding sphere center in the frustum ?
  102415. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  102416. */
  102417. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  102418. /**
  102419. * No billboard
  102420. */
  102421. static get BILLBOARDMODE_NONE(): number;
  102422. /** Billboard on X axis */
  102423. static get BILLBOARDMODE_X(): number;
  102424. /** Billboard on Y axis */
  102425. static get BILLBOARDMODE_Y(): number;
  102426. /** Billboard on Z axis */
  102427. static get BILLBOARDMODE_Z(): number;
  102428. /** Billboard on all axes */
  102429. static get BILLBOARDMODE_ALL(): number;
  102430. /** Billboard on using position instead of orientation */
  102431. static get BILLBOARDMODE_USE_POSITION(): number;
  102432. /** @hidden */
  102433. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  102434. /**
  102435. * The culling strategy to use to check whether the mesh must be rendered or not.
  102436. * This value can be changed at any time and will be used on the next render mesh selection.
  102437. * The possible values are :
  102438. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  102439. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  102440. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  102441. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  102442. * Please read each static variable documentation to get details about the culling process.
  102443. * */
  102444. cullingStrategy: number;
  102445. /**
  102446. * Gets the number of facets in the mesh
  102447. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  102448. */
  102449. get facetNb(): number;
  102450. /**
  102451. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  102452. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  102453. */
  102454. get partitioningSubdivisions(): number;
  102455. set partitioningSubdivisions(nb: number);
  102456. /**
  102457. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  102458. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  102459. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  102460. */
  102461. get partitioningBBoxRatio(): number;
  102462. set partitioningBBoxRatio(ratio: number);
  102463. /**
  102464. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  102465. * Works only for updatable meshes.
  102466. * Doesn't work with multi-materials
  102467. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  102468. */
  102469. get mustDepthSortFacets(): boolean;
  102470. set mustDepthSortFacets(sort: boolean);
  102471. /**
  102472. * The location (Vector3) where the facet depth sort must be computed from.
  102473. * By default, the active camera position.
  102474. * Used only when facet depth sort is enabled
  102475. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  102476. */
  102477. get facetDepthSortFrom(): Vector3;
  102478. set facetDepthSortFrom(location: Vector3);
  102479. /**
  102480. * gets a boolean indicating if facetData is enabled
  102481. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  102482. */
  102483. get isFacetDataEnabled(): boolean;
  102484. /** @hidden */
  102485. _updateNonUniformScalingState(value: boolean): boolean;
  102486. /**
  102487. * An event triggered when this mesh collides with another one
  102488. */
  102489. onCollideObservable: Observable<AbstractMesh>;
  102490. /** Set a function to call when this mesh collides with another one */
  102491. set onCollide(callback: () => void);
  102492. /**
  102493. * An event triggered when the collision's position changes
  102494. */
  102495. onCollisionPositionChangeObservable: Observable<Vector3>;
  102496. /** Set a function to call when the collision's position changes */
  102497. set onCollisionPositionChange(callback: () => void);
  102498. /**
  102499. * An event triggered when material is changed
  102500. */
  102501. onMaterialChangedObservable: Observable<AbstractMesh>;
  102502. /**
  102503. * Gets or sets the orientation for POV movement & rotation
  102504. */
  102505. definedFacingForward: boolean;
  102506. /** @hidden */
  102507. _occlusionQuery: Nullable<WebGLQuery>;
  102508. /** @hidden */
  102509. _renderingGroup: Nullable<RenderingGroup>;
  102510. /**
  102511. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  102512. */
  102513. get visibility(): number;
  102514. /**
  102515. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  102516. */
  102517. set visibility(value: number);
  102518. /** Gets or sets the alpha index used to sort transparent meshes
  102519. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  102520. */
  102521. alphaIndex: number;
  102522. /**
  102523. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  102524. */
  102525. isVisible: boolean;
  102526. /**
  102527. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  102528. */
  102529. isPickable: boolean;
  102530. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  102531. showSubMeshesBoundingBox: boolean;
  102532. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  102533. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  102534. */
  102535. isBlocker: boolean;
  102536. /**
  102537. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  102538. */
  102539. enablePointerMoveEvents: boolean;
  102540. /**
  102541. * Specifies the rendering group id for this mesh (0 by default)
  102542. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  102543. */
  102544. renderingGroupId: number;
  102545. private _material;
  102546. /** Gets or sets current material */
  102547. get material(): Nullable<Material>;
  102548. set material(value: Nullable<Material>);
  102549. /**
  102550. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  102551. * @see http://doc.babylonjs.com/babylon101/shadows
  102552. */
  102553. get receiveShadows(): boolean;
  102554. set receiveShadows(value: boolean);
  102555. /** Defines color to use when rendering outline */
  102556. outlineColor: Color3;
  102557. /** Define width to use when rendering outline */
  102558. outlineWidth: number;
  102559. /** Defines color to use when rendering overlay */
  102560. overlayColor: Color3;
  102561. /** Defines alpha to use when rendering overlay */
  102562. overlayAlpha: number;
  102563. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  102564. get hasVertexAlpha(): boolean;
  102565. set hasVertexAlpha(value: boolean);
  102566. /** 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) */
  102567. get useVertexColors(): boolean;
  102568. set useVertexColors(value: boolean);
  102569. /**
  102570. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  102571. */
  102572. get computeBonesUsingShaders(): boolean;
  102573. set computeBonesUsingShaders(value: boolean);
  102574. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  102575. get numBoneInfluencers(): number;
  102576. set numBoneInfluencers(value: number);
  102577. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  102578. get applyFog(): boolean;
  102579. set applyFog(value: boolean);
  102580. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  102581. useOctreeForRenderingSelection: boolean;
  102582. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  102583. useOctreeForPicking: boolean;
  102584. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  102585. useOctreeForCollisions: boolean;
  102586. /**
  102587. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  102588. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  102589. */
  102590. get layerMask(): number;
  102591. set layerMask(value: number);
  102592. /**
  102593. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  102594. */
  102595. alwaysSelectAsActiveMesh: boolean;
  102596. /**
  102597. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  102598. */
  102599. doNotSyncBoundingInfo: boolean;
  102600. /**
  102601. * Gets or sets the current action manager
  102602. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  102603. */
  102604. actionManager: Nullable<AbstractActionManager>;
  102605. private _meshCollisionData;
  102606. /**
  102607. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  102608. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  102609. */
  102610. ellipsoid: Vector3;
  102611. /**
  102612. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  102613. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  102614. */
  102615. ellipsoidOffset: Vector3;
  102616. /**
  102617. * Gets or sets a collision mask used to mask collisions (default is -1).
  102618. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  102619. */
  102620. get collisionMask(): number;
  102621. set collisionMask(mask: number);
  102622. /**
  102623. * Gets or sets the current collision group mask (-1 by default).
  102624. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  102625. */
  102626. get collisionGroup(): number;
  102627. set collisionGroup(mask: number);
  102628. /**
  102629. * Gets or sets current surrounding meshes (null by default).
  102630. *
  102631. * By default collision detection is tested against every mesh in the scene.
  102632. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  102633. * meshes will be tested for the collision.
  102634. *
  102635. * Note: if set to an empty array no collision will happen when this mesh is moved.
  102636. */
  102637. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  102638. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  102639. /**
  102640. * Defines edge width used when edgesRenderer is enabled
  102641. * @see https://www.babylonjs-playground.com/#10OJSG#13
  102642. */
  102643. edgesWidth: number;
  102644. /**
  102645. * Defines edge color used when edgesRenderer is enabled
  102646. * @see https://www.babylonjs-playground.com/#10OJSG#13
  102647. */
  102648. edgesColor: Color4;
  102649. /** @hidden */
  102650. _edgesRenderer: Nullable<IEdgesRenderer>;
  102651. /** @hidden */
  102652. _masterMesh: Nullable<AbstractMesh>;
  102653. /** @hidden */
  102654. _boundingInfo: Nullable<BoundingInfo>;
  102655. /** @hidden */
  102656. _renderId: number;
  102657. /**
  102658. * Gets or sets the list of subMeshes
  102659. * @see http://doc.babylonjs.com/how_to/multi_materials
  102660. */
  102661. subMeshes: SubMesh[];
  102662. /** @hidden */
  102663. _intersectionsInProgress: AbstractMesh[];
  102664. /** @hidden */
  102665. _unIndexed: boolean;
  102666. /** @hidden */
  102667. _lightSources: Light[];
  102668. /** Gets the list of lights affecting that mesh */
  102669. get lightSources(): Light[];
  102670. /** @hidden */
  102671. get _positions(): Nullable<Vector3[]>;
  102672. /** @hidden */
  102673. _waitingData: {
  102674. lods: Nullable<any>;
  102675. actions: Nullable<any>;
  102676. freezeWorldMatrix: Nullable<boolean>;
  102677. };
  102678. /** @hidden */
  102679. _bonesTransformMatrices: Nullable<Float32Array>;
  102680. /** @hidden */
  102681. _transformMatrixTexture: Nullable<RawTexture>;
  102682. /**
  102683. * Gets or sets a skeleton to apply skining transformations
  102684. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  102685. */
  102686. set skeleton(value: Nullable<Skeleton>);
  102687. get skeleton(): Nullable<Skeleton>;
  102688. /**
  102689. * An event triggered when the mesh is rebuilt.
  102690. */
  102691. onRebuildObservable: Observable<AbstractMesh>;
  102692. /**
  102693. * Creates a new AbstractMesh
  102694. * @param name defines the name of the mesh
  102695. * @param scene defines the hosting scene
  102696. */
  102697. constructor(name: string, scene?: Nullable<Scene>);
  102698. /**
  102699. * Returns the string "AbstractMesh"
  102700. * @returns "AbstractMesh"
  102701. */
  102702. getClassName(): string;
  102703. /**
  102704. * Gets a string representation of the current mesh
  102705. * @param fullDetails defines a boolean indicating if full details must be included
  102706. * @returns a string representation of the current mesh
  102707. */
  102708. toString(fullDetails?: boolean): string;
  102709. /**
  102710. * @hidden
  102711. */
  102712. protected _getEffectiveParent(): Nullable<Node>;
  102713. /** @hidden */
  102714. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  102715. /** @hidden */
  102716. _rebuild(): void;
  102717. /** @hidden */
  102718. _resyncLightSources(): void;
  102719. /** @hidden */
  102720. _resyncLightSource(light: Light): void;
  102721. /** @hidden */
  102722. _unBindEffect(): void;
  102723. /** @hidden */
  102724. _removeLightSource(light: Light, dispose: boolean): void;
  102725. private _markSubMeshesAsDirty;
  102726. /** @hidden */
  102727. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  102728. /** @hidden */
  102729. _markSubMeshesAsAttributesDirty(): void;
  102730. /** @hidden */
  102731. _markSubMeshesAsMiscDirty(): void;
  102732. /**
  102733. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  102734. */
  102735. get scaling(): Vector3;
  102736. set scaling(newScaling: Vector3);
  102737. /**
  102738. * Returns true if the mesh is blocked. Implemented by child classes
  102739. */
  102740. get isBlocked(): boolean;
  102741. /**
  102742. * Returns the mesh itself by default. Implemented by child classes
  102743. * @param camera defines the camera to use to pick the right LOD level
  102744. * @returns the currentAbstractMesh
  102745. */
  102746. getLOD(camera: Camera): Nullable<AbstractMesh>;
  102747. /**
  102748. * Returns 0 by default. Implemented by child classes
  102749. * @returns an integer
  102750. */
  102751. getTotalVertices(): number;
  102752. /**
  102753. * Returns a positive integer : the total number of indices in this mesh geometry.
  102754. * @returns the numner of indices or zero if the mesh has no geometry.
  102755. */
  102756. getTotalIndices(): number;
  102757. /**
  102758. * Returns null by default. Implemented by child classes
  102759. * @returns null
  102760. */
  102761. getIndices(): Nullable<IndicesArray>;
  102762. /**
  102763. * Returns the array of the requested vertex data kind. Implemented by child classes
  102764. * @param kind defines the vertex data kind to use
  102765. * @returns null
  102766. */
  102767. getVerticesData(kind: string): Nullable<FloatArray>;
  102768. /**
  102769. * Sets the vertex data of the mesh geometry for the requested `kind`.
  102770. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  102771. * Note that a new underlying VertexBuffer object is created each call.
  102772. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  102773. * @param kind defines vertex data kind:
  102774. * * VertexBuffer.PositionKind
  102775. * * VertexBuffer.UVKind
  102776. * * VertexBuffer.UV2Kind
  102777. * * VertexBuffer.UV3Kind
  102778. * * VertexBuffer.UV4Kind
  102779. * * VertexBuffer.UV5Kind
  102780. * * VertexBuffer.UV6Kind
  102781. * * VertexBuffer.ColorKind
  102782. * * VertexBuffer.MatricesIndicesKind
  102783. * * VertexBuffer.MatricesIndicesExtraKind
  102784. * * VertexBuffer.MatricesWeightsKind
  102785. * * VertexBuffer.MatricesWeightsExtraKind
  102786. * @param data defines the data source
  102787. * @param updatable defines if the data must be flagged as updatable (or static)
  102788. * @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
  102789. * @returns the current mesh
  102790. */
  102791. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  102792. /**
  102793. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  102794. * If the mesh has no geometry, it is simply returned as it is.
  102795. * @param kind defines vertex data kind:
  102796. * * VertexBuffer.PositionKind
  102797. * * VertexBuffer.UVKind
  102798. * * VertexBuffer.UV2Kind
  102799. * * VertexBuffer.UV3Kind
  102800. * * VertexBuffer.UV4Kind
  102801. * * VertexBuffer.UV5Kind
  102802. * * VertexBuffer.UV6Kind
  102803. * * VertexBuffer.ColorKind
  102804. * * VertexBuffer.MatricesIndicesKind
  102805. * * VertexBuffer.MatricesIndicesExtraKind
  102806. * * VertexBuffer.MatricesWeightsKind
  102807. * * VertexBuffer.MatricesWeightsExtraKind
  102808. * @param data defines the data source
  102809. * @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
  102810. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  102811. * @returns the current mesh
  102812. */
  102813. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  102814. /**
  102815. * Sets the mesh indices,
  102816. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  102817. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  102818. * @param totalVertices Defines the total number of vertices
  102819. * @returns the current mesh
  102820. */
  102821. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  102822. /**
  102823. * Gets a boolean indicating if specific vertex data is present
  102824. * @param kind defines the vertex data kind to use
  102825. * @returns true is data kind is present
  102826. */
  102827. isVerticesDataPresent(kind: string): boolean;
  102828. /**
  102829. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  102830. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  102831. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  102832. * @returns a BoundingInfo
  102833. */
  102834. getBoundingInfo(): BoundingInfo;
  102835. /**
  102836. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  102837. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  102838. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  102839. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  102840. * @returns the current mesh
  102841. */
  102842. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  102843. /**
  102844. * Overwrite the current bounding info
  102845. * @param boundingInfo defines the new bounding info
  102846. * @returns the current mesh
  102847. */
  102848. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  102849. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  102850. get useBones(): boolean;
  102851. /** @hidden */
  102852. _preActivate(): void;
  102853. /** @hidden */
  102854. _preActivateForIntermediateRendering(renderId: number): void;
  102855. /** @hidden */
  102856. _activate(renderId: number, intermediateRendering: boolean): boolean;
  102857. /** @hidden */
  102858. _postActivate(): void;
  102859. /** @hidden */
  102860. _freeze(): void;
  102861. /** @hidden */
  102862. _unFreeze(): void;
  102863. /**
  102864. * Gets the current world matrix
  102865. * @returns a Matrix
  102866. */
  102867. getWorldMatrix(): Matrix;
  102868. /** @hidden */
  102869. _getWorldMatrixDeterminant(): number;
  102870. /**
  102871. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  102872. */
  102873. get isAnInstance(): boolean;
  102874. /**
  102875. * Gets a boolean indicating if this mesh has instances
  102876. */
  102877. get hasInstances(): boolean;
  102878. /**
  102879. * Perform relative position change from the point of view of behind the front of the mesh.
  102880. * This is performed taking into account the meshes current rotation, so you do not have to care.
  102881. * Supports definition of mesh facing forward or backward
  102882. * @param amountRight defines the distance on the right axis
  102883. * @param amountUp defines the distance on the up axis
  102884. * @param amountForward defines the distance on the forward axis
  102885. * @returns the current mesh
  102886. */
  102887. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  102888. /**
  102889. * Calculate relative position change from the point of view of behind the front of the mesh.
  102890. * This is performed taking into account the meshes current rotation, so you do not have to care.
  102891. * Supports definition of mesh facing forward or backward
  102892. * @param amountRight defines the distance on the right axis
  102893. * @param amountUp defines the distance on the up axis
  102894. * @param amountForward defines the distance on the forward axis
  102895. * @returns the new displacement vector
  102896. */
  102897. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  102898. /**
  102899. * Perform relative rotation change from the point of view of behind the front of the mesh.
  102900. * Supports definition of mesh facing forward or backward
  102901. * @param flipBack defines the flip
  102902. * @param twirlClockwise defines the twirl
  102903. * @param tiltRight defines the tilt
  102904. * @returns the current mesh
  102905. */
  102906. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  102907. /**
  102908. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  102909. * Supports definition of mesh facing forward or backward.
  102910. * @param flipBack defines the flip
  102911. * @param twirlClockwise defines the twirl
  102912. * @param tiltRight defines the tilt
  102913. * @returns the new rotation vector
  102914. */
  102915. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  102916. /**
  102917. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  102918. * This means the mesh underlying bounding box and sphere are recomputed.
  102919. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  102920. * @returns the current mesh
  102921. */
  102922. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  102923. /** @hidden */
  102924. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  102925. /** @hidden */
  102926. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  102927. /** @hidden */
  102928. _updateBoundingInfo(): AbstractMesh;
  102929. /** @hidden */
  102930. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  102931. /** @hidden */
  102932. protected _afterComputeWorldMatrix(): void;
  102933. /** @hidden */
  102934. get _effectiveMesh(): AbstractMesh;
  102935. /**
  102936. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  102937. * A mesh is in the frustum if its bounding box intersects the frustum
  102938. * @param frustumPlanes defines the frustum to test
  102939. * @returns true if the mesh is in the frustum planes
  102940. */
  102941. isInFrustum(frustumPlanes: Plane[]): boolean;
  102942. /**
  102943. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  102944. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  102945. * @param frustumPlanes defines the frustum to test
  102946. * @returns true if the mesh is completely in the frustum planes
  102947. */
  102948. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  102949. /**
  102950. * True if the mesh intersects another mesh or a SolidParticle object
  102951. * @param mesh defines a target mesh or SolidParticle to test
  102952. * @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)
  102953. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  102954. * @returns true if there is an intersection
  102955. */
  102956. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  102957. /**
  102958. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  102959. * @param point defines the point to test
  102960. * @returns true if there is an intersection
  102961. */
  102962. intersectsPoint(point: Vector3): boolean;
  102963. /**
  102964. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  102965. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  102966. */
  102967. get checkCollisions(): boolean;
  102968. set checkCollisions(collisionEnabled: boolean);
  102969. /**
  102970. * Gets Collider object used to compute collisions (not physics)
  102971. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  102972. */
  102973. get collider(): Nullable<Collider>;
  102974. /**
  102975. * Move the mesh using collision engine
  102976. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  102977. * @param displacement defines the requested displacement vector
  102978. * @returns the current mesh
  102979. */
  102980. moveWithCollisions(displacement: Vector3): AbstractMesh;
  102981. private _onCollisionPositionChange;
  102982. /** @hidden */
  102983. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  102984. /** @hidden */
  102985. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  102986. /** @hidden */
  102987. _checkCollision(collider: Collider): AbstractMesh;
  102988. /** @hidden */
  102989. _generatePointsArray(): boolean;
  102990. /**
  102991. * Checks if the passed Ray intersects with the mesh
  102992. * @param ray defines the ray to use
  102993. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  102994. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  102995. * @returns the picking info
  102996. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  102997. */
  102998. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  102999. /**
  103000. * Clones the current mesh
  103001. * @param name defines the mesh name
  103002. * @param newParent defines the new mesh parent
  103003. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  103004. * @returns the new mesh
  103005. */
  103006. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  103007. /**
  103008. * Disposes all the submeshes of the current meshnp
  103009. * @returns the current mesh
  103010. */
  103011. releaseSubMeshes(): AbstractMesh;
  103012. /**
  103013. * Releases resources associated with this abstract mesh.
  103014. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  103015. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  103016. */
  103017. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  103018. /**
  103019. * Adds the passed mesh as a child to the current mesh
  103020. * @param mesh defines the child mesh
  103021. * @returns the current mesh
  103022. */
  103023. addChild(mesh: AbstractMesh): AbstractMesh;
  103024. /**
  103025. * Removes the passed mesh from the current mesh children list
  103026. * @param mesh defines the child mesh
  103027. * @returns the current mesh
  103028. */
  103029. removeChild(mesh: AbstractMesh): AbstractMesh;
  103030. /** @hidden */
  103031. private _initFacetData;
  103032. /**
  103033. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  103034. * This method can be called within the render loop.
  103035. * 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
  103036. * @returns the current mesh
  103037. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  103038. */
  103039. updateFacetData(): AbstractMesh;
  103040. /**
  103041. * Returns the facetLocalNormals array.
  103042. * The normals are expressed in the mesh local spac
  103043. * @returns an array of Vector3
  103044. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  103045. */
  103046. getFacetLocalNormals(): Vector3[];
  103047. /**
  103048. * Returns the facetLocalPositions array.
  103049. * The facet positions are expressed in the mesh local space
  103050. * @returns an array of Vector3
  103051. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  103052. */
  103053. getFacetLocalPositions(): Vector3[];
  103054. /**
  103055. * Returns the facetLocalPartioning array
  103056. * @returns an array of array of numbers
  103057. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  103058. */
  103059. getFacetLocalPartitioning(): number[][];
  103060. /**
  103061. * Returns the i-th facet position in the world system.
  103062. * This method allocates a new Vector3 per call
  103063. * @param i defines the facet index
  103064. * @returns a new Vector3
  103065. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  103066. */
  103067. getFacetPosition(i: number): Vector3;
  103068. /**
  103069. * Sets the reference Vector3 with the i-th facet position in the world system
  103070. * @param i defines the facet index
  103071. * @param ref defines the target vector
  103072. * @returns the current mesh
  103073. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  103074. */
  103075. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  103076. /**
  103077. * Returns the i-th facet normal in the world system.
  103078. * This method allocates a new Vector3 per call
  103079. * @param i defines the facet index
  103080. * @returns a new Vector3
  103081. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  103082. */
  103083. getFacetNormal(i: number): Vector3;
  103084. /**
  103085. * Sets the reference Vector3 with the i-th facet normal in the world system
  103086. * @param i defines the facet index
  103087. * @param ref defines the target vector
  103088. * @returns the current mesh
  103089. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  103090. */
  103091. getFacetNormalToRef(i: number, ref: Vector3): this;
  103092. /**
  103093. * 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)
  103094. * @param x defines x coordinate
  103095. * @param y defines y coordinate
  103096. * @param z defines z coordinate
  103097. * @returns the array of facet indexes
  103098. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  103099. */
  103100. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  103101. /**
  103102. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  103103. * @param projected sets as the (x,y,z) world projection on the facet
  103104. * @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
  103105. * @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
  103106. * @param x defines x coordinate
  103107. * @param y defines y coordinate
  103108. * @param z defines z coordinate
  103109. * @returns the face index if found (or null instead)
  103110. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  103111. */
  103112. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  103113. /**
  103114. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  103115. * @param projected sets as the (x,y,z) local projection on the facet
  103116. * @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
  103117. * @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
  103118. * @param x defines x coordinate
  103119. * @param y defines y coordinate
  103120. * @param z defines z coordinate
  103121. * @returns the face index if found (or null instead)
  103122. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  103123. */
  103124. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  103125. /**
  103126. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  103127. * @returns the parameters
  103128. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  103129. */
  103130. getFacetDataParameters(): any;
  103131. /**
  103132. * Disables the feature FacetData and frees the related memory
  103133. * @returns the current mesh
  103134. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  103135. */
  103136. disableFacetData(): AbstractMesh;
  103137. /**
  103138. * Updates the AbstractMesh indices array
  103139. * @param indices defines the data source
  103140. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  103141. * @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)
  103142. * @returns the current mesh
  103143. */
  103144. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  103145. /**
  103146. * Creates new normals data for the mesh
  103147. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  103148. * @returns the current mesh
  103149. */
  103150. createNormals(updatable: boolean): AbstractMesh;
  103151. /**
  103152. * Align the mesh with a normal
  103153. * @param normal defines the normal to use
  103154. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  103155. * @returns the current mesh
  103156. */
  103157. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  103158. /** @hidden */
  103159. _checkOcclusionQuery(): boolean;
  103160. /**
  103161. * Disables the mesh edge rendering mode
  103162. * @returns the currentAbstractMesh
  103163. */
  103164. disableEdgesRendering(): AbstractMesh;
  103165. /**
  103166. * Enables the edge rendering mode on the mesh.
  103167. * This mode makes the mesh edges visible
  103168. * @param epsilon defines the maximal distance between two angles to detect a face
  103169. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  103170. * @returns the currentAbstractMesh
  103171. * @see https://www.babylonjs-playground.com/#19O9TU#0
  103172. */
  103173. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  103174. }
  103175. }
  103176. declare module BABYLON {
  103177. /**
  103178. * Interface used to define ActionEvent
  103179. */
  103180. export interface IActionEvent {
  103181. /** The mesh or sprite that triggered the action */
  103182. source: any;
  103183. /** The X mouse cursor position at the time of the event */
  103184. pointerX: number;
  103185. /** The Y mouse cursor position at the time of the event */
  103186. pointerY: number;
  103187. /** The mesh that is currently pointed at (can be null) */
  103188. meshUnderPointer: Nullable<AbstractMesh>;
  103189. /** the original (browser) event that triggered the ActionEvent */
  103190. sourceEvent?: any;
  103191. /** additional data for the event */
  103192. additionalData?: any;
  103193. }
  103194. /**
  103195. * ActionEvent is the event being sent when an action is triggered.
  103196. */
  103197. export class ActionEvent implements 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. * Creates a new ActionEvent
  103212. * @param source The mesh or sprite that triggered the action
  103213. * @param pointerX The X mouse cursor position at the time of the event
  103214. * @param pointerY The Y mouse cursor position at the time of the event
  103215. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  103216. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  103217. * @param additionalData additional data for the event
  103218. */
  103219. constructor(
  103220. /** The mesh or sprite that triggered the action */
  103221. source: any,
  103222. /** The X mouse cursor position at the time of the event */
  103223. pointerX: number,
  103224. /** The Y mouse cursor position at the time of the event */
  103225. pointerY: number,
  103226. /** The mesh that is currently pointed at (can be null) */
  103227. meshUnderPointer: Nullable<AbstractMesh>,
  103228. /** the original (browser) event that triggered the ActionEvent */
  103229. sourceEvent?: any,
  103230. /** additional data for the event */
  103231. additionalData?: any);
  103232. /**
  103233. * Helper function to auto-create an ActionEvent from a source mesh.
  103234. * @param source The source mesh that triggered the event
  103235. * @param evt The original (browser) event
  103236. * @param additionalData additional data for the event
  103237. * @returns the new ActionEvent
  103238. */
  103239. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  103240. /**
  103241. * Helper function to auto-create an ActionEvent from a source sprite
  103242. * @param source The source sprite that triggered the event
  103243. * @param scene Scene associated with the sprite
  103244. * @param evt The original (browser) event
  103245. * @param additionalData additional data for the event
  103246. * @returns the new ActionEvent
  103247. */
  103248. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  103249. /**
  103250. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  103251. * @param scene the scene where the event occurred
  103252. * @param evt The original (browser) event
  103253. * @returns the new ActionEvent
  103254. */
  103255. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  103256. /**
  103257. * Helper function to auto-create an ActionEvent from a primitive
  103258. * @param prim defines the target primitive
  103259. * @param pointerPos defines the pointer position
  103260. * @param evt The original (browser) event
  103261. * @param additionalData additional data for the event
  103262. * @returns the new ActionEvent
  103263. */
  103264. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  103265. }
  103266. }
  103267. declare module BABYLON {
  103268. /**
  103269. * Abstract class used to decouple action Manager from scene and meshes.
  103270. * Do not instantiate.
  103271. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  103272. */
  103273. export abstract class AbstractActionManager implements IDisposable {
  103274. /** Gets the list of active triggers */
  103275. static Triggers: {
  103276. [key: string]: number;
  103277. };
  103278. /** Gets the cursor to use when hovering items */
  103279. hoverCursor: string;
  103280. /** Gets the list of actions */
  103281. actions: IAction[];
  103282. /**
  103283. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  103284. */
  103285. isRecursive: boolean;
  103286. /**
  103287. * Releases all associated resources
  103288. */
  103289. abstract dispose(): void;
  103290. /**
  103291. * Does this action manager has pointer triggers
  103292. */
  103293. abstract get hasPointerTriggers(): boolean;
  103294. /**
  103295. * Does this action manager has pick triggers
  103296. */
  103297. abstract get hasPickTriggers(): boolean;
  103298. /**
  103299. * Process a specific trigger
  103300. * @param trigger defines the trigger to process
  103301. * @param evt defines the event details to be processed
  103302. */
  103303. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  103304. /**
  103305. * Does this action manager handles actions of any of the given triggers
  103306. * @param triggers defines the triggers to be tested
  103307. * @return a boolean indicating whether one (or more) of the triggers is handled
  103308. */
  103309. abstract hasSpecificTriggers(triggers: number[]): boolean;
  103310. /**
  103311. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  103312. * speed.
  103313. * @param triggerA defines the trigger to be tested
  103314. * @param triggerB defines the trigger to be tested
  103315. * @return a boolean indicating whether one (or more) of the triggers is handled
  103316. */
  103317. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  103318. /**
  103319. * Does this action manager handles actions of a given trigger
  103320. * @param trigger defines the trigger to be tested
  103321. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  103322. * @return whether the trigger is handled
  103323. */
  103324. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  103325. /**
  103326. * Serialize this manager to a JSON object
  103327. * @param name defines the property name to store this manager
  103328. * @returns a JSON representation of this manager
  103329. */
  103330. abstract serialize(name: string): any;
  103331. /**
  103332. * Registers an action to this action manager
  103333. * @param action defines the action to be registered
  103334. * @return the action amended (prepared) after registration
  103335. */
  103336. abstract registerAction(action: IAction): Nullable<IAction>;
  103337. /**
  103338. * Unregisters an action to this action manager
  103339. * @param action defines the action to be unregistered
  103340. * @return a boolean indicating whether the action has been unregistered
  103341. */
  103342. abstract unregisterAction(action: IAction): Boolean;
  103343. /**
  103344. * Does exist one action manager with at least one trigger
  103345. **/
  103346. static get HasTriggers(): boolean;
  103347. /**
  103348. * Does exist one action manager with at least one pick trigger
  103349. **/
  103350. static get HasPickTriggers(): boolean;
  103351. /**
  103352. * Does exist one action manager that handles actions of a given trigger
  103353. * @param trigger defines the trigger to be tested
  103354. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  103355. **/
  103356. static HasSpecificTrigger(trigger: number): boolean;
  103357. }
  103358. }
  103359. declare module BABYLON {
  103360. /**
  103361. * Defines how a node can be built from a string name.
  103362. */
  103363. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  103364. /**
  103365. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  103366. */
  103367. export class Node implements IBehaviorAware<Node> {
  103368. /** @hidden */
  103369. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  103370. private static _NodeConstructors;
  103371. /**
  103372. * Add a new node constructor
  103373. * @param type defines the type name of the node to construct
  103374. * @param constructorFunc defines the constructor function
  103375. */
  103376. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  103377. /**
  103378. * Returns a node constructor based on type name
  103379. * @param type defines the type name
  103380. * @param name defines the new node name
  103381. * @param scene defines the hosting scene
  103382. * @param options defines optional options to transmit to constructors
  103383. * @returns the new constructor or null
  103384. */
  103385. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  103386. /**
  103387. * Gets or sets the name of the node
  103388. */
  103389. name: string;
  103390. /**
  103391. * Gets or sets the id of the node
  103392. */
  103393. id: string;
  103394. /**
  103395. * Gets or sets the unique id of the node
  103396. */
  103397. uniqueId: number;
  103398. /**
  103399. * Gets or sets a string used to store user defined state for the node
  103400. */
  103401. state: string;
  103402. /**
  103403. * Gets or sets an object used to store user defined information for the node
  103404. */
  103405. metadata: any;
  103406. /**
  103407. * For internal use only. Please do not use.
  103408. */
  103409. reservedDataStore: any;
  103410. /**
  103411. * List of inspectable custom properties (used by the Inspector)
  103412. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  103413. */
  103414. inspectableCustomProperties: IInspectable[];
  103415. private _doNotSerialize;
  103416. /**
  103417. * Gets or sets a boolean used to define if the node must be serialized
  103418. */
  103419. get doNotSerialize(): boolean;
  103420. set doNotSerialize(value: boolean);
  103421. /** @hidden */
  103422. _isDisposed: boolean;
  103423. /**
  103424. * Gets a list of Animations associated with the node
  103425. */
  103426. animations: Animation[];
  103427. protected _ranges: {
  103428. [name: string]: Nullable<AnimationRange>;
  103429. };
  103430. /**
  103431. * Callback raised when the node is ready to be used
  103432. */
  103433. onReady: Nullable<(node: Node) => void>;
  103434. private _isEnabled;
  103435. private _isParentEnabled;
  103436. private _isReady;
  103437. /** @hidden */
  103438. _currentRenderId: number;
  103439. private _parentUpdateId;
  103440. /** @hidden */
  103441. _childUpdateId: number;
  103442. /** @hidden */
  103443. _waitingParentId: Nullable<string>;
  103444. /** @hidden */
  103445. _scene: Scene;
  103446. /** @hidden */
  103447. _cache: any;
  103448. private _parentNode;
  103449. private _children;
  103450. /** @hidden */
  103451. _worldMatrix: Matrix;
  103452. /** @hidden */
  103453. _worldMatrixDeterminant: number;
  103454. /** @hidden */
  103455. _worldMatrixDeterminantIsDirty: boolean;
  103456. /** @hidden */
  103457. private _sceneRootNodesIndex;
  103458. /**
  103459. * Gets a boolean indicating if the node has been disposed
  103460. * @returns true if the node was disposed
  103461. */
  103462. isDisposed(): boolean;
  103463. /**
  103464. * Gets or sets the parent of the node (without keeping the current position in the scene)
  103465. * @see https://doc.babylonjs.com/how_to/parenting
  103466. */
  103467. set parent(parent: Nullable<Node>);
  103468. get parent(): Nullable<Node>;
  103469. /** @hidden */
  103470. _addToSceneRootNodes(): void;
  103471. /** @hidden */
  103472. _removeFromSceneRootNodes(): void;
  103473. private _animationPropertiesOverride;
  103474. /**
  103475. * Gets or sets the animation properties override
  103476. */
  103477. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  103478. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  103479. /**
  103480. * Gets a string idenfifying the name of the class
  103481. * @returns "Node" string
  103482. */
  103483. getClassName(): string;
  103484. /** @hidden */
  103485. readonly _isNode: boolean;
  103486. /**
  103487. * An event triggered when the mesh is disposed
  103488. */
  103489. onDisposeObservable: Observable<Node>;
  103490. private _onDisposeObserver;
  103491. /**
  103492. * Sets a callback that will be raised when the node will be disposed
  103493. */
  103494. set onDispose(callback: () => void);
  103495. /**
  103496. * Creates a new Node
  103497. * @param name the name and id to be given to this node
  103498. * @param scene the scene this node will be added to
  103499. */
  103500. constructor(name: string, scene?: Nullable<Scene>);
  103501. /**
  103502. * Gets the scene of the node
  103503. * @returns a scene
  103504. */
  103505. getScene(): Scene;
  103506. /**
  103507. * Gets the engine of the node
  103508. * @returns a Engine
  103509. */
  103510. getEngine(): Engine;
  103511. private _behaviors;
  103512. /**
  103513. * Attach a behavior to the node
  103514. * @see http://doc.babylonjs.com/features/behaviour
  103515. * @param behavior defines the behavior to attach
  103516. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  103517. * @returns the current Node
  103518. */
  103519. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  103520. /**
  103521. * Remove an attached behavior
  103522. * @see http://doc.babylonjs.com/features/behaviour
  103523. * @param behavior defines the behavior to attach
  103524. * @returns the current Node
  103525. */
  103526. removeBehavior(behavior: Behavior<Node>): Node;
  103527. /**
  103528. * Gets the list of attached behaviors
  103529. * @see http://doc.babylonjs.com/features/behaviour
  103530. */
  103531. get behaviors(): Behavior<Node>[];
  103532. /**
  103533. * Gets an attached behavior by name
  103534. * @param name defines the name of the behavior to look for
  103535. * @see http://doc.babylonjs.com/features/behaviour
  103536. * @returns null if behavior was not found else the requested behavior
  103537. */
  103538. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  103539. /**
  103540. * Returns the latest update of the World matrix
  103541. * @returns a Matrix
  103542. */
  103543. getWorldMatrix(): Matrix;
  103544. /** @hidden */
  103545. _getWorldMatrixDeterminant(): number;
  103546. /**
  103547. * Returns directly the latest state of the mesh World matrix.
  103548. * A Matrix is returned.
  103549. */
  103550. get worldMatrixFromCache(): Matrix;
  103551. /** @hidden */
  103552. _initCache(): void;
  103553. /** @hidden */
  103554. updateCache(force?: boolean): void;
  103555. /** @hidden */
  103556. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  103557. /** @hidden */
  103558. _updateCache(ignoreParentClass?: boolean): void;
  103559. /** @hidden */
  103560. _isSynchronized(): boolean;
  103561. /** @hidden */
  103562. _markSyncedWithParent(): void;
  103563. /** @hidden */
  103564. isSynchronizedWithParent(): boolean;
  103565. /** @hidden */
  103566. isSynchronized(): boolean;
  103567. /**
  103568. * Is this node ready to be used/rendered
  103569. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  103570. * @return true if the node is ready
  103571. */
  103572. isReady(completeCheck?: boolean): boolean;
  103573. /**
  103574. * Is this node enabled?
  103575. * 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
  103576. * @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
  103577. * @return whether this node (and its parent) is enabled
  103578. */
  103579. isEnabled(checkAncestors?: boolean): boolean;
  103580. /** @hidden */
  103581. protected _syncParentEnabledState(): void;
  103582. /**
  103583. * Set the enabled state of this node
  103584. * @param value defines the new enabled state
  103585. */
  103586. setEnabled(value: boolean): void;
  103587. /**
  103588. * Is this node a descendant of the given node?
  103589. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  103590. * @param ancestor defines the parent node to inspect
  103591. * @returns a boolean indicating if this node is a descendant of the given node
  103592. */
  103593. isDescendantOf(ancestor: Node): boolean;
  103594. /** @hidden */
  103595. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  103596. /**
  103597. * Will return all nodes that have this node as ascendant
  103598. * @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
  103599. * @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
  103600. * @return all children nodes of all types
  103601. */
  103602. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  103603. /**
  103604. * Get all child-meshes of this node
  103605. * @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)
  103606. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  103607. * @returns an array of AbstractMesh
  103608. */
  103609. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  103610. /**
  103611. * Get all direct children of this node
  103612. * @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
  103613. * @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)
  103614. * @returns an array of Node
  103615. */
  103616. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  103617. /** @hidden */
  103618. _setReady(state: boolean): void;
  103619. /**
  103620. * Get an animation by name
  103621. * @param name defines the name of the animation to look for
  103622. * @returns null if not found else the requested animation
  103623. */
  103624. getAnimationByName(name: string): Nullable<Animation>;
  103625. /**
  103626. * Creates an animation range for this node
  103627. * @param name defines the name of the range
  103628. * @param from defines the starting key
  103629. * @param to defines the end key
  103630. */
  103631. createAnimationRange(name: string, from: number, to: number): void;
  103632. /**
  103633. * Delete a specific animation range
  103634. * @param name defines the name of the range to delete
  103635. * @param deleteFrames defines if animation frames from the range must be deleted as well
  103636. */
  103637. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  103638. /**
  103639. * Get an animation range by name
  103640. * @param name defines the name of the animation range to look for
  103641. * @returns null if not found else the requested animation range
  103642. */
  103643. getAnimationRange(name: string): Nullable<AnimationRange>;
  103644. /**
  103645. * Gets the list of all animation ranges defined on this node
  103646. * @returns an array
  103647. */
  103648. getAnimationRanges(): Nullable<AnimationRange>[];
  103649. /**
  103650. * Will start the animation sequence
  103651. * @param name defines the range frames for animation sequence
  103652. * @param loop defines if the animation should loop (false by default)
  103653. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  103654. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  103655. * @returns the object created for this animation. If range does not exist, it will return null
  103656. */
  103657. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  103658. /**
  103659. * Serialize animation ranges into a JSON compatible object
  103660. * @returns serialization object
  103661. */
  103662. serializeAnimationRanges(): any;
  103663. /**
  103664. * Computes the world matrix of the node
  103665. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  103666. * @returns the world matrix
  103667. */
  103668. computeWorldMatrix(force?: boolean): Matrix;
  103669. /**
  103670. * Releases resources associated with this node.
  103671. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  103672. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  103673. */
  103674. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  103675. /**
  103676. * Parse animation range data from a serialization object and store them into a given node
  103677. * @param node defines where to store the animation ranges
  103678. * @param parsedNode defines the serialization object to read data from
  103679. * @param scene defines the hosting scene
  103680. */
  103681. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  103682. /**
  103683. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  103684. * @param includeDescendants Include bounding info from descendants as well (true by default)
  103685. * @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
  103686. * @returns the new bounding vectors
  103687. */
  103688. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  103689. min: Vector3;
  103690. max: Vector3;
  103691. };
  103692. }
  103693. }
  103694. declare module BABYLON {
  103695. /**
  103696. * @hidden
  103697. */
  103698. export class _IAnimationState {
  103699. key: number;
  103700. repeatCount: number;
  103701. workValue?: any;
  103702. loopMode?: number;
  103703. offsetValue?: any;
  103704. highLimitValue?: any;
  103705. }
  103706. /**
  103707. * Class used to store any kind of animation
  103708. */
  103709. export class Animation {
  103710. /**Name of the animation */
  103711. name: string;
  103712. /**Property to animate */
  103713. targetProperty: string;
  103714. /**The frames per second of the animation */
  103715. framePerSecond: number;
  103716. /**The data type of the animation */
  103717. dataType: number;
  103718. /**The loop mode of the animation */
  103719. loopMode?: number | undefined;
  103720. /**Specifies if blending should be enabled */
  103721. enableBlending?: boolean | undefined;
  103722. /**
  103723. * Use matrix interpolation instead of using direct key value when animating matrices
  103724. */
  103725. static AllowMatricesInterpolation: boolean;
  103726. /**
  103727. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  103728. */
  103729. static AllowMatrixDecomposeForInterpolation: boolean;
  103730. /**
  103731. * Stores the key frames of the animation
  103732. */
  103733. private _keys;
  103734. /**
  103735. * Stores the easing function of the animation
  103736. */
  103737. private _easingFunction;
  103738. /**
  103739. * @hidden Internal use only
  103740. */
  103741. _runtimeAnimations: RuntimeAnimation[];
  103742. /**
  103743. * The set of event that will be linked to this animation
  103744. */
  103745. private _events;
  103746. /**
  103747. * Stores an array of target property paths
  103748. */
  103749. targetPropertyPath: string[];
  103750. /**
  103751. * Stores the blending speed of the animation
  103752. */
  103753. blendingSpeed: number;
  103754. /**
  103755. * Stores the animation ranges for the animation
  103756. */
  103757. private _ranges;
  103758. /**
  103759. * @hidden Internal use
  103760. */
  103761. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  103762. /**
  103763. * Sets up an animation
  103764. * @param property The property to animate
  103765. * @param animationType The animation type to apply
  103766. * @param framePerSecond The frames per second of the animation
  103767. * @param easingFunction The easing function used in the animation
  103768. * @returns The created animation
  103769. */
  103770. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  103771. /**
  103772. * Create and start an animation on a node
  103773. * @param name defines the name of the global animation that will be run on all nodes
  103774. * @param node defines the root node where the animation will take place
  103775. * @param targetProperty defines property to animate
  103776. * @param framePerSecond defines the number of frame per second yo use
  103777. * @param totalFrame defines the number of frames in total
  103778. * @param from defines the initial value
  103779. * @param to defines the final value
  103780. * @param loopMode defines which loop mode you want to use (off by default)
  103781. * @param easingFunction defines the easing function to use (linear by default)
  103782. * @param onAnimationEnd defines the callback to call when animation end
  103783. * @returns the animatable created for this animation
  103784. */
  103785. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  103786. /**
  103787. * Create and start an animation on a node and its descendants
  103788. * @param name defines the name of the global animation that will be run on all nodes
  103789. * @param node defines the root node where the animation will take place
  103790. * @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
  103791. * @param targetProperty defines property to animate
  103792. * @param framePerSecond defines the number of frame per second to use
  103793. * @param totalFrame defines the number of frames in total
  103794. * @param from defines the initial value
  103795. * @param to defines the final value
  103796. * @param loopMode defines which loop mode you want to use (off by default)
  103797. * @param easingFunction defines the easing function to use (linear by default)
  103798. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  103799. * @returns the list of animatables created for all nodes
  103800. * @example https://www.babylonjs-playground.com/#MH0VLI
  103801. */
  103802. 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[]>;
  103803. /**
  103804. * Creates a new animation, merges it with the existing animations and starts it
  103805. * @param name Name of the animation
  103806. * @param node Node which contains the scene that begins the animations
  103807. * @param targetProperty Specifies which property to animate
  103808. * @param framePerSecond The frames per second of the animation
  103809. * @param totalFrame The total number of frames
  103810. * @param from The frame at the beginning of the animation
  103811. * @param to The frame at the end of the animation
  103812. * @param loopMode Specifies the loop mode of the animation
  103813. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  103814. * @param onAnimationEnd Callback to run once the animation is complete
  103815. * @returns Nullable animation
  103816. */
  103817. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  103818. /**
  103819. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  103820. * @param sourceAnimation defines the Animation containing keyframes to convert
  103821. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  103822. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  103823. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  103824. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  103825. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  103826. */
  103827. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  103828. /**
  103829. * Transition property of an host to the target Value
  103830. * @param property The property to transition
  103831. * @param targetValue The target Value of the property
  103832. * @param host The object where the property to animate belongs
  103833. * @param scene Scene used to run the animation
  103834. * @param frameRate Framerate (in frame/s) to use
  103835. * @param transition The transition type we want to use
  103836. * @param duration The duration of the animation, in milliseconds
  103837. * @param onAnimationEnd Callback trigger at the end of the animation
  103838. * @returns Nullable animation
  103839. */
  103840. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  103841. /**
  103842. * Return the array of runtime animations currently using this animation
  103843. */
  103844. get runtimeAnimations(): RuntimeAnimation[];
  103845. /**
  103846. * Specifies if any of the runtime animations are currently running
  103847. */
  103848. get hasRunningRuntimeAnimations(): boolean;
  103849. /**
  103850. * Initializes the animation
  103851. * @param name Name of the animation
  103852. * @param targetProperty Property to animate
  103853. * @param framePerSecond The frames per second of the animation
  103854. * @param dataType The data type of the animation
  103855. * @param loopMode The loop mode of the animation
  103856. * @param enableBlending Specifies if blending should be enabled
  103857. */
  103858. constructor(
  103859. /**Name of the animation */
  103860. name: string,
  103861. /**Property to animate */
  103862. targetProperty: string,
  103863. /**The frames per second of the animation */
  103864. framePerSecond: number,
  103865. /**The data type of the animation */
  103866. dataType: number,
  103867. /**The loop mode of the animation */
  103868. loopMode?: number | undefined,
  103869. /**Specifies if blending should be enabled */
  103870. enableBlending?: boolean | undefined);
  103871. /**
  103872. * Converts the animation to a string
  103873. * @param fullDetails support for multiple levels of logging within scene loading
  103874. * @returns String form of the animation
  103875. */
  103876. toString(fullDetails?: boolean): string;
  103877. /**
  103878. * Add an event to this animation
  103879. * @param event Event to add
  103880. */
  103881. addEvent(event: AnimationEvent): void;
  103882. /**
  103883. * Remove all events found at the given frame
  103884. * @param frame The frame to remove events from
  103885. */
  103886. removeEvents(frame: number): void;
  103887. /**
  103888. * Retrieves all the events from the animation
  103889. * @returns Events from the animation
  103890. */
  103891. getEvents(): AnimationEvent[];
  103892. /**
  103893. * Creates an animation range
  103894. * @param name Name of the animation range
  103895. * @param from Starting frame of the animation range
  103896. * @param to Ending frame of the animation
  103897. */
  103898. createRange(name: string, from: number, to: number): void;
  103899. /**
  103900. * Deletes an animation range by name
  103901. * @param name Name of the animation range to delete
  103902. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  103903. */
  103904. deleteRange(name: string, deleteFrames?: boolean): void;
  103905. /**
  103906. * Gets the animation range by name, or null if not defined
  103907. * @param name Name of the animation range
  103908. * @returns Nullable animation range
  103909. */
  103910. getRange(name: string): Nullable<AnimationRange>;
  103911. /**
  103912. * Gets the key frames from the animation
  103913. * @returns The key frames of the animation
  103914. */
  103915. getKeys(): Array<IAnimationKey>;
  103916. /**
  103917. * Gets the highest frame rate of the animation
  103918. * @returns Highest frame rate of the animation
  103919. */
  103920. getHighestFrame(): number;
  103921. /**
  103922. * Gets the easing function of the animation
  103923. * @returns Easing function of the animation
  103924. */
  103925. getEasingFunction(): IEasingFunction;
  103926. /**
  103927. * Sets the easing function of the animation
  103928. * @param easingFunction A custom mathematical formula for animation
  103929. */
  103930. setEasingFunction(easingFunction: EasingFunction): void;
  103931. /**
  103932. * Interpolates a scalar linearly
  103933. * @param startValue Start value of the animation curve
  103934. * @param endValue End value of the animation curve
  103935. * @param gradient Scalar amount to interpolate
  103936. * @returns Interpolated scalar value
  103937. */
  103938. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  103939. /**
  103940. * Interpolates a scalar cubically
  103941. * @param startValue Start value of the animation curve
  103942. * @param outTangent End tangent of the animation
  103943. * @param endValue End value of the animation curve
  103944. * @param inTangent Start tangent of the animation curve
  103945. * @param gradient Scalar amount to interpolate
  103946. * @returns Interpolated scalar value
  103947. */
  103948. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  103949. /**
  103950. * Interpolates a quaternion using a spherical linear interpolation
  103951. * @param startValue Start value of the animation curve
  103952. * @param endValue End value of the animation curve
  103953. * @param gradient Scalar amount to interpolate
  103954. * @returns Interpolated quaternion value
  103955. */
  103956. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  103957. /**
  103958. * Interpolates a quaternion cubically
  103959. * @param startValue Start value of the animation curve
  103960. * @param outTangent End tangent of the animation curve
  103961. * @param endValue End value of the animation curve
  103962. * @param inTangent Start tangent of the animation curve
  103963. * @param gradient Scalar amount to interpolate
  103964. * @returns Interpolated quaternion value
  103965. */
  103966. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  103967. /**
  103968. * Interpolates a Vector3 linearl
  103969. * @param startValue Start value of the animation curve
  103970. * @param endValue End value of the animation curve
  103971. * @param gradient Scalar amount to interpolate
  103972. * @returns Interpolated scalar value
  103973. */
  103974. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  103975. /**
  103976. * Interpolates a Vector3 cubically
  103977. * @param startValue Start value of the animation curve
  103978. * @param outTangent End tangent of the animation
  103979. * @param endValue End value of the animation curve
  103980. * @param inTangent Start tangent of the animation curve
  103981. * @param gradient Scalar amount to interpolate
  103982. * @returns InterpolatedVector3 value
  103983. */
  103984. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  103985. /**
  103986. * Interpolates a Vector2 linearly
  103987. * @param startValue Start value of the animation curve
  103988. * @param endValue End value of the animation curve
  103989. * @param gradient Scalar amount to interpolate
  103990. * @returns Interpolated Vector2 value
  103991. */
  103992. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  103993. /**
  103994. * Interpolates a Vector2 cubically
  103995. * @param startValue Start value of the animation curve
  103996. * @param outTangent End tangent of the animation
  103997. * @param endValue End value of the animation curve
  103998. * @param inTangent Start tangent of the animation curve
  103999. * @param gradient Scalar amount to interpolate
  104000. * @returns Interpolated Vector2 value
  104001. */
  104002. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  104003. /**
  104004. * Interpolates a size linearly
  104005. * @param startValue Start value of the animation curve
  104006. * @param endValue End value of the animation curve
  104007. * @param gradient Scalar amount to interpolate
  104008. * @returns Interpolated Size value
  104009. */
  104010. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  104011. /**
  104012. * Interpolates a Color3 linearly
  104013. * @param startValue Start value of the animation curve
  104014. * @param endValue End value of the animation curve
  104015. * @param gradient Scalar amount to interpolate
  104016. * @returns Interpolated Color3 value
  104017. */
  104018. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  104019. /**
  104020. * Interpolates a Color4 linearly
  104021. * @param startValue Start value of the animation curve
  104022. * @param endValue End value of the animation curve
  104023. * @param gradient Scalar amount to interpolate
  104024. * @returns Interpolated Color3 value
  104025. */
  104026. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  104027. /**
  104028. * @hidden Internal use only
  104029. */
  104030. _getKeyValue(value: any): any;
  104031. /**
  104032. * @hidden Internal use only
  104033. */
  104034. _interpolate(currentFrame: number, state: _IAnimationState): any;
  104035. /**
  104036. * Defines the function to use to interpolate matrices
  104037. * @param startValue defines the start matrix
  104038. * @param endValue defines the end matrix
  104039. * @param gradient defines the gradient between both matrices
  104040. * @param result defines an optional target matrix where to store the interpolation
  104041. * @returns the interpolated matrix
  104042. */
  104043. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  104044. /**
  104045. * Makes a copy of the animation
  104046. * @returns Cloned animation
  104047. */
  104048. clone(): Animation;
  104049. /**
  104050. * Sets the key frames of the animation
  104051. * @param values The animation key frames to set
  104052. */
  104053. setKeys(values: Array<IAnimationKey>): void;
  104054. /**
  104055. * Serializes the animation to an object
  104056. * @returns Serialized object
  104057. */
  104058. serialize(): any;
  104059. /**
  104060. * Float animation type
  104061. */
  104062. static readonly ANIMATIONTYPE_FLOAT: number;
  104063. /**
  104064. * Vector3 animation type
  104065. */
  104066. static readonly ANIMATIONTYPE_VECTOR3: number;
  104067. /**
  104068. * Quaternion animation type
  104069. */
  104070. static readonly ANIMATIONTYPE_QUATERNION: number;
  104071. /**
  104072. * Matrix animation type
  104073. */
  104074. static readonly ANIMATIONTYPE_MATRIX: number;
  104075. /**
  104076. * Color3 animation type
  104077. */
  104078. static readonly ANIMATIONTYPE_COLOR3: number;
  104079. /**
  104080. * Color3 animation type
  104081. */
  104082. static readonly ANIMATIONTYPE_COLOR4: number;
  104083. /**
  104084. * Vector2 animation type
  104085. */
  104086. static readonly ANIMATIONTYPE_VECTOR2: number;
  104087. /**
  104088. * Size animation type
  104089. */
  104090. static readonly ANIMATIONTYPE_SIZE: number;
  104091. /**
  104092. * Relative Loop Mode
  104093. */
  104094. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  104095. /**
  104096. * Cycle Loop Mode
  104097. */
  104098. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  104099. /**
  104100. * Constant Loop Mode
  104101. */
  104102. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  104103. /** @hidden */
  104104. static _UniversalLerp(left: any, right: any, amount: number): any;
  104105. /**
  104106. * Parses an animation object and creates an animation
  104107. * @param parsedAnimation Parsed animation object
  104108. * @returns Animation object
  104109. */
  104110. static Parse(parsedAnimation: any): Animation;
  104111. /**
  104112. * Appends the serialized animations from the source animations
  104113. * @param source Source containing the animations
  104114. * @param destination Target to store the animations
  104115. */
  104116. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  104117. }
  104118. }
  104119. declare module BABYLON {
  104120. /**
  104121. * Interface containing an array of animations
  104122. */
  104123. export interface IAnimatable {
  104124. /**
  104125. * Array of animations
  104126. */
  104127. animations: Nullable<Array<Animation>>;
  104128. }
  104129. }
  104130. declare module BABYLON {
  104131. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  104132. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  104133. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  104134. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  104135. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  104136. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  104137. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  104138. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  104139. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  104140. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  104141. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  104142. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  104143. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  104144. /**
  104145. * Decorator used to define property that can be serialized as reference to a camera
  104146. * @param sourceName defines the name of the property to decorate
  104147. */
  104148. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  104149. /**
  104150. * Class used to help serialization objects
  104151. */
  104152. export class SerializationHelper {
  104153. /** @hidden */
  104154. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  104155. /** @hidden */
  104156. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  104157. /** @hidden */
  104158. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  104159. /** @hidden */
  104160. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  104161. /**
  104162. * Appends the serialized animations from the source animations
  104163. * @param source Source containing the animations
  104164. * @param destination Target to store the animations
  104165. */
  104166. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  104167. /**
  104168. * Static function used to serialized a specific entity
  104169. * @param entity defines the entity to serialize
  104170. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  104171. * @returns a JSON compatible object representing the serialization of the entity
  104172. */
  104173. static Serialize<T>(entity: T, serializationObject?: any): any;
  104174. /**
  104175. * Creates a new entity from a serialization data object
  104176. * @param creationFunction defines a function used to instanciated the new entity
  104177. * @param source defines the source serialization data
  104178. * @param scene defines the hosting scene
  104179. * @param rootUrl defines the root url for resources
  104180. * @returns a new entity
  104181. */
  104182. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  104183. /**
  104184. * Clones an object
  104185. * @param creationFunction defines the function used to instanciate the new object
  104186. * @param source defines the source object
  104187. * @returns the cloned object
  104188. */
  104189. static Clone<T>(creationFunction: () => T, source: T): T;
  104190. /**
  104191. * Instanciates a new object based on a source one (some data will be shared between both object)
  104192. * @param creationFunction defines the function used to instanciate the new object
  104193. * @param source defines the source object
  104194. * @returns the new object
  104195. */
  104196. static Instanciate<T>(creationFunction: () => T, source: T): T;
  104197. }
  104198. }
  104199. declare module BABYLON {
  104200. /**
  104201. * Class used to manipulate GUIDs
  104202. */
  104203. export class GUID {
  104204. /**
  104205. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  104206. * Be aware Math.random() could cause collisions, but:
  104207. * "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"
  104208. * @returns a pseudo random id
  104209. */
  104210. static RandomId(): string;
  104211. }
  104212. }
  104213. declare module BABYLON {
  104214. /**
  104215. * Base class of all the textures in babylon.
  104216. * It groups all the common properties the materials, post process, lights... might need
  104217. * in order to make a correct use of the texture.
  104218. */
  104219. export class BaseTexture implements IAnimatable {
  104220. /**
  104221. * Default anisotropic filtering level for the application.
  104222. * It is set to 4 as a good tradeoff between perf and quality.
  104223. */
  104224. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  104225. /**
  104226. * Gets or sets the unique id of the texture
  104227. */
  104228. uniqueId: number;
  104229. /**
  104230. * Define the name of the texture.
  104231. */
  104232. name: string;
  104233. /**
  104234. * Gets or sets an object used to store user defined information.
  104235. */
  104236. metadata: any;
  104237. /**
  104238. * For internal use only. Please do not use.
  104239. */
  104240. reservedDataStore: any;
  104241. private _hasAlpha;
  104242. /**
  104243. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  104244. */
  104245. set hasAlpha(value: boolean);
  104246. get hasAlpha(): boolean;
  104247. /**
  104248. * Defines if the alpha value should be determined via the rgb values.
  104249. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  104250. */
  104251. getAlphaFromRGB: boolean;
  104252. /**
  104253. * Intensity or strength of the texture.
  104254. * It is commonly used by materials to fine tune the intensity of the texture
  104255. */
  104256. level: number;
  104257. /**
  104258. * Define the UV chanel to use starting from 0 and defaulting to 0.
  104259. * This is part of the texture as textures usually maps to one uv set.
  104260. */
  104261. coordinatesIndex: number;
  104262. private _coordinatesMode;
  104263. /**
  104264. * How a texture is mapped.
  104265. *
  104266. * | Value | Type | Description |
  104267. * | ----- | ----------------------------------- | ----------- |
  104268. * | 0 | EXPLICIT_MODE | |
  104269. * | 1 | SPHERICAL_MODE | |
  104270. * | 2 | PLANAR_MODE | |
  104271. * | 3 | CUBIC_MODE | |
  104272. * | 4 | PROJECTION_MODE | |
  104273. * | 5 | SKYBOX_MODE | |
  104274. * | 6 | INVCUBIC_MODE | |
  104275. * | 7 | EQUIRECTANGULAR_MODE | |
  104276. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  104277. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  104278. */
  104279. set coordinatesMode(value: number);
  104280. get coordinatesMode(): number;
  104281. /**
  104282. * | Value | Type | Description |
  104283. * | ----- | ------------------ | ----------- |
  104284. * | 0 | CLAMP_ADDRESSMODE | |
  104285. * | 1 | WRAP_ADDRESSMODE | |
  104286. * | 2 | MIRROR_ADDRESSMODE | |
  104287. */
  104288. wrapU: number;
  104289. /**
  104290. * | Value | Type | Description |
  104291. * | ----- | ------------------ | ----------- |
  104292. * | 0 | CLAMP_ADDRESSMODE | |
  104293. * | 1 | WRAP_ADDRESSMODE | |
  104294. * | 2 | MIRROR_ADDRESSMODE | |
  104295. */
  104296. wrapV: number;
  104297. /**
  104298. * | Value | Type | Description |
  104299. * | ----- | ------------------ | ----------- |
  104300. * | 0 | CLAMP_ADDRESSMODE | |
  104301. * | 1 | WRAP_ADDRESSMODE | |
  104302. * | 2 | MIRROR_ADDRESSMODE | |
  104303. */
  104304. wrapR: number;
  104305. /**
  104306. * With compliant hardware and browser (supporting anisotropic filtering)
  104307. * this defines the level of anisotropic filtering in the texture.
  104308. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  104309. */
  104310. anisotropicFilteringLevel: number;
  104311. /**
  104312. * Define if the texture is a cube texture or if false a 2d texture.
  104313. */
  104314. get isCube(): boolean;
  104315. set isCube(value: boolean);
  104316. /**
  104317. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  104318. */
  104319. get is3D(): boolean;
  104320. set is3D(value: boolean);
  104321. /**
  104322. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  104323. */
  104324. get is2DArray(): boolean;
  104325. set is2DArray(value: boolean);
  104326. /**
  104327. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  104328. * HDR texture are usually stored in linear space.
  104329. * This only impacts the PBR and Background materials
  104330. */
  104331. gammaSpace: boolean;
  104332. /**
  104333. * Gets or sets whether or not the texture contains RGBD data.
  104334. */
  104335. get isRGBD(): boolean;
  104336. set isRGBD(value: boolean);
  104337. /**
  104338. * Is Z inverted in the texture (useful in a cube texture).
  104339. */
  104340. invertZ: boolean;
  104341. /**
  104342. * Are mip maps generated for this texture or not.
  104343. */
  104344. get noMipmap(): boolean;
  104345. /**
  104346. * @hidden
  104347. */
  104348. lodLevelInAlpha: boolean;
  104349. /**
  104350. * With prefiltered texture, defined the offset used during the prefiltering steps.
  104351. */
  104352. get lodGenerationOffset(): number;
  104353. set lodGenerationOffset(value: number);
  104354. /**
  104355. * With prefiltered texture, defined the scale used during the prefiltering steps.
  104356. */
  104357. get lodGenerationScale(): number;
  104358. set lodGenerationScale(value: number);
  104359. /**
  104360. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  104361. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  104362. * average roughness values.
  104363. */
  104364. get linearSpecularLOD(): boolean;
  104365. set linearSpecularLOD(value: boolean);
  104366. /**
  104367. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  104368. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  104369. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  104370. */
  104371. get irradianceTexture(): Nullable<BaseTexture>;
  104372. set irradianceTexture(value: Nullable<BaseTexture>);
  104373. /**
  104374. * Define if the texture is a render target.
  104375. */
  104376. isRenderTarget: boolean;
  104377. /**
  104378. * Define the unique id of the texture in the scene.
  104379. */
  104380. get uid(): string;
  104381. /**
  104382. * Return a string representation of the texture.
  104383. * @returns the texture as a string
  104384. */
  104385. toString(): string;
  104386. /**
  104387. * Get the class name of the texture.
  104388. * @returns "BaseTexture"
  104389. */
  104390. getClassName(): string;
  104391. /**
  104392. * Define the list of animation attached to the texture.
  104393. */
  104394. animations: Animation[];
  104395. /**
  104396. * An event triggered when the texture is disposed.
  104397. */
  104398. onDisposeObservable: Observable<BaseTexture>;
  104399. private _onDisposeObserver;
  104400. /**
  104401. * Callback triggered when the texture has been disposed.
  104402. * Kept for back compatibility, you can use the onDisposeObservable instead.
  104403. */
  104404. set onDispose(callback: () => void);
  104405. /**
  104406. * Define the current state of the loading sequence when in delayed load mode.
  104407. */
  104408. delayLoadState: number;
  104409. private _scene;
  104410. /** @hidden */
  104411. _texture: Nullable<InternalTexture>;
  104412. private _uid;
  104413. /**
  104414. * Define if the texture is preventinga material to render or not.
  104415. * If not and the texture is not ready, the engine will use a default black texture instead.
  104416. */
  104417. get isBlocking(): boolean;
  104418. /**
  104419. * Instantiates a new BaseTexture.
  104420. * Base class of all the textures in babylon.
  104421. * It groups all the common properties the materials, post process, lights... might need
  104422. * in order to make a correct use of the texture.
  104423. * @param scene Define the scene the texture blongs to
  104424. */
  104425. constructor(scene: Nullable<Scene>);
  104426. /**
  104427. * Get the scene the texture belongs to.
  104428. * @returns the scene or null if undefined
  104429. */
  104430. getScene(): Nullable<Scene>;
  104431. /**
  104432. * Get the texture transform matrix used to offset tile the texture for istance.
  104433. * @returns the transformation matrix
  104434. */
  104435. getTextureMatrix(): Matrix;
  104436. /**
  104437. * Get the texture reflection matrix used to rotate/transform the reflection.
  104438. * @returns the reflection matrix
  104439. */
  104440. getReflectionTextureMatrix(): Matrix;
  104441. /**
  104442. * Get the underlying lower level texture from Babylon.
  104443. * @returns the insternal texture
  104444. */
  104445. getInternalTexture(): Nullable<InternalTexture>;
  104446. /**
  104447. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  104448. * @returns true if ready or not blocking
  104449. */
  104450. isReadyOrNotBlocking(): boolean;
  104451. /**
  104452. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  104453. * @returns true if fully ready
  104454. */
  104455. isReady(): boolean;
  104456. private _cachedSize;
  104457. /**
  104458. * Get the size of the texture.
  104459. * @returns the texture size.
  104460. */
  104461. getSize(): ISize;
  104462. /**
  104463. * Get the base size of the texture.
  104464. * It can be different from the size if the texture has been resized for POT for instance
  104465. * @returns the base size
  104466. */
  104467. getBaseSize(): ISize;
  104468. /**
  104469. * Update the sampling mode of the texture.
  104470. * Default is Trilinear mode.
  104471. *
  104472. * | Value | Type | Description |
  104473. * | ----- | ------------------ | ----------- |
  104474. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  104475. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  104476. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  104477. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  104478. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  104479. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  104480. * | 7 | NEAREST_LINEAR | |
  104481. * | 8 | NEAREST_NEAREST | |
  104482. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  104483. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  104484. * | 11 | LINEAR_LINEAR | |
  104485. * | 12 | LINEAR_NEAREST | |
  104486. *
  104487. * > _mag_: magnification filter (close to the viewer)
  104488. * > _min_: minification filter (far from the viewer)
  104489. * > _mip_: filter used between mip map levels
  104490. *@param samplingMode Define the new sampling mode of the texture
  104491. */
  104492. updateSamplingMode(samplingMode: number): void;
  104493. /**
  104494. * Scales the texture if is `canRescale()`
  104495. * @param ratio the resize factor we want to use to rescale
  104496. */
  104497. scale(ratio: number): void;
  104498. /**
  104499. * Get if the texture can rescale.
  104500. */
  104501. get canRescale(): boolean;
  104502. /** @hidden */
  104503. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  104504. /** @hidden */
  104505. _rebuild(): void;
  104506. /**
  104507. * Triggers the load sequence in delayed load mode.
  104508. */
  104509. delayLoad(): void;
  104510. /**
  104511. * Clones the texture.
  104512. * @returns the cloned texture
  104513. */
  104514. clone(): Nullable<BaseTexture>;
  104515. /**
  104516. * Get the texture underlying type (INT, FLOAT...)
  104517. */
  104518. get textureType(): number;
  104519. /**
  104520. * Get the texture underlying format (RGB, RGBA...)
  104521. */
  104522. get textureFormat(): number;
  104523. /**
  104524. * Indicates that textures need to be re-calculated for all materials
  104525. */
  104526. protected _markAllSubMeshesAsTexturesDirty(): void;
  104527. /**
  104528. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  104529. * This will returns an RGBA array buffer containing either in values (0-255) or
  104530. * float values (0-1) depending of the underlying buffer type.
  104531. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  104532. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  104533. * @param buffer defines a user defined buffer to fill with data (can be null)
  104534. * @returns The Array buffer containing the pixels data.
  104535. */
  104536. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  104537. /**
  104538. * Release and destroy the underlying lower level texture aka internalTexture.
  104539. */
  104540. releaseInternalTexture(): void;
  104541. /** @hidden */
  104542. get _lodTextureHigh(): Nullable<BaseTexture>;
  104543. /** @hidden */
  104544. get _lodTextureMid(): Nullable<BaseTexture>;
  104545. /** @hidden */
  104546. get _lodTextureLow(): Nullable<BaseTexture>;
  104547. /**
  104548. * Dispose the texture and release its associated resources.
  104549. */
  104550. dispose(): void;
  104551. /**
  104552. * Serialize the texture into a JSON representation that can be parsed later on.
  104553. * @returns the JSON representation of the texture
  104554. */
  104555. serialize(): any;
  104556. /**
  104557. * Helper function to be called back once a list of texture contains only ready textures.
  104558. * @param textures Define the list of textures to wait for
  104559. * @param callback Define the callback triggered once the entire list will be ready
  104560. */
  104561. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  104562. }
  104563. }
  104564. declare module BABYLON {
  104565. /**
  104566. * Options to be used when creating an effect.
  104567. */
  104568. export interface IEffectCreationOptions {
  104569. /**
  104570. * Atrributes that will be used in the shader.
  104571. */
  104572. attributes: string[];
  104573. /**
  104574. * Uniform varible names that will be set in the shader.
  104575. */
  104576. uniformsNames: string[];
  104577. /**
  104578. * Uniform buffer variable names that will be set in the shader.
  104579. */
  104580. uniformBuffersNames: string[];
  104581. /**
  104582. * Sampler texture variable names that will be set in the shader.
  104583. */
  104584. samplers: string[];
  104585. /**
  104586. * Define statements that will be set in the shader.
  104587. */
  104588. defines: any;
  104589. /**
  104590. * Possible fallbacks for this effect to improve performance when needed.
  104591. */
  104592. fallbacks: Nullable<IEffectFallbacks>;
  104593. /**
  104594. * Callback that will be called when the shader is compiled.
  104595. */
  104596. onCompiled: Nullable<(effect: Effect) => void>;
  104597. /**
  104598. * Callback that will be called if an error occurs during shader compilation.
  104599. */
  104600. onError: Nullable<(effect: Effect, errors: string) => void>;
  104601. /**
  104602. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  104603. */
  104604. indexParameters?: any;
  104605. /**
  104606. * Max number of lights that can be used in the shader.
  104607. */
  104608. maxSimultaneousLights?: number;
  104609. /**
  104610. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  104611. */
  104612. transformFeedbackVaryings?: Nullable<string[]>;
  104613. }
  104614. /**
  104615. * Effect containing vertex and fragment shader that can be executed on an object.
  104616. */
  104617. export class Effect implements IDisposable {
  104618. /**
  104619. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  104620. */
  104621. static ShadersRepository: string;
  104622. /**
  104623. * Enable logging of the shader code when a compilation error occurs
  104624. */
  104625. static LogShaderCodeOnCompilationError: boolean;
  104626. /**
  104627. * Name of the effect.
  104628. */
  104629. name: any;
  104630. /**
  104631. * String container all the define statements that should be set on the shader.
  104632. */
  104633. defines: string;
  104634. /**
  104635. * Callback that will be called when the shader is compiled.
  104636. */
  104637. onCompiled: Nullable<(effect: Effect) => void>;
  104638. /**
  104639. * Callback that will be called if an error occurs during shader compilation.
  104640. */
  104641. onError: Nullable<(effect: Effect, errors: string) => void>;
  104642. /**
  104643. * Callback that will be called when effect is bound.
  104644. */
  104645. onBind: Nullable<(effect: Effect) => void>;
  104646. /**
  104647. * Unique ID of the effect.
  104648. */
  104649. uniqueId: number;
  104650. /**
  104651. * Observable that will be called when the shader is compiled.
  104652. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  104653. */
  104654. onCompileObservable: Observable<Effect>;
  104655. /**
  104656. * Observable that will be called if an error occurs during shader compilation.
  104657. */
  104658. onErrorObservable: Observable<Effect>;
  104659. /** @hidden */
  104660. _onBindObservable: Nullable<Observable<Effect>>;
  104661. /**
  104662. * @hidden
  104663. * Specifies if the effect was previously ready
  104664. */
  104665. _wasPreviouslyReady: boolean;
  104666. /**
  104667. * Observable that will be called when effect is bound.
  104668. */
  104669. get onBindObservable(): Observable<Effect>;
  104670. /** @hidden */
  104671. _bonesComputationForcedToCPU: boolean;
  104672. private static _uniqueIdSeed;
  104673. private _engine;
  104674. private _uniformBuffersNames;
  104675. private _uniformsNames;
  104676. private _samplerList;
  104677. private _samplers;
  104678. private _isReady;
  104679. private _compilationError;
  104680. private _allFallbacksProcessed;
  104681. private _attributesNames;
  104682. private _attributes;
  104683. private _attributeLocationByName;
  104684. private _uniforms;
  104685. /**
  104686. * Key for the effect.
  104687. * @hidden
  104688. */
  104689. _key: string;
  104690. private _indexParameters;
  104691. private _fallbacks;
  104692. private _vertexSourceCode;
  104693. private _fragmentSourceCode;
  104694. private _vertexSourceCodeOverride;
  104695. private _fragmentSourceCodeOverride;
  104696. private _transformFeedbackVaryings;
  104697. /**
  104698. * Compiled shader to webGL program.
  104699. * @hidden
  104700. */
  104701. _pipelineContext: Nullable<IPipelineContext>;
  104702. private _valueCache;
  104703. private static _baseCache;
  104704. /**
  104705. * Instantiates an effect.
  104706. * An effect can be used to create/manage/execute vertex and fragment shaders.
  104707. * @param baseName Name of the effect.
  104708. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  104709. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  104710. * @param samplers List of sampler variables that will be passed to the shader.
  104711. * @param engine Engine to be used to render the effect
  104712. * @param defines Define statements to be added to the shader.
  104713. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  104714. * @param onCompiled Callback that will be called when the shader is compiled.
  104715. * @param onError Callback that will be called if an error occurs during shader compilation.
  104716. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  104717. */
  104718. 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);
  104719. private _useFinalCode;
  104720. /**
  104721. * Unique key for this effect
  104722. */
  104723. get key(): string;
  104724. /**
  104725. * If the effect has been compiled and prepared.
  104726. * @returns if the effect is compiled and prepared.
  104727. */
  104728. isReady(): boolean;
  104729. private _isReadyInternal;
  104730. /**
  104731. * The engine the effect was initialized with.
  104732. * @returns the engine.
  104733. */
  104734. getEngine(): Engine;
  104735. /**
  104736. * The pipeline context for this effect
  104737. * @returns the associated pipeline context
  104738. */
  104739. getPipelineContext(): Nullable<IPipelineContext>;
  104740. /**
  104741. * The set of names of attribute variables for the shader.
  104742. * @returns An array of attribute names.
  104743. */
  104744. getAttributesNames(): string[];
  104745. /**
  104746. * Returns the attribute at the given index.
  104747. * @param index The index of the attribute.
  104748. * @returns The location of the attribute.
  104749. */
  104750. getAttributeLocation(index: number): number;
  104751. /**
  104752. * Returns the attribute based on the name of the variable.
  104753. * @param name of the attribute to look up.
  104754. * @returns the attribute location.
  104755. */
  104756. getAttributeLocationByName(name: string): number;
  104757. /**
  104758. * The number of attributes.
  104759. * @returns the numnber of attributes.
  104760. */
  104761. getAttributesCount(): number;
  104762. /**
  104763. * Gets the index of a uniform variable.
  104764. * @param uniformName of the uniform to look up.
  104765. * @returns the index.
  104766. */
  104767. getUniformIndex(uniformName: string): number;
  104768. /**
  104769. * Returns the attribute based on the name of the variable.
  104770. * @param uniformName of the uniform to look up.
  104771. * @returns the location of the uniform.
  104772. */
  104773. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  104774. /**
  104775. * Returns an array of sampler variable names
  104776. * @returns The array of sampler variable neames.
  104777. */
  104778. getSamplers(): string[];
  104779. /**
  104780. * The error from the last compilation.
  104781. * @returns the error string.
  104782. */
  104783. getCompilationError(): string;
  104784. /**
  104785. * Gets a boolean indicating that all fallbacks were used during compilation
  104786. * @returns true if all fallbacks were used
  104787. */
  104788. allFallbacksProcessed(): boolean;
  104789. /**
  104790. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  104791. * @param func The callback to be used.
  104792. */
  104793. executeWhenCompiled(func: (effect: Effect) => void): void;
  104794. private _checkIsReady;
  104795. private _loadShader;
  104796. /**
  104797. * Recompiles the webGL program
  104798. * @param vertexSourceCode The source code for the vertex shader.
  104799. * @param fragmentSourceCode The source code for the fragment shader.
  104800. * @param onCompiled Callback called when completed.
  104801. * @param onError Callback called on error.
  104802. * @hidden
  104803. */
  104804. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  104805. /**
  104806. * Prepares the effect
  104807. * @hidden
  104808. */
  104809. _prepareEffect(): void;
  104810. private _getShaderCodeAndErrorLine;
  104811. private _processCompilationErrors;
  104812. /**
  104813. * Checks if the effect is supported. (Must be called after compilation)
  104814. */
  104815. get isSupported(): boolean;
  104816. /**
  104817. * Binds a texture to the engine to be used as output of the shader.
  104818. * @param channel Name of the output variable.
  104819. * @param texture Texture to bind.
  104820. * @hidden
  104821. */
  104822. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  104823. /**
  104824. * Sets a texture on the engine to be used in the shader.
  104825. * @param channel Name of the sampler variable.
  104826. * @param texture Texture to set.
  104827. */
  104828. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  104829. /**
  104830. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  104831. * @param channel Name of the sampler variable.
  104832. * @param texture Texture to set.
  104833. */
  104834. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  104835. /**
  104836. * Sets an array of textures on the engine to be used in the shader.
  104837. * @param channel Name of the variable.
  104838. * @param textures Textures to set.
  104839. */
  104840. setTextureArray(channel: string, textures: BaseTexture[]): void;
  104841. /**
  104842. * 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)
  104843. * @param channel Name of the sampler variable.
  104844. * @param postProcess Post process to get the input texture from.
  104845. */
  104846. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  104847. /**
  104848. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  104849. * 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)
  104850. * @param channel Name of the sampler variable.
  104851. * @param postProcess Post process to get the output texture from.
  104852. */
  104853. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  104854. /** @hidden */
  104855. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  104856. /** @hidden */
  104857. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  104858. /** @hidden */
  104859. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  104860. /** @hidden */
  104861. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  104862. /**
  104863. * Binds a buffer to a uniform.
  104864. * @param buffer Buffer to bind.
  104865. * @param name Name of the uniform variable to bind to.
  104866. */
  104867. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  104868. /**
  104869. * Binds block to a uniform.
  104870. * @param blockName Name of the block to bind.
  104871. * @param index Index to bind.
  104872. */
  104873. bindUniformBlock(blockName: string, index: number): void;
  104874. /**
  104875. * Sets an interger value on a uniform variable.
  104876. * @param uniformName Name of the variable.
  104877. * @param value Value to be set.
  104878. * @returns this effect.
  104879. */
  104880. setInt(uniformName: string, value: number): Effect;
  104881. /**
  104882. * Sets an int array on a uniform variable.
  104883. * @param uniformName Name of the variable.
  104884. * @param array array to be set.
  104885. * @returns this effect.
  104886. */
  104887. setIntArray(uniformName: string, array: Int32Array): Effect;
  104888. /**
  104889. * 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)
  104890. * @param uniformName Name of the variable.
  104891. * @param array array to be set.
  104892. * @returns this effect.
  104893. */
  104894. setIntArray2(uniformName: string, array: Int32Array): Effect;
  104895. /**
  104896. * 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)
  104897. * @param uniformName Name of the variable.
  104898. * @param array array to be set.
  104899. * @returns this effect.
  104900. */
  104901. setIntArray3(uniformName: string, array: Int32Array): Effect;
  104902. /**
  104903. * 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)
  104904. * @param uniformName Name of the variable.
  104905. * @param array array to be set.
  104906. * @returns this effect.
  104907. */
  104908. setIntArray4(uniformName: string, array: Int32Array): Effect;
  104909. /**
  104910. * Sets an float array on a uniform variable.
  104911. * @param uniformName Name of the variable.
  104912. * @param array array to be set.
  104913. * @returns this effect.
  104914. */
  104915. setFloatArray(uniformName: string, array: Float32Array): Effect;
  104916. /**
  104917. * 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)
  104918. * @param uniformName Name of the variable.
  104919. * @param array array to be set.
  104920. * @returns this effect.
  104921. */
  104922. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  104923. /**
  104924. * 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)
  104925. * @param uniformName Name of the variable.
  104926. * @param array array to be set.
  104927. * @returns this effect.
  104928. */
  104929. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  104930. /**
  104931. * 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)
  104932. * @param uniformName Name of the variable.
  104933. * @param array array to be set.
  104934. * @returns this effect.
  104935. */
  104936. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  104937. /**
  104938. * Sets an array on a uniform variable.
  104939. * @param uniformName Name of the variable.
  104940. * @param array array to be set.
  104941. * @returns this effect.
  104942. */
  104943. setArray(uniformName: string, array: number[]): Effect;
  104944. /**
  104945. * 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)
  104946. * @param uniformName Name of the variable.
  104947. * @param array array to be set.
  104948. * @returns this effect.
  104949. */
  104950. setArray2(uniformName: string, array: number[]): Effect;
  104951. /**
  104952. * 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)
  104953. * @param uniformName Name of the variable.
  104954. * @param array array to be set.
  104955. * @returns this effect.
  104956. */
  104957. setArray3(uniformName: string, array: number[]): Effect;
  104958. /**
  104959. * 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)
  104960. * @param uniformName Name of the variable.
  104961. * @param array array to be set.
  104962. * @returns this effect.
  104963. */
  104964. setArray4(uniformName: string, array: number[]): Effect;
  104965. /**
  104966. * Sets matrices on a uniform variable.
  104967. * @param uniformName Name of the variable.
  104968. * @param matrices matrices to be set.
  104969. * @returns this effect.
  104970. */
  104971. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  104972. /**
  104973. * Sets matrix on a uniform variable.
  104974. * @param uniformName Name of the variable.
  104975. * @param matrix matrix to be set.
  104976. * @returns this effect.
  104977. */
  104978. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  104979. /**
  104980. * 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)
  104981. * @param uniformName Name of the variable.
  104982. * @param matrix matrix to be set.
  104983. * @returns this effect.
  104984. */
  104985. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  104986. /**
  104987. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  104988. * @param uniformName Name of the variable.
  104989. * @param matrix matrix to be set.
  104990. * @returns this effect.
  104991. */
  104992. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  104993. /**
  104994. * Sets a float on a uniform variable.
  104995. * @param uniformName Name of the variable.
  104996. * @param value value to be set.
  104997. * @returns this effect.
  104998. */
  104999. setFloat(uniformName: string, value: number): Effect;
  105000. /**
  105001. * Sets a boolean on a uniform variable.
  105002. * @param uniformName Name of the variable.
  105003. * @param bool value to be set.
  105004. * @returns this effect.
  105005. */
  105006. setBool(uniformName: string, bool: boolean): Effect;
  105007. /**
  105008. * Sets a Vector2 on a uniform variable.
  105009. * @param uniformName Name of the variable.
  105010. * @param vector2 vector2 to be set.
  105011. * @returns this effect.
  105012. */
  105013. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  105014. /**
  105015. * Sets a float2 on a uniform variable.
  105016. * @param uniformName Name of the variable.
  105017. * @param x First float in float2.
  105018. * @param y Second float in float2.
  105019. * @returns this effect.
  105020. */
  105021. setFloat2(uniformName: string, x: number, y: number): Effect;
  105022. /**
  105023. * Sets a Vector3 on a uniform variable.
  105024. * @param uniformName Name of the variable.
  105025. * @param vector3 Value to be set.
  105026. * @returns this effect.
  105027. */
  105028. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  105029. /**
  105030. * Sets a float3 on a uniform variable.
  105031. * @param uniformName Name of the variable.
  105032. * @param x First float in float3.
  105033. * @param y Second float in float3.
  105034. * @param z Third float in float3.
  105035. * @returns this effect.
  105036. */
  105037. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  105038. /**
  105039. * Sets a Vector4 on a uniform variable.
  105040. * @param uniformName Name of the variable.
  105041. * @param vector4 Value to be set.
  105042. * @returns this effect.
  105043. */
  105044. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  105045. /**
  105046. * Sets a float4 on a uniform variable.
  105047. * @param uniformName Name of the variable.
  105048. * @param x First float in float4.
  105049. * @param y Second float in float4.
  105050. * @param z Third float in float4.
  105051. * @param w Fourth float in float4.
  105052. * @returns this effect.
  105053. */
  105054. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  105055. /**
  105056. * Sets a Color3 on a uniform variable.
  105057. * @param uniformName Name of the variable.
  105058. * @param color3 Value to be set.
  105059. * @returns this effect.
  105060. */
  105061. setColor3(uniformName: string, color3: IColor3Like): Effect;
  105062. /**
  105063. * Sets a Color4 on a uniform variable.
  105064. * @param uniformName Name of the variable.
  105065. * @param color3 Value to be set.
  105066. * @param alpha Alpha value to be set.
  105067. * @returns this effect.
  105068. */
  105069. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  105070. /**
  105071. * Sets a Color4 on a uniform variable
  105072. * @param uniformName defines the name of the variable
  105073. * @param color4 defines the value to be set
  105074. * @returns this effect.
  105075. */
  105076. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  105077. /** Release all associated resources */
  105078. dispose(): void;
  105079. /**
  105080. * This function will add a new shader to the shader store
  105081. * @param name the name of the shader
  105082. * @param pixelShader optional pixel shader content
  105083. * @param vertexShader optional vertex shader content
  105084. */
  105085. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  105086. /**
  105087. * Store of each shader (The can be looked up using effect.key)
  105088. */
  105089. static ShadersStore: {
  105090. [key: string]: string;
  105091. };
  105092. /**
  105093. * Store of each included file for a shader (The can be looked up using effect.key)
  105094. */
  105095. static IncludesShadersStore: {
  105096. [key: string]: string;
  105097. };
  105098. /**
  105099. * Resets the cache of effects.
  105100. */
  105101. static ResetCache(): void;
  105102. }
  105103. }
  105104. declare module BABYLON {
  105105. /**
  105106. * Interface used to describe the capabilities of the engine relatively to the current browser
  105107. */
  105108. export interface EngineCapabilities {
  105109. /** Maximum textures units per fragment shader */
  105110. maxTexturesImageUnits: number;
  105111. /** Maximum texture units per vertex shader */
  105112. maxVertexTextureImageUnits: number;
  105113. /** Maximum textures units in the entire pipeline */
  105114. maxCombinedTexturesImageUnits: number;
  105115. /** Maximum texture size */
  105116. maxTextureSize: number;
  105117. /** Maximum texture samples */
  105118. maxSamples?: number;
  105119. /** Maximum cube texture size */
  105120. maxCubemapTextureSize: number;
  105121. /** Maximum render texture size */
  105122. maxRenderTextureSize: number;
  105123. /** Maximum number of vertex attributes */
  105124. maxVertexAttribs: number;
  105125. /** Maximum number of varyings */
  105126. maxVaryingVectors: number;
  105127. /** Maximum number of uniforms per vertex shader */
  105128. maxVertexUniformVectors: number;
  105129. /** Maximum number of uniforms per fragment shader */
  105130. maxFragmentUniformVectors: number;
  105131. /** Defines if standard derivates (dx/dy) are supported */
  105132. standardDerivatives: boolean;
  105133. /** Defines if s3tc texture compression is supported */
  105134. s3tc?: WEBGL_compressed_texture_s3tc;
  105135. /** Defines if pvrtc texture compression is supported */
  105136. pvrtc: any;
  105137. /** Defines if etc1 texture compression is supported */
  105138. etc1: any;
  105139. /** Defines if etc2 texture compression is supported */
  105140. etc2: any;
  105141. /** Defines if astc texture compression is supported */
  105142. astc: any;
  105143. /** Defines if float textures are supported */
  105144. textureFloat: boolean;
  105145. /** Defines if vertex array objects are supported */
  105146. vertexArrayObject: boolean;
  105147. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  105148. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  105149. /** Gets the maximum level of anisotropy supported */
  105150. maxAnisotropy: number;
  105151. /** Defines if instancing is supported */
  105152. instancedArrays: boolean;
  105153. /** Defines if 32 bits indices are supported */
  105154. uintIndices: boolean;
  105155. /** Defines if high precision shaders are supported */
  105156. highPrecisionShaderSupported: boolean;
  105157. /** Defines if depth reading in the fragment shader is supported */
  105158. fragmentDepthSupported: boolean;
  105159. /** Defines if float texture linear filtering is supported*/
  105160. textureFloatLinearFiltering: boolean;
  105161. /** Defines if rendering to float textures is supported */
  105162. textureFloatRender: boolean;
  105163. /** Defines if half float textures are supported*/
  105164. textureHalfFloat: boolean;
  105165. /** Defines if half float texture linear filtering is supported*/
  105166. textureHalfFloatLinearFiltering: boolean;
  105167. /** Defines if rendering to half float textures is supported */
  105168. textureHalfFloatRender: boolean;
  105169. /** Defines if textureLOD shader command is supported */
  105170. textureLOD: boolean;
  105171. /** Defines if draw buffers extension is supported */
  105172. drawBuffersExtension: boolean;
  105173. /** Defines if depth textures are supported */
  105174. depthTextureExtension: boolean;
  105175. /** Defines if float color buffer are supported */
  105176. colorBufferFloat: boolean;
  105177. /** Gets disjoint timer query extension (null if not supported) */
  105178. timerQuery?: EXT_disjoint_timer_query;
  105179. /** Defines if timestamp can be used with timer query */
  105180. canUseTimestampForTimerQuery: boolean;
  105181. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  105182. multiview?: any;
  105183. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  105184. oculusMultiview?: any;
  105185. /** Function used to let the system compiles shaders in background */
  105186. parallelShaderCompile?: {
  105187. COMPLETION_STATUS_KHR: number;
  105188. };
  105189. /** Max number of texture samples for MSAA */
  105190. maxMSAASamples: number;
  105191. /** Defines if the blend min max extension is supported */
  105192. blendMinMax: boolean;
  105193. }
  105194. }
  105195. declare module BABYLON {
  105196. /**
  105197. * @hidden
  105198. **/
  105199. export class DepthCullingState {
  105200. private _isDepthTestDirty;
  105201. private _isDepthMaskDirty;
  105202. private _isDepthFuncDirty;
  105203. private _isCullFaceDirty;
  105204. private _isCullDirty;
  105205. private _isZOffsetDirty;
  105206. private _isFrontFaceDirty;
  105207. private _depthTest;
  105208. private _depthMask;
  105209. private _depthFunc;
  105210. private _cull;
  105211. private _cullFace;
  105212. private _zOffset;
  105213. private _frontFace;
  105214. /**
  105215. * Initializes the state.
  105216. */
  105217. constructor();
  105218. get isDirty(): boolean;
  105219. get zOffset(): number;
  105220. set zOffset(value: number);
  105221. get cullFace(): Nullable<number>;
  105222. set cullFace(value: Nullable<number>);
  105223. get cull(): Nullable<boolean>;
  105224. set cull(value: Nullable<boolean>);
  105225. get depthFunc(): Nullable<number>;
  105226. set depthFunc(value: Nullable<number>);
  105227. get depthMask(): boolean;
  105228. set depthMask(value: boolean);
  105229. get depthTest(): boolean;
  105230. set depthTest(value: boolean);
  105231. get frontFace(): Nullable<number>;
  105232. set frontFace(value: Nullable<number>);
  105233. reset(): void;
  105234. apply(gl: WebGLRenderingContext): void;
  105235. }
  105236. }
  105237. declare module BABYLON {
  105238. /**
  105239. * @hidden
  105240. **/
  105241. export class StencilState {
  105242. /** 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 */
  105243. static readonly ALWAYS: number;
  105244. /** Passed to stencilOperation to specify that stencil value must be kept */
  105245. static readonly KEEP: number;
  105246. /** Passed to stencilOperation to specify that stencil value must be replaced */
  105247. static readonly REPLACE: number;
  105248. private _isStencilTestDirty;
  105249. private _isStencilMaskDirty;
  105250. private _isStencilFuncDirty;
  105251. private _isStencilOpDirty;
  105252. private _stencilTest;
  105253. private _stencilMask;
  105254. private _stencilFunc;
  105255. private _stencilFuncRef;
  105256. private _stencilFuncMask;
  105257. private _stencilOpStencilFail;
  105258. private _stencilOpDepthFail;
  105259. private _stencilOpStencilDepthPass;
  105260. get isDirty(): boolean;
  105261. get stencilFunc(): number;
  105262. set stencilFunc(value: number);
  105263. get stencilFuncRef(): number;
  105264. set stencilFuncRef(value: number);
  105265. get stencilFuncMask(): number;
  105266. set stencilFuncMask(value: number);
  105267. get stencilOpStencilFail(): number;
  105268. set stencilOpStencilFail(value: number);
  105269. get stencilOpDepthFail(): number;
  105270. set stencilOpDepthFail(value: number);
  105271. get stencilOpStencilDepthPass(): number;
  105272. set stencilOpStencilDepthPass(value: number);
  105273. get stencilMask(): number;
  105274. set stencilMask(value: number);
  105275. get stencilTest(): boolean;
  105276. set stencilTest(value: boolean);
  105277. constructor();
  105278. reset(): void;
  105279. apply(gl: WebGLRenderingContext): void;
  105280. }
  105281. }
  105282. declare module BABYLON {
  105283. /**
  105284. * @hidden
  105285. **/
  105286. export class AlphaState {
  105287. private _isAlphaBlendDirty;
  105288. private _isBlendFunctionParametersDirty;
  105289. private _isBlendEquationParametersDirty;
  105290. private _isBlendConstantsDirty;
  105291. private _alphaBlend;
  105292. private _blendFunctionParameters;
  105293. private _blendEquationParameters;
  105294. private _blendConstants;
  105295. /**
  105296. * Initializes the state.
  105297. */
  105298. constructor();
  105299. get isDirty(): boolean;
  105300. get alphaBlend(): boolean;
  105301. set alphaBlend(value: boolean);
  105302. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  105303. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  105304. setAlphaEquationParameters(rgb: number, alpha: number): void;
  105305. reset(): void;
  105306. apply(gl: WebGLRenderingContext): void;
  105307. }
  105308. }
  105309. declare module BABYLON {
  105310. /** @hidden */
  105311. export class WebGL2ShaderProcessor implements IShaderProcessor {
  105312. attributeProcessor(attribute: string): string;
  105313. varyingProcessor(varying: string, isFragment: boolean): string;
  105314. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  105315. }
  105316. }
  105317. declare module BABYLON {
  105318. /**
  105319. * Interface for attribute information associated with buffer instanciation
  105320. */
  105321. export interface InstancingAttributeInfo {
  105322. /**
  105323. * Name of the GLSL attribute
  105324. * if attribute index is not specified, this is used to retrieve the index from the effect
  105325. */
  105326. attributeName: string;
  105327. /**
  105328. * Index/offset of the attribute in the vertex shader
  105329. * if not specified, this will be computes from the name.
  105330. */
  105331. index?: number;
  105332. /**
  105333. * size of the attribute, 1, 2, 3 or 4
  105334. */
  105335. attributeSize: number;
  105336. /**
  105337. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  105338. */
  105339. offset: number;
  105340. /**
  105341. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  105342. * default to 1
  105343. */
  105344. divisor?: number;
  105345. /**
  105346. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  105347. * default is FLOAT
  105348. */
  105349. attributeType?: number;
  105350. /**
  105351. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  105352. */
  105353. normalized?: boolean;
  105354. }
  105355. }
  105356. declare module BABYLON {
  105357. interface ThinEngine {
  105358. /**
  105359. * Update a video texture
  105360. * @param texture defines the texture to update
  105361. * @param video defines the video element to use
  105362. * @param invertY defines if data must be stored with Y axis inverted
  105363. */
  105364. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  105365. }
  105366. }
  105367. declare module BABYLON {
  105368. /**
  105369. * Settings for finer control over video usage
  105370. */
  105371. export interface VideoTextureSettings {
  105372. /**
  105373. * Applies `autoplay` to video, if specified
  105374. */
  105375. autoPlay?: boolean;
  105376. /**
  105377. * Applies `loop` to video, if specified
  105378. */
  105379. loop?: boolean;
  105380. /**
  105381. * Automatically updates internal texture from video at every frame in the render loop
  105382. */
  105383. autoUpdateTexture: boolean;
  105384. /**
  105385. * Image src displayed during the video loading or until the user interacts with the video.
  105386. */
  105387. poster?: string;
  105388. }
  105389. /**
  105390. * If you want to display a video in your scene, this is the special texture for that.
  105391. * This special texture works similar to other textures, with the exception of a few parameters.
  105392. * @see https://doc.babylonjs.com/how_to/video_texture
  105393. */
  105394. export class VideoTexture extends Texture {
  105395. /**
  105396. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  105397. */
  105398. readonly autoUpdateTexture: boolean;
  105399. /**
  105400. * The video instance used by the texture internally
  105401. */
  105402. readonly video: HTMLVideoElement;
  105403. private _onUserActionRequestedObservable;
  105404. /**
  105405. * Event triggerd when a dom action is required by the user to play the video.
  105406. * This happens due to recent changes in browser policies preventing video to auto start.
  105407. */
  105408. get onUserActionRequestedObservable(): Observable<Texture>;
  105409. private _generateMipMaps;
  105410. private _engine;
  105411. private _stillImageCaptured;
  105412. private _displayingPosterTexture;
  105413. private _settings;
  105414. private _createInternalTextureOnEvent;
  105415. private _frameId;
  105416. private _currentSrc;
  105417. /**
  105418. * Creates a video texture.
  105419. * If you want to display a video in your scene, this is the special texture for that.
  105420. * This special texture works similar to other textures, with the exception of a few parameters.
  105421. * @see https://doc.babylonjs.com/how_to/video_texture
  105422. * @param name optional name, will detect from video source, if not defined
  105423. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  105424. * @param scene is obviously the current scene.
  105425. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  105426. * @param invertY is false by default but can be used to invert video on Y axis
  105427. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  105428. * @param settings allows finer control over video usage
  105429. */
  105430. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  105431. private _getName;
  105432. private _getVideo;
  105433. private _createInternalTexture;
  105434. private reset;
  105435. /**
  105436. * @hidden Internal method to initiate `update`.
  105437. */
  105438. _rebuild(): void;
  105439. /**
  105440. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  105441. */
  105442. update(): void;
  105443. /**
  105444. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  105445. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  105446. */
  105447. updateTexture(isVisible: boolean): void;
  105448. protected _updateInternalTexture: () => void;
  105449. /**
  105450. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  105451. * @param url New url.
  105452. */
  105453. updateURL(url: string): void;
  105454. /**
  105455. * Clones the texture.
  105456. * @returns the cloned texture
  105457. */
  105458. clone(): VideoTexture;
  105459. /**
  105460. * Dispose the texture and release its associated resources.
  105461. */
  105462. dispose(): void;
  105463. /**
  105464. * Creates a video texture straight from a stream.
  105465. * @param scene Define the scene the texture should be created in
  105466. * @param stream Define the stream the texture should be created from
  105467. * @returns The created video texture as a promise
  105468. */
  105469. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  105470. /**
  105471. * Creates a video texture straight from your WebCam video feed.
  105472. * @param scene Define the scene the texture should be created in
  105473. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  105474. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  105475. * @returns The created video texture as a promise
  105476. */
  105477. static CreateFromWebCamAsync(scene: Scene, constraints: {
  105478. minWidth: number;
  105479. maxWidth: number;
  105480. minHeight: number;
  105481. maxHeight: number;
  105482. deviceId: string;
  105483. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  105484. /**
  105485. * Creates a video texture straight from your WebCam video feed.
  105486. * @param scene Define the scene the texture should be created in
  105487. * @param onReady Define a callback to triggered once the texture will be ready
  105488. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  105489. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  105490. */
  105491. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  105492. minWidth: number;
  105493. maxWidth: number;
  105494. minHeight: number;
  105495. maxHeight: number;
  105496. deviceId: string;
  105497. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  105498. }
  105499. }
  105500. declare module BABYLON {
  105501. /**
  105502. * Defines the interface used by objects working like Scene
  105503. * @hidden
  105504. */
  105505. export interface ISceneLike {
  105506. _addPendingData(data: any): void;
  105507. _removePendingData(data: any): void;
  105508. offlineProvider: IOfflineProvider;
  105509. }
  105510. /** Interface defining initialization parameters for Engine class */
  105511. export interface EngineOptions extends WebGLContextAttributes {
  105512. /**
  105513. * Defines if the engine should no exceed a specified device ratio
  105514. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  105515. */
  105516. limitDeviceRatio?: number;
  105517. /**
  105518. * Defines if webvr should be enabled automatically
  105519. * @see http://doc.babylonjs.com/how_to/webvr_camera
  105520. */
  105521. autoEnableWebVR?: boolean;
  105522. /**
  105523. * Defines if webgl2 should be turned off even if supported
  105524. * @see http://doc.babylonjs.com/features/webgl2
  105525. */
  105526. disableWebGL2Support?: boolean;
  105527. /**
  105528. * Defines if webaudio should be initialized as well
  105529. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  105530. */
  105531. audioEngine?: boolean;
  105532. /**
  105533. * Defines if animations should run using a deterministic lock step
  105534. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  105535. */
  105536. deterministicLockstep?: boolean;
  105537. /** Defines the maximum steps to use with deterministic lock step mode */
  105538. lockstepMaxSteps?: number;
  105539. /** Defines the seconds between each deterministic lock step */
  105540. timeStep?: number;
  105541. /**
  105542. * Defines that engine should ignore context lost events
  105543. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  105544. */
  105545. doNotHandleContextLost?: boolean;
  105546. /**
  105547. * Defines that engine should ignore modifying touch action attribute and style
  105548. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  105549. */
  105550. doNotHandleTouchAction?: boolean;
  105551. /**
  105552. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  105553. */
  105554. useHighPrecisionFloats?: boolean;
  105555. }
  105556. /**
  105557. * The base engine class (root of all engines)
  105558. */
  105559. export class ThinEngine {
  105560. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  105561. static ExceptionList: ({
  105562. key: string;
  105563. capture: string;
  105564. captureConstraint: number;
  105565. targets: string[];
  105566. } | {
  105567. key: string;
  105568. capture: null;
  105569. captureConstraint: null;
  105570. targets: string[];
  105571. })[];
  105572. /** @hidden */
  105573. static _TextureLoaders: IInternalTextureLoader[];
  105574. /**
  105575. * Returns the current npm package of the sdk
  105576. */
  105577. static get NpmPackage(): string;
  105578. /**
  105579. * Returns the current version of the framework
  105580. */
  105581. static get Version(): string;
  105582. /**
  105583. * Returns a string describing the current engine
  105584. */
  105585. get description(): string;
  105586. /**
  105587. * Gets or sets the epsilon value used by collision engine
  105588. */
  105589. static CollisionsEpsilon: number;
  105590. /**
  105591. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  105592. */
  105593. static get ShadersRepository(): string;
  105594. static set ShadersRepository(value: string);
  105595. /** @hidden */
  105596. _shaderProcessor: IShaderProcessor;
  105597. /**
  105598. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  105599. */
  105600. forcePOTTextures: boolean;
  105601. /**
  105602. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  105603. */
  105604. isFullscreen: boolean;
  105605. /**
  105606. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  105607. */
  105608. cullBackFaces: boolean;
  105609. /**
  105610. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  105611. */
  105612. renderEvenInBackground: boolean;
  105613. /**
  105614. * Gets or sets a boolean indicating that cache can be kept between frames
  105615. */
  105616. preventCacheWipeBetweenFrames: boolean;
  105617. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  105618. validateShaderPrograms: boolean;
  105619. /**
  105620. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  105621. * This can provide greater z depth for distant objects.
  105622. */
  105623. useReverseDepthBuffer: boolean;
  105624. /**
  105625. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  105626. */
  105627. disableUniformBuffers: boolean;
  105628. /** @hidden */
  105629. _uniformBuffers: UniformBuffer[];
  105630. /**
  105631. * Gets a boolean indicating that the engine supports uniform buffers
  105632. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  105633. */
  105634. get supportsUniformBuffers(): boolean;
  105635. /** @hidden */
  105636. _gl: WebGLRenderingContext;
  105637. /** @hidden */
  105638. _webGLVersion: number;
  105639. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  105640. protected _windowIsBackground: boolean;
  105641. protected _creationOptions: EngineOptions;
  105642. protected _highPrecisionShadersAllowed: boolean;
  105643. /** @hidden */
  105644. get _shouldUseHighPrecisionShader(): boolean;
  105645. /**
  105646. * Gets a boolean indicating that only power of 2 textures are supported
  105647. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  105648. */
  105649. get needPOTTextures(): boolean;
  105650. /** @hidden */
  105651. _badOS: boolean;
  105652. /** @hidden */
  105653. _badDesktopOS: boolean;
  105654. private _hardwareScalingLevel;
  105655. /** @hidden */
  105656. _caps: EngineCapabilities;
  105657. private _isStencilEnable;
  105658. private _glVersion;
  105659. private _glRenderer;
  105660. private _glVendor;
  105661. /** @hidden */
  105662. _videoTextureSupported: boolean;
  105663. protected _renderingQueueLaunched: boolean;
  105664. protected _activeRenderLoops: (() => void)[];
  105665. /**
  105666. * Observable signaled when a context lost event is raised
  105667. */
  105668. onContextLostObservable: Observable<ThinEngine>;
  105669. /**
  105670. * Observable signaled when a context restored event is raised
  105671. */
  105672. onContextRestoredObservable: Observable<ThinEngine>;
  105673. private _onContextLost;
  105674. private _onContextRestored;
  105675. protected _contextWasLost: boolean;
  105676. /** @hidden */
  105677. _doNotHandleContextLost: boolean;
  105678. /**
  105679. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  105680. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  105681. */
  105682. get doNotHandleContextLost(): boolean;
  105683. set doNotHandleContextLost(value: boolean);
  105684. /**
  105685. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  105686. */
  105687. disableVertexArrayObjects: boolean;
  105688. /** @hidden */
  105689. protected _colorWrite: boolean;
  105690. /** @hidden */
  105691. protected _colorWriteChanged: boolean;
  105692. /** @hidden */
  105693. protected _depthCullingState: DepthCullingState;
  105694. /** @hidden */
  105695. protected _stencilState: StencilState;
  105696. /** @hidden */
  105697. _alphaState: AlphaState;
  105698. /** @hidden */
  105699. _alphaMode: number;
  105700. /** @hidden */
  105701. _alphaEquation: number;
  105702. /** @hidden */
  105703. _internalTexturesCache: InternalTexture[];
  105704. /** @hidden */
  105705. protected _activeChannel: number;
  105706. private _currentTextureChannel;
  105707. /** @hidden */
  105708. protected _boundTexturesCache: {
  105709. [key: string]: Nullable<InternalTexture>;
  105710. };
  105711. /** @hidden */
  105712. protected _currentEffect: Nullable<Effect>;
  105713. /** @hidden */
  105714. protected _currentProgram: Nullable<WebGLProgram>;
  105715. private _compiledEffects;
  105716. private _vertexAttribArraysEnabled;
  105717. /** @hidden */
  105718. protected _cachedViewport: Nullable<IViewportLike>;
  105719. private _cachedVertexArrayObject;
  105720. /** @hidden */
  105721. protected _cachedVertexBuffers: any;
  105722. /** @hidden */
  105723. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  105724. /** @hidden */
  105725. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  105726. /** @hidden */
  105727. _currentRenderTarget: Nullable<InternalTexture>;
  105728. private _uintIndicesCurrentlySet;
  105729. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  105730. /** @hidden */
  105731. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  105732. private _currentBufferPointers;
  105733. private _currentInstanceLocations;
  105734. private _currentInstanceBuffers;
  105735. private _textureUnits;
  105736. /** @hidden */
  105737. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  105738. /** @hidden */
  105739. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  105740. /** @hidden */
  105741. _boundRenderFunction: any;
  105742. private _vaoRecordInProgress;
  105743. private _mustWipeVertexAttributes;
  105744. private _emptyTexture;
  105745. private _emptyCubeTexture;
  105746. private _emptyTexture3D;
  105747. private _emptyTexture2DArray;
  105748. /** @hidden */
  105749. _frameHandler: number;
  105750. private _nextFreeTextureSlots;
  105751. private _maxSimultaneousTextures;
  105752. private _activeRequests;
  105753. /** @hidden */
  105754. _transformTextureUrl: Nullable<(url: string) => string>;
  105755. protected get _supportsHardwareTextureRescaling(): boolean;
  105756. private _framebufferDimensionsObject;
  105757. /**
  105758. * sets the object from which width and height will be taken from when getting render width and height
  105759. * Will fallback to the gl object
  105760. * @param dimensions the framebuffer width and height that will be used.
  105761. */
  105762. set framebufferDimensionsObject(dimensions: Nullable<{
  105763. framebufferWidth: number;
  105764. framebufferHeight: number;
  105765. }>);
  105766. /**
  105767. * Gets the current viewport
  105768. */
  105769. get currentViewport(): Nullable<IViewportLike>;
  105770. /**
  105771. * Gets the default empty texture
  105772. */
  105773. get emptyTexture(): InternalTexture;
  105774. /**
  105775. * Gets the default empty 3D texture
  105776. */
  105777. get emptyTexture3D(): InternalTexture;
  105778. /**
  105779. * Gets the default empty 2D array texture
  105780. */
  105781. get emptyTexture2DArray(): InternalTexture;
  105782. /**
  105783. * Gets the default empty cube texture
  105784. */
  105785. get emptyCubeTexture(): InternalTexture;
  105786. /**
  105787. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  105788. */
  105789. readonly premultipliedAlpha: boolean;
  105790. /**
  105791. * Observable event triggered before each texture is initialized
  105792. */
  105793. onBeforeTextureInitObservable: Observable<Texture>;
  105794. /**
  105795. * Creates a new engine
  105796. * @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
  105797. * @param antialias defines enable antialiasing (default: false)
  105798. * @param options defines further options to be sent to the getContext() function
  105799. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  105800. */
  105801. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  105802. private _rebuildInternalTextures;
  105803. private _rebuildEffects;
  105804. /**
  105805. * Gets a boolean indicating if all created effects are ready
  105806. * @returns true if all effects are ready
  105807. */
  105808. areAllEffectsReady(): boolean;
  105809. protected _rebuildBuffers(): void;
  105810. protected _initGLContext(): void;
  105811. /**
  105812. * Gets version of the current webGL context
  105813. */
  105814. get webGLVersion(): number;
  105815. /**
  105816. * Gets a string idenfifying the name of the class
  105817. * @returns "Engine" string
  105818. */
  105819. getClassName(): string;
  105820. /**
  105821. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  105822. */
  105823. get isStencilEnable(): boolean;
  105824. /** @hidden */
  105825. _prepareWorkingCanvas(): void;
  105826. /**
  105827. * Reset the texture cache to empty state
  105828. */
  105829. resetTextureCache(): void;
  105830. /**
  105831. * Gets an object containing information about the current webGL context
  105832. * @returns an object containing the vender, the renderer and the version of the current webGL context
  105833. */
  105834. getGlInfo(): {
  105835. vendor: string;
  105836. renderer: string;
  105837. version: string;
  105838. };
  105839. /**
  105840. * Defines the hardware scaling level.
  105841. * By default the hardware scaling level is computed from the window device ratio.
  105842. * 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.
  105843. * @param level defines the level to use
  105844. */
  105845. setHardwareScalingLevel(level: number): void;
  105846. /**
  105847. * Gets the current hardware scaling level.
  105848. * By default the hardware scaling level is computed from the window device ratio.
  105849. * 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.
  105850. * @returns a number indicating the current hardware scaling level
  105851. */
  105852. getHardwareScalingLevel(): number;
  105853. /**
  105854. * Gets the list of loaded textures
  105855. * @returns an array containing all loaded textures
  105856. */
  105857. getLoadedTexturesCache(): InternalTexture[];
  105858. /**
  105859. * Gets the object containing all engine capabilities
  105860. * @returns the EngineCapabilities object
  105861. */
  105862. getCaps(): EngineCapabilities;
  105863. /**
  105864. * stop executing a render loop function and remove it from the execution array
  105865. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  105866. */
  105867. stopRenderLoop(renderFunction?: () => void): void;
  105868. /** @hidden */
  105869. _renderLoop(): void;
  105870. /**
  105871. * Gets the HTML canvas attached with the current webGL context
  105872. * @returns a HTML canvas
  105873. */
  105874. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  105875. /**
  105876. * Gets host window
  105877. * @returns the host window object
  105878. */
  105879. getHostWindow(): Nullable<Window>;
  105880. /**
  105881. * Gets the current render width
  105882. * @param useScreen defines if screen size must be used (or the current render target if any)
  105883. * @returns a number defining the current render width
  105884. */
  105885. getRenderWidth(useScreen?: boolean): number;
  105886. /**
  105887. * Gets the current render height
  105888. * @param useScreen defines if screen size must be used (or the current render target if any)
  105889. * @returns a number defining the current render height
  105890. */
  105891. getRenderHeight(useScreen?: boolean): number;
  105892. /**
  105893. * Can be used to override the current requestAnimationFrame requester.
  105894. * @hidden
  105895. */
  105896. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  105897. /**
  105898. * Register and execute a render loop. The engine can have more than one render function
  105899. * @param renderFunction defines the function to continuously execute
  105900. */
  105901. runRenderLoop(renderFunction: () => void): void;
  105902. /**
  105903. * Clear the current render buffer or the current render target (if any is set up)
  105904. * @param color defines the color to use
  105905. * @param backBuffer defines if the back buffer must be cleared
  105906. * @param depth defines if the depth buffer must be cleared
  105907. * @param stencil defines if the stencil buffer must be cleared
  105908. */
  105909. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  105910. private _viewportCached;
  105911. /** @hidden */
  105912. _viewport(x: number, y: number, width: number, height: number): void;
  105913. /**
  105914. * Set the WebGL's viewport
  105915. * @param viewport defines the viewport element to be used
  105916. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  105917. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  105918. */
  105919. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  105920. /**
  105921. * Begin a new frame
  105922. */
  105923. beginFrame(): void;
  105924. /**
  105925. * Enf the current frame
  105926. */
  105927. endFrame(): void;
  105928. /**
  105929. * Resize the view according to the canvas' size
  105930. */
  105931. resize(): void;
  105932. /**
  105933. * Force a specific size of the canvas
  105934. * @param width defines the new canvas' width
  105935. * @param height defines the new canvas' height
  105936. */
  105937. setSize(width: number, height: number): void;
  105938. /**
  105939. * Binds the frame buffer to the specified texture.
  105940. * @param texture The texture to render to or null for the default canvas
  105941. * @param faceIndex The face of the texture to render to in case of cube texture
  105942. * @param requiredWidth The width of the target to render to
  105943. * @param requiredHeight The height of the target to render to
  105944. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  105945. * @param lodLevel defines the lod level to bind to the frame buffer
  105946. * @param layer defines the 2d array index to bind to frame buffer to
  105947. */
  105948. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  105949. /** @hidden */
  105950. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  105951. /**
  105952. * Unbind the current render target texture from the webGL context
  105953. * @param texture defines the render target texture to unbind
  105954. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  105955. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  105956. */
  105957. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  105958. /**
  105959. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  105960. */
  105961. flushFramebuffer(): void;
  105962. /**
  105963. * Unbind the current render target and bind the default framebuffer
  105964. */
  105965. restoreDefaultFramebuffer(): void;
  105966. /** @hidden */
  105967. protected _resetVertexBufferBinding(): void;
  105968. /**
  105969. * Creates a vertex buffer
  105970. * @param data the data for the vertex buffer
  105971. * @returns the new WebGL static buffer
  105972. */
  105973. createVertexBuffer(data: DataArray): DataBuffer;
  105974. private _createVertexBuffer;
  105975. /**
  105976. * Creates a dynamic vertex buffer
  105977. * @param data the data for the dynamic vertex buffer
  105978. * @returns the new WebGL dynamic buffer
  105979. */
  105980. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  105981. protected _resetIndexBufferBinding(): void;
  105982. /**
  105983. * Creates a new index buffer
  105984. * @param indices defines the content of the index buffer
  105985. * @param updatable defines if the index buffer must be updatable
  105986. * @returns a new webGL buffer
  105987. */
  105988. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  105989. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  105990. /**
  105991. * Bind a webGL buffer to the webGL context
  105992. * @param buffer defines the buffer to bind
  105993. */
  105994. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  105995. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  105996. private bindBuffer;
  105997. /**
  105998. * update the bound buffer with the given data
  105999. * @param data defines the data to update
  106000. */
  106001. updateArrayBuffer(data: Float32Array): void;
  106002. private _vertexAttribPointer;
  106003. /** @hidden */
  106004. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  106005. private _bindVertexBuffersAttributes;
  106006. /**
  106007. * Records a vertex array object
  106008. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  106009. * @param vertexBuffers defines the list of vertex buffers to store
  106010. * @param indexBuffer defines the index buffer to store
  106011. * @param effect defines the effect to store
  106012. * @returns the new vertex array object
  106013. */
  106014. recordVertexArrayObject(vertexBuffers: {
  106015. [key: string]: VertexBuffer;
  106016. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  106017. /**
  106018. * Bind a specific vertex array object
  106019. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  106020. * @param vertexArrayObject defines the vertex array object to bind
  106021. * @param indexBuffer defines the index buffer to bind
  106022. */
  106023. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  106024. /**
  106025. * Bind webGl buffers directly to the webGL context
  106026. * @param vertexBuffer defines the vertex buffer to bind
  106027. * @param indexBuffer defines the index buffer to bind
  106028. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  106029. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  106030. * @param effect defines the effect associated with the vertex buffer
  106031. */
  106032. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  106033. private _unbindVertexArrayObject;
  106034. /**
  106035. * Bind a list of vertex buffers to the webGL context
  106036. * @param vertexBuffers defines the list of vertex buffers to bind
  106037. * @param indexBuffer defines the index buffer to bind
  106038. * @param effect defines the effect associated with the vertex buffers
  106039. */
  106040. bindBuffers(vertexBuffers: {
  106041. [key: string]: Nullable<VertexBuffer>;
  106042. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  106043. /**
  106044. * Unbind all instance attributes
  106045. */
  106046. unbindInstanceAttributes(): void;
  106047. /**
  106048. * Release and free the memory of a vertex array object
  106049. * @param vao defines the vertex array object to delete
  106050. */
  106051. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  106052. /** @hidden */
  106053. _releaseBuffer(buffer: DataBuffer): boolean;
  106054. protected _deleteBuffer(buffer: DataBuffer): void;
  106055. /**
  106056. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  106057. * @param instancesBuffer defines the webGL buffer to update and bind
  106058. * @param data defines the data to store in the buffer
  106059. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  106060. */
  106061. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  106062. /**
  106063. * Bind the content of a webGL buffer used with instantiation
  106064. * @param instancesBuffer defines the webGL buffer to bind
  106065. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  106066. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  106067. */
  106068. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  106069. /**
  106070. * Disable the instance attribute corresponding to the name in parameter
  106071. * @param name defines the name of the attribute to disable
  106072. */
  106073. disableInstanceAttributeByName(name: string): void;
  106074. /**
  106075. * Disable the instance attribute corresponding to the location in parameter
  106076. * @param attributeLocation defines the attribute location of the attribute to disable
  106077. */
  106078. disableInstanceAttribute(attributeLocation: number): void;
  106079. /**
  106080. * Disable the attribute corresponding to the location in parameter
  106081. * @param attributeLocation defines the attribute location of the attribute to disable
  106082. */
  106083. disableAttributeByIndex(attributeLocation: number): void;
  106084. /**
  106085. * Send a draw order
  106086. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  106087. * @param indexStart defines the starting index
  106088. * @param indexCount defines the number of index to draw
  106089. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  106090. */
  106091. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  106092. /**
  106093. * Draw a list of points
  106094. * @param verticesStart defines the index of first vertex to draw
  106095. * @param verticesCount defines the count of vertices to draw
  106096. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  106097. */
  106098. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  106099. /**
  106100. * Draw a list of unindexed primitives
  106101. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  106102. * @param verticesStart defines the index of first vertex to draw
  106103. * @param verticesCount defines the count of vertices to draw
  106104. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  106105. */
  106106. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  106107. /**
  106108. * Draw a list of indexed primitives
  106109. * @param fillMode defines the primitive to use
  106110. * @param indexStart defines the starting index
  106111. * @param indexCount defines the number of index to draw
  106112. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  106113. */
  106114. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  106115. /**
  106116. * Draw a list of unindexed primitives
  106117. * @param fillMode defines the primitive to use
  106118. * @param verticesStart defines the index of first vertex to draw
  106119. * @param verticesCount defines the count of vertices to draw
  106120. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  106121. */
  106122. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  106123. private _drawMode;
  106124. /** @hidden */
  106125. protected _reportDrawCall(): void;
  106126. /** @hidden */
  106127. _releaseEffect(effect: Effect): void;
  106128. /** @hidden */
  106129. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  106130. /**
  106131. * Create a new effect (used to store vertex/fragment shaders)
  106132. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  106133. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  106134. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  106135. * @param samplers defines an array of string used to represent textures
  106136. * @param defines defines the string containing the defines to use to compile the shaders
  106137. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  106138. * @param onCompiled defines a function to call when the effect creation is successful
  106139. * @param onError defines a function to call when the effect creation has failed
  106140. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  106141. * @returns the new Effect
  106142. */
  106143. 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;
  106144. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  106145. private _compileShader;
  106146. private _compileRawShader;
  106147. /** @hidden */
  106148. _getShaderSource(shader: WebGLShader): Nullable<string>;
  106149. /**
  106150. * Directly creates a webGL program
  106151. * @param pipelineContext defines the pipeline context to attach to
  106152. * @param vertexCode defines the vertex shader code to use
  106153. * @param fragmentCode defines the fragment shader code to use
  106154. * @param context defines the webGL context to use (if not set, the current one will be used)
  106155. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  106156. * @returns the new webGL program
  106157. */
  106158. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  106159. /**
  106160. * Creates a webGL program
  106161. * @param pipelineContext defines the pipeline context to attach to
  106162. * @param vertexCode defines the vertex shader code to use
  106163. * @param fragmentCode defines the fragment shader code to use
  106164. * @param defines defines the string containing the defines to use to compile the shaders
  106165. * @param context defines the webGL context to use (if not set, the current one will be used)
  106166. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  106167. * @returns the new webGL program
  106168. */
  106169. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  106170. /**
  106171. * Creates a new pipeline context
  106172. * @returns the new pipeline
  106173. */
  106174. createPipelineContext(): IPipelineContext;
  106175. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  106176. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  106177. /** @hidden */
  106178. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  106179. /** @hidden */
  106180. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  106181. /** @hidden */
  106182. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  106183. /**
  106184. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  106185. * @param pipelineContext defines the pipeline context to use
  106186. * @param uniformsNames defines the list of uniform names
  106187. * @returns an array of webGL uniform locations
  106188. */
  106189. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  106190. /**
  106191. * Gets the lsit of active attributes for a given webGL program
  106192. * @param pipelineContext defines the pipeline context to use
  106193. * @param attributesNames defines the list of attribute names to get
  106194. * @returns an array of indices indicating the offset of each attribute
  106195. */
  106196. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  106197. /**
  106198. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  106199. * @param effect defines the effect to activate
  106200. */
  106201. enableEffect(effect: Nullable<Effect>): void;
  106202. /**
  106203. * Set the value of an uniform to a number (int)
  106204. * @param uniform defines the webGL uniform location where to store the value
  106205. * @param value defines the int number to store
  106206. */
  106207. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  106208. /**
  106209. * Set the value of an uniform to an array of int32
  106210. * @param uniform defines the webGL uniform location where to store the value
  106211. * @param array defines the array of int32 to store
  106212. */
  106213. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  106214. /**
  106215. * Set the value of an uniform to an array of int32 (stored as vec2)
  106216. * @param uniform defines the webGL uniform location where to store the value
  106217. * @param array defines the array of int32 to store
  106218. */
  106219. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  106220. /**
  106221. * Set the value of an uniform to an array of int32 (stored as vec3)
  106222. * @param uniform defines the webGL uniform location where to store the value
  106223. * @param array defines the array of int32 to store
  106224. */
  106225. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  106226. /**
  106227. * Set the value of an uniform to an array of int32 (stored as vec4)
  106228. * @param uniform defines the webGL uniform location where to store the value
  106229. * @param array defines the array of int32 to store
  106230. */
  106231. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  106232. /**
  106233. * Set the value of an uniform to an array of number
  106234. * @param uniform defines the webGL uniform location where to store the value
  106235. * @param array defines the array of number to store
  106236. */
  106237. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  106238. /**
  106239. * Set the value of an uniform to an array of number (stored as vec2)
  106240. * @param uniform defines the webGL uniform location where to store the value
  106241. * @param array defines the array of number to store
  106242. */
  106243. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  106244. /**
  106245. * Set the value of an uniform to an array of number (stored as vec3)
  106246. * @param uniform defines the webGL uniform location where to store the value
  106247. * @param array defines the array of number to store
  106248. */
  106249. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  106250. /**
  106251. * Set the value of an uniform to an array of number (stored as vec4)
  106252. * @param uniform defines the webGL uniform location where to store the value
  106253. * @param array defines the array of number to store
  106254. */
  106255. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  106256. /**
  106257. * Set the value of an uniform to an array of float32 (stored as matrices)
  106258. * @param uniform defines the webGL uniform location where to store the value
  106259. * @param matrices defines the array of float32 to store
  106260. */
  106261. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  106262. /**
  106263. * Set the value of an uniform to a matrix (3x3)
  106264. * @param uniform defines the webGL uniform location where to store the value
  106265. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  106266. */
  106267. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  106268. /**
  106269. * Set the value of an uniform to a matrix (2x2)
  106270. * @param uniform defines the webGL uniform location where to store the value
  106271. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  106272. */
  106273. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  106274. /**
  106275. * Set the value of an uniform to a number (float)
  106276. * @param uniform defines the webGL uniform location where to store the value
  106277. * @param value defines the float number to store
  106278. */
  106279. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  106280. /**
  106281. * Set the value of an uniform to a vec2
  106282. * @param uniform defines the webGL uniform location where to store the value
  106283. * @param x defines the 1st component of the value
  106284. * @param y defines the 2nd component of the value
  106285. */
  106286. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  106287. /**
  106288. * Set the value of an uniform to a vec3
  106289. * @param uniform defines the webGL uniform location where to store the value
  106290. * @param x defines the 1st component of the value
  106291. * @param y defines the 2nd component of the value
  106292. * @param z defines the 3rd component of the value
  106293. */
  106294. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  106295. /**
  106296. * Set the value of an uniform to a vec4
  106297. * @param uniform defines the webGL uniform location where to store the value
  106298. * @param x defines the 1st component of the value
  106299. * @param y defines the 2nd component of the value
  106300. * @param z defines the 3rd component of the value
  106301. * @param w defines the 4th component of the value
  106302. */
  106303. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  106304. /**
  106305. * Apply all cached states (depth, culling, stencil and alpha)
  106306. */
  106307. applyStates(): void;
  106308. /**
  106309. * Enable or disable color writing
  106310. * @param enable defines the state to set
  106311. */
  106312. setColorWrite(enable: boolean): void;
  106313. /**
  106314. * Gets a boolean indicating if color writing is enabled
  106315. * @returns the current color writing state
  106316. */
  106317. getColorWrite(): boolean;
  106318. /**
  106319. * Gets the depth culling state manager
  106320. */
  106321. get depthCullingState(): DepthCullingState;
  106322. /**
  106323. * Gets the alpha state manager
  106324. */
  106325. get alphaState(): AlphaState;
  106326. /**
  106327. * Gets the stencil state manager
  106328. */
  106329. get stencilState(): StencilState;
  106330. /**
  106331. * Clears the list of texture accessible through engine.
  106332. * This can help preventing texture load conflict due to name collision.
  106333. */
  106334. clearInternalTexturesCache(): void;
  106335. /**
  106336. * Force the entire cache to be cleared
  106337. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  106338. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  106339. */
  106340. wipeCaches(bruteForce?: boolean): void;
  106341. /** @hidden */
  106342. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  106343. min: number;
  106344. mag: number;
  106345. };
  106346. /** @hidden */
  106347. _createTexture(): WebGLTexture;
  106348. /**
  106349. * Usually called from Texture.ts.
  106350. * Passed information to create a WebGLTexture
  106351. * @param url defines a value which contains one of the following:
  106352. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  106353. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  106354. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  106355. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  106356. * @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)
  106357. * @param scene needed for loading to the correct scene
  106358. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  106359. * @param onLoad optional callback to be called upon successful completion
  106360. * @param onError optional callback to be called upon failure
  106361. * @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
  106362. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  106363. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  106364. * @param forcedExtension defines the extension to use to pick the right loader
  106365. * @param mimeType defines an optional mime type
  106366. * @returns a InternalTexture for assignment back into BABYLON.Texture
  106367. */
  106368. 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;
  106369. /**
  106370. * Loads an image as an HTMLImageElement.
  106371. * @param input url string, ArrayBuffer, or Blob to load
  106372. * @param onLoad callback called when the image successfully loads
  106373. * @param onError callback called when the image fails to load
  106374. * @param offlineProvider offline provider for caching
  106375. * @param mimeType optional mime type
  106376. * @returns the HTMLImageElement of the loaded image
  106377. * @hidden
  106378. */
  106379. 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>;
  106380. /**
  106381. * @hidden
  106382. */
  106383. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  106384. /**
  106385. * Creates a raw texture
  106386. * @param data defines the data to store in the texture
  106387. * @param width defines the width of the texture
  106388. * @param height defines the height of the texture
  106389. * @param format defines the format of the data
  106390. * @param generateMipMaps defines if the engine should generate the mip levels
  106391. * @param invertY defines if data must be stored with Y axis inverted
  106392. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  106393. * @param compression defines the compression used (null by default)
  106394. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  106395. * @returns the raw texture inside an InternalTexture
  106396. */
  106397. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  106398. /**
  106399. * Creates a new raw cube texture
  106400. * @param data defines the array of data to use to create each face
  106401. * @param size defines the size of the textures
  106402. * @param format defines the format of the data
  106403. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  106404. * @param generateMipMaps defines if the engine should generate the mip levels
  106405. * @param invertY defines if data must be stored with Y axis inverted
  106406. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  106407. * @param compression defines the compression used (null by default)
  106408. * @returns the cube texture as an InternalTexture
  106409. */
  106410. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  106411. /**
  106412. * Creates a new raw 3D texture
  106413. * @param data defines the data used to create the texture
  106414. * @param width defines the width of the texture
  106415. * @param height defines the height of the texture
  106416. * @param depth defines the depth of the texture
  106417. * @param format defines the format of the texture
  106418. * @param generateMipMaps defines if the engine must generate mip levels
  106419. * @param invertY defines if data must be stored with Y axis inverted
  106420. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  106421. * @param compression defines the compressed used (can be null)
  106422. * @param textureType defines the compressed used (can be null)
  106423. * @returns a new raw 3D texture (stored in an InternalTexture)
  106424. */
  106425. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  106426. /**
  106427. * Creates a new raw 2D array texture
  106428. * @param data defines the data used to create the texture
  106429. * @param width defines the width of the texture
  106430. * @param height defines the height of the texture
  106431. * @param depth defines the number of layers of the texture
  106432. * @param format defines the format of the texture
  106433. * @param generateMipMaps defines if the engine must generate mip levels
  106434. * @param invertY defines if data must be stored with Y axis inverted
  106435. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  106436. * @param compression defines the compressed used (can be null)
  106437. * @param textureType defines the compressed used (can be null)
  106438. * @returns a new raw 2D array texture (stored in an InternalTexture)
  106439. */
  106440. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  106441. private _unpackFlipYCached;
  106442. /**
  106443. * In case you are sharing the context with other applications, it might
  106444. * be interested to not cache the unpack flip y state to ensure a consistent
  106445. * value would be set.
  106446. */
  106447. enableUnpackFlipYCached: boolean;
  106448. /** @hidden */
  106449. _unpackFlipY(value: boolean): void;
  106450. /** @hidden */
  106451. _getUnpackAlignement(): number;
  106452. private _getTextureTarget;
  106453. /**
  106454. * Update the sampling mode of a given texture
  106455. * @param samplingMode defines the required sampling mode
  106456. * @param texture defines the texture to update
  106457. * @param generateMipMaps defines whether to generate mipmaps for the texture
  106458. */
  106459. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  106460. /**
  106461. * Update the sampling mode of a given texture
  106462. * @param texture defines the texture to update
  106463. * @param wrapU defines the texture wrap mode of the u coordinates
  106464. * @param wrapV defines the texture wrap mode of the v coordinates
  106465. * @param wrapR defines the texture wrap mode of the r coordinates
  106466. */
  106467. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  106468. /** @hidden */
  106469. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  106470. width: number;
  106471. height: number;
  106472. layers?: number;
  106473. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  106474. /** @hidden */
  106475. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  106476. /** @hidden */
  106477. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  106478. /**
  106479. * Update a portion of an internal texture
  106480. * @param texture defines the texture to update
  106481. * @param imageData defines the data to store into the texture
  106482. * @param xOffset defines the x coordinates of the update rectangle
  106483. * @param yOffset defines the y coordinates of the update rectangle
  106484. * @param width defines the width of the update rectangle
  106485. * @param height defines the height of the update rectangle
  106486. * @param faceIndex defines the face index if texture is a cube (0 by default)
  106487. * @param lod defines the lod level to update (0 by default)
  106488. */
  106489. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  106490. /** @hidden */
  106491. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  106492. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  106493. private _prepareWebGLTexture;
  106494. /** @hidden */
  106495. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  106496. private _getDepthStencilBuffer;
  106497. /** @hidden */
  106498. _releaseFramebufferObjects(texture: InternalTexture): void;
  106499. /** @hidden */
  106500. _releaseTexture(texture: InternalTexture): void;
  106501. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  106502. protected _setProgram(program: WebGLProgram): void;
  106503. protected _boundUniforms: {
  106504. [key: number]: WebGLUniformLocation;
  106505. };
  106506. /**
  106507. * Binds an effect to the webGL context
  106508. * @param effect defines the effect to bind
  106509. */
  106510. bindSamplers(effect: Effect): void;
  106511. private _activateCurrentTexture;
  106512. /** @hidden */
  106513. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  106514. /** @hidden */
  106515. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  106516. /**
  106517. * Unbind all textures from the webGL context
  106518. */
  106519. unbindAllTextures(): void;
  106520. /**
  106521. * Sets a texture to the according uniform.
  106522. * @param channel The texture channel
  106523. * @param uniform The uniform to set
  106524. * @param texture The texture to apply
  106525. */
  106526. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  106527. private _bindSamplerUniformToChannel;
  106528. private _getTextureWrapMode;
  106529. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  106530. /**
  106531. * Sets an array of texture to the webGL context
  106532. * @param channel defines the channel where the texture array must be set
  106533. * @param uniform defines the associated uniform location
  106534. * @param textures defines the array of textures to bind
  106535. */
  106536. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  106537. /** @hidden */
  106538. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  106539. private _setTextureParameterFloat;
  106540. private _setTextureParameterInteger;
  106541. /**
  106542. * Unbind all vertex attributes from the webGL context
  106543. */
  106544. unbindAllAttributes(): void;
  106545. /**
  106546. * 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
  106547. */
  106548. releaseEffects(): void;
  106549. /**
  106550. * Dispose and release all associated resources
  106551. */
  106552. dispose(): void;
  106553. /**
  106554. * Attach a new callback raised when context lost event is fired
  106555. * @param callback defines the callback to call
  106556. */
  106557. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  106558. /**
  106559. * Attach a new callback raised when context restored event is fired
  106560. * @param callback defines the callback to call
  106561. */
  106562. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  106563. /**
  106564. * Get the current error code of the webGL context
  106565. * @returns the error code
  106566. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  106567. */
  106568. getError(): number;
  106569. private _canRenderToFloatFramebuffer;
  106570. private _canRenderToHalfFloatFramebuffer;
  106571. private _canRenderToFramebuffer;
  106572. /** @hidden */
  106573. _getWebGLTextureType(type: number): number;
  106574. /** @hidden */
  106575. _getInternalFormat(format: number): number;
  106576. /** @hidden */
  106577. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  106578. /** @hidden */
  106579. _getRGBAMultiSampleBufferFormat(type: number): number;
  106580. /** @hidden */
  106581. _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;
  106582. /**
  106583. * Loads a file from a url
  106584. * @param url url to load
  106585. * @param onSuccess callback called when the file successfully loads
  106586. * @param onProgress callback called while file is loading (if the server supports this mode)
  106587. * @param offlineProvider defines the offline provider for caching
  106588. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  106589. * @param onError callback called when the file fails to load
  106590. * @returns a file request object
  106591. * @hidden
  106592. */
  106593. 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;
  106594. /**
  106595. * Reads pixels from the current frame buffer. Please note that this function can be slow
  106596. * @param x defines the x coordinate of the rectangle where pixels must be read
  106597. * @param y defines the y coordinate of the rectangle where pixels must be read
  106598. * @param width defines the width of the rectangle where pixels must be read
  106599. * @param height defines the height of the rectangle where pixels must be read
  106600. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  106601. * @returns a Uint8Array containing RGBA colors
  106602. */
  106603. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  106604. private static _isSupported;
  106605. /**
  106606. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  106607. * @returns true if the engine can be created
  106608. * @ignorenaming
  106609. */
  106610. static isSupported(): boolean;
  106611. /**
  106612. * Find the next highest power of two.
  106613. * @param x Number to start search from.
  106614. * @return Next highest power of two.
  106615. */
  106616. static CeilingPOT(x: number): number;
  106617. /**
  106618. * Find the next lowest power of two.
  106619. * @param x Number to start search from.
  106620. * @return Next lowest power of two.
  106621. */
  106622. static FloorPOT(x: number): number;
  106623. /**
  106624. * Find the nearest power of two.
  106625. * @param x Number to start search from.
  106626. * @return Next nearest power of two.
  106627. */
  106628. static NearestPOT(x: number): number;
  106629. /**
  106630. * Get the closest exponent of two
  106631. * @param value defines the value to approximate
  106632. * @param max defines the maximum value to return
  106633. * @param mode defines how to define the closest value
  106634. * @returns closest exponent of two of the given value
  106635. */
  106636. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  106637. /**
  106638. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  106639. * @param func - the function to be called
  106640. * @param requester - the object that will request the next frame. Falls back to window.
  106641. * @returns frame number
  106642. */
  106643. static QueueNewFrame(func: () => void, requester?: any): number;
  106644. /**
  106645. * Gets host document
  106646. * @returns the host document object
  106647. */
  106648. getHostDocument(): Nullable<Document>;
  106649. }
  106650. }
  106651. declare module BABYLON {
  106652. /**
  106653. * Class representing spherical harmonics coefficients to the 3rd degree
  106654. */
  106655. export class SphericalHarmonics {
  106656. /**
  106657. * Defines whether or not the harmonics have been prescaled for rendering.
  106658. */
  106659. preScaled: boolean;
  106660. /**
  106661. * The l0,0 coefficients of the spherical harmonics
  106662. */
  106663. l00: Vector3;
  106664. /**
  106665. * The l1,-1 coefficients of the spherical harmonics
  106666. */
  106667. l1_1: Vector3;
  106668. /**
  106669. * The l1,0 coefficients of the spherical harmonics
  106670. */
  106671. l10: Vector3;
  106672. /**
  106673. * The l1,1 coefficients of the spherical harmonics
  106674. */
  106675. l11: Vector3;
  106676. /**
  106677. * The l2,-2 coefficients of the spherical harmonics
  106678. */
  106679. l2_2: Vector3;
  106680. /**
  106681. * The l2,-1 coefficients of the spherical harmonics
  106682. */
  106683. l2_1: Vector3;
  106684. /**
  106685. * The l2,0 coefficients of the spherical harmonics
  106686. */
  106687. l20: Vector3;
  106688. /**
  106689. * The l2,1 coefficients of the spherical harmonics
  106690. */
  106691. l21: Vector3;
  106692. /**
  106693. * The l2,2 coefficients of the spherical harmonics
  106694. */
  106695. l22: Vector3;
  106696. /**
  106697. * Adds a light to the spherical harmonics
  106698. * @param direction the direction of the light
  106699. * @param color the color of the light
  106700. * @param deltaSolidAngle the delta solid angle of the light
  106701. */
  106702. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  106703. /**
  106704. * Scales the spherical harmonics by the given amount
  106705. * @param scale the amount to scale
  106706. */
  106707. scaleInPlace(scale: number): void;
  106708. /**
  106709. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  106710. *
  106711. * ```
  106712. * E_lm = A_l * L_lm
  106713. * ```
  106714. *
  106715. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  106716. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  106717. * the scaling factors are given in equation 9.
  106718. */
  106719. convertIncidentRadianceToIrradiance(): void;
  106720. /**
  106721. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  106722. *
  106723. * ```
  106724. * L = (1/pi) * E * rho
  106725. * ```
  106726. *
  106727. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  106728. */
  106729. convertIrradianceToLambertianRadiance(): void;
  106730. /**
  106731. * Integrates the reconstruction coefficients directly in to the SH preventing further
  106732. * required operations at run time.
  106733. *
  106734. * This is simply done by scaling back the SH with Ylm constants parameter.
  106735. * The trigonometric part being applied by the shader at run time.
  106736. */
  106737. preScaleForRendering(): void;
  106738. /**
  106739. * Constructs a spherical harmonics from an array.
  106740. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  106741. * @returns the spherical harmonics
  106742. */
  106743. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  106744. /**
  106745. * Gets the spherical harmonics from polynomial
  106746. * @param polynomial the spherical polynomial
  106747. * @returns the spherical harmonics
  106748. */
  106749. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  106750. }
  106751. /**
  106752. * Class representing spherical polynomial coefficients to the 3rd degree
  106753. */
  106754. export class SphericalPolynomial {
  106755. private _harmonics;
  106756. /**
  106757. * The spherical harmonics used to create the polynomials.
  106758. */
  106759. get preScaledHarmonics(): SphericalHarmonics;
  106760. /**
  106761. * The x coefficients of the spherical polynomial
  106762. */
  106763. x: Vector3;
  106764. /**
  106765. * The y coefficients of the spherical polynomial
  106766. */
  106767. y: Vector3;
  106768. /**
  106769. * The z coefficients of the spherical polynomial
  106770. */
  106771. z: Vector3;
  106772. /**
  106773. * The xx coefficients of the spherical polynomial
  106774. */
  106775. xx: Vector3;
  106776. /**
  106777. * The yy coefficients of the spherical polynomial
  106778. */
  106779. yy: Vector3;
  106780. /**
  106781. * The zz coefficients of the spherical polynomial
  106782. */
  106783. zz: Vector3;
  106784. /**
  106785. * The xy coefficients of the spherical polynomial
  106786. */
  106787. xy: Vector3;
  106788. /**
  106789. * The yz coefficients of the spherical polynomial
  106790. */
  106791. yz: Vector3;
  106792. /**
  106793. * The zx coefficients of the spherical polynomial
  106794. */
  106795. zx: Vector3;
  106796. /**
  106797. * Adds an ambient color to the spherical polynomial
  106798. * @param color the color to add
  106799. */
  106800. addAmbient(color: Color3): void;
  106801. /**
  106802. * Scales the spherical polynomial by the given amount
  106803. * @param scale the amount to scale
  106804. */
  106805. scaleInPlace(scale: number): void;
  106806. /**
  106807. * Gets the spherical polynomial from harmonics
  106808. * @param harmonics the spherical harmonics
  106809. * @returns the spherical polynomial
  106810. */
  106811. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  106812. /**
  106813. * Constructs a spherical polynomial from an array.
  106814. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  106815. * @returns the spherical polynomial
  106816. */
  106817. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  106818. }
  106819. }
  106820. declare module BABYLON {
  106821. /**
  106822. * Defines the source of the internal texture
  106823. */
  106824. export enum InternalTextureSource {
  106825. /**
  106826. * The source of the texture data is unknown
  106827. */
  106828. Unknown = 0,
  106829. /**
  106830. * Texture data comes from an URL
  106831. */
  106832. Url = 1,
  106833. /**
  106834. * Texture data is only used for temporary storage
  106835. */
  106836. Temp = 2,
  106837. /**
  106838. * Texture data comes from raw data (ArrayBuffer)
  106839. */
  106840. Raw = 3,
  106841. /**
  106842. * Texture content is dynamic (video or dynamic texture)
  106843. */
  106844. Dynamic = 4,
  106845. /**
  106846. * Texture content is generated by rendering to it
  106847. */
  106848. RenderTarget = 5,
  106849. /**
  106850. * Texture content is part of a multi render target process
  106851. */
  106852. MultiRenderTarget = 6,
  106853. /**
  106854. * Texture data comes from a cube data file
  106855. */
  106856. Cube = 7,
  106857. /**
  106858. * Texture data comes from a raw cube data
  106859. */
  106860. CubeRaw = 8,
  106861. /**
  106862. * Texture data come from a prefiltered cube data file
  106863. */
  106864. CubePrefiltered = 9,
  106865. /**
  106866. * Texture content is raw 3D data
  106867. */
  106868. Raw3D = 10,
  106869. /**
  106870. * Texture content is raw 2D array data
  106871. */
  106872. Raw2DArray = 11,
  106873. /**
  106874. * Texture content is a depth texture
  106875. */
  106876. Depth = 12,
  106877. /**
  106878. * Texture data comes from a raw cube data encoded with RGBD
  106879. */
  106880. CubeRawRGBD = 13
  106881. }
  106882. /**
  106883. * Class used to store data associated with WebGL texture data for the engine
  106884. * This class should not be used directly
  106885. */
  106886. export class InternalTexture {
  106887. /** @hidden */
  106888. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  106889. /**
  106890. * Defines if the texture is ready
  106891. */
  106892. isReady: boolean;
  106893. /**
  106894. * Defines if the texture is a cube texture
  106895. */
  106896. isCube: boolean;
  106897. /**
  106898. * Defines if the texture contains 3D data
  106899. */
  106900. is3D: boolean;
  106901. /**
  106902. * Defines if the texture contains 2D array data
  106903. */
  106904. is2DArray: boolean;
  106905. /**
  106906. * Defines if the texture contains multiview data
  106907. */
  106908. isMultiview: boolean;
  106909. /**
  106910. * Gets the URL used to load this texture
  106911. */
  106912. url: string;
  106913. /**
  106914. * Gets the sampling mode of the texture
  106915. */
  106916. samplingMode: number;
  106917. /**
  106918. * Gets a boolean indicating if the texture needs mipmaps generation
  106919. */
  106920. generateMipMaps: boolean;
  106921. /**
  106922. * Gets the number of samples used by the texture (WebGL2+ only)
  106923. */
  106924. samples: number;
  106925. /**
  106926. * Gets the type of the texture (int, float...)
  106927. */
  106928. type: number;
  106929. /**
  106930. * Gets the format of the texture (RGB, RGBA...)
  106931. */
  106932. format: number;
  106933. /**
  106934. * Observable called when the texture is loaded
  106935. */
  106936. onLoadedObservable: Observable<InternalTexture>;
  106937. /**
  106938. * Gets the width of the texture
  106939. */
  106940. width: number;
  106941. /**
  106942. * Gets the height of the texture
  106943. */
  106944. height: number;
  106945. /**
  106946. * Gets the depth of the texture
  106947. */
  106948. depth: number;
  106949. /**
  106950. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  106951. */
  106952. baseWidth: number;
  106953. /**
  106954. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  106955. */
  106956. baseHeight: number;
  106957. /**
  106958. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  106959. */
  106960. baseDepth: number;
  106961. /**
  106962. * Gets a boolean indicating if the texture is inverted on Y axis
  106963. */
  106964. invertY: boolean;
  106965. /** @hidden */
  106966. _invertVScale: boolean;
  106967. /** @hidden */
  106968. _associatedChannel: number;
  106969. /** @hidden */
  106970. _source: InternalTextureSource;
  106971. /** @hidden */
  106972. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  106973. /** @hidden */
  106974. _bufferView: Nullable<ArrayBufferView>;
  106975. /** @hidden */
  106976. _bufferViewArray: Nullable<ArrayBufferView[]>;
  106977. /** @hidden */
  106978. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  106979. /** @hidden */
  106980. _size: number;
  106981. /** @hidden */
  106982. _extension: string;
  106983. /** @hidden */
  106984. _files: Nullable<string[]>;
  106985. /** @hidden */
  106986. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  106987. /** @hidden */
  106988. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  106989. /** @hidden */
  106990. _framebuffer: Nullable<WebGLFramebuffer>;
  106991. /** @hidden */
  106992. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  106993. /** @hidden */
  106994. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  106995. /** @hidden */
  106996. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  106997. /** @hidden */
  106998. _attachments: Nullable<number[]>;
  106999. /** @hidden */
  107000. _cachedCoordinatesMode: Nullable<number>;
  107001. /** @hidden */
  107002. _cachedWrapU: Nullable<number>;
  107003. /** @hidden */
  107004. _cachedWrapV: Nullable<number>;
  107005. /** @hidden */
  107006. _cachedWrapR: Nullable<number>;
  107007. /** @hidden */
  107008. _cachedAnisotropicFilteringLevel: Nullable<number>;
  107009. /** @hidden */
  107010. _isDisabled: boolean;
  107011. /** @hidden */
  107012. _compression: Nullable<string>;
  107013. /** @hidden */
  107014. _generateStencilBuffer: boolean;
  107015. /** @hidden */
  107016. _generateDepthBuffer: boolean;
  107017. /** @hidden */
  107018. _comparisonFunction: number;
  107019. /** @hidden */
  107020. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  107021. /** @hidden */
  107022. _lodGenerationScale: number;
  107023. /** @hidden */
  107024. _lodGenerationOffset: number;
  107025. /** @hidden */
  107026. _depthStencilTexture: Nullable<InternalTexture>;
  107027. /** @hidden */
  107028. _colorTextureArray: Nullable<WebGLTexture>;
  107029. /** @hidden */
  107030. _depthStencilTextureArray: Nullable<WebGLTexture>;
  107031. /** @hidden */
  107032. _lodTextureHigh: Nullable<BaseTexture>;
  107033. /** @hidden */
  107034. _lodTextureMid: Nullable<BaseTexture>;
  107035. /** @hidden */
  107036. _lodTextureLow: Nullable<BaseTexture>;
  107037. /** @hidden */
  107038. _isRGBD: boolean;
  107039. /** @hidden */
  107040. _linearSpecularLOD: boolean;
  107041. /** @hidden */
  107042. _irradianceTexture: Nullable<BaseTexture>;
  107043. /** @hidden */
  107044. _webGLTexture: Nullable<WebGLTexture>;
  107045. /** @hidden */
  107046. _references: number;
  107047. private _engine;
  107048. /**
  107049. * Gets the Engine the texture belongs to.
  107050. * @returns The babylon engine
  107051. */
  107052. getEngine(): ThinEngine;
  107053. /**
  107054. * Gets the data source type of the texture
  107055. */
  107056. get source(): InternalTextureSource;
  107057. /**
  107058. * Creates a new InternalTexture
  107059. * @param engine defines the engine to use
  107060. * @param source defines the type of data that will be used
  107061. * @param delayAllocation if the texture allocation should be delayed (default: false)
  107062. */
  107063. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  107064. /**
  107065. * Increments the number of references (ie. the number of Texture that point to it)
  107066. */
  107067. incrementReferences(): void;
  107068. /**
  107069. * Change the size of the texture (not the size of the content)
  107070. * @param width defines the new width
  107071. * @param height defines the new height
  107072. * @param depth defines the new depth (1 by default)
  107073. */
  107074. updateSize(width: int, height: int, depth?: int): void;
  107075. /** @hidden */
  107076. _rebuild(): void;
  107077. /** @hidden */
  107078. _swapAndDie(target: InternalTexture): void;
  107079. /**
  107080. * Dispose the current allocated resources
  107081. */
  107082. dispose(): void;
  107083. }
  107084. }
  107085. declare module BABYLON {
  107086. /**
  107087. * Class used to work with sound analyzer using fast fourier transform (FFT)
  107088. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  107089. */
  107090. export class Analyser {
  107091. /**
  107092. * Gets or sets the smoothing
  107093. * @ignorenaming
  107094. */
  107095. SMOOTHING: number;
  107096. /**
  107097. * Gets or sets the FFT table size
  107098. * @ignorenaming
  107099. */
  107100. FFT_SIZE: number;
  107101. /**
  107102. * Gets or sets the bar graph amplitude
  107103. * @ignorenaming
  107104. */
  107105. BARGRAPHAMPLITUDE: number;
  107106. /**
  107107. * Gets or sets the position of the debug canvas
  107108. * @ignorenaming
  107109. */
  107110. DEBUGCANVASPOS: {
  107111. x: number;
  107112. y: number;
  107113. };
  107114. /**
  107115. * Gets or sets the debug canvas size
  107116. * @ignorenaming
  107117. */
  107118. DEBUGCANVASSIZE: {
  107119. width: number;
  107120. height: number;
  107121. };
  107122. private _byteFreqs;
  107123. private _byteTime;
  107124. private _floatFreqs;
  107125. private _webAudioAnalyser;
  107126. private _debugCanvas;
  107127. private _debugCanvasContext;
  107128. private _scene;
  107129. private _registerFunc;
  107130. private _audioEngine;
  107131. /**
  107132. * Creates a new analyser
  107133. * @param scene defines hosting scene
  107134. */
  107135. constructor(scene: Scene);
  107136. /**
  107137. * Get the number of data values you will have to play with for the visualization
  107138. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  107139. * @returns a number
  107140. */
  107141. getFrequencyBinCount(): number;
  107142. /**
  107143. * Gets the current frequency data as a byte array
  107144. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  107145. * @returns a Uint8Array
  107146. */
  107147. getByteFrequencyData(): Uint8Array;
  107148. /**
  107149. * Gets the current waveform as a byte array
  107150. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  107151. * @returns a Uint8Array
  107152. */
  107153. getByteTimeDomainData(): Uint8Array;
  107154. /**
  107155. * Gets the current frequency data as a float array
  107156. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  107157. * @returns a Float32Array
  107158. */
  107159. getFloatFrequencyData(): Float32Array;
  107160. /**
  107161. * Renders the debug canvas
  107162. */
  107163. drawDebugCanvas(): void;
  107164. /**
  107165. * Stops rendering the debug canvas and removes it
  107166. */
  107167. stopDebugCanvas(): void;
  107168. /**
  107169. * Connects two audio nodes
  107170. * @param inputAudioNode defines first node to connect
  107171. * @param outputAudioNode defines second node to connect
  107172. */
  107173. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  107174. /**
  107175. * Releases all associated resources
  107176. */
  107177. dispose(): void;
  107178. }
  107179. }
  107180. declare module BABYLON {
  107181. /**
  107182. * This represents an audio engine and it is responsible
  107183. * to play, synchronize and analyse sounds throughout the application.
  107184. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  107185. */
  107186. export interface IAudioEngine extends IDisposable {
  107187. /**
  107188. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  107189. */
  107190. readonly canUseWebAudio: boolean;
  107191. /**
  107192. * Gets the current AudioContext if available.
  107193. */
  107194. readonly audioContext: Nullable<AudioContext>;
  107195. /**
  107196. * The master gain node defines the global audio volume of your audio engine.
  107197. */
  107198. readonly masterGain: GainNode;
  107199. /**
  107200. * Gets whether or not mp3 are supported by your browser.
  107201. */
  107202. readonly isMP3supported: boolean;
  107203. /**
  107204. * Gets whether or not ogg are supported by your browser.
  107205. */
  107206. readonly isOGGsupported: boolean;
  107207. /**
  107208. * Defines if Babylon should emit a warning if WebAudio is not supported.
  107209. * @ignoreNaming
  107210. */
  107211. WarnedWebAudioUnsupported: boolean;
  107212. /**
  107213. * Defines if the audio engine relies on a custom unlocked button.
  107214. * In this case, the embedded button will not be displayed.
  107215. */
  107216. useCustomUnlockedButton: boolean;
  107217. /**
  107218. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  107219. */
  107220. readonly unlocked: boolean;
  107221. /**
  107222. * Event raised when audio has been unlocked on the browser.
  107223. */
  107224. onAudioUnlockedObservable: Observable<AudioEngine>;
  107225. /**
  107226. * Event raised when audio has been locked on the browser.
  107227. */
  107228. onAudioLockedObservable: Observable<AudioEngine>;
  107229. /**
  107230. * Flags the audio engine in Locked state.
  107231. * This happens due to new browser policies preventing audio to autoplay.
  107232. */
  107233. lock(): void;
  107234. /**
  107235. * Unlocks the audio engine once a user action has been done on the dom.
  107236. * This is helpful to resume play once browser policies have been satisfied.
  107237. */
  107238. unlock(): void;
  107239. /**
  107240. * Gets the global volume sets on the master gain.
  107241. * @returns the global volume if set or -1 otherwise
  107242. */
  107243. getGlobalVolume(): number;
  107244. /**
  107245. * Sets the global volume of your experience (sets on the master gain).
  107246. * @param newVolume Defines the new global volume of the application
  107247. */
  107248. setGlobalVolume(newVolume: number): void;
  107249. /**
  107250. * Connect the audio engine to an audio analyser allowing some amazing
  107251. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  107252. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  107253. * @param analyser The analyser to connect to the engine
  107254. */
  107255. connectToAnalyser(analyser: Analyser): void;
  107256. }
  107257. /**
  107258. * This represents the default audio engine used in babylon.
  107259. * It is responsible to play, synchronize and analyse sounds throughout the application.
  107260. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  107261. */
  107262. export class AudioEngine implements IAudioEngine {
  107263. private _audioContext;
  107264. private _audioContextInitialized;
  107265. private _muteButton;
  107266. private _hostElement;
  107267. /**
  107268. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  107269. */
  107270. canUseWebAudio: boolean;
  107271. /**
  107272. * The master gain node defines the global audio volume of your audio engine.
  107273. */
  107274. masterGain: GainNode;
  107275. /**
  107276. * Defines if Babylon should emit a warning if WebAudio is not supported.
  107277. * @ignoreNaming
  107278. */
  107279. WarnedWebAudioUnsupported: boolean;
  107280. /**
  107281. * Gets whether or not mp3 are supported by your browser.
  107282. */
  107283. isMP3supported: boolean;
  107284. /**
  107285. * Gets whether or not ogg are supported by your browser.
  107286. */
  107287. isOGGsupported: boolean;
  107288. /**
  107289. * Gets whether audio has been unlocked on the device.
  107290. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  107291. * a user interaction has happened.
  107292. */
  107293. unlocked: boolean;
  107294. /**
  107295. * Defines if the audio engine relies on a custom unlocked button.
  107296. * In this case, the embedded button will not be displayed.
  107297. */
  107298. useCustomUnlockedButton: boolean;
  107299. /**
  107300. * Event raised when audio has been unlocked on the browser.
  107301. */
  107302. onAudioUnlockedObservable: Observable<AudioEngine>;
  107303. /**
  107304. * Event raised when audio has been locked on the browser.
  107305. */
  107306. onAudioLockedObservable: Observable<AudioEngine>;
  107307. /**
  107308. * Gets the current AudioContext if available.
  107309. */
  107310. get audioContext(): Nullable<AudioContext>;
  107311. private _connectedAnalyser;
  107312. /**
  107313. * Instantiates a new audio engine.
  107314. *
  107315. * There should be only one per page as some browsers restrict the number
  107316. * of audio contexts you can create.
  107317. * @param hostElement defines the host element where to display the mute icon if necessary
  107318. */
  107319. constructor(hostElement?: Nullable<HTMLElement>);
  107320. /**
  107321. * Flags the audio engine in Locked state.
  107322. * This happens due to new browser policies preventing audio to autoplay.
  107323. */
  107324. lock(): void;
  107325. /**
  107326. * Unlocks the audio engine once a user action has been done on the dom.
  107327. * This is helpful to resume play once browser policies have been satisfied.
  107328. */
  107329. unlock(): void;
  107330. private _resumeAudioContext;
  107331. private _initializeAudioContext;
  107332. private _tryToRun;
  107333. private _triggerRunningState;
  107334. private _triggerSuspendedState;
  107335. private _displayMuteButton;
  107336. private _moveButtonToTopLeft;
  107337. private _onResize;
  107338. private _hideMuteButton;
  107339. /**
  107340. * Destroy and release the resources associated with the audio ccontext.
  107341. */
  107342. dispose(): void;
  107343. /**
  107344. * Gets the global volume sets on the master gain.
  107345. * @returns the global volume if set or -1 otherwise
  107346. */
  107347. getGlobalVolume(): number;
  107348. /**
  107349. * Sets the global volume of your experience (sets on the master gain).
  107350. * @param newVolume Defines the new global volume of the application
  107351. */
  107352. setGlobalVolume(newVolume: number): void;
  107353. /**
  107354. * Connect the audio engine to an audio analyser allowing some amazing
  107355. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  107356. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  107357. * @param analyser The analyser to connect to the engine
  107358. */
  107359. connectToAnalyser(analyser: Analyser): void;
  107360. }
  107361. }
  107362. declare module BABYLON {
  107363. /**
  107364. * Interface used to present a loading screen while loading a scene
  107365. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  107366. */
  107367. export interface ILoadingScreen {
  107368. /**
  107369. * Function called to display the loading screen
  107370. */
  107371. displayLoadingUI: () => void;
  107372. /**
  107373. * Function called to hide the loading screen
  107374. */
  107375. hideLoadingUI: () => void;
  107376. /**
  107377. * Gets or sets the color to use for the background
  107378. */
  107379. loadingUIBackgroundColor: string;
  107380. /**
  107381. * Gets or sets the text to display while loading
  107382. */
  107383. loadingUIText: string;
  107384. }
  107385. /**
  107386. * Class used for the default loading screen
  107387. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  107388. */
  107389. export class DefaultLoadingScreen implements ILoadingScreen {
  107390. private _renderingCanvas;
  107391. private _loadingText;
  107392. private _loadingDivBackgroundColor;
  107393. private _loadingDiv;
  107394. private _loadingTextDiv;
  107395. /** Gets or sets the logo url to use for the default loading screen */
  107396. static DefaultLogoUrl: string;
  107397. /** Gets or sets the spinner url to use for the default loading screen */
  107398. static DefaultSpinnerUrl: string;
  107399. /**
  107400. * Creates a new default loading screen
  107401. * @param _renderingCanvas defines the canvas used to render the scene
  107402. * @param _loadingText defines the default text to display
  107403. * @param _loadingDivBackgroundColor defines the default background color
  107404. */
  107405. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  107406. /**
  107407. * Function called to display the loading screen
  107408. */
  107409. displayLoadingUI(): void;
  107410. /**
  107411. * Function called to hide the loading screen
  107412. */
  107413. hideLoadingUI(): void;
  107414. /**
  107415. * Gets or sets the text to display while loading
  107416. */
  107417. set loadingUIText(text: string);
  107418. get loadingUIText(): string;
  107419. /**
  107420. * Gets or sets the color to use for the background
  107421. */
  107422. get loadingUIBackgroundColor(): string;
  107423. set loadingUIBackgroundColor(color: string);
  107424. private _resizeLoadingUI;
  107425. }
  107426. }
  107427. declare module BABYLON {
  107428. /**
  107429. * Interface for any object that can request an animation frame
  107430. */
  107431. export interface ICustomAnimationFrameRequester {
  107432. /**
  107433. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  107434. */
  107435. renderFunction?: Function;
  107436. /**
  107437. * Called to request the next frame to render to
  107438. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  107439. */
  107440. requestAnimationFrame: Function;
  107441. /**
  107442. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  107443. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  107444. */
  107445. requestID?: number;
  107446. }
  107447. }
  107448. declare module BABYLON {
  107449. /**
  107450. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  107451. */
  107452. export class PerformanceMonitor {
  107453. private _enabled;
  107454. private _rollingFrameTime;
  107455. private _lastFrameTimeMs;
  107456. /**
  107457. * constructor
  107458. * @param frameSampleSize The number of samples required to saturate the sliding window
  107459. */
  107460. constructor(frameSampleSize?: number);
  107461. /**
  107462. * Samples current frame
  107463. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  107464. */
  107465. sampleFrame(timeMs?: number): void;
  107466. /**
  107467. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  107468. */
  107469. get averageFrameTime(): number;
  107470. /**
  107471. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  107472. */
  107473. get averageFrameTimeVariance(): number;
  107474. /**
  107475. * Returns the frame time of the most recent frame
  107476. */
  107477. get instantaneousFrameTime(): number;
  107478. /**
  107479. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  107480. */
  107481. get averageFPS(): number;
  107482. /**
  107483. * Returns the average framerate in frames per second using the most recent frame time
  107484. */
  107485. get instantaneousFPS(): number;
  107486. /**
  107487. * Returns true if enough samples have been taken to completely fill the sliding window
  107488. */
  107489. get isSaturated(): boolean;
  107490. /**
  107491. * Enables contributions to the sliding window sample set
  107492. */
  107493. enable(): void;
  107494. /**
  107495. * Disables contributions to the sliding window sample set
  107496. * Samples will not be interpolated over the disabled period
  107497. */
  107498. disable(): void;
  107499. /**
  107500. * Returns true if sampling is enabled
  107501. */
  107502. get isEnabled(): boolean;
  107503. /**
  107504. * Resets performance monitor
  107505. */
  107506. reset(): void;
  107507. }
  107508. /**
  107509. * RollingAverage
  107510. *
  107511. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  107512. */
  107513. export class RollingAverage {
  107514. /**
  107515. * Current average
  107516. */
  107517. average: number;
  107518. /**
  107519. * Current variance
  107520. */
  107521. variance: number;
  107522. protected _samples: Array<number>;
  107523. protected _sampleCount: number;
  107524. protected _pos: number;
  107525. protected _m2: number;
  107526. /**
  107527. * constructor
  107528. * @param length The number of samples required to saturate the sliding window
  107529. */
  107530. constructor(length: number);
  107531. /**
  107532. * Adds a sample to the sample set
  107533. * @param v The sample value
  107534. */
  107535. add(v: number): void;
  107536. /**
  107537. * Returns previously added values or null if outside of history or outside the sliding window domain
  107538. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  107539. * @return Value previously recorded with add() or null if outside of range
  107540. */
  107541. history(i: number): number;
  107542. /**
  107543. * Returns true if enough samples have been taken to completely fill the sliding window
  107544. * @return true if sample-set saturated
  107545. */
  107546. isSaturated(): boolean;
  107547. /**
  107548. * Resets the rolling average (equivalent to 0 samples taken so far)
  107549. */
  107550. reset(): void;
  107551. /**
  107552. * Wraps a value around the sample range boundaries
  107553. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  107554. * @return Wrapped position in sample range
  107555. */
  107556. protected _wrapPosition(i: number): number;
  107557. }
  107558. }
  107559. declare module BABYLON {
  107560. /**
  107561. * This class is used to track a performance counter which is number based.
  107562. * The user has access to many properties which give statistics of different nature.
  107563. *
  107564. * The implementer can track two kinds of Performance Counter: time and count.
  107565. * 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.
  107566. * 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.
  107567. */
  107568. export class PerfCounter {
  107569. /**
  107570. * Gets or sets a global boolean to turn on and off all the counters
  107571. */
  107572. static Enabled: boolean;
  107573. /**
  107574. * Returns the smallest value ever
  107575. */
  107576. get min(): number;
  107577. /**
  107578. * Returns the biggest value ever
  107579. */
  107580. get max(): number;
  107581. /**
  107582. * Returns the average value since the performance counter is running
  107583. */
  107584. get average(): number;
  107585. /**
  107586. * Returns the average value of the last second the counter was monitored
  107587. */
  107588. get lastSecAverage(): number;
  107589. /**
  107590. * Returns the current value
  107591. */
  107592. get current(): number;
  107593. /**
  107594. * Gets the accumulated total
  107595. */
  107596. get total(): number;
  107597. /**
  107598. * Gets the total value count
  107599. */
  107600. get count(): number;
  107601. /**
  107602. * Creates a new counter
  107603. */
  107604. constructor();
  107605. /**
  107606. * Call this method to start monitoring a new frame.
  107607. * 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.
  107608. */
  107609. fetchNewFrame(): void;
  107610. /**
  107611. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  107612. * @param newCount the count value to add to the monitored count
  107613. * @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.
  107614. */
  107615. addCount(newCount: number, fetchResult: boolean): void;
  107616. /**
  107617. * Start monitoring this performance counter
  107618. */
  107619. beginMonitoring(): void;
  107620. /**
  107621. * Compute the time lapsed since the previous beginMonitoring() call.
  107622. * @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
  107623. */
  107624. endMonitoring(newFrame?: boolean): void;
  107625. private _fetchResult;
  107626. private _startMonitoringTime;
  107627. private _min;
  107628. private _max;
  107629. private _average;
  107630. private _current;
  107631. private _totalValueCount;
  107632. private _totalAccumulated;
  107633. private _lastSecAverage;
  107634. private _lastSecAccumulated;
  107635. private _lastSecTime;
  107636. private _lastSecValueCount;
  107637. }
  107638. }
  107639. declare module BABYLON {
  107640. interface ThinEngine {
  107641. /**
  107642. * Sets alpha constants used by some alpha blending modes
  107643. * @param r defines the red component
  107644. * @param g defines the green component
  107645. * @param b defines the blue component
  107646. * @param a defines the alpha component
  107647. */
  107648. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  107649. /**
  107650. * Sets the current alpha mode
  107651. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  107652. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  107653. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  107654. */
  107655. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  107656. /**
  107657. * Gets the current alpha mode
  107658. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  107659. * @returns the current alpha mode
  107660. */
  107661. getAlphaMode(): number;
  107662. /**
  107663. * Sets the current alpha equation
  107664. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  107665. */
  107666. setAlphaEquation(equation: number): void;
  107667. /**
  107668. * Gets the current alpha equation.
  107669. * @returns the current alpha equation
  107670. */
  107671. getAlphaEquation(): number;
  107672. }
  107673. }
  107674. declare module BABYLON {
  107675. /**
  107676. * Defines the interface used by display changed events
  107677. */
  107678. export interface IDisplayChangedEventArgs {
  107679. /** Gets the vrDisplay object (if any) */
  107680. vrDisplay: Nullable<any>;
  107681. /** Gets a boolean indicating if webVR is supported */
  107682. vrSupported: boolean;
  107683. }
  107684. /**
  107685. * Defines the interface used by objects containing a viewport (like a camera)
  107686. */
  107687. interface IViewportOwnerLike {
  107688. /**
  107689. * Gets or sets the viewport
  107690. */
  107691. viewport: IViewportLike;
  107692. }
  107693. /**
  107694. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  107695. */
  107696. export class Engine extends ThinEngine {
  107697. /** Defines that alpha blending is disabled */
  107698. static readonly ALPHA_DISABLE: number;
  107699. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  107700. static readonly ALPHA_ADD: number;
  107701. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  107702. static readonly ALPHA_COMBINE: number;
  107703. /** Defines that alpha blending to DEST - SRC * DEST */
  107704. static readonly ALPHA_SUBTRACT: number;
  107705. /** Defines that alpha blending to SRC * DEST */
  107706. static readonly ALPHA_MULTIPLY: number;
  107707. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  107708. static readonly ALPHA_MAXIMIZED: number;
  107709. /** Defines that alpha blending to SRC + DEST */
  107710. static readonly ALPHA_ONEONE: number;
  107711. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  107712. static readonly ALPHA_PREMULTIPLIED: number;
  107713. /**
  107714. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  107715. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  107716. */
  107717. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  107718. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  107719. static readonly ALPHA_INTERPOLATE: number;
  107720. /**
  107721. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  107722. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  107723. */
  107724. static readonly ALPHA_SCREENMODE: number;
  107725. /** Defines that the ressource is not delayed*/
  107726. static readonly DELAYLOADSTATE_NONE: number;
  107727. /** Defines that the ressource was successfully delay loaded */
  107728. static readonly DELAYLOADSTATE_LOADED: number;
  107729. /** Defines that the ressource is currently delay loading */
  107730. static readonly DELAYLOADSTATE_LOADING: number;
  107731. /** Defines that the ressource is delayed and has not started loading */
  107732. static readonly DELAYLOADSTATE_NOTLOADED: number;
  107733. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  107734. static readonly NEVER: number;
  107735. /** 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 */
  107736. static readonly ALWAYS: number;
  107737. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  107738. static readonly LESS: number;
  107739. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  107740. static readonly EQUAL: number;
  107741. /** 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 */
  107742. static readonly LEQUAL: number;
  107743. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  107744. static readonly GREATER: number;
  107745. /** 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 */
  107746. static readonly GEQUAL: number;
  107747. /** 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 */
  107748. static readonly NOTEQUAL: number;
  107749. /** Passed to stencilOperation to specify that stencil value must be kept */
  107750. static readonly KEEP: number;
  107751. /** Passed to stencilOperation to specify that stencil value must be replaced */
  107752. static readonly REPLACE: number;
  107753. /** Passed to stencilOperation to specify that stencil value must be incremented */
  107754. static readonly INCR: number;
  107755. /** Passed to stencilOperation to specify that stencil value must be decremented */
  107756. static readonly DECR: number;
  107757. /** Passed to stencilOperation to specify that stencil value must be inverted */
  107758. static readonly INVERT: number;
  107759. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  107760. static readonly INCR_WRAP: number;
  107761. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  107762. static readonly DECR_WRAP: number;
  107763. /** Texture is not repeating outside of 0..1 UVs */
  107764. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  107765. /** Texture is repeating outside of 0..1 UVs */
  107766. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  107767. /** Texture is repeating and mirrored */
  107768. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  107769. /** ALPHA */
  107770. static readonly TEXTUREFORMAT_ALPHA: number;
  107771. /** LUMINANCE */
  107772. static readonly TEXTUREFORMAT_LUMINANCE: number;
  107773. /** LUMINANCE_ALPHA */
  107774. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  107775. /** RGB */
  107776. static readonly TEXTUREFORMAT_RGB: number;
  107777. /** RGBA */
  107778. static readonly TEXTUREFORMAT_RGBA: number;
  107779. /** RED */
  107780. static readonly TEXTUREFORMAT_RED: number;
  107781. /** RED (2nd reference) */
  107782. static readonly TEXTUREFORMAT_R: number;
  107783. /** RG */
  107784. static readonly TEXTUREFORMAT_RG: number;
  107785. /** RED_INTEGER */
  107786. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  107787. /** RED_INTEGER (2nd reference) */
  107788. static readonly TEXTUREFORMAT_R_INTEGER: number;
  107789. /** RG_INTEGER */
  107790. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  107791. /** RGB_INTEGER */
  107792. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  107793. /** RGBA_INTEGER */
  107794. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  107795. /** UNSIGNED_BYTE */
  107796. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  107797. /** UNSIGNED_BYTE (2nd reference) */
  107798. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  107799. /** FLOAT */
  107800. static readonly TEXTURETYPE_FLOAT: number;
  107801. /** HALF_FLOAT */
  107802. static readonly TEXTURETYPE_HALF_FLOAT: number;
  107803. /** BYTE */
  107804. static readonly TEXTURETYPE_BYTE: number;
  107805. /** SHORT */
  107806. static readonly TEXTURETYPE_SHORT: number;
  107807. /** UNSIGNED_SHORT */
  107808. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  107809. /** INT */
  107810. static readonly TEXTURETYPE_INT: number;
  107811. /** UNSIGNED_INT */
  107812. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  107813. /** UNSIGNED_SHORT_4_4_4_4 */
  107814. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  107815. /** UNSIGNED_SHORT_5_5_5_1 */
  107816. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  107817. /** UNSIGNED_SHORT_5_6_5 */
  107818. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  107819. /** UNSIGNED_INT_2_10_10_10_REV */
  107820. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  107821. /** UNSIGNED_INT_24_8 */
  107822. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  107823. /** UNSIGNED_INT_10F_11F_11F_REV */
  107824. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  107825. /** UNSIGNED_INT_5_9_9_9_REV */
  107826. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  107827. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  107828. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  107829. /** nearest is mag = nearest and min = nearest and mip = linear */
  107830. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  107831. /** Bilinear is mag = linear and min = linear and mip = nearest */
  107832. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  107833. /** Trilinear is mag = linear and min = linear and mip = linear */
  107834. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  107835. /** nearest is mag = nearest and min = nearest and mip = linear */
  107836. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  107837. /** Bilinear is mag = linear and min = linear and mip = nearest */
  107838. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  107839. /** Trilinear is mag = linear and min = linear and mip = linear */
  107840. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  107841. /** mag = nearest and min = nearest and mip = nearest */
  107842. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  107843. /** mag = nearest and min = linear and mip = nearest */
  107844. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  107845. /** mag = nearest and min = linear and mip = linear */
  107846. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  107847. /** mag = nearest and min = linear and mip = none */
  107848. static readonly TEXTURE_NEAREST_LINEAR: number;
  107849. /** mag = nearest and min = nearest and mip = none */
  107850. static readonly TEXTURE_NEAREST_NEAREST: number;
  107851. /** mag = linear and min = nearest and mip = nearest */
  107852. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  107853. /** mag = linear and min = nearest and mip = linear */
  107854. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  107855. /** mag = linear and min = linear and mip = none */
  107856. static readonly TEXTURE_LINEAR_LINEAR: number;
  107857. /** mag = linear and min = nearest and mip = none */
  107858. static readonly TEXTURE_LINEAR_NEAREST: number;
  107859. /** Explicit coordinates mode */
  107860. static readonly TEXTURE_EXPLICIT_MODE: number;
  107861. /** Spherical coordinates mode */
  107862. static readonly TEXTURE_SPHERICAL_MODE: number;
  107863. /** Planar coordinates mode */
  107864. static readonly TEXTURE_PLANAR_MODE: number;
  107865. /** Cubic coordinates mode */
  107866. static readonly TEXTURE_CUBIC_MODE: number;
  107867. /** Projection coordinates mode */
  107868. static readonly TEXTURE_PROJECTION_MODE: number;
  107869. /** Skybox coordinates mode */
  107870. static readonly TEXTURE_SKYBOX_MODE: number;
  107871. /** Inverse Cubic coordinates mode */
  107872. static readonly TEXTURE_INVCUBIC_MODE: number;
  107873. /** Equirectangular coordinates mode */
  107874. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  107875. /** Equirectangular Fixed coordinates mode */
  107876. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  107877. /** Equirectangular Fixed Mirrored coordinates mode */
  107878. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  107879. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  107880. static readonly SCALEMODE_FLOOR: number;
  107881. /** Defines that texture rescaling will look for the nearest power of 2 size */
  107882. static readonly SCALEMODE_NEAREST: number;
  107883. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  107884. static readonly SCALEMODE_CEILING: number;
  107885. /**
  107886. * Returns the current npm package of the sdk
  107887. */
  107888. static get NpmPackage(): string;
  107889. /**
  107890. * Returns the current version of the framework
  107891. */
  107892. static get Version(): string;
  107893. /** Gets the list of created engines */
  107894. static get Instances(): Engine[];
  107895. /**
  107896. * Gets the latest created engine
  107897. */
  107898. static get LastCreatedEngine(): Nullable<Engine>;
  107899. /**
  107900. * Gets the latest created scene
  107901. */
  107902. static get LastCreatedScene(): Nullable<Scene>;
  107903. /**
  107904. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  107905. * @param flag defines which part of the materials must be marked as dirty
  107906. * @param predicate defines a predicate used to filter which materials should be affected
  107907. */
  107908. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  107909. /**
  107910. * Method called to create the default loading screen.
  107911. * This can be overriden in your own app.
  107912. * @param canvas The rendering canvas element
  107913. * @returns The loading screen
  107914. */
  107915. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  107916. /**
  107917. * Method called to create the default rescale post process on each engine.
  107918. */
  107919. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  107920. /**
  107921. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  107922. **/
  107923. enableOfflineSupport: boolean;
  107924. /**
  107925. * 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)
  107926. **/
  107927. disableManifestCheck: boolean;
  107928. /**
  107929. * Gets the list of created scenes
  107930. */
  107931. scenes: Scene[];
  107932. /**
  107933. * Event raised when a new scene is created
  107934. */
  107935. onNewSceneAddedObservable: Observable<Scene>;
  107936. /**
  107937. * Gets the list of created postprocesses
  107938. */
  107939. postProcesses: PostProcess[];
  107940. /**
  107941. * Gets a boolean indicating if the pointer is currently locked
  107942. */
  107943. isPointerLock: boolean;
  107944. /**
  107945. * Observable event triggered each time the rendering canvas is resized
  107946. */
  107947. onResizeObservable: Observable<Engine>;
  107948. /**
  107949. * Observable event triggered each time the canvas loses focus
  107950. */
  107951. onCanvasBlurObservable: Observable<Engine>;
  107952. /**
  107953. * Observable event triggered each time the canvas gains focus
  107954. */
  107955. onCanvasFocusObservable: Observable<Engine>;
  107956. /**
  107957. * Observable event triggered each time the canvas receives pointerout event
  107958. */
  107959. onCanvasPointerOutObservable: Observable<PointerEvent>;
  107960. /**
  107961. * Observable raised when the engine begins a new frame
  107962. */
  107963. onBeginFrameObservable: Observable<Engine>;
  107964. /**
  107965. * If set, will be used to request the next animation frame for the render loop
  107966. */
  107967. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  107968. /**
  107969. * Observable raised when the engine ends the current frame
  107970. */
  107971. onEndFrameObservable: Observable<Engine>;
  107972. /**
  107973. * Observable raised when the engine is about to compile a shader
  107974. */
  107975. onBeforeShaderCompilationObservable: Observable<Engine>;
  107976. /**
  107977. * Observable raised when the engine has jsut compiled a shader
  107978. */
  107979. onAfterShaderCompilationObservable: Observable<Engine>;
  107980. /**
  107981. * Gets the audio engine
  107982. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  107983. * @ignorenaming
  107984. */
  107985. static audioEngine: IAudioEngine;
  107986. /**
  107987. * Default AudioEngine factory responsible of creating the Audio Engine.
  107988. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  107989. */
  107990. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  107991. /**
  107992. * Default offline support factory responsible of creating a tool used to store data locally.
  107993. * By default, this will create a Database object if the workload has been embedded.
  107994. */
  107995. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  107996. private _loadingScreen;
  107997. private _pointerLockRequested;
  107998. private _dummyFramebuffer;
  107999. private _rescalePostProcess;
  108000. private _deterministicLockstep;
  108001. private _lockstepMaxSteps;
  108002. private _timeStep;
  108003. protected get _supportsHardwareTextureRescaling(): boolean;
  108004. private _fps;
  108005. private _deltaTime;
  108006. /** @hidden */
  108007. _drawCalls: PerfCounter;
  108008. /** 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 */
  108009. canvasTabIndex: number;
  108010. /**
  108011. * Turn this value on if you want to pause FPS computation when in background
  108012. */
  108013. disablePerformanceMonitorInBackground: boolean;
  108014. private _performanceMonitor;
  108015. /**
  108016. * Gets the performance monitor attached to this engine
  108017. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  108018. */
  108019. get performanceMonitor(): PerformanceMonitor;
  108020. private _onFocus;
  108021. private _onBlur;
  108022. private _onCanvasPointerOut;
  108023. private _onCanvasBlur;
  108024. private _onCanvasFocus;
  108025. private _onFullscreenChange;
  108026. private _onPointerLockChange;
  108027. /**
  108028. * Gets the HTML element used to attach event listeners
  108029. * @returns a HTML element
  108030. */
  108031. getInputElement(): Nullable<HTMLElement>;
  108032. /**
  108033. * Creates a new engine
  108034. * @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
  108035. * @param antialias defines enable antialiasing (default: false)
  108036. * @param options defines further options to be sent to the getContext() function
  108037. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  108038. */
  108039. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  108040. /**
  108041. * Gets current aspect ratio
  108042. * @param viewportOwner defines the camera to use to get the aspect ratio
  108043. * @param useScreen defines if screen size must be used (or the current render target if any)
  108044. * @returns a number defining the aspect ratio
  108045. */
  108046. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  108047. /**
  108048. * Gets current screen aspect ratio
  108049. * @returns a number defining the aspect ratio
  108050. */
  108051. getScreenAspectRatio(): number;
  108052. /**
  108053. * Gets the client rect of the HTML canvas attached with the current webGL context
  108054. * @returns a client rectanglee
  108055. */
  108056. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  108057. /**
  108058. * Gets the client rect of the HTML element used for events
  108059. * @returns a client rectanglee
  108060. */
  108061. getInputElementClientRect(): Nullable<ClientRect>;
  108062. /**
  108063. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  108064. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  108065. * @returns true if engine is in deterministic lock step mode
  108066. */
  108067. isDeterministicLockStep(): boolean;
  108068. /**
  108069. * Gets the max steps when engine is running in deterministic lock step
  108070. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  108071. * @returns the max steps
  108072. */
  108073. getLockstepMaxSteps(): number;
  108074. /**
  108075. * Returns the time in ms between steps when using deterministic lock step.
  108076. * @returns time step in (ms)
  108077. */
  108078. getTimeStep(): number;
  108079. /**
  108080. * Force the mipmap generation for the given render target texture
  108081. * @param texture defines the render target texture to use
  108082. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  108083. */
  108084. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  108085. /** States */
  108086. /**
  108087. * Set various states to the webGL context
  108088. * @param culling defines backface culling state
  108089. * @param zOffset defines the value to apply to zOffset (0 by default)
  108090. * @param force defines if states must be applied even if cache is up to date
  108091. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  108092. */
  108093. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  108094. /**
  108095. * Set the z offset to apply to current rendering
  108096. * @param value defines the offset to apply
  108097. */
  108098. setZOffset(value: number): void;
  108099. /**
  108100. * Gets the current value of the zOffset
  108101. * @returns the current zOffset state
  108102. */
  108103. getZOffset(): number;
  108104. /**
  108105. * Enable or disable depth buffering
  108106. * @param enable defines the state to set
  108107. */
  108108. setDepthBuffer(enable: boolean): void;
  108109. /**
  108110. * Gets a boolean indicating if depth writing is enabled
  108111. * @returns the current depth writing state
  108112. */
  108113. getDepthWrite(): boolean;
  108114. /**
  108115. * Enable or disable depth writing
  108116. * @param enable defines the state to set
  108117. */
  108118. setDepthWrite(enable: boolean): void;
  108119. /**
  108120. * Gets a boolean indicating if stencil buffer is enabled
  108121. * @returns the current stencil buffer state
  108122. */
  108123. getStencilBuffer(): boolean;
  108124. /**
  108125. * Enable or disable the stencil buffer
  108126. * @param enable defines if the stencil buffer must be enabled or disabled
  108127. */
  108128. setStencilBuffer(enable: boolean): void;
  108129. /**
  108130. * Gets the current stencil mask
  108131. * @returns a number defining the new stencil mask to use
  108132. */
  108133. getStencilMask(): number;
  108134. /**
  108135. * Sets the current stencil mask
  108136. * @param mask defines the new stencil mask to use
  108137. */
  108138. setStencilMask(mask: number): void;
  108139. /**
  108140. * Gets the current stencil function
  108141. * @returns a number defining the stencil function to use
  108142. */
  108143. getStencilFunction(): number;
  108144. /**
  108145. * Gets the current stencil reference value
  108146. * @returns a number defining the stencil reference value to use
  108147. */
  108148. getStencilFunctionReference(): number;
  108149. /**
  108150. * Gets the current stencil mask
  108151. * @returns a number defining the stencil mask to use
  108152. */
  108153. getStencilFunctionMask(): number;
  108154. /**
  108155. * Sets the current stencil function
  108156. * @param stencilFunc defines the new stencil function to use
  108157. */
  108158. setStencilFunction(stencilFunc: number): void;
  108159. /**
  108160. * Sets the current stencil reference
  108161. * @param reference defines the new stencil reference to use
  108162. */
  108163. setStencilFunctionReference(reference: number): void;
  108164. /**
  108165. * Sets the current stencil mask
  108166. * @param mask defines the new stencil mask to use
  108167. */
  108168. setStencilFunctionMask(mask: number): void;
  108169. /**
  108170. * Gets the current stencil operation when stencil fails
  108171. * @returns a number defining stencil operation to use when stencil fails
  108172. */
  108173. getStencilOperationFail(): number;
  108174. /**
  108175. * Gets the current stencil operation when depth fails
  108176. * @returns a number defining stencil operation to use when depth fails
  108177. */
  108178. getStencilOperationDepthFail(): number;
  108179. /**
  108180. * Gets the current stencil operation when stencil passes
  108181. * @returns a number defining stencil operation to use when stencil passes
  108182. */
  108183. getStencilOperationPass(): number;
  108184. /**
  108185. * Sets the stencil operation to use when stencil fails
  108186. * @param operation defines the stencil operation to use when stencil fails
  108187. */
  108188. setStencilOperationFail(operation: number): void;
  108189. /**
  108190. * Sets the stencil operation to use when depth fails
  108191. * @param operation defines the stencil operation to use when depth fails
  108192. */
  108193. setStencilOperationDepthFail(operation: number): void;
  108194. /**
  108195. * Sets the stencil operation to use when stencil passes
  108196. * @param operation defines the stencil operation to use when stencil passes
  108197. */
  108198. setStencilOperationPass(operation: number): void;
  108199. /**
  108200. * Sets a boolean indicating if the dithering state is enabled or disabled
  108201. * @param value defines the dithering state
  108202. */
  108203. setDitheringState(value: boolean): void;
  108204. /**
  108205. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  108206. * @param value defines the rasterizer state
  108207. */
  108208. setRasterizerState(value: boolean): void;
  108209. /**
  108210. * Gets the current depth function
  108211. * @returns a number defining the depth function
  108212. */
  108213. getDepthFunction(): Nullable<number>;
  108214. /**
  108215. * Sets the current depth function
  108216. * @param depthFunc defines the function to use
  108217. */
  108218. setDepthFunction(depthFunc: number): void;
  108219. /**
  108220. * Sets the current depth function to GREATER
  108221. */
  108222. setDepthFunctionToGreater(): void;
  108223. /**
  108224. * Sets the current depth function to GEQUAL
  108225. */
  108226. setDepthFunctionToGreaterOrEqual(): void;
  108227. /**
  108228. * Sets the current depth function to LESS
  108229. */
  108230. setDepthFunctionToLess(): void;
  108231. /**
  108232. * Sets the current depth function to LEQUAL
  108233. */
  108234. setDepthFunctionToLessOrEqual(): void;
  108235. private _cachedStencilBuffer;
  108236. private _cachedStencilFunction;
  108237. private _cachedStencilMask;
  108238. private _cachedStencilOperationPass;
  108239. private _cachedStencilOperationFail;
  108240. private _cachedStencilOperationDepthFail;
  108241. private _cachedStencilReference;
  108242. /**
  108243. * Caches the the state of the stencil buffer
  108244. */
  108245. cacheStencilState(): void;
  108246. /**
  108247. * Restores the state of the stencil buffer
  108248. */
  108249. restoreStencilState(): void;
  108250. /**
  108251. * Directly set the WebGL Viewport
  108252. * @param x defines the x coordinate of the viewport (in screen space)
  108253. * @param y defines the y coordinate of the viewport (in screen space)
  108254. * @param width defines the width of the viewport (in screen space)
  108255. * @param height defines the height of the viewport (in screen space)
  108256. * @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
  108257. */
  108258. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  108259. /**
  108260. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  108261. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  108262. * @param y defines the y-coordinate of the corner of the clear rectangle
  108263. * @param width defines the width of the clear rectangle
  108264. * @param height defines the height of the clear rectangle
  108265. * @param clearColor defines the clear color
  108266. */
  108267. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  108268. /**
  108269. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  108270. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  108271. * @param y defines the y-coordinate of the corner of the clear rectangle
  108272. * @param width defines the width of the clear rectangle
  108273. * @param height defines the height of the clear rectangle
  108274. */
  108275. enableScissor(x: number, y: number, width: number, height: number): void;
  108276. /**
  108277. * Disable previously set scissor test rectangle
  108278. */
  108279. disableScissor(): void;
  108280. protected _reportDrawCall(): void;
  108281. /**
  108282. * Initializes a webVR display and starts listening to display change events
  108283. * The onVRDisplayChangedObservable will be notified upon these changes
  108284. * @returns The onVRDisplayChangedObservable
  108285. */
  108286. initWebVR(): Observable<IDisplayChangedEventArgs>;
  108287. /** @hidden */
  108288. _prepareVRComponent(): void;
  108289. /** @hidden */
  108290. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  108291. /** @hidden */
  108292. _submitVRFrame(): void;
  108293. /**
  108294. * Call this function to leave webVR mode
  108295. * Will do nothing if webVR is not supported or if there is no webVR device
  108296. * @see http://doc.babylonjs.com/how_to/webvr_camera
  108297. */
  108298. disableVR(): void;
  108299. /**
  108300. * Gets a boolean indicating that the system is in VR mode and is presenting
  108301. * @returns true if VR mode is engaged
  108302. */
  108303. isVRPresenting(): boolean;
  108304. /** @hidden */
  108305. _requestVRFrame(): void;
  108306. /** @hidden */
  108307. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  108308. /**
  108309. * Gets the source code of the vertex shader associated with a specific webGL program
  108310. * @param program defines the program to use
  108311. * @returns a string containing the source code of the vertex shader associated with the program
  108312. */
  108313. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  108314. /**
  108315. * Gets the source code of the fragment shader associated with a specific webGL program
  108316. * @param program defines the program to use
  108317. * @returns a string containing the source code of the fragment shader associated with the program
  108318. */
  108319. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  108320. /**
  108321. * Sets a depth stencil texture from a render target to the according uniform.
  108322. * @param channel The texture channel
  108323. * @param uniform The uniform to set
  108324. * @param texture The render target texture containing the depth stencil texture to apply
  108325. */
  108326. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  108327. /**
  108328. * Sets a texture to the webGL context from a postprocess
  108329. * @param channel defines the channel to use
  108330. * @param postProcess defines the source postprocess
  108331. */
  108332. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  108333. /**
  108334. * Binds the output of the passed in post process to the texture channel specified
  108335. * @param channel The channel the texture should be bound to
  108336. * @param postProcess The post process which's output should be bound
  108337. */
  108338. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  108339. /** @hidden */
  108340. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  108341. protected _rebuildBuffers(): void;
  108342. /** @hidden */
  108343. _renderFrame(): void;
  108344. _renderLoop(): void;
  108345. /** @hidden */
  108346. _renderViews(): boolean;
  108347. /**
  108348. * Toggle full screen mode
  108349. * @param requestPointerLock defines if a pointer lock should be requested from the user
  108350. */
  108351. switchFullscreen(requestPointerLock: boolean): void;
  108352. /**
  108353. * Enters full screen mode
  108354. * @param requestPointerLock defines if a pointer lock should be requested from the user
  108355. */
  108356. enterFullscreen(requestPointerLock: boolean): void;
  108357. /**
  108358. * Exits full screen mode
  108359. */
  108360. exitFullscreen(): void;
  108361. /**
  108362. * Enters Pointerlock mode
  108363. */
  108364. enterPointerlock(): void;
  108365. /**
  108366. * Exits Pointerlock mode
  108367. */
  108368. exitPointerlock(): void;
  108369. /**
  108370. * Begin a new frame
  108371. */
  108372. beginFrame(): void;
  108373. /**
  108374. * Enf the current frame
  108375. */
  108376. endFrame(): void;
  108377. resize(): void;
  108378. /**
  108379. * Force a specific size of the canvas
  108380. * @param width defines the new canvas' width
  108381. * @param height defines the new canvas' height
  108382. */
  108383. setSize(width: number, height: number): void;
  108384. /**
  108385. * Updates a dynamic vertex buffer.
  108386. * @param vertexBuffer the vertex buffer to update
  108387. * @param data the data used to update the vertex buffer
  108388. * @param byteOffset the byte offset of the data
  108389. * @param byteLength the byte length of the data
  108390. */
  108391. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  108392. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  108393. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  108394. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  108395. _releaseTexture(texture: InternalTexture): void;
  108396. /**
  108397. * @hidden
  108398. * Rescales a texture
  108399. * @param source input texutre
  108400. * @param destination destination texture
  108401. * @param scene scene to use to render the resize
  108402. * @param internalFormat format to use when resizing
  108403. * @param onComplete callback to be called when resize has completed
  108404. */
  108405. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  108406. /**
  108407. * Gets the current framerate
  108408. * @returns a number representing the framerate
  108409. */
  108410. getFps(): number;
  108411. /**
  108412. * Gets the time spent between current and previous frame
  108413. * @returns a number representing the delta time in ms
  108414. */
  108415. getDeltaTime(): number;
  108416. private _measureFps;
  108417. /** @hidden */
  108418. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  108419. /**
  108420. * Update a dynamic index buffer
  108421. * @param indexBuffer defines the target index buffer
  108422. * @param indices defines the data to update
  108423. * @param offset defines the offset in the target index buffer where update should start
  108424. */
  108425. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  108426. /**
  108427. * Updates the sample count of a render target texture
  108428. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  108429. * @param texture defines the texture to update
  108430. * @param samples defines the sample count to set
  108431. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  108432. */
  108433. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  108434. /**
  108435. * Updates a depth texture Comparison Mode and Function.
  108436. * If the comparison Function is equal to 0, the mode will be set to none.
  108437. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  108438. * @param texture The texture to set the comparison function for
  108439. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  108440. */
  108441. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  108442. /**
  108443. * Creates a webGL buffer to use with instanciation
  108444. * @param capacity defines the size of the buffer
  108445. * @returns the webGL buffer
  108446. */
  108447. createInstancesBuffer(capacity: number): DataBuffer;
  108448. /**
  108449. * Delete a webGL buffer used with instanciation
  108450. * @param buffer defines the webGL buffer to delete
  108451. */
  108452. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  108453. private _clientWaitAsync;
  108454. /** @hidden */
  108455. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  108456. /** @hidden */
  108457. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  108458. dispose(): void;
  108459. private _disableTouchAction;
  108460. /**
  108461. * Display the loading screen
  108462. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  108463. */
  108464. displayLoadingUI(): void;
  108465. /**
  108466. * Hide the loading screen
  108467. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  108468. */
  108469. hideLoadingUI(): void;
  108470. /**
  108471. * Gets the current loading screen object
  108472. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  108473. */
  108474. get loadingScreen(): ILoadingScreen;
  108475. /**
  108476. * Sets the current loading screen object
  108477. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  108478. */
  108479. set loadingScreen(loadingScreen: ILoadingScreen);
  108480. /**
  108481. * Sets the current loading screen text
  108482. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  108483. */
  108484. set loadingUIText(text: string);
  108485. /**
  108486. * Sets the current loading screen background color
  108487. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  108488. */
  108489. set loadingUIBackgroundColor(color: string);
  108490. /** Pointerlock and fullscreen */
  108491. /**
  108492. * Ask the browser to promote the current element to pointerlock mode
  108493. * @param element defines the DOM element to promote
  108494. */
  108495. static _RequestPointerlock(element: HTMLElement): void;
  108496. /**
  108497. * Asks the browser to exit pointerlock mode
  108498. */
  108499. static _ExitPointerlock(): void;
  108500. /**
  108501. * Ask the browser to promote the current element to fullscreen rendering mode
  108502. * @param element defines the DOM element to promote
  108503. */
  108504. static _RequestFullscreen(element: HTMLElement): void;
  108505. /**
  108506. * Asks the browser to exit fullscreen mode
  108507. */
  108508. static _ExitFullscreen(): void;
  108509. }
  108510. }
  108511. declare module BABYLON {
  108512. /**
  108513. * The engine store class is responsible to hold all the instances of Engine and Scene created
  108514. * during the life time of the application.
  108515. */
  108516. export class EngineStore {
  108517. /** Gets the list of created engines */
  108518. static Instances: Engine[];
  108519. /** @hidden */
  108520. static _LastCreatedScene: Nullable<Scene>;
  108521. /**
  108522. * Gets the latest created engine
  108523. */
  108524. static get LastCreatedEngine(): Nullable<Engine>;
  108525. /**
  108526. * Gets the latest created scene
  108527. */
  108528. static get LastCreatedScene(): Nullable<Scene>;
  108529. /**
  108530. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  108531. * @ignorenaming
  108532. */
  108533. static UseFallbackTexture: boolean;
  108534. /**
  108535. * Texture content used if a texture cannot loaded
  108536. * @ignorenaming
  108537. */
  108538. static FallbackTexture: string;
  108539. }
  108540. }
  108541. declare module BABYLON {
  108542. /**
  108543. * Helper class that provides a small promise polyfill
  108544. */
  108545. export class PromisePolyfill {
  108546. /**
  108547. * Static function used to check if the polyfill is required
  108548. * If this is the case then the function will inject the polyfill to window.Promise
  108549. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  108550. */
  108551. static Apply(force?: boolean): void;
  108552. }
  108553. }
  108554. declare module BABYLON {
  108555. /**
  108556. * Interface for screenshot methods with describe argument called `size` as object with options
  108557. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  108558. */
  108559. export interface IScreenshotSize {
  108560. /**
  108561. * number in pixels for canvas height
  108562. */
  108563. height?: number;
  108564. /**
  108565. * multiplier allowing render at a higher or lower resolution
  108566. * If value is defined then height and width will be ignored and taken from camera
  108567. */
  108568. precision?: number;
  108569. /**
  108570. * number in pixels for canvas width
  108571. */
  108572. width?: number;
  108573. }
  108574. }
  108575. declare module BABYLON {
  108576. interface IColor4Like {
  108577. r: float;
  108578. g: float;
  108579. b: float;
  108580. a: float;
  108581. }
  108582. /**
  108583. * Class containing a set of static utilities functions
  108584. */
  108585. export class Tools {
  108586. /**
  108587. * Gets or sets the base URL to use to load assets
  108588. */
  108589. static get BaseUrl(): string;
  108590. static set BaseUrl(value: string);
  108591. /**
  108592. * Enable/Disable Custom HTTP Request Headers globally.
  108593. * default = false
  108594. * @see CustomRequestHeaders
  108595. */
  108596. static UseCustomRequestHeaders: boolean;
  108597. /**
  108598. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  108599. * i.e. when loading files, where the server/service expects an Authorization header
  108600. */
  108601. static CustomRequestHeaders: {
  108602. [key: string]: string;
  108603. };
  108604. /**
  108605. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  108606. */
  108607. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  108608. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  108609. /**
  108610. * Default behaviour for cors in the application.
  108611. * It can be a string if the expected behavior is identical in the entire app.
  108612. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  108613. */
  108614. static get CorsBehavior(): string | ((url: string | string[]) => string);
  108615. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  108616. /**
  108617. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  108618. * @ignorenaming
  108619. */
  108620. static get UseFallbackTexture(): boolean;
  108621. static set UseFallbackTexture(value: boolean);
  108622. /**
  108623. * Use this object to register external classes like custom textures or material
  108624. * to allow the laoders to instantiate them
  108625. */
  108626. static get RegisteredExternalClasses(): {
  108627. [key: string]: Object;
  108628. };
  108629. static set RegisteredExternalClasses(classes: {
  108630. [key: string]: Object;
  108631. });
  108632. /**
  108633. * Texture content used if a texture cannot loaded
  108634. * @ignorenaming
  108635. */
  108636. static get fallbackTexture(): string;
  108637. static set fallbackTexture(value: string);
  108638. /**
  108639. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  108640. * @param u defines the coordinate on X axis
  108641. * @param v defines the coordinate on Y axis
  108642. * @param width defines the width of the source data
  108643. * @param height defines the height of the source data
  108644. * @param pixels defines the source byte array
  108645. * @param color defines the output color
  108646. */
  108647. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  108648. /**
  108649. * Interpolates between a and b via alpha
  108650. * @param a The lower value (returned when alpha = 0)
  108651. * @param b The upper value (returned when alpha = 1)
  108652. * @param alpha The interpolation-factor
  108653. * @return The mixed value
  108654. */
  108655. static Mix(a: number, b: number, alpha: number): number;
  108656. /**
  108657. * Tries to instantiate a new object from a given class name
  108658. * @param className defines the class name to instantiate
  108659. * @returns the new object or null if the system was not able to do the instantiation
  108660. */
  108661. static Instantiate(className: string): any;
  108662. /**
  108663. * Provides a slice function that will work even on IE
  108664. * @param data defines the array to slice
  108665. * @param start defines the start of the data (optional)
  108666. * @param end defines the end of the data (optional)
  108667. * @returns the new sliced array
  108668. */
  108669. static Slice<T>(data: T, start?: number, end?: number): T;
  108670. /**
  108671. * Polyfill for setImmediate
  108672. * @param action defines the action to execute after the current execution block
  108673. */
  108674. static SetImmediate(action: () => void): void;
  108675. /**
  108676. * Function indicating if a number is an exponent of 2
  108677. * @param value defines the value to test
  108678. * @returns true if the value is an exponent of 2
  108679. */
  108680. static IsExponentOfTwo(value: number): boolean;
  108681. private static _tmpFloatArray;
  108682. /**
  108683. * Returns the nearest 32-bit single precision float representation of a Number
  108684. * @param value A Number. If the parameter is of a different type, it will get converted
  108685. * to a number or to NaN if it cannot be converted
  108686. * @returns number
  108687. */
  108688. static FloatRound(value: number): number;
  108689. /**
  108690. * Extracts the filename from a path
  108691. * @param path defines the path to use
  108692. * @returns the filename
  108693. */
  108694. static GetFilename(path: string): string;
  108695. /**
  108696. * Extracts the "folder" part of a path (everything before the filename).
  108697. * @param uri The URI to extract the info from
  108698. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  108699. * @returns The "folder" part of the path
  108700. */
  108701. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  108702. /**
  108703. * Extracts text content from a DOM element hierarchy
  108704. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  108705. */
  108706. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  108707. /**
  108708. * Convert an angle in radians to degrees
  108709. * @param angle defines the angle to convert
  108710. * @returns the angle in degrees
  108711. */
  108712. static ToDegrees(angle: number): number;
  108713. /**
  108714. * Convert an angle in degrees to radians
  108715. * @param angle defines the angle to convert
  108716. * @returns the angle in radians
  108717. */
  108718. static ToRadians(angle: number): number;
  108719. /**
  108720. * Returns an array if obj is not an array
  108721. * @param obj defines the object to evaluate as an array
  108722. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  108723. * @returns either obj directly if obj is an array or a new array containing obj
  108724. */
  108725. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  108726. /**
  108727. * Gets the pointer prefix to use
  108728. * @returns "pointer" if touch is enabled. Else returns "mouse"
  108729. */
  108730. static GetPointerPrefix(): string;
  108731. /**
  108732. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  108733. * @param url define the url we are trying
  108734. * @param element define the dom element where to configure the cors policy
  108735. */
  108736. static SetCorsBehavior(url: string | string[], element: {
  108737. crossOrigin: string | null;
  108738. }): void;
  108739. /**
  108740. * Removes unwanted characters from an url
  108741. * @param url defines the url to clean
  108742. * @returns the cleaned url
  108743. */
  108744. static CleanUrl(url: string): string;
  108745. /**
  108746. * Gets or sets a function used to pre-process url before using them to load assets
  108747. */
  108748. static get PreprocessUrl(): (url: string) => string;
  108749. static set PreprocessUrl(processor: (url: string) => string);
  108750. /**
  108751. * Loads an image as an HTMLImageElement.
  108752. * @param input url string, ArrayBuffer, or Blob to load
  108753. * @param onLoad callback called when the image successfully loads
  108754. * @param onError callback called when the image fails to load
  108755. * @param offlineProvider offline provider for caching
  108756. * @param mimeType optional mime type
  108757. * @returns the HTMLImageElement of the loaded image
  108758. */
  108759. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  108760. /**
  108761. * Loads a file from a url
  108762. * @param url url string, ArrayBuffer, or Blob to load
  108763. * @param onSuccess callback called when the file successfully loads
  108764. * @param onProgress callback called while file is loading (if the server supports this mode)
  108765. * @param offlineProvider defines the offline provider for caching
  108766. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  108767. * @param onError callback called when the file fails to load
  108768. * @returns a file request object
  108769. */
  108770. 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;
  108771. /**
  108772. * Loads a file from a url
  108773. * @param url the file url to load
  108774. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  108775. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  108776. */
  108777. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  108778. /**
  108779. * Load a script (identified by an url). When the url returns, the
  108780. * content of this file is added into a new script element, attached to the DOM (body element)
  108781. * @param scriptUrl defines the url of the script to laod
  108782. * @param onSuccess defines the callback called when the script is loaded
  108783. * @param onError defines the callback to call if an error occurs
  108784. * @param scriptId defines the id of the script element
  108785. */
  108786. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  108787. /**
  108788. * Load an asynchronous script (identified by an url). When the url returns, the
  108789. * content of this file is added into a new script element, attached to the DOM (body element)
  108790. * @param scriptUrl defines the url of the script to laod
  108791. * @param scriptId defines the id of the script element
  108792. * @returns a promise request object
  108793. */
  108794. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  108795. /**
  108796. * Loads a file from a blob
  108797. * @param fileToLoad defines the blob to use
  108798. * @param callback defines the callback to call when data is loaded
  108799. * @param progressCallback defines the callback to call during loading process
  108800. * @returns a file request object
  108801. */
  108802. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  108803. /**
  108804. * Reads a file from a File object
  108805. * @param file defines the file to load
  108806. * @param onSuccess defines the callback to call when data is loaded
  108807. * @param onProgress defines the callback to call during loading process
  108808. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  108809. * @param onError defines the callback to call when an error occurs
  108810. * @returns a file request object
  108811. */
  108812. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  108813. /**
  108814. * Creates a data url from a given string content
  108815. * @param content defines the content to convert
  108816. * @returns the new data url link
  108817. */
  108818. static FileAsURL(content: string): string;
  108819. /**
  108820. * Format the given number to a specific decimal format
  108821. * @param value defines the number to format
  108822. * @param decimals defines the number of decimals to use
  108823. * @returns the formatted string
  108824. */
  108825. static Format(value: number, decimals?: number): string;
  108826. /**
  108827. * Tries to copy an object by duplicating every property
  108828. * @param source defines the source object
  108829. * @param destination defines the target object
  108830. * @param doNotCopyList defines a list of properties to avoid
  108831. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  108832. */
  108833. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  108834. /**
  108835. * Gets a boolean indicating if the given object has no own property
  108836. * @param obj defines the object to test
  108837. * @returns true if object has no own property
  108838. */
  108839. static IsEmpty(obj: any): boolean;
  108840. /**
  108841. * Function used to register events at window level
  108842. * @param windowElement defines the Window object to use
  108843. * @param events defines the events to register
  108844. */
  108845. static RegisterTopRootEvents(windowElement: Window, events: {
  108846. name: string;
  108847. handler: Nullable<(e: FocusEvent) => any>;
  108848. }[]): void;
  108849. /**
  108850. * Function used to unregister events from window level
  108851. * @param windowElement defines the Window object to use
  108852. * @param events defines the events to unregister
  108853. */
  108854. static UnregisterTopRootEvents(windowElement: Window, events: {
  108855. name: string;
  108856. handler: Nullable<(e: FocusEvent) => any>;
  108857. }[]): void;
  108858. /**
  108859. * @ignore
  108860. */
  108861. static _ScreenshotCanvas: HTMLCanvasElement;
  108862. /**
  108863. * Dumps the current bound framebuffer
  108864. * @param width defines the rendering width
  108865. * @param height defines the rendering height
  108866. * @param engine defines the hosting engine
  108867. * @param successCallback defines the callback triggered once the data are available
  108868. * @param mimeType defines the mime type of the result
  108869. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  108870. */
  108871. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  108872. /**
  108873. * Converts the canvas data to blob.
  108874. * This acts as a polyfill for browsers not supporting the to blob function.
  108875. * @param canvas Defines the canvas to extract the data from
  108876. * @param successCallback Defines the callback triggered once the data are available
  108877. * @param mimeType Defines the mime type of the result
  108878. */
  108879. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  108880. /**
  108881. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  108882. * @param successCallback defines the callback triggered once the data are available
  108883. * @param mimeType defines the mime type of the result
  108884. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  108885. */
  108886. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  108887. /**
  108888. * Downloads a blob in the browser
  108889. * @param blob defines the blob to download
  108890. * @param fileName defines the name of the downloaded file
  108891. */
  108892. static Download(blob: Blob, fileName: string): void;
  108893. /**
  108894. * Captures a screenshot of the current rendering
  108895. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  108896. * @param engine defines the rendering engine
  108897. * @param camera defines the source camera
  108898. * @param size This parameter can be set to a single number or to an object with the
  108899. * following (optional) properties: precision, width, height. If a single number is passed,
  108900. * it will be used for both width and height. If an object is passed, the screenshot size
  108901. * will be derived from the parameters. The precision property is a multiplier allowing
  108902. * rendering at a higher or lower resolution
  108903. * @param successCallback defines the callback receives a single parameter which contains the
  108904. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  108905. * src parameter of an <img> to display it
  108906. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  108907. * Check your browser for supported MIME types
  108908. */
  108909. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: 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 mimeType defines the MIME type of the screenshot image (default: image/png).
  108921. * Check your browser for supported MIME types
  108922. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  108923. * to the src parameter of an <img> to display it
  108924. */
  108925. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  108926. /**
  108927. * Generates an image screenshot from the specified camera.
  108928. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  108929. * @param engine The engine to use for rendering
  108930. * @param camera The camera to use for rendering
  108931. * @param size This parameter can be set to a single number or to an object with the
  108932. * following (optional) properties: precision, width, height. If a single number is passed,
  108933. * it will be used for both width and height. If an object is passed, the screenshot size
  108934. * will be derived from the parameters. The precision property is a multiplier allowing
  108935. * rendering at a higher or lower resolution
  108936. * @param successCallback The callback receives a single parameter which contains the
  108937. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  108938. * src parameter of an <img> to display it
  108939. * @param mimeType The MIME type of the screenshot image (default: image/png).
  108940. * Check your browser for supported MIME types
  108941. * @param samples Texture samples (default: 1)
  108942. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  108943. * @param fileName A name for for the downloaded file.
  108944. */
  108945. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  108946. /**
  108947. * Generates an image screenshot from the specified camera.
  108948. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  108949. * @param engine The engine to use for rendering
  108950. * @param camera The camera to use for rendering
  108951. * @param size This parameter can be set to a single number or to an object with the
  108952. * following (optional) properties: precision, width, height. If a single number is passed,
  108953. * it will be used for both width and height. If an object is passed, the screenshot size
  108954. * will be derived from the parameters. The precision property is a multiplier allowing
  108955. * rendering at a higher or lower resolution
  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. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  108962. * to the src parameter of an <img> to display it
  108963. */
  108964. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  108965. /**
  108966. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  108967. * Be aware Math.random() could cause collisions, but:
  108968. * "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"
  108969. * @returns a pseudo random id
  108970. */
  108971. static RandomId(): string;
  108972. /**
  108973. * Test if the given uri is a base64 string
  108974. * @param uri The uri to test
  108975. * @return True if the uri is a base64 string or false otherwise
  108976. */
  108977. static IsBase64(uri: string): boolean;
  108978. /**
  108979. * Decode the given base64 uri.
  108980. * @param uri The uri to decode
  108981. * @return The decoded base64 data.
  108982. */
  108983. static DecodeBase64(uri: string): ArrayBuffer;
  108984. /**
  108985. * Gets the absolute url.
  108986. * @param url the input url
  108987. * @return the absolute url
  108988. */
  108989. static GetAbsoluteUrl(url: string): string;
  108990. /**
  108991. * No log
  108992. */
  108993. static readonly NoneLogLevel: number;
  108994. /**
  108995. * Only message logs
  108996. */
  108997. static readonly MessageLogLevel: number;
  108998. /**
  108999. * Only warning logs
  109000. */
  109001. static readonly WarningLogLevel: number;
  109002. /**
  109003. * Only error logs
  109004. */
  109005. static readonly ErrorLogLevel: number;
  109006. /**
  109007. * All logs
  109008. */
  109009. static readonly AllLogLevel: number;
  109010. /**
  109011. * Gets a value indicating the number of loading errors
  109012. * @ignorenaming
  109013. */
  109014. static get errorsCount(): number;
  109015. /**
  109016. * Callback called when a new log is added
  109017. */
  109018. static OnNewCacheEntry: (entry: string) => void;
  109019. /**
  109020. * Log a message to the console
  109021. * @param message defines the message to log
  109022. */
  109023. static Log(message: string): void;
  109024. /**
  109025. * Write a warning message to the console
  109026. * @param message defines the message to log
  109027. */
  109028. static Warn(message: string): void;
  109029. /**
  109030. * Write an error message to the console
  109031. * @param message defines the message to log
  109032. */
  109033. static Error(message: string): void;
  109034. /**
  109035. * Gets current log cache (list of logs)
  109036. */
  109037. static get LogCache(): string;
  109038. /**
  109039. * Clears the log cache
  109040. */
  109041. static ClearLogCache(): void;
  109042. /**
  109043. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  109044. */
  109045. static set LogLevels(level: number);
  109046. /**
  109047. * Checks if the window object exists
  109048. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  109049. */
  109050. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  109051. /**
  109052. * No performance log
  109053. */
  109054. static readonly PerformanceNoneLogLevel: number;
  109055. /**
  109056. * Use user marks to log performance
  109057. */
  109058. static readonly PerformanceUserMarkLogLevel: number;
  109059. /**
  109060. * Log performance to the console
  109061. */
  109062. static readonly PerformanceConsoleLogLevel: number;
  109063. private static _performance;
  109064. /**
  109065. * Sets the current performance log level
  109066. */
  109067. static set PerformanceLogLevel(level: number);
  109068. private static _StartPerformanceCounterDisabled;
  109069. private static _EndPerformanceCounterDisabled;
  109070. private static _StartUserMark;
  109071. private static _EndUserMark;
  109072. private static _StartPerformanceConsole;
  109073. private static _EndPerformanceConsole;
  109074. /**
  109075. * Starts a performance counter
  109076. */
  109077. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  109078. /**
  109079. * Ends a specific performance coutner
  109080. */
  109081. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  109082. /**
  109083. * Gets either window.performance.now() if supported or Date.now() else
  109084. */
  109085. static get Now(): number;
  109086. /**
  109087. * This method will return the name of the class used to create the instance of the given object.
  109088. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  109089. * @param object the object to get the class name from
  109090. * @param isType defines if the object is actually a type
  109091. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  109092. */
  109093. static GetClassName(object: any, isType?: boolean): string;
  109094. /**
  109095. * Gets the first element of an array satisfying a given predicate
  109096. * @param array defines the array to browse
  109097. * @param predicate defines the predicate to use
  109098. * @returns null if not found or the element
  109099. */
  109100. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  109101. /**
  109102. * This method will return the name of the full name of the class, including its owning module (if any).
  109103. * 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).
  109104. * @param object the object to get the class name from
  109105. * @param isType defines if the object is actually a type
  109106. * @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.
  109107. * @ignorenaming
  109108. */
  109109. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  109110. /**
  109111. * Returns a promise that resolves after the given amount of time.
  109112. * @param delay Number of milliseconds to delay
  109113. * @returns Promise that resolves after the given amount of time
  109114. */
  109115. static DelayAsync(delay: number): Promise<void>;
  109116. /**
  109117. * Utility function to detect if the current user agent is Safari
  109118. * @returns whether or not the current user agent is safari
  109119. */
  109120. static IsSafari(): boolean;
  109121. }
  109122. /**
  109123. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  109124. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  109125. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  109126. * @param name The name of the class, case should be preserved
  109127. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  109128. */
  109129. export function className(name: string, module?: string): (target: Object) => void;
  109130. /**
  109131. * An implementation of a loop for asynchronous functions.
  109132. */
  109133. export class AsyncLoop {
  109134. /**
  109135. * Defines the number of iterations for the loop
  109136. */
  109137. iterations: number;
  109138. /**
  109139. * Defines the current index of the loop.
  109140. */
  109141. index: number;
  109142. private _done;
  109143. private _fn;
  109144. private _successCallback;
  109145. /**
  109146. * Constructor.
  109147. * @param iterations the number of iterations.
  109148. * @param func the function to run each iteration
  109149. * @param successCallback the callback that will be called upon succesful execution
  109150. * @param offset starting offset.
  109151. */
  109152. constructor(
  109153. /**
  109154. * Defines the number of iterations for the loop
  109155. */
  109156. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  109157. /**
  109158. * Execute the next iteration. Must be called after the last iteration was finished.
  109159. */
  109160. executeNext(): void;
  109161. /**
  109162. * Break the loop and run the success callback.
  109163. */
  109164. breakLoop(): void;
  109165. /**
  109166. * Create and run an async loop.
  109167. * @param iterations the number of iterations.
  109168. * @param fn the function to run each iteration
  109169. * @param successCallback the callback that will be called upon succesful execution
  109170. * @param offset starting offset.
  109171. * @returns the created async loop object
  109172. */
  109173. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  109174. /**
  109175. * A for-loop that will run a given number of iterations synchronous and the rest async.
  109176. * @param iterations total number of iterations
  109177. * @param syncedIterations number of synchronous iterations in each async iteration.
  109178. * @param fn the function to call each iteration.
  109179. * @param callback a success call back that will be called when iterating stops.
  109180. * @param breakFunction a break condition (optional)
  109181. * @param timeout timeout settings for the setTimeout function. default - 0.
  109182. * @returns the created async loop object
  109183. */
  109184. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  109185. }
  109186. }
  109187. declare module BABYLON {
  109188. /**
  109189. * This class implement a typical dictionary using a string as key and the generic type T as value.
  109190. * The underlying implementation relies on an associative array to ensure the best performances.
  109191. * The value can be anything including 'null' but except 'undefined'
  109192. */
  109193. export class StringDictionary<T> {
  109194. /**
  109195. * This will clear this dictionary and copy the content from the 'source' one.
  109196. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  109197. * @param source the dictionary to take the content from and copy to this dictionary
  109198. */
  109199. copyFrom(source: StringDictionary<T>): void;
  109200. /**
  109201. * Get a value based from its key
  109202. * @param key the given key to get the matching value from
  109203. * @return the value if found, otherwise undefined is returned
  109204. */
  109205. get(key: string): T | undefined;
  109206. /**
  109207. * Get a value from its key or add it if it doesn't exist.
  109208. * This method will ensure you that a given key/data will be present in the dictionary.
  109209. * @param key the given key to get the matching value from
  109210. * @param factory the factory that will create the value if the key is not present in the dictionary.
  109211. * The factory will only be invoked if there's no data for the given key.
  109212. * @return the value corresponding to the key.
  109213. */
  109214. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  109215. /**
  109216. * Get a value from its key if present in the dictionary otherwise add it
  109217. * @param key the key to get the value from
  109218. * @param val if there's no such key/value pair in the dictionary add it with this value
  109219. * @return the value corresponding to the key
  109220. */
  109221. getOrAdd(key: string, val: T): T;
  109222. /**
  109223. * Check if there's a given key in the dictionary
  109224. * @param key the key to check for
  109225. * @return true if the key is present, false otherwise
  109226. */
  109227. contains(key: string): boolean;
  109228. /**
  109229. * Add a new key and its corresponding value
  109230. * @param key the key to add
  109231. * @param value the value corresponding to the key
  109232. * @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
  109233. */
  109234. add(key: string, value: T): boolean;
  109235. /**
  109236. * Update a specific value associated to a key
  109237. * @param key defines the key to use
  109238. * @param value defines the value to store
  109239. * @returns true if the value was updated (or false if the key was not found)
  109240. */
  109241. set(key: string, value: T): boolean;
  109242. /**
  109243. * Get the element of the given key and remove it from the dictionary
  109244. * @param key defines the key to search
  109245. * @returns the value associated with the key or null if not found
  109246. */
  109247. getAndRemove(key: string): Nullable<T>;
  109248. /**
  109249. * Remove a key/value from the dictionary.
  109250. * @param key the key to remove
  109251. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  109252. */
  109253. remove(key: string): boolean;
  109254. /**
  109255. * Clear the whole content of the dictionary
  109256. */
  109257. clear(): void;
  109258. /**
  109259. * Gets the current count
  109260. */
  109261. get count(): number;
  109262. /**
  109263. * Execute a callback on each key/val of the dictionary.
  109264. * Note that you can remove any element in this dictionary in the callback implementation
  109265. * @param callback the callback to execute on a given key/value pair
  109266. */
  109267. forEach(callback: (key: string, val: T) => void): void;
  109268. /**
  109269. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  109270. * If the callback returns null or undefined the method will iterate to the next key/value pair
  109271. * Note that you can remove any element in this dictionary in the callback implementation
  109272. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  109273. * @returns the first item
  109274. */
  109275. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  109276. private _count;
  109277. private _data;
  109278. }
  109279. }
  109280. declare module BABYLON {
  109281. /** @hidden */
  109282. export interface ICollisionCoordinator {
  109283. createCollider(): Collider;
  109284. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  109285. init(scene: Scene): void;
  109286. }
  109287. /** @hidden */
  109288. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  109289. private _scene;
  109290. private _scaledPosition;
  109291. private _scaledVelocity;
  109292. private _finalPosition;
  109293. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  109294. createCollider(): Collider;
  109295. init(scene: Scene): void;
  109296. private _collideWithWorld;
  109297. }
  109298. }
  109299. declare module BABYLON {
  109300. /**
  109301. * Class used to manage all inputs for the scene.
  109302. */
  109303. export class InputManager {
  109304. /** The distance in pixel that you have to move to prevent some events */
  109305. static DragMovementThreshold: number;
  109306. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  109307. static LongPressDelay: number;
  109308. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  109309. static DoubleClickDelay: number;
  109310. /** If you need to check double click without raising a single click at first click, enable this flag */
  109311. static ExclusiveDoubleClickMode: boolean;
  109312. private _wheelEventName;
  109313. private _onPointerMove;
  109314. private _onPointerDown;
  109315. private _onPointerUp;
  109316. private _initClickEvent;
  109317. private _initActionManager;
  109318. private _delayedSimpleClick;
  109319. private _delayedSimpleClickTimeout;
  109320. private _previousDelayedSimpleClickTimeout;
  109321. private _meshPickProceed;
  109322. private _previousButtonPressed;
  109323. private _currentPickResult;
  109324. private _previousPickResult;
  109325. private _totalPointersPressed;
  109326. private _doubleClickOccured;
  109327. private _pointerOverMesh;
  109328. private _pickedDownMesh;
  109329. private _pickedUpMesh;
  109330. private _pointerX;
  109331. private _pointerY;
  109332. private _unTranslatedPointerX;
  109333. private _unTranslatedPointerY;
  109334. private _startingPointerPosition;
  109335. private _previousStartingPointerPosition;
  109336. private _startingPointerTime;
  109337. private _previousStartingPointerTime;
  109338. private _pointerCaptures;
  109339. private _onKeyDown;
  109340. private _onKeyUp;
  109341. private _onCanvasFocusObserver;
  109342. private _onCanvasBlurObserver;
  109343. private _scene;
  109344. /**
  109345. * Creates a new InputManager
  109346. * @param scene defines the hosting scene
  109347. */
  109348. constructor(scene: Scene);
  109349. /**
  109350. * Gets the mesh that is currently under the pointer
  109351. */
  109352. get meshUnderPointer(): Nullable<AbstractMesh>;
  109353. /**
  109354. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  109355. */
  109356. get unTranslatedPointer(): Vector2;
  109357. /**
  109358. * Gets or sets the current on-screen X position of the pointer
  109359. */
  109360. get pointerX(): number;
  109361. set pointerX(value: number);
  109362. /**
  109363. * Gets or sets the current on-screen Y position of the pointer
  109364. */
  109365. get pointerY(): number;
  109366. set pointerY(value: number);
  109367. private _updatePointerPosition;
  109368. private _processPointerMove;
  109369. private _setRayOnPointerInfo;
  109370. private _checkPrePointerObservable;
  109371. /**
  109372. * Use this method to simulate a pointer move on a mesh
  109373. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  109374. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  109375. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  109376. */
  109377. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  109378. /**
  109379. * Use this method to simulate a pointer down on a mesh
  109380. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  109381. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  109382. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  109383. */
  109384. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  109385. private _processPointerDown;
  109386. /** @hidden */
  109387. _isPointerSwiping(): boolean;
  109388. /**
  109389. * Use this method to simulate a pointer up 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. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  109394. */
  109395. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  109396. private _processPointerUp;
  109397. /**
  109398. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  109399. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  109400. * @returns true if the pointer was captured
  109401. */
  109402. isPointerCaptured(pointerId?: number): boolean;
  109403. /**
  109404. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  109405. * @param attachUp defines if you want to attach events to pointerup
  109406. * @param attachDown defines if you want to attach events to pointerdown
  109407. * @param attachMove defines if you want to attach events to pointermove
  109408. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  109409. */
  109410. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  109411. /**
  109412. * Detaches all event handlers
  109413. */
  109414. detachControl(): void;
  109415. /**
  109416. * Force the value of meshUnderPointer
  109417. * @param mesh defines the mesh to use
  109418. */
  109419. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  109420. /**
  109421. * Gets the mesh under the pointer
  109422. * @returns a Mesh or null if no mesh is under the pointer
  109423. */
  109424. getPointerOverMesh(): Nullable<AbstractMesh>;
  109425. }
  109426. }
  109427. declare module BABYLON {
  109428. /**
  109429. * Helper class used to generate session unique ID
  109430. */
  109431. export class UniqueIdGenerator {
  109432. private static _UniqueIdCounter;
  109433. /**
  109434. * Gets an unique (relatively to the current scene) Id
  109435. */
  109436. static get UniqueId(): number;
  109437. }
  109438. }
  109439. declare module BABYLON {
  109440. /**
  109441. * This class defines the direct association between an animation and a target
  109442. */
  109443. export class TargetedAnimation {
  109444. /**
  109445. * Animation to perform
  109446. */
  109447. animation: Animation;
  109448. /**
  109449. * Target to animate
  109450. */
  109451. target: any;
  109452. /**
  109453. * Serialize the object
  109454. * @returns the JSON object representing the current entity
  109455. */
  109456. serialize(): any;
  109457. }
  109458. /**
  109459. * Use this class to create coordinated animations on multiple targets
  109460. */
  109461. export class AnimationGroup implements IDisposable {
  109462. /** The name of the animation group */
  109463. name: string;
  109464. private _scene;
  109465. private _targetedAnimations;
  109466. private _animatables;
  109467. private _from;
  109468. private _to;
  109469. private _isStarted;
  109470. private _isPaused;
  109471. private _speedRatio;
  109472. private _loopAnimation;
  109473. private _isAdditive;
  109474. /**
  109475. * Gets or sets the unique id of the node
  109476. */
  109477. uniqueId: number;
  109478. /**
  109479. * This observable will notify when one animation have ended
  109480. */
  109481. onAnimationEndObservable: Observable<TargetedAnimation>;
  109482. /**
  109483. * Observer raised when one animation loops
  109484. */
  109485. onAnimationLoopObservable: Observable<TargetedAnimation>;
  109486. /**
  109487. * Observer raised when all animations have looped
  109488. */
  109489. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  109490. /**
  109491. * This observable will notify when all animations have ended.
  109492. */
  109493. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  109494. /**
  109495. * This observable will notify when all animations have paused.
  109496. */
  109497. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  109498. /**
  109499. * This observable will notify when all animations are playing.
  109500. */
  109501. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  109502. /**
  109503. * Gets the first frame
  109504. */
  109505. get from(): number;
  109506. /**
  109507. * Gets the last frame
  109508. */
  109509. get to(): number;
  109510. /**
  109511. * Define if the animations are started
  109512. */
  109513. get isStarted(): boolean;
  109514. /**
  109515. * Gets a value indicating that the current group is playing
  109516. */
  109517. get isPlaying(): boolean;
  109518. /**
  109519. * Gets or sets the speed ratio to use for all animations
  109520. */
  109521. get speedRatio(): number;
  109522. /**
  109523. * Gets or sets the speed ratio to use for all animations
  109524. */
  109525. set speedRatio(value: number);
  109526. /**
  109527. * Gets or sets if all animations should loop or not
  109528. */
  109529. get loopAnimation(): boolean;
  109530. set loopAnimation(value: boolean);
  109531. /**
  109532. * Gets or sets if all animations should be evaluated additively
  109533. */
  109534. get isAdditive(): boolean;
  109535. set isAdditive(value: boolean);
  109536. /**
  109537. * Gets the targeted animations for this animation group
  109538. */
  109539. get targetedAnimations(): Array<TargetedAnimation>;
  109540. /**
  109541. * returning the list of animatables controlled by this animation group.
  109542. */
  109543. get animatables(): Array<Animatable>;
  109544. /**
  109545. * Instantiates a new Animation Group.
  109546. * This helps managing several animations at once.
  109547. * @see http://doc.babylonjs.com/how_to/group
  109548. * @param name Defines the name of the group
  109549. * @param scene Defines the scene the group belongs to
  109550. */
  109551. constructor(
  109552. /** The name of the animation group */
  109553. name: string, scene?: Nullable<Scene>);
  109554. /**
  109555. * Add an animation (with its target) in the group
  109556. * @param animation defines the animation we want to add
  109557. * @param target defines the target of the animation
  109558. * @returns the TargetedAnimation object
  109559. */
  109560. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  109561. /**
  109562. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  109563. * It can add constant keys at begin or end
  109564. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  109565. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  109566. * @returns the animation group
  109567. */
  109568. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  109569. private _animationLoopCount;
  109570. private _animationLoopFlags;
  109571. private _processLoop;
  109572. /**
  109573. * Start all animations on given targets
  109574. * @param loop defines if animations must loop
  109575. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  109576. * @param from defines the from key (optional)
  109577. * @param to defines the to key (optional)
  109578. * @param isAdditive defines the additive state for the resulting animatables (optional)
  109579. * @returns the current animation group
  109580. */
  109581. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  109582. /**
  109583. * Pause all animations
  109584. * @returns the animation group
  109585. */
  109586. pause(): AnimationGroup;
  109587. /**
  109588. * Play all animations to initial state
  109589. * This function will start() the animations if they were not started or will restart() them if they were paused
  109590. * @param loop defines if animations must loop
  109591. * @returns the animation group
  109592. */
  109593. play(loop?: boolean): AnimationGroup;
  109594. /**
  109595. * Reset all animations to initial state
  109596. * @returns the animation group
  109597. */
  109598. reset(): AnimationGroup;
  109599. /**
  109600. * Restart animations from key 0
  109601. * @returns the animation group
  109602. */
  109603. restart(): AnimationGroup;
  109604. /**
  109605. * Stop all animations
  109606. * @returns the animation group
  109607. */
  109608. stop(): AnimationGroup;
  109609. /**
  109610. * Set animation weight for all animatables
  109611. * @param weight defines the weight to use
  109612. * @return the animationGroup
  109613. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  109614. */
  109615. setWeightForAllAnimatables(weight: number): AnimationGroup;
  109616. /**
  109617. * Synchronize and normalize all animatables with a source animatable
  109618. * @param root defines the root animatable to synchronize with
  109619. * @return the animationGroup
  109620. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  109621. */
  109622. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  109623. /**
  109624. * Goes to a specific frame in this animation group
  109625. * @param frame the frame number to go to
  109626. * @return the animationGroup
  109627. */
  109628. goToFrame(frame: number): AnimationGroup;
  109629. /**
  109630. * Dispose all associated resources
  109631. */
  109632. dispose(): void;
  109633. private _checkAnimationGroupEnded;
  109634. /**
  109635. * Clone the current animation group and returns a copy
  109636. * @param newName defines the name of the new group
  109637. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  109638. * @returns the new aniamtion group
  109639. */
  109640. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  109641. /**
  109642. * Serializes the animationGroup to an object
  109643. * @returns Serialized object
  109644. */
  109645. serialize(): any;
  109646. /**
  109647. * Returns a new AnimationGroup object parsed from the source provided.
  109648. * @param parsedAnimationGroup defines the source
  109649. * @param scene defines the scene that will receive the animationGroup
  109650. * @returns a new AnimationGroup
  109651. */
  109652. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  109653. /**
  109654. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  109655. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  109656. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  109657. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  109658. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  109659. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  109660. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  109661. */
  109662. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  109663. /**
  109664. * Returns the string "AnimationGroup"
  109665. * @returns "AnimationGroup"
  109666. */
  109667. getClassName(): string;
  109668. /**
  109669. * Creates a detailled string about the object
  109670. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  109671. * @returns a string representing the object
  109672. */
  109673. toString(fullDetails?: boolean): string;
  109674. }
  109675. }
  109676. declare module BABYLON {
  109677. /**
  109678. * Define an interface for all classes that will hold resources
  109679. */
  109680. export interface IDisposable {
  109681. /**
  109682. * Releases all held resources
  109683. */
  109684. dispose(): void;
  109685. }
  109686. /** Interface defining initialization parameters for Scene class */
  109687. export interface SceneOptions {
  109688. /**
  109689. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  109690. * It will improve performance when the number of geometries becomes important.
  109691. */
  109692. useGeometryUniqueIdsMap?: boolean;
  109693. /**
  109694. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  109695. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  109696. */
  109697. useMaterialMeshMap?: boolean;
  109698. /**
  109699. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  109700. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  109701. */
  109702. useClonedMeshMap?: boolean;
  109703. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  109704. virtual?: boolean;
  109705. }
  109706. /**
  109707. * Represents a scene to be rendered by the engine.
  109708. * @see http://doc.babylonjs.com/features/scene
  109709. */
  109710. export class Scene extends AbstractScene implements IAnimatable {
  109711. /** The fog is deactivated */
  109712. static readonly FOGMODE_NONE: number;
  109713. /** The fog density is following an exponential function */
  109714. static readonly FOGMODE_EXP: number;
  109715. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  109716. static readonly FOGMODE_EXP2: number;
  109717. /** The fog density is following a linear function. */
  109718. static readonly FOGMODE_LINEAR: number;
  109719. /**
  109720. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  109721. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  109722. */
  109723. static MinDeltaTime: number;
  109724. /**
  109725. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  109726. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  109727. */
  109728. static MaxDeltaTime: number;
  109729. /**
  109730. * Factory used to create the default material.
  109731. * @param name The name of the material to create
  109732. * @param scene The scene to create the material for
  109733. * @returns The default material
  109734. */
  109735. static DefaultMaterialFactory(scene: Scene): Material;
  109736. /**
  109737. * Factory used to create the a collision coordinator.
  109738. * @returns The collision coordinator
  109739. */
  109740. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  109741. /** @hidden */
  109742. _inputManager: InputManager;
  109743. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  109744. cameraToUseForPointers: Nullable<Camera>;
  109745. /** @hidden */
  109746. readonly _isScene: boolean;
  109747. /** @hidden */
  109748. _blockEntityCollection: boolean;
  109749. /**
  109750. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  109751. */
  109752. autoClear: boolean;
  109753. /**
  109754. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  109755. */
  109756. autoClearDepthAndStencil: boolean;
  109757. /**
  109758. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  109759. */
  109760. clearColor: Color4;
  109761. /**
  109762. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  109763. */
  109764. ambientColor: Color3;
  109765. /**
  109766. * This is use to store the default BRDF lookup for PBR materials in your scene.
  109767. * It should only be one of the following (if not the default embedded one):
  109768. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  109769. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  109770. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  109771. * The material properties need to be setup according to the type of texture in use.
  109772. */
  109773. environmentBRDFTexture: BaseTexture;
  109774. /** @hidden */
  109775. protected _environmentTexture: Nullable<BaseTexture>;
  109776. /**
  109777. * Texture used in all pbr material as the reflection texture.
  109778. * As in the majority of the scene they are the same (exception for multi room and so on),
  109779. * this is easier to reference from here than from all the materials.
  109780. */
  109781. get environmentTexture(): Nullable<BaseTexture>;
  109782. /**
  109783. * Texture used in all pbr material as the reflection texture.
  109784. * As in the majority of the scene they are the same (exception for multi room and so on),
  109785. * this is easier to set here than in all the materials.
  109786. */
  109787. set environmentTexture(value: Nullable<BaseTexture>);
  109788. /** @hidden */
  109789. protected _environmentIntensity: number;
  109790. /**
  109791. * Intensity of the environment in all pbr material.
  109792. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  109793. * As in the majority of the scene they are the same (exception for multi room and so on),
  109794. * this is easier to reference from here than from all the materials.
  109795. */
  109796. get environmentIntensity(): number;
  109797. /**
  109798. * Intensity of the environment in all pbr material.
  109799. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  109800. * As in the majority of the scene they are the same (exception for multi room and so on),
  109801. * this is easier to set here than in all the materials.
  109802. */
  109803. set environmentIntensity(value: number);
  109804. /** @hidden */
  109805. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  109806. /**
  109807. * Default image processing configuration used either in the rendering
  109808. * Forward main pass or through the imageProcessingPostProcess if present.
  109809. * As in the majority of the scene they are the same (exception for multi camera),
  109810. * this is easier to reference from here than from all the materials and post process.
  109811. *
  109812. * No setter as we it is a shared configuration, you can set the values instead.
  109813. */
  109814. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  109815. private _forceWireframe;
  109816. /**
  109817. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  109818. */
  109819. set forceWireframe(value: boolean);
  109820. get forceWireframe(): boolean;
  109821. private _skipFrustumClipping;
  109822. /**
  109823. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  109824. */
  109825. set skipFrustumClipping(value: boolean);
  109826. get skipFrustumClipping(): boolean;
  109827. private _forcePointsCloud;
  109828. /**
  109829. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  109830. */
  109831. set forcePointsCloud(value: boolean);
  109832. get forcePointsCloud(): boolean;
  109833. /**
  109834. * Gets or sets the active clipplane 1
  109835. */
  109836. clipPlane: Nullable<Plane>;
  109837. /**
  109838. * Gets or sets the active clipplane 2
  109839. */
  109840. clipPlane2: Nullable<Plane>;
  109841. /**
  109842. * Gets or sets the active clipplane 3
  109843. */
  109844. clipPlane3: Nullable<Plane>;
  109845. /**
  109846. * Gets or sets the active clipplane 4
  109847. */
  109848. clipPlane4: Nullable<Plane>;
  109849. /**
  109850. * Gets or sets the active clipplane 5
  109851. */
  109852. clipPlane5: Nullable<Plane>;
  109853. /**
  109854. * Gets or sets the active clipplane 6
  109855. */
  109856. clipPlane6: Nullable<Plane>;
  109857. /**
  109858. * Gets or sets a boolean indicating if animations are enabled
  109859. */
  109860. animationsEnabled: boolean;
  109861. private _animationPropertiesOverride;
  109862. /**
  109863. * Gets or sets the animation properties override
  109864. */
  109865. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  109866. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  109867. /**
  109868. * Gets or sets a boolean indicating if a constant deltatime has to be used
  109869. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  109870. */
  109871. useConstantAnimationDeltaTime: boolean;
  109872. /**
  109873. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  109874. * Please note that it requires to run a ray cast through the scene on every frame
  109875. */
  109876. constantlyUpdateMeshUnderPointer: boolean;
  109877. /**
  109878. * Defines the HTML cursor to use when hovering over interactive elements
  109879. */
  109880. hoverCursor: string;
  109881. /**
  109882. * Defines the HTML default cursor to use (empty by default)
  109883. */
  109884. defaultCursor: string;
  109885. /**
  109886. * Defines whether cursors are handled by the scene.
  109887. */
  109888. doNotHandleCursors: boolean;
  109889. /**
  109890. * This is used to call preventDefault() on pointer down
  109891. * in order to block unwanted artifacts like system double clicks
  109892. */
  109893. preventDefaultOnPointerDown: boolean;
  109894. /**
  109895. * This is used to call preventDefault() on pointer up
  109896. * in order to block unwanted artifacts like system double clicks
  109897. */
  109898. preventDefaultOnPointerUp: boolean;
  109899. /**
  109900. * Gets or sets user defined metadata
  109901. */
  109902. metadata: any;
  109903. /**
  109904. * For internal use only. Please do not use.
  109905. */
  109906. reservedDataStore: any;
  109907. /**
  109908. * Gets the name of the plugin used to load this scene (null by default)
  109909. */
  109910. loadingPluginName: string;
  109911. /**
  109912. * Use this array to add regular expressions used to disable offline support for specific urls
  109913. */
  109914. disableOfflineSupportExceptionRules: RegExp[];
  109915. /**
  109916. * An event triggered when the scene is disposed.
  109917. */
  109918. onDisposeObservable: Observable<Scene>;
  109919. private _onDisposeObserver;
  109920. /** Sets a function to be executed when this scene is disposed. */
  109921. set onDispose(callback: () => void);
  109922. /**
  109923. * An event triggered before rendering the scene (right after animations and physics)
  109924. */
  109925. onBeforeRenderObservable: Observable<Scene>;
  109926. private _onBeforeRenderObserver;
  109927. /** Sets a function to be executed before rendering this scene */
  109928. set beforeRender(callback: Nullable<() => void>);
  109929. /**
  109930. * An event triggered after rendering the scene
  109931. */
  109932. onAfterRenderObservable: Observable<Scene>;
  109933. /**
  109934. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  109935. */
  109936. onAfterRenderCameraObservable: Observable<Camera>;
  109937. private _onAfterRenderObserver;
  109938. /** Sets a function to be executed after rendering this scene */
  109939. set afterRender(callback: Nullable<() => void>);
  109940. /**
  109941. * An event triggered before animating the scene
  109942. */
  109943. onBeforeAnimationsObservable: Observable<Scene>;
  109944. /**
  109945. * An event triggered after animations processing
  109946. */
  109947. onAfterAnimationsObservable: Observable<Scene>;
  109948. /**
  109949. * An event triggered before draw calls are ready to be sent
  109950. */
  109951. onBeforeDrawPhaseObservable: Observable<Scene>;
  109952. /**
  109953. * An event triggered after draw calls have been sent
  109954. */
  109955. onAfterDrawPhaseObservable: Observable<Scene>;
  109956. /**
  109957. * An event triggered when the scene is ready
  109958. */
  109959. onReadyObservable: Observable<Scene>;
  109960. /**
  109961. * An event triggered before rendering a camera
  109962. */
  109963. onBeforeCameraRenderObservable: Observable<Camera>;
  109964. private _onBeforeCameraRenderObserver;
  109965. /** Sets a function to be executed before rendering a camera*/
  109966. set beforeCameraRender(callback: () => void);
  109967. /**
  109968. * An event triggered after rendering a camera
  109969. */
  109970. onAfterCameraRenderObservable: Observable<Camera>;
  109971. private _onAfterCameraRenderObserver;
  109972. /** Sets a function to be executed after rendering a camera*/
  109973. set afterCameraRender(callback: () => void);
  109974. /**
  109975. * An event triggered when active meshes evaluation is about to start
  109976. */
  109977. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  109978. /**
  109979. * An event triggered when active meshes evaluation is done
  109980. */
  109981. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  109982. /**
  109983. * An event triggered when particles rendering is about to start
  109984. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  109985. */
  109986. onBeforeParticlesRenderingObservable: Observable<Scene>;
  109987. /**
  109988. * An event triggered when particles rendering is done
  109989. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  109990. */
  109991. onAfterParticlesRenderingObservable: Observable<Scene>;
  109992. /**
  109993. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  109994. */
  109995. onDataLoadedObservable: Observable<Scene>;
  109996. /**
  109997. * An event triggered when a camera is created
  109998. */
  109999. onNewCameraAddedObservable: Observable<Camera>;
  110000. /**
  110001. * An event triggered when a camera is removed
  110002. */
  110003. onCameraRemovedObservable: Observable<Camera>;
  110004. /**
  110005. * An event triggered when a light is created
  110006. */
  110007. onNewLightAddedObservable: Observable<Light>;
  110008. /**
  110009. * An event triggered when a light is removed
  110010. */
  110011. onLightRemovedObservable: Observable<Light>;
  110012. /**
  110013. * An event triggered when a geometry is created
  110014. */
  110015. onNewGeometryAddedObservable: Observable<Geometry>;
  110016. /**
  110017. * An event triggered when a geometry is removed
  110018. */
  110019. onGeometryRemovedObservable: Observable<Geometry>;
  110020. /**
  110021. * An event triggered when a transform node is created
  110022. */
  110023. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  110024. /**
  110025. * An event triggered when a transform node is removed
  110026. */
  110027. onTransformNodeRemovedObservable: Observable<TransformNode>;
  110028. /**
  110029. * An event triggered when a mesh is created
  110030. */
  110031. onNewMeshAddedObservable: Observable<AbstractMesh>;
  110032. /**
  110033. * An event triggered when a mesh is removed
  110034. */
  110035. onMeshRemovedObservable: Observable<AbstractMesh>;
  110036. /**
  110037. * An event triggered when a skeleton is created
  110038. */
  110039. onNewSkeletonAddedObservable: Observable<Skeleton>;
  110040. /**
  110041. * An event triggered when a skeleton is removed
  110042. */
  110043. onSkeletonRemovedObservable: Observable<Skeleton>;
  110044. /**
  110045. * An event triggered when a material is created
  110046. */
  110047. onNewMaterialAddedObservable: Observable<Material>;
  110048. /**
  110049. * An event triggered when a material is removed
  110050. */
  110051. onMaterialRemovedObservable: Observable<Material>;
  110052. /**
  110053. * An event triggered when a texture is created
  110054. */
  110055. onNewTextureAddedObservable: Observable<BaseTexture>;
  110056. /**
  110057. * An event triggered when a texture is removed
  110058. */
  110059. onTextureRemovedObservable: Observable<BaseTexture>;
  110060. /**
  110061. * An event triggered when render targets are about to be rendered
  110062. * Can happen multiple times per frame.
  110063. */
  110064. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  110065. /**
  110066. * An event triggered when render targets were rendered.
  110067. * Can happen multiple times per frame.
  110068. */
  110069. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  110070. /**
  110071. * An event triggered before calculating deterministic simulation step
  110072. */
  110073. onBeforeStepObservable: Observable<Scene>;
  110074. /**
  110075. * An event triggered after calculating deterministic simulation step
  110076. */
  110077. onAfterStepObservable: Observable<Scene>;
  110078. /**
  110079. * An event triggered when the activeCamera property is updated
  110080. */
  110081. onActiveCameraChanged: Observable<Scene>;
  110082. /**
  110083. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  110084. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  110085. * If you wish to register an Observer only for a given set of renderingGroup, use the mask with a combination of the renderingGroup index elevated to the power of two (1 for renderingGroup 0, 2 for renderingrOup1, 4 for 2 and 8 for 3)
  110086. */
  110087. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  110088. /**
  110089. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  110090. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  110091. * 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)
  110092. */
  110093. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  110094. /**
  110095. * This Observable will when a mesh has been imported into the scene.
  110096. */
  110097. onMeshImportedObservable: Observable<AbstractMesh>;
  110098. /**
  110099. * This Observable will when an animation file has been imported into the scene.
  110100. */
  110101. onAnimationFileImportedObservable: Observable<Scene>;
  110102. /**
  110103. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  110104. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  110105. */
  110106. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  110107. /** @hidden */
  110108. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  110109. /**
  110110. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  110111. */
  110112. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  110113. /**
  110114. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  110115. */
  110116. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  110117. /**
  110118. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  110119. */
  110120. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  110121. /** Callback called when a pointer move is detected */
  110122. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  110123. /** Callback called when a pointer down is detected */
  110124. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  110125. /** Callback called when a pointer up is detected */
  110126. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  110127. /** Callback called when a pointer pick is detected */
  110128. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  110129. /**
  110130. * 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).
  110131. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  110132. */
  110133. onPrePointerObservable: Observable<PointerInfoPre>;
  110134. /**
  110135. * Observable event triggered each time an input event is received from the rendering canvas
  110136. */
  110137. onPointerObservable: Observable<PointerInfo>;
  110138. /**
  110139. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  110140. */
  110141. get unTranslatedPointer(): Vector2;
  110142. /**
  110143. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  110144. */
  110145. static get DragMovementThreshold(): number;
  110146. static set DragMovementThreshold(value: number);
  110147. /**
  110148. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  110149. */
  110150. static get LongPressDelay(): number;
  110151. static set LongPressDelay(value: number);
  110152. /**
  110153. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  110154. */
  110155. static get DoubleClickDelay(): number;
  110156. static set DoubleClickDelay(value: number);
  110157. /** If you need to check double click without raising a single click at first click, enable this flag */
  110158. static get ExclusiveDoubleClickMode(): boolean;
  110159. static set ExclusiveDoubleClickMode(value: boolean);
  110160. /** @hidden */
  110161. _mirroredCameraPosition: Nullable<Vector3>;
  110162. /**
  110163. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  110164. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  110165. */
  110166. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  110167. /**
  110168. * Observable event triggered each time an keyboard event is received from the hosting window
  110169. */
  110170. onKeyboardObservable: Observable<KeyboardInfo>;
  110171. private _useRightHandedSystem;
  110172. /**
  110173. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  110174. */
  110175. set useRightHandedSystem(value: boolean);
  110176. get useRightHandedSystem(): boolean;
  110177. private _timeAccumulator;
  110178. private _currentStepId;
  110179. private _currentInternalStep;
  110180. /**
  110181. * Sets the step Id used by deterministic lock step
  110182. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  110183. * @param newStepId defines the step Id
  110184. */
  110185. setStepId(newStepId: number): void;
  110186. /**
  110187. * Gets the step Id used by deterministic lock step
  110188. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  110189. * @returns the step Id
  110190. */
  110191. getStepId(): number;
  110192. /**
  110193. * Gets the internal step used by deterministic lock step
  110194. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  110195. * @returns the internal step
  110196. */
  110197. getInternalStep(): number;
  110198. private _fogEnabled;
  110199. /**
  110200. * Gets or sets a boolean indicating if fog is enabled on this scene
  110201. * @see http://doc.babylonjs.com/babylon101/environment#fog
  110202. * (Default is true)
  110203. */
  110204. set fogEnabled(value: boolean);
  110205. get fogEnabled(): boolean;
  110206. private _fogMode;
  110207. /**
  110208. * Gets or sets the fog mode to use
  110209. * @see http://doc.babylonjs.com/babylon101/environment#fog
  110210. * | mode | value |
  110211. * | --- | --- |
  110212. * | FOGMODE_NONE | 0 |
  110213. * | FOGMODE_EXP | 1 |
  110214. * | FOGMODE_EXP2 | 2 |
  110215. * | FOGMODE_LINEAR | 3 |
  110216. */
  110217. set fogMode(value: number);
  110218. get fogMode(): number;
  110219. /**
  110220. * Gets or sets the fog color to use
  110221. * @see http://doc.babylonjs.com/babylon101/environment#fog
  110222. * (Default is Color3(0.2, 0.2, 0.3))
  110223. */
  110224. fogColor: Color3;
  110225. /**
  110226. * Gets or sets the fog density to use
  110227. * @see http://doc.babylonjs.com/babylon101/environment#fog
  110228. * (Default is 0.1)
  110229. */
  110230. fogDensity: number;
  110231. /**
  110232. * Gets or sets the fog start distance to use
  110233. * @see http://doc.babylonjs.com/babylon101/environment#fog
  110234. * (Default is 0)
  110235. */
  110236. fogStart: number;
  110237. /**
  110238. * Gets or sets the fog end distance to use
  110239. * @see http://doc.babylonjs.com/babylon101/environment#fog
  110240. * (Default is 1000)
  110241. */
  110242. fogEnd: number;
  110243. private _shadowsEnabled;
  110244. /**
  110245. * Gets or sets a boolean indicating if shadows are enabled on this scene
  110246. */
  110247. set shadowsEnabled(value: boolean);
  110248. get shadowsEnabled(): boolean;
  110249. private _lightsEnabled;
  110250. /**
  110251. * Gets or sets a boolean indicating if lights are enabled on this scene
  110252. */
  110253. set lightsEnabled(value: boolean);
  110254. get lightsEnabled(): boolean;
  110255. /** All of the active cameras added to this scene. */
  110256. activeCameras: Camera[];
  110257. /** @hidden */
  110258. _activeCamera: Nullable<Camera>;
  110259. /** Gets or sets the current active camera */
  110260. get activeCamera(): Nullable<Camera>;
  110261. set activeCamera(value: Nullable<Camera>);
  110262. private _defaultMaterial;
  110263. /** The default material used on meshes when no material is affected */
  110264. get defaultMaterial(): Material;
  110265. /** The default material used on meshes when no material is affected */
  110266. set defaultMaterial(value: Material);
  110267. private _texturesEnabled;
  110268. /**
  110269. * Gets or sets a boolean indicating if textures are enabled on this scene
  110270. */
  110271. set texturesEnabled(value: boolean);
  110272. get texturesEnabled(): boolean;
  110273. /**
  110274. * Gets or sets a boolean indicating if particles are enabled on this scene
  110275. */
  110276. particlesEnabled: boolean;
  110277. /**
  110278. * Gets or sets a boolean indicating if sprites are enabled on this scene
  110279. */
  110280. spritesEnabled: boolean;
  110281. private _skeletonsEnabled;
  110282. /**
  110283. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  110284. */
  110285. set skeletonsEnabled(value: boolean);
  110286. get skeletonsEnabled(): boolean;
  110287. /**
  110288. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  110289. */
  110290. lensFlaresEnabled: boolean;
  110291. /**
  110292. * Gets or sets a boolean indicating if collisions are enabled on this scene
  110293. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  110294. */
  110295. collisionsEnabled: boolean;
  110296. private _collisionCoordinator;
  110297. /** @hidden */
  110298. get collisionCoordinator(): ICollisionCoordinator;
  110299. /**
  110300. * Defines the gravity applied to this scene (used only for collisions)
  110301. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  110302. */
  110303. gravity: Vector3;
  110304. /**
  110305. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  110306. */
  110307. postProcessesEnabled: boolean;
  110308. /**
  110309. * The list of postprocesses added to the scene
  110310. */
  110311. postProcesses: PostProcess[];
  110312. /**
  110313. * Gets the current postprocess manager
  110314. */
  110315. postProcessManager: PostProcessManager;
  110316. /**
  110317. * Gets or sets a boolean indicating if render targets are enabled on this scene
  110318. */
  110319. renderTargetsEnabled: boolean;
  110320. /**
  110321. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  110322. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  110323. */
  110324. dumpNextRenderTargets: boolean;
  110325. /**
  110326. * The list of user defined render targets added to the scene
  110327. */
  110328. customRenderTargets: RenderTargetTexture[];
  110329. /**
  110330. * Defines if texture loading must be delayed
  110331. * If true, textures will only be loaded when they need to be rendered
  110332. */
  110333. useDelayedTextureLoading: boolean;
  110334. /**
  110335. * Gets the list of meshes imported to the scene through SceneLoader
  110336. */
  110337. importedMeshesFiles: String[];
  110338. /**
  110339. * Gets or sets a boolean indicating if probes are enabled on this scene
  110340. */
  110341. probesEnabled: boolean;
  110342. /**
  110343. * Gets or sets the current offline provider to use to store scene data
  110344. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  110345. */
  110346. offlineProvider: IOfflineProvider;
  110347. /**
  110348. * Gets or sets the action manager associated with the scene
  110349. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  110350. */
  110351. actionManager: AbstractActionManager;
  110352. private _meshesForIntersections;
  110353. /**
  110354. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  110355. */
  110356. proceduralTexturesEnabled: boolean;
  110357. private _engine;
  110358. private _totalVertices;
  110359. /** @hidden */
  110360. _activeIndices: PerfCounter;
  110361. /** @hidden */
  110362. _activeParticles: PerfCounter;
  110363. /** @hidden */
  110364. _activeBones: PerfCounter;
  110365. private _animationRatio;
  110366. /** @hidden */
  110367. _animationTimeLast: number;
  110368. /** @hidden */
  110369. _animationTime: number;
  110370. /**
  110371. * Gets or sets a general scale for animation speed
  110372. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  110373. */
  110374. animationTimeScale: number;
  110375. /** @hidden */
  110376. _cachedMaterial: Nullable<Material>;
  110377. /** @hidden */
  110378. _cachedEffect: Nullable<Effect>;
  110379. /** @hidden */
  110380. _cachedVisibility: Nullable<number>;
  110381. private _renderId;
  110382. private _frameId;
  110383. private _executeWhenReadyTimeoutId;
  110384. private _intermediateRendering;
  110385. private _viewUpdateFlag;
  110386. private _projectionUpdateFlag;
  110387. /** @hidden */
  110388. _toBeDisposed: Nullable<IDisposable>[];
  110389. private _activeRequests;
  110390. /** @hidden */
  110391. _pendingData: any[];
  110392. private _isDisposed;
  110393. /**
  110394. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  110395. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  110396. */
  110397. dispatchAllSubMeshesOfActiveMeshes: boolean;
  110398. private _activeMeshes;
  110399. private _processedMaterials;
  110400. private _renderTargets;
  110401. /** @hidden */
  110402. _activeParticleSystems: SmartArray<IParticleSystem>;
  110403. private _activeSkeletons;
  110404. private _softwareSkinnedMeshes;
  110405. private _renderingManager;
  110406. /** @hidden */
  110407. _activeAnimatables: Animatable[];
  110408. private _transformMatrix;
  110409. private _sceneUbo;
  110410. /** @hidden */
  110411. _viewMatrix: Matrix;
  110412. private _projectionMatrix;
  110413. /** @hidden */
  110414. _forcedViewPosition: Nullable<Vector3>;
  110415. /** @hidden */
  110416. _frustumPlanes: Plane[];
  110417. /**
  110418. * Gets the list of frustum planes (built from the active camera)
  110419. */
  110420. get frustumPlanes(): Plane[];
  110421. /**
  110422. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  110423. * This is useful if there are more lights that the maximum simulteanous authorized
  110424. */
  110425. requireLightSorting: boolean;
  110426. /** @hidden */
  110427. readonly useMaterialMeshMap: boolean;
  110428. /** @hidden */
  110429. readonly useClonedMeshMap: boolean;
  110430. private _externalData;
  110431. private _uid;
  110432. /**
  110433. * @hidden
  110434. * Backing store of defined scene components.
  110435. */
  110436. _components: ISceneComponent[];
  110437. /**
  110438. * @hidden
  110439. * Backing store of defined scene components.
  110440. */
  110441. _serializableComponents: ISceneSerializableComponent[];
  110442. /**
  110443. * List of components to register on the next registration step.
  110444. */
  110445. private _transientComponents;
  110446. /**
  110447. * Registers the transient components if needed.
  110448. */
  110449. private _registerTransientComponents;
  110450. /**
  110451. * @hidden
  110452. * Add a component to the scene.
  110453. * Note that the ccomponent could be registered on th next frame if this is called after
  110454. * the register component stage.
  110455. * @param component Defines the component to add to the scene
  110456. */
  110457. _addComponent(component: ISceneComponent): void;
  110458. /**
  110459. * @hidden
  110460. * Gets a component from the scene.
  110461. * @param name defines the name of the component to retrieve
  110462. * @returns the component or null if not present
  110463. */
  110464. _getComponent(name: string): Nullable<ISceneComponent>;
  110465. /**
  110466. * @hidden
  110467. * Defines the actions happening before camera updates.
  110468. */
  110469. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  110470. /**
  110471. * @hidden
  110472. * Defines the actions happening before clear the canvas.
  110473. */
  110474. _beforeClearStage: Stage<SimpleStageAction>;
  110475. /**
  110476. * @hidden
  110477. * Defines the actions when collecting render targets for the frame.
  110478. */
  110479. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  110480. /**
  110481. * @hidden
  110482. * Defines the actions happening for one camera in the frame.
  110483. */
  110484. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  110485. /**
  110486. * @hidden
  110487. * Defines the actions happening during the per mesh ready checks.
  110488. */
  110489. _isReadyForMeshStage: Stage<MeshStageAction>;
  110490. /**
  110491. * @hidden
  110492. * Defines the actions happening before evaluate active mesh checks.
  110493. */
  110494. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  110495. /**
  110496. * @hidden
  110497. * Defines the actions happening during the evaluate sub mesh checks.
  110498. */
  110499. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  110500. /**
  110501. * @hidden
  110502. * Defines the actions happening during the active mesh stage.
  110503. */
  110504. _activeMeshStage: Stage<ActiveMeshStageAction>;
  110505. /**
  110506. * @hidden
  110507. * Defines the actions happening during the per camera render target step.
  110508. */
  110509. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  110510. /**
  110511. * @hidden
  110512. * Defines the actions happening just before the active camera is drawing.
  110513. */
  110514. _beforeCameraDrawStage: Stage<CameraStageAction>;
  110515. /**
  110516. * @hidden
  110517. * Defines the actions happening just before a render target is drawing.
  110518. */
  110519. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  110520. /**
  110521. * @hidden
  110522. * Defines the actions happening just before a rendering group is drawing.
  110523. */
  110524. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  110525. /**
  110526. * @hidden
  110527. * Defines the actions happening just before a mesh is drawing.
  110528. */
  110529. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  110530. /**
  110531. * @hidden
  110532. * Defines the actions happening just after a mesh has been drawn.
  110533. */
  110534. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  110535. /**
  110536. * @hidden
  110537. * Defines the actions happening just after a rendering group has been drawn.
  110538. */
  110539. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  110540. /**
  110541. * @hidden
  110542. * Defines the actions happening just after the active camera has been drawn.
  110543. */
  110544. _afterCameraDrawStage: Stage<CameraStageAction>;
  110545. /**
  110546. * @hidden
  110547. * Defines the actions happening just after a render target has been drawn.
  110548. */
  110549. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  110550. /**
  110551. * @hidden
  110552. * Defines the actions happening just after rendering all cameras and computing intersections.
  110553. */
  110554. _afterRenderStage: Stage<SimpleStageAction>;
  110555. /**
  110556. * @hidden
  110557. * Defines the actions happening when a pointer move event happens.
  110558. */
  110559. _pointerMoveStage: Stage<PointerMoveStageAction>;
  110560. /**
  110561. * @hidden
  110562. * Defines the actions happening when a pointer down event happens.
  110563. */
  110564. _pointerDownStage: Stage<PointerUpDownStageAction>;
  110565. /**
  110566. * @hidden
  110567. * Defines the actions happening when a pointer up event happens.
  110568. */
  110569. _pointerUpStage: Stage<PointerUpDownStageAction>;
  110570. /**
  110571. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  110572. */
  110573. private geometriesByUniqueId;
  110574. /**
  110575. * Creates a new Scene
  110576. * @param engine defines the engine to use to render this scene
  110577. * @param options defines the scene options
  110578. */
  110579. constructor(engine: Engine, options?: SceneOptions);
  110580. /**
  110581. * Gets a string idenfifying the name of the class
  110582. * @returns "Scene" string
  110583. */
  110584. getClassName(): string;
  110585. private _defaultMeshCandidates;
  110586. /**
  110587. * @hidden
  110588. */
  110589. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  110590. private _defaultSubMeshCandidates;
  110591. /**
  110592. * @hidden
  110593. */
  110594. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  110595. /**
  110596. * Sets the default candidate providers for the scene.
  110597. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  110598. * and getCollidingSubMeshCandidates to their default function
  110599. */
  110600. setDefaultCandidateProviders(): void;
  110601. /**
  110602. * Gets the mesh that is currently under the pointer
  110603. */
  110604. get meshUnderPointer(): Nullable<AbstractMesh>;
  110605. /**
  110606. * Gets or sets the current on-screen X position of the pointer
  110607. */
  110608. get pointerX(): number;
  110609. set pointerX(value: number);
  110610. /**
  110611. * Gets or sets the current on-screen Y position of the pointer
  110612. */
  110613. get pointerY(): number;
  110614. set pointerY(value: number);
  110615. /**
  110616. * Gets the cached material (ie. the latest rendered one)
  110617. * @returns the cached material
  110618. */
  110619. getCachedMaterial(): Nullable<Material>;
  110620. /**
  110621. * Gets the cached effect (ie. the latest rendered one)
  110622. * @returns the cached effect
  110623. */
  110624. getCachedEffect(): Nullable<Effect>;
  110625. /**
  110626. * Gets the cached visibility state (ie. the latest rendered one)
  110627. * @returns the cached visibility state
  110628. */
  110629. getCachedVisibility(): Nullable<number>;
  110630. /**
  110631. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  110632. * @param material defines the current material
  110633. * @param effect defines the current effect
  110634. * @param visibility defines the current visibility state
  110635. * @returns true if one parameter is not cached
  110636. */
  110637. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  110638. /**
  110639. * Gets the engine associated with the scene
  110640. * @returns an Engine
  110641. */
  110642. getEngine(): Engine;
  110643. /**
  110644. * Gets the total number of vertices rendered per frame
  110645. * @returns the total number of vertices rendered per frame
  110646. */
  110647. getTotalVertices(): number;
  110648. /**
  110649. * Gets the performance counter for total vertices
  110650. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  110651. */
  110652. get totalVerticesPerfCounter(): PerfCounter;
  110653. /**
  110654. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  110655. * @returns the total number of active indices rendered per frame
  110656. */
  110657. getActiveIndices(): number;
  110658. /**
  110659. * Gets the performance counter for active indices
  110660. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  110661. */
  110662. get totalActiveIndicesPerfCounter(): PerfCounter;
  110663. /**
  110664. * Gets the total number of active particles rendered per frame
  110665. * @returns the total number of active particles rendered per frame
  110666. */
  110667. getActiveParticles(): number;
  110668. /**
  110669. * Gets the performance counter for active particles
  110670. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  110671. */
  110672. get activeParticlesPerfCounter(): PerfCounter;
  110673. /**
  110674. * Gets the total number of active bones rendered per frame
  110675. * @returns the total number of active bones rendered per frame
  110676. */
  110677. getActiveBones(): number;
  110678. /**
  110679. * Gets the performance counter for active bones
  110680. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  110681. */
  110682. get activeBonesPerfCounter(): PerfCounter;
  110683. /**
  110684. * Gets the array of active meshes
  110685. * @returns an array of AbstractMesh
  110686. */
  110687. getActiveMeshes(): SmartArray<AbstractMesh>;
  110688. /**
  110689. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  110690. * @returns a number
  110691. */
  110692. getAnimationRatio(): number;
  110693. /**
  110694. * Gets an unique Id for the current render phase
  110695. * @returns a number
  110696. */
  110697. getRenderId(): number;
  110698. /**
  110699. * Gets an unique Id for the current frame
  110700. * @returns a number
  110701. */
  110702. getFrameId(): number;
  110703. /** Call this function if you want to manually increment the render Id*/
  110704. incrementRenderId(): void;
  110705. private _createUbo;
  110706. /**
  110707. * Use this method to simulate a pointer move on a mesh
  110708. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  110709. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  110710. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  110711. * @returns the current scene
  110712. */
  110713. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  110714. /**
  110715. * Use this method to simulate a pointer down on a mesh
  110716. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  110717. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  110718. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  110719. * @returns the current scene
  110720. */
  110721. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  110722. /**
  110723. * Use this method to simulate a pointer up on a mesh
  110724. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  110725. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  110726. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  110727. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  110728. * @returns the current scene
  110729. */
  110730. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  110731. /**
  110732. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  110733. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  110734. * @returns true if the pointer was captured
  110735. */
  110736. isPointerCaptured(pointerId?: number): boolean;
  110737. /**
  110738. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  110739. * @param attachUp defines if you want to attach events to pointerup
  110740. * @param attachDown defines if you want to attach events to pointerdown
  110741. * @param attachMove defines if you want to attach events to pointermove
  110742. */
  110743. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  110744. /** Detaches all event handlers*/
  110745. detachControl(): void;
  110746. /**
  110747. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  110748. * Delay loaded resources are not taking in account
  110749. * @return true if all required resources are ready
  110750. */
  110751. isReady(): boolean;
  110752. /** Resets all cached information relative to material (including effect and visibility) */
  110753. resetCachedMaterial(): void;
  110754. /**
  110755. * Registers a function to be called before every frame render
  110756. * @param func defines the function to register
  110757. */
  110758. registerBeforeRender(func: () => void): void;
  110759. /**
  110760. * Unregisters a function called before every frame render
  110761. * @param func defines the function to unregister
  110762. */
  110763. unregisterBeforeRender(func: () => void): void;
  110764. /**
  110765. * Registers a function to be called after every frame render
  110766. * @param func defines the function to register
  110767. */
  110768. registerAfterRender(func: () => void): void;
  110769. /**
  110770. * Unregisters a function called after every frame render
  110771. * @param func defines the function to unregister
  110772. */
  110773. unregisterAfterRender(func: () => void): void;
  110774. private _executeOnceBeforeRender;
  110775. /**
  110776. * The provided function will run before render once and will be disposed afterwards.
  110777. * A timeout delay can be provided so that the function will be executed in N ms.
  110778. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  110779. * @param func The function to be executed.
  110780. * @param timeout optional delay in ms
  110781. */
  110782. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  110783. /** @hidden */
  110784. _addPendingData(data: any): void;
  110785. /** @hidden */
  110786. _removePendingData(data: any): void;
  110787. /**
  110788. * Returns the number of items waiting to be loaded
  110789. * @returns the number of items waiting to be loaded
  110790. */
  110791. getWaitingItemsCount(): number;
  110792. /**
  110793. * Returns a boolean indicating if the scene is still loading data
  110794. */
  110795. get isLoading(): boolean;
  110796. /**
  110797. * Registers a function to be executed when the scene is ready
  110798. * @param {Function} func - the function to be executed
  110799. */
  110800. executeWhenReady(func: () => void): void;
  110801. /**
  110802. * Returns a promise that resolves when the scene is ready
  110803. * @returns A promise that resolves when the scene is ready
  110804. */
  110805. whenReadyAsync(): Promise<void>;
  110806. /** @hidden */
  110807. _checkIsReady(): void;
  110808. /**
  110809. * Gets all animatable attached to the scene
  110810. */
  110811. get animatables(): Animatable[];
  110812. /**
  110813. * Resets the last animation time frame.
  110814. * Useful to override when animations start running when loading a scene for the first time.
  110815. */
  110816. resetLastAnimationTimeFrame(): void;
  110817. /**
  110818. * Gets the current view matrix
  110819. * @returns a Matrix
  110820. */
  110821. getViewMatrix(): Matrix;
  110822. /**
  110823. * Gets the current projection matrix
  110824. * @returns a Matrix
  110825. */
  110826. getProjectionMatrix(): Matrix;
  110827. /**
  110828. * Gets the current transform matrix
  110829. * @returns a Matrix made of View * Projection
  110830. */
  110831. getTransformMatrix(): Matrix;
  110832. /**
  110833. * Sets the current transform matrix
  110834. * @param viewL defines the View matrix to use
  110835. * @param projectionL defines the Projection matrix to use
  110836. * @param viewR defines the right View matrix to use (if provided)
  110837. * @param projectionR defines the right Projection matrix to use (if provided)
  110838. */
  110839. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  110840. /**
  110841. * Gets the uniform buffer used to store scene data
  110842. * @returns a UniformBuffer
  110843. */
  110844. getSceneUniformBuffer(): UniformBuffer;
  110845. /**
  110846. * Gets an unique (relatively to the current scene) Id
  110847. * @returns an unique number for the scene
  110848. */
  110849. getUniqueId(): number;
  110850. /**
  110851. * Add a mesh to the list of scene's meshes
  110852. * @param newMesh defines the mesh to add
  110853. * @param recursive if all child meshes should also be added to the scene
  110854. */
  110855. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  110856. /**
  110857. * Remove a mesh for the list of scene's meshes
  110858. * @param toRemove defines the mesh to remove
  110859. * @param recursive if all child meshes should also be removed from the scene
  110860. * @returns the index where the mesh was in the mesh list
  110861. */
  110862. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  110863. /**
  110864. * Add a transform node to the list of scene's transform nodes
  110865. * @param newTransformNode defines the transform node to add
  110866. */
  110867. addTransformNode(newTransformNode: TransformNode): void;
  110868. /**
  110869. * Remove a transform node for the list of scene's transform nodes
  110870. * @param toRemove defines the transform node to remove
  110871. * @returns the index where the transform node was in the transform node list
  110872. */
  110873. removeTransformNode(toRemove: TransformNode): number;
  110874. /**
  110875. * Remove a skeleton for the list of scene's skeletons
  110876. * @param toRemove defines the skeleton to remove
  110877. * @returns the index where the skeleton was in the skeleton list
  110878. */
  110879. removeSkeleton(toRemove: Skeleton): number;
  110880. /**
  110881. * Remove a morph target for the list of scene's morph targets
  110882. * @param toRemove defines the morph target to remove
  110883. * @returns the index where the morph target was in the morph target list
  110884. */
  110885. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  110886. /**
  110887. * Remove a light for the list of scene's lights
  110888. * @param toRemove defines the light to remove
  110889. * @returns the index where the light was in the light list
  110890. */
  110891. removeLight(toRemove: Light): number;
  110892. /**
  110893. * Remove a camera for the list of scene's cameras
  110894. * @param toRemove defines the camera to remove
  110895. * @returns the index where the camera was in the camera list
  110896. */
  110897. removeCamera(toRemove: Camera): number;
  110898. /**
  110899. * Remove a particle system for the list of scene's particle systems
  110900. * @param toRemove defines the particle system to remove
  110901. * @returns the index where the particle system was in the particle system list
  110902. */
  110903. removeParticleSystem(toRemove: IParticleSystem): number;
  110904. /**
  110905. * Remove a animation for the list of scene's animations
  110906. * @param toRemove defines the animation to remove
  110907. * @returns the index where the animation was in the animation list
  110908. */
  110909. removeAnimation(toRemove: Animation): number;
  110910. /**
  110911. * Will stop the animation of the given target
  110912. * @param target - the target
  110913. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  110914. * @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)
  110915. */
  110916. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  110917. /**
  110918. * Removes the given animation group from this scene.
  110919. * @param toRemove The animation group to remove
  110920. * @returns The index of the removed animation group
  110921. */
  110922. removeAnimationGroup(toRemove: AnimationGroup): number;
  110923. /**
  110924. * Removes the given multi-material from this scene.
  110925. * @param toRemove The multi-material to remove
  110926. * @returns The index of the removed multi-material
  110927. */
  110928. removeMultiMaterial(toRemove: MultiMaterial): number;
  110929. /**
  110930. * Removes the given material from this scene.
  110931. * @param toRemove The material to remove
  110932. * @returns The index of the removed material
  110933. */
  110934. removeMaterial(toRemove: Material): number;
  110935. /**
  110936. * Removes the given action manager from this scene.
  110937. * @param toRemove The action manager to remove
  110938. * @returns The index of the removed action manager
  110939. */
  110940. removeActionManager(toRemove: AbstractActionManager): number;
  110941. /**
  110942. * Removes the given texture from this scene.
  110943. * @param toRemove The texture to remove
  110944. * @returns The index of the removed texture
  110945. */
  110946. removeTexture(toRemove: BaseTexture): number;
  110947. /**
  110948. * Adds the given light to this scene
  110949. * @param newLight The light to add
  110950. */
  110951. addLight(newLight: Light): void;
  110952. /**
  110953. * Sorts the list list based on light priorities
  110954. */
  110955. sortLightsByPriority(): void;
  110956. /**
  110957. * Adds the given camera to this scene
  110958. * @param newCamera The camera to add
  110959. */
  110960. addCamera(newCamera: Camera): void;
  110961. /**
  110962. * Adds the given skeleton to this scene
  110963. * @param newSkeleton The skeleton to add
  110964. */
  110965. addSkeleton(newSkeleton: Skeleton): void;
  110966. /**
  110967. * Adds the given particle system to this scene
  110968. * @param newParticleSystem The particle system to add
  110969. */
  110970. addParticleSystem(newParticleSystem: IParticleSystem): void;
  110971. /**
  110972. * Adds the given animation to this scene
  110973. * @param newAnimation The animation to add
  110974. */
  110975. addAnimation(newAnimation: Animation): void;
  110976. /**
  110977. * Adds the given animation group to this scene.
  110978. * @param newAnimationGroup The animation group to add
  110979. */
  110980. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  110981. /**
  110982. * Adds the given multi-material to this scene
  110983. * @param newMultiMaterial The multi-material to add
  110984. */
  110985. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  110986. /**
  110987. * Adds the given material to this scene
  110988. * @param newMaterial The material to add
  110989. */
  110990. addMaterial(newMaterial: Material): void;
  110991. /**
  110992. * Adds the given morph target to this scene
  110993. * @param newMorphTargetManager The morph target to add
  110994. */
  110995. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  110996. /**
  110997. * Adds the given geometry to this scene
  110998. * @param newGeometry The geometry to add
  110999. */
  111000. addGeometry(newGeometry: Geometry): void;
  111001. /**
  111002. * Adds the given action manager to this scene
  111003. * @param newActionManager The action manager to add
  111004. */
  111005. addActionManager(newActionManager: AbstractActionManager): void;
  111006. /**
  111007. * Adds the given texture to this scene.
  111008. * @param newTexture The texture to add
  111009. */
  111010. addTexture(newTexture: BaseTexture): void;
  111011. /**
  111012. * Switch active camera
  111013. * @param newCamera defines the new active camera
  111014. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  111015. */
  111016. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  111017. /**
  111018. * sets the active camera of the scene using its ID
  111019. * @param id defines the camera's ID
  111020. * @return the new active camera or null if none found.
  111021. */
  111022. setActiveCameraByID(id: string): Nullable<Camera>;
  111023. /**
  111024. * sets the active camera of the scene using its name
  111025. * @param name defines the camera's name
  111026. * @returns the new active camera or null if none found.
  111027. */
  111028. setActiveCameraByName(name: string): Nullable<Camera>;
  111029. /**
  111030. * get an animation group using its name
  111031. * @param name defines the material's name
  111032. * @return the animation group or null if none found.
  111033. */
  111034. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  111035. /**
  111036. * Get a material using its unique id
  111037. * @param uniqueId defines the material's unique id
  111038. * @return the material or null if none found.
  111039. */
  111040. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  111041. /**
  111042. * get a material using its id
  111043. * @param id defines the material's ID
  111044. * @return the material or null if none found.
  111045. */
  111046. getMaterialByID(id: string): Nullable<Material>;
  111047. /**
  111048. * Gets a the last added material using a given id
  111049. * @param id defines the material's ID
  111050. * @return the last material with the given id or null if none found.
  111051. */
  111052. getLastMaterialByID(id: string): Nullable<Material>;
  111053. /**
  111054. * Gets a material using its name
  111055. * @param name defines the material's name
  111056. * @return the material or null if none found.
  111057. */
  111058. getMaterialByName(name: string): Nullable<Material>;
  111059. /**
  111060. * Get a texture using its unique id
  111061. * @param uniqueId defines the texture's unique id
  111062. * @return the texture or null if none found.
  111063. */
  111064. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  111065. /**
  111066. * Gets a camera using its id
  111067. * @param id defines the id to look for
  111068. * @returns the camera or null if not found
  111069. */
  111070. getCameraByID(id: string): Nullable<Camera>;
  111071. /**
  111072. * Gets a camera using its unique id
  111073. * @param uniqueId defines the unique id to look for
  111074. * @returns the camera or null if not found
  111075. */
  111076. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  111077. /**
  111078. * Gets a camera using its name
  111079. * @param name defines the camera's name
  111080. * @return the camera or null if none found.
  111081. */
  111082. getCameraByName(name: string): Nullable<Camera>;
  111083. /**
  111084. * Gets a bone using its id
  111085. * @param id defines the bone's id
  111086. * @return the bone or null if not found
  111087. */
  111088. getBoneByID(id: string): Nullable<Bone>;
  111089. /**
  111090. * Gets a bone using its id
  111091. * @param name defines the bone's name
  111092. * @return the bone or null if not found
  111093. */
  111094. getBoneByName(name: string): Nullable<Bone>;
  111095. /**
  111096. * Gets a light node using its name
  111097. * @param name defines the the light's name
  111098. * @return the light or null if none found.
  111099. */
  111100. getLightByName(name: string): Nullable<Light>;
  111101. /**
  111102. * Gets a light node using its id
  111103. * @param id defines the light's id
  111104. * @return the light or null if none found.
  111105. */
  111106. getLightByID(id: string): Nullable<Light>;
  111107. /**
  111108. * Gets a light node using its scene-generated unique ID
  111109. * @param uniqueId defines the light's unique id
  111110. * @return the light or null if none found.
  111111. */
  111112. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  111113. /**
  111114. * Gets a particle system by id
  111115. * @param id defines the particle system id
  111116. * @return the corresponding system or null if none found
  111117. */
  111118. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  111119. /**
  111120. * Gets a geometry using its ID
  111121. * @param id defines the geometry's id
  111122. * @return the geometry or null if none found.
  111123. */
  111124. getGeometryByID(id: string): Nullable<Geometry>;
  111125. private _getGeometryByUniqueID;
  111126. /**
  111127. * Add a new geometry to this scene
  111128. * @param geometry defines the geometry to be added to the scene.
  111129. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  111130. * @return a boolean defining if the geometry was added or not
  111131. */
  111132. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  111133. /**
  111134. * Removes an existing geometry
  111135. * @param geometry defines the geometry to be removed from the scene
  111136. * @return a boolean defining if the geometry was removed or not
  111137. */
  111138. removeGeometry(geometry: Geometry): boolean;
  111139. /**
  111140. * Gets the list of geometries attached to the scene
  111141. * @returns an array of Geometry
  111142. */
  111143. getGeometries(): Geometry[];
  111144. /**
  111145. * Gets the first added mesh found of a given ID
  111146. * @param id defines the id to search for
  111147. * @return the mesh found or null if not found at all
  111148. */
  111149. getMeshByID(id: string): Nullable<AbstractMesh>;
  111150. /**
  111151. * Gets a list of meshes using their id
  111152. * @param id defines the id to search for
  111153. * @returns a list of meshes
  111154. */
  111155. getMeshesByID(id: string): Array<AbstractMesh>;
  111156. /**
  111157. * Gets the first added transform node found of a given ID
  111158. * @param id defines the id to search for
  111159. * @return the found transform node or null if not found at all.
  111160. */
  111161. getTransformNodeByID(id: string): Nullable<TransformNode>;
  111162. /**
  111163. * Gets a transform node with its auto-generated unique id
  111164. * @param uniqueId efines the unique id to search for
  111165. * @return the found transform node or null if not found at all.
  111166. */
  111167. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  111168. /**
  111169. * Gets a list of transform nodes using their id
  111170. * @param id defines the id to search for
  111171. * @returns a list of transform nodes
  111172. */
  111173. getTransformNodesByID(id: string): Array<TransformNode>;
  111174. /**
  111175. * Gets a mesh with its auto-generated unique id
  111176. * @param uniqueId defines the unique id to search for
  111177. * @return the found mesh or null if not found at all.
  111178. */
  111179. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  111180. /**
  111181. * Gets a the last added mesh using a given id
  111182. * @param id defines the id to search for
  111183. * @return the found mesh or null if not found at all.
  111184. */
  111185. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  111186. /**
  111187. * Gets a the last added node (Mesh, Camera, Light) using a given id
  111188. * @param id defines the id to search for
  111189. * @return the found node or null if not found at all
  111190. */
  111191. getLastEntryByID(id: string): Nullable<Node>;
  111192. /**
  111193. * Gets a node (Mesh, Camera, Light) using a given id
  111194. * @param id defines the id to search for
  111195. * @return the found node or null if not found at all
  111196. */
  111197. getNodeByID(id: string): Nullable<Node>;
  111198. /**
  111199. * Gets a node (Mesh, Camera, Light) using a given name
  111200. * @param name defines the name to search for
  111201. * @return the found node or null if not found at all.
  111202. */
  111203. getNodeByName(name: string): Nullable<Node>;
  111204. /**
  111205. * Gets a mesh using a given name
  111206. * @param name defines the name to search for
  111207. * @return the found mesh or null if not found at all.
  111208. */
  111209. getMeshByName(name: string): Nullable<AbstractMesh>;
  111210. /**
  111211. * Gets a transform node using a given name
  111212. * @param name defines the name to search for
  111213. * @return the found transform node or null if not found at all.
  111214. */
  111215. getTransformNodeByName(name: string): Nullable<TransformNode>;
  111216. /**
  111217. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  111218. * @param id defines the id to search for
  111219. * @return the found skeleton or null if not found at all.
  111220. */
  111221. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  111222. /**
  111223. * Gets a skeleton using a given auto generated unique id
  111224. * @param uniqueId defines the unique id to search for
  111225. * @return the found skeleton or null if not found at all.
  111226. */
  111227. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  111228. /**
  111229. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  111230. * @param id defines the id to search for
  111231. * @return the found skeleton or null if not found at all.
  111232. */
  111233. getSkeletonById(id: string): Nullable<Skeleton>;
  111234. /**
  111235. * Gets a skeleton using a given name
  111236. * @param name defines the name to search for
  111237. * @return the found skeleton or null if not found at all.
  111238. */
  111239. getSkeletonByName(name: string): Nullable<Skeleton>;
  111240. /**
  111241. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  111242. * @param id defines the id to search for
  111243. * @return the found morph target manager or null if not found at all.
  111244. */
  111245. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  111246. /**
  111247. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  111248. * @param id defines the id to search for
  111249. * @return the found morph target or null if not found at all.
  111250. */
  111251. getMorphTargetById(id: string): Nullable<MorphTarget>;
  111252. /**
  111253. * Gets a boolean indicating if the given mesh is active
  111254. * @param mesh defines the mesh to look for
  111255. * @returns true if the mesh is in the active list
  111256. */
  111257. isActiveMesh(mesh: AbstractMesh): boolean;
  111258. /**
  111259. * Return a unique id as a string which can serve as an identifier for the scene
  111260. */
  111261. get uid(): string;
  111262. /**
  111263. * Add an externaly attached data from its key.
  111264. * This method call will fail and return false, if such key already exists.
  111265. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  111266. * @param key the unique key that identifies the data
  111267. * @param data the data object to associate to the key for this Engine instance
  111268. * @return true if no such key were already present and the data was added successfully, false otherwise
  111269. */
  111270. addExternalData<T>(key: string, data: T): boolean;
  111271. /**
  111272. * Get an externaly attached data from its key
  111273. * @param key the unique key that identifies the data
  111274. * @return the associated data, if present (can be null), or undefined if not present
  111275. */
  111276. getExternalData<T>(key: string): Nullable<T>;
  111277. /**
  111278. * Get an externaly attached data from its key, create it using a factory if it's not already present
  111279. * @param key the unique key that identifies the data
  111280. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  111281. * @return the associated data, can be null if the factory returned null.
  111282. */
  111283. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  111284. /**
  111285. * Remove an externaly attached data from the Engine instance
  111286. * @param key the unique key that identifies the data
  111287. * @return true if the data was successfully removed, false if it doesn't exist
  111288. */
  111289. removeExternalData(key: string): boolean;
  111290. private _evaluateSubMesh;
  111291. /**
  111292. * Clear the processed materials smart array preventing retention point in material dispose.
  111293. */
  111294. freeProcessedMaterials(): void;
  111295. private _preventFreeActiveMeshesAndRenderingGroups;
  111296. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  111297. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  111298. * when disposing several meshes in a row or a hierarchy of meshes.
  111299. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  111300. */
  111301. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  111302. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  111303. /**
  111304. * Clear the active meshes smart array preventing retention point in mesh dispose.
  111305. */
  111306. freeActiveMeshes(): void;
  111307. /**
  111308. * Clear the info related to rendering groups preventing retention points during dispose.
  111309. */
  111310. freeRenderingGroups(): void;
  111311. /** @hidden */
  111312. _isInIntermediateRendering(): boolean;
  111313. /**
  111314. * Lambda returning the list of potentially active meshes.
  111315. */
  111316. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  111317. /**
  111318. * Lambda returning the list of potentially active sub meshes.
  111319. */
  111320. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  111321. /**
  111322. * Lambda returning the list of potentially intersecting sub meshes.
  111323. */
  111324. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  111325. /**
  111326. * Lambda returning the list of potentially colliding sub meshes.
  111327. */
  111328. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  111329. private _activeMeshesFrozen;
  111330. private _skipEvaluateActiveMeshesCompletely;
  111331. /**
  111332. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  111333. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  111334. * @returns the current scene
  111335. */
  111336. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  111337. /**
  111338. * Use this function to restart evaluating active meshes on every frame
  111339. * @returns the current scene
  111340. */
  111341. unfreezeActiveMeshes(): Scene;
  111342. private _evaluateActiveMeshes;
  111343. private _activeMesh;
  111344. /**
  111345. * Update the transform matrix to update from the current active camera
  111346. * @param force defines a boolean used to force the update even if cache is up to date
  111347. */
  111348. updateTransformMatrix(force?: boolean): void;
  111349. private _bindFrameBuffer;
  111350. /** @hidden */
  111351. _allowPostProcessClearColor: boolean;
  111352. /** @hidden */
  111353. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  111354. private _processSubCameras;
  111355. private _checkIntersections;
  111356. /** @hidden */
  111357. _advancePhysicsEngineStep(step: number): void;
  111358. /**
  111359. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  111360. */
  111361. getDeterministicFrameTime: () => number;
  111362. /** @hidden */
  111363. _animate(): void;
  111364. /** Execute all animations (for a frame) */
  111365. animate(): void;
  111366. /**
  111367. * Render the scene
  111368. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  111369. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  111370. */
  111371. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  111372. /**
  111373. * Freeze all materials
  111374. * A frozen material will not be updatable but should be faster to render
  111375. */
  111376. freezeMaterials(): void;
  111377. /**
  111378. * Unfreeze all materials
  111379. * A frozen material will not be updatable but should be faster to render
  111380. */
  111381. unfreezeMaterials(): void;
  111382. /**
  111383. * Releases all held ressources
  111384. */
  111385. dispose(): void;
  111386. /**
  111387. * Gets if the scene is already disposed
  111388. */
  111389. get isDisposed(): boolean;
  111390. /**
  111391. * Call this function to reduce memory footprint of the scene.
  111392. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  111393. */
  111394. clearCachedVertexData(): void;
  111395. /**
  111396. * This function will remove the local cached buffer data from texture.
  111397. * It will save memory but will prevent the texture from being rebuilt
  111398. */
  111399. cleanCachedTextureBuffer(): void;
  111400. /**
  111401. * Get the world extend vectors with an optional filter
  111402. *
  111403. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  111404. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  111405. */
  111406. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  111407. min: Vector3;
  111408. max: Vector3;
  111409. };
  111410. /**
  111411. * Creates a ray that can be used to pick in the scene
  111412. * @param x defines the x coordinate of the origin (on-screen)
  111413. * @param y defines the y coordinate of the origin (on-screen)
  111414. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  111415. * @param camera defines the camera to use for the picking
  111416. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  111417. * @returns a Ray
  111418. */
  111419. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  111420. /**
  111421. * Creates a ray that can be used to pick in the scene
  111422. * @param x defines the x coordinate of the origin (on-screen)
  111423. * @param y defines the y coordinate of the origin (on-screen)
  111424. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  111425. * @param result defines the ray where to store the picking ray
  111426. * @param camera defines the camera to use for the picking
  111427. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  111428. * @returns the current scene
  111429. */
  111430. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  111431. /**
  111432. * Creates a ray that can be used to pick in the scene
  111433. * @param x defines the x coordinate of the origin (on-screen)
  111434. * @param y defines the y coordinate of the origin (on-screen)
  111435. * @param camera defines the camera to use for the picking
  111436. * @returns a Ray
  111437. */
  111438. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  111439. /**
  111440. * Creates a ray that can be used to pick in the scene
  111441. * @param x defines the x coordinate of the origin (on-screen)
  111442. * @param y defines the y coordinate of the origin (on-screen)
  111443. * @param result defines the ray where to store the picking ray
  111444. * @param camera defines the camera to use for the picking
  111445. * @returns the current scene
  111446. */
  111447. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  111448. /** Launch a ray to try to pick a mesh in the scene
  111449. * @param x position on screen
  111450. * @param y position on screen
  111451. * @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
  111452. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  111453. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  111454. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  111455. * @returns a PickingInfo
  111456. */
  111457. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  111458. /** Use the given ray to pick a mesh in the scene
  111459. * @param ray The ray to use to pick meshes
  111460. * @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
  111461. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  111462. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  111463. * @returns a PickingInfo
  111464. */
  111465. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  111466. /**
  111467. * Launch a ray to try to pick a mesh in the scene
  111468. * @param x X position on screen
  111469. * @param y Y position on screen
  111470. * @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
  111471. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  111472. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  111473. * @returns an array of PickingInfo
  111474. */
  111475. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  111476. /**
  111477. * Launch a ray to try to pick a mesh in the scene
  111478. * @param ray Ray to use
  111479. * @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
  111480. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  111481. * @returns an array of PickingInfo
  111482. */
  111483. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  111484. /**
  111485. * Force the value of meshUnderPointer
  111486. * @param mesh defines the mesh to use
  111487. */
  111488. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  111489. /**
  111490. * Gets the mesh under the pointer
  111491. * @returns a Mesh or null if no mesh is under the pointer
  111492. */
  111493. getPointerOverMesh(): Nullable<AbstractMesh>;
  111494. /** @hidden */
  111495. _rebuildGeometries(): void;
  111496. /** @hidden */
  111497. _rebuildTextures(): void;
  111498. private _getByTags;
  111499. /**
  111500. * Get a list of meshes by tags
  111501. * @param tagsQuery defines the tags query to use
  111502. * @param forEach defines a predicate used to filter results
  111503. * @returns an array of Mesh
  111504. */
  111505. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  111506. /**
  111507. * Get a list of cameras by tags
  111508. * @param tagsQuery defines the tags query to use
  111509. * @param forEach defines a predicate used to filter results
  111510. * @returns an array of Camera
  111511. */
  111512. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  111513. /**
  111514. * Get a list of lights by tags
  111515. * @param tagsQuery defines the tags query to use
  111516. * @param forEach defines a predicate used to filter results
  111517. * @returns an array of Light
  111518. */
  111519. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  111520. /**
  111521. * Get a list of materials by tags
  111522. * @param tagsQuery defines the tags query to use
  111523. * @param forEach defines a predicate used to filter results
  111524. * @returns an array of Material
  111525. */
  111526. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  111527. /**
  111528. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  111529. * This allowed control for front to back rendering or reversly depending of the special needs.
  111530. *
  111531. * @param renderingGroupId The rendering group id corresponding to its index
  111532. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  111533. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  111534. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  111535. */
  111536. 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;
  111537. /**
  111538. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  111539. *
  111540. * @param renderingGroupId The rendering group id corresponding to its index
  111541. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  111542. * @param depth Automatically clears depth between groups if true and autoClear is true.
  111543. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  111544. */
  111545. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  111546. /**
  111547. * Gets the current auto clear configuration for one rendering group of the rendering
  111548. * manager.
  111549. * @param index the rendering group index to get the information for
  111550. * @returns The auto clear setup for the requested rendering group
  111551. */
  111552. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  111553. private _blockMaterialDirtyMechanism;
  111554. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  111555. get blockMaterialDirtyMechanism(): boolean;
  111556. set blockMaterialDirtyMechanism(value: boolean);
  111557. /**
  111558. * Will flag all materials as dirty to trigger new shader compilation
  111559. * @param flag defines the flag used to specify which material part must be marked as dirty
  111560. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  111561. */
  111562. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  111563. /** @hidden */
  111564. _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;
  111565. /** @hidden */
  111566. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  111567. /** @hidden */
  111568. _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;
  111569. /** @hidden */
  111570. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  111571. /** @hidden */
  111572. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  111573. /** @hidden */
  111574. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  111575. }
  111576. }
  111577. declare module BABYLON {
  111578. /**
  111579. * Set of assets to keep when moving a scene into an asset container.
  111580. */
  111581. export class KeepAssets extends AbstractScene {
  111582. }
  111583. /**
  111584. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  111585. */
  111586. export class InstantiatedEntries {
  111587. /**
  111588. * List of new root nodes (eg. nodes with no parent)
  111589. */
  111590. rootNodes: TransformNode[];
  111591. /**
  111592. * List of new skeletons
  111593. */
  111594. skeletons: Skeleton[];
  111595. /**
  111596. * List of new animation groups
  111597. */
  111598. animationGroups: AnimationGroup[];
  111599. }
  111600. /**
  111601. * Container with a set of assets that can be added or removed from a scene.
  111602. */
  111603. export class AssetContainer extends AbstractScene {
  111604. private _wasAddedToScene;
  111605. /**
  111606. * The scene the AssetContainer belongs to.
  111607. */
  111608. scene: Scene;
  111609. /**
  111610. * Instantiates an AssetContainer.
  111611. * @param scene The scene the AssetContainer belongs to.
  111612. */
  111613. constructor(scene: Scene);
  111614. /**
  111615. * Instantiate or clone all meshes and add the new ones to the scene.
  111616. * Skeletons and animation groups will all be cloned
  111617. * @param nameFunction defines an optional function used to get new names for clones
  111618. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  111619. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  111620. */
  111621. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  111622. /**
  111623. * Adds all the assets from the container to the scene.
  111624. */
  111625. addAllToScene(): void;
  111626. /**
  111627. * Removes all the assets in the container from the scene
  111628. */
  111629. removeAllFromScene(): void;
  111630. /**
  111631. * Disposes all the assets in the container
  111632. */
  111633. dispose(): void;
  111634. private _moveAssets;
  111635. /**
  111636. * Removes all the assets contained in the scene and adds them to the container.
  111637. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  111638. */
  111639. moveAllFromScene(keepAssets?: KeepAssets): void;
  111640. /**
  111641. * 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.
  111642. * @returns the root mesh
  111643. */
  111644. createRootMesh(): Mesh;
  111645. /**
  111646. * Merge animations from this asset container into a scene
  111647. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  111648. * @param animatables set of animatables to retarget to a node from the scene
  111649. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  111650. */
  111651. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): void;
  111652. }
  111653. }
  111654. declare module BABYLON {
  111655. /**
  111656. * Defines how the parser contract is defined.
  111657. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  111658. */
  111659. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  111660. /**
  111661. * Defines how the individual parser contract is defined.
  111662. * These parser can parse an individual asset
  111663. */
  111664. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  111665. /**
  111666. * Base class of the scene acting as a container for the different elements composing a scene.
  111667. * This class is dynamically extended by the different components of the scene increasing
  111668. * flexibility and reducing coupling
  111669. */
  111670. export abstract class AbstractScene {
  111671. /**
  111672. * Stores the list of available parsers in the application.
  111673. */
  111674. private static _BabylonFileParsers;
  111675. /**
  111676. * Stores the list of available individual parsers in the application.
  111677. */
  111678. private static _IndividualBabylonFileParsers;
  111679. /**
  111680. * Adds a parser in the list of available ones
  111681. * @param name Defines the name of the parser
  111682. * @param parser Defines the parser to add
  111683. */
  111684. static AddParser(name: string, parser: BabylonFileParser): void;
  111685. /**
  111686. * Gets a general parser from the list of avaialble ones
  111687. * @param name Defines the name of the parser
  111688. * @returns the requested parser or null
  111689. */
  111690. static GetParser(name: string): Nullable<BabylonFileParser>;
  111691. /**
  111692. * Adds n individual parser in the list of available ones
  111693. * @param name Defines the name of the parser
  111694. * @param parser Defines the parser to add
  111695. */
  111696. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  111697. /**
  111698. * Gets an individual parser from the list of avaialble ones
  111699. * @param name Defines the name of the parser
  111700. * @returns the requested parser or null
  111701. */
  111702. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  111703. /**
  111704. * Parser json data and populate both a scene and its associated container object
  111705. * @param jsonData Defines the data to parse
  111706. * @param scene Defines the scene to parse the data for
  111707. * @param container Defines the container attached to the parsing sequence
  111708. * @param rootUrl Defines the root url of the data
  111709. */
  111710. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  111711. /**
  111712. * Gets the list of root nodes (ie. nodes with no parent)
  111713. */
  111714. rootNodes: Node[];
  111715. /** All of the cameras added to this scene
  111716. * @see http://doc.babylonjs.com/babylon101/cameras
  111717. */
  111718. cameras: Camera[];
  111719. /**
  111720. * All of the lights added to this scene
  111721. * @see http://doc.babylonjs.com/babylon101/lights
  111722. */
  111723. lights: Light[];
  111724. /**
  111725. * All of the (abstract) meshes added to this scene
  111726. */
  111727. meshes: AbstractMesh[];
  111728. /**
  111729. * The list of skeletons added to the scene
  111730. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  111731. */
  111732. skeletons: Skeleton[];
  111733. /**
  111734. * All of the particle systems added to this scene
  111735. * @see http://doc.babylonjs.com/babylon101/particles
  111736. */
  111737. particleSystems: IParticleSystem[];
  111738. /**
  111739. * Gets a list of Animations associated with the scene
  111740. */
  111741. animations: Animation[];
  111742. /**
  111743. * All of the animation groups added to this scene
  111744. * @see http://doc.babylonjs.com/how_to/group
  111745. */
  111746. animationGroups: AnimationGroup[];
  111747. /**
  111748. * All of the multi-materials added to this scene
  111749. * @see http://doc.babylonjs.com/how_to/multi_materials
  111750. */
  111751. multiMaterials: MultiMaterial[];
  111752. /**
  111753. * All of the materials added to this scene
  111754. * In the context of a Scene, it is not supposed to be modified manually.
  111755. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  111756. * Note also that the order of the Material within the array is not significant and might change.
  111757. * @see http://doc.babylonjs.com/babylon101/materials
  111758. */
  111759. materials: Material[];
  111760. /**
  111761. * The list of morph target managers added to the scene
  111762. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  111763. */
  111764. morphTargetManagers: MorphTargetManager[];
  111765. /**
  111766. * The list of geometries used in the scene.
  111767. */
  111768. geometries: Geometry[];
  111769. /**
  111770. * All of the tranform nodes 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 addTransformNode and removeTransformNode Scene methods.
  111773. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  111774. * @see http://doc.babylonjs.com/how_to/transformnode
  111775. */
  111776. transformNodes: TransformNode[];
  111777. /**
  111778. * ActionManagers available on the scene.
  111779. */
  111780. actionManagers: AbstractActionManager[];
  111781. /**
  111782. * Textures to keep.
  111783. */
  111784. textures: BaseTexture[];
  111785. /**
  111786. * Environment texture for the scene
  111787. */
  111788. environmentTexture: Nullable<BaseTexture>;
  111789. /**
  111790. * @returns all meshes, lights, cameras, transformNodes and bones
  111791. */
  111792. getNodes(): Array<Node>;
  111793. }
  111794. }
  111795. declare module BABYLON {
  111796. /**
  111797. * Interface used to define options for Sound class
  111798. */
  111799. export interface ISoundOptions {
  111800. /**
  111801. * Does the sound autoplay once loaded.
  111802. */
  111803. autoplay?: boolean;
  111804. /**
  111805. * Does the sound loop after it finishes playing once.
  111806. */
  111807. loop?: boolean;
  111808. /**
  111809. * Sound's volume
  111810. */
  111811. volume?: number;
  111812. /**
  111813. * Is it a spatial sound?
  111814. */
  111815. spatialSound?: boolean;
  111816. /**
  111817. * Maximum distance to hear that sound
  111818. */
  111819. maxDistance?: number;
  111820. /**
  111821. * Uses user defined attenuation function
  111822. */
  111823. useCustomAttenuation?: boolean;
  111824. /**
  111825. * Define the roll off factor of spatial sounds.
  111826. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  111827. */
  111828. rolloffFactor?: number;
  111829. /**
  111830. * Define the reference distance the sound should be heard perfectly.
  111831. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  111832. */
  111833. refDistance?: number;
  111834. /**
  111835. * Define the distance attenuation model the sound will follow.
  111836. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  111837. */
  111838. distanceModel?: string;
  111839. /**
  111840. * Defines the playback speed (1 by default)
  111841. */
  111842. playbackRate?: number;
  111843. /**
  111844. * Defines if the sound is from a streaming source
  111845. */
  111846. streaming?: boolean;
  111847. /**
  111848. * Defines an optional length (in seconds) inside the sound file
  111849. */
  111850. length?: number;
  111851. /**
  111852. * Defines an optional offset (in seconds) inside the sound file
  111853. */
  111854. offset?: number;
  111855. /**
  111856. * If true, URLs will not be required to state the audio file codec to use.
  111857. */
  111858. skipCodecCheck?: boolean;
  111859. }
  111860. /**
  111861. * Defines a sound that can be played in the application.
  111862. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  111863. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  111864. */
  111865. export class Sound {
  111866. /**
  111867. * The name of the sound in the scene.
  111868. */
  111869. name: string;
  111870. /**
  111871. * Does the sound autoplay once loaded.
  111872. */
  111873. autoplay: boolean;
  111874. /**
  111875. * Does the sound loop after it finishes playing once.
  111876. */
  111877. loop: boolean;
  111878. /**
  111879. * Does the sound use a custom attenuation curve to simulate the falloff
  111880. * happening when the source gets further away from the camera.
  111881. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  111882. */
  111883. useCustomAttenuation: boolean;
  111884. /**
  111885. * The sound track id this sound belongs to.
  111886. */
  111887. soundTrackId: number;
  111888. /**
  111889. * Is this sound currently played.
  111890. */
  111891. isPlaying: boolean;
  111892. /**
  111893. * Is this sound currently paused.
  111894. */
  111895. isPaused: boolean;
  111896. /**
  111897. * Does this sound enables spatial sound.
  111898. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  111899. */
  111900. spatialSound: boolean;
  111901. /**
  111902. * Define the reference distance the sound should be heard perfectly.
  111903. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  111904. */
  111905. refDistance: number;
  111906. /**
  111907. * Define the roll off factor of spatial sounds.
  111908. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  111909. */
  111910. rolloffFactor: number;
  111911. /**
  111912. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  111913. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  111914. */
  111915. maxDistance: number;
  111916. /**
  111917. * Define the distance attenuation model the sound will follow.
  111918. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  111919. */
  111920. distanceModel: string;
  111921. /**
  111922. * @hidden
  111923. * Back Compat
  111924. **/
  111925. onended: () => any;
  111926. /**
  111927. * Observable event when the current playing sound finishes.
  111928. */
  111929. onEndedObservable: Observable<Sound>;
  111930. private _panningModel;
  111931. private _playbackRate;
  111932. private _streaming;
  111933. private _startTime;
  111934. private _startOffset;
  111935. private _position;
  111936. /** @hidden */
  111937. _positionInEmitterSpace: boolean;
  111938. private _localDirection;
  111939. private _volume;
  111940. private _isReadyToPlay;
  111941. private _isDirectional;
  111942. private _readyToPlayCallback;
  111943. private _audioBuffer;
  111944. private _soundSource;
  111945. private _streamingSource;
  111946. private _soundPanner;
  111947. private _soundGain;
  111948. private _inputAudioNode;
  111949. private _outputAudioNode;
  111950. private _coneInnerAngle;
  111951. private _coneOuterAngle;
  111952. private _coneOuterGain;
  111953. private _scene;
  111954. private _connectedTransformNode;
  111955. private _customAttenuationFunction;
  111956. private _registerFunc;
  111957. private _isOutputConnected;
  111958. private _htmlAudioElement;
  111959. private _urlType;
  111960. private _length?;
  111961. private _offset?;
  111962. /** @hidden */
  111963. static _SceneComponentInitialization: (scene: Scene) => void;
  111964. /**
  111965. * Create a sound and attach it to a scene
  111966. * @param name Name of your sound
  111967. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  111968. * @param scene defines the scene the sound belongs to
  111969. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  111970. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  111971. */
  111972. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  111973. /**
  111974. * Release the sound and its associated resources
  111975. */
  111976. dispose(): void;
  111977. /**
  111978. * Gets if the sounds is ready to be played or not.
  111979. * @returns true if ready, otherwise false
  111980. */
  111981. isReady(): boolean;
  111982. private _soundLoaded;
  111983. /**
  111984. * Sets the data of the sound from an audiobuffer
  111985. * @param audioBuffer The audioBuffer containing the data
  111986. */
  111987. setAudioBuffer(audioBuffer: AudioBuffer): void;
  111988. /**
  111989. * Updates the current sounds options such as maxdistance, loop...
  111990. * @param options A JSON object containing values named as the object properties
  111991. */
  111992. updateOptions(options: ISoundOptions): void;
  111993. private _createSpatialParameters;
  111994. private _updateSpatialParameters;
  111995. /**
  111996. * Switch the panning model to HRTF:
  111997. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  111998. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  111999. */
  112000. switchPanningModelToHRTF(): void;
  112001. /**
  112002. * Switch the panning model to Equal Power:
  112003. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  112004. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  112005. */
  112006. switchPanningModelToEqualPower(): void;
  112007. private _switchPanningModel;
  112008. /**
  112009. * Connect this sound to a sound track audio node like gain...
  112010. * @param soundTrackAudioNode the sound track audio node to connect to
  112011. */
  112012. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  112013. /**
  112014. * Transform this sound into a directional source
  112015. * @param coneInnerAngle Size of the inner cone in degree
  112016. * @param coneOuterAngle Size of the outer cone in degree
  112017. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  112018. */
  112019. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  112020. /**
  112021. * Gets or sets the inner angle for the directional cone.
  112022. */
  112023. get directionalConeInnerAngle(): number;
  112024. /**
  112025. * Gets or sets the inner angle for the directional cone.
  112026. */
  112027. set directionalConeInnerAngle(value: number);
  112028. /**
  112029. * Gets or sets the outer angle for the directional cone.
  112030. */
  112031. get directionalConeOuterAngle(): number;
  112032. /**
  112033. * Gets or sets the outer angle for the directional cone.
  112034. */
  112035. set directionalConeOuterAngle(value: number);
  112036. /**
  112037. * Sets the position of the emitter if spatial sound is enabled
  112038. * @param newPosition Defines the new posisiton
  112039. */
  112040. setPosition(newPosition: Vector3): void;
  112041. /**
  112042. * Sets the local direction of the emitter if spatial sound is enabled
  112043. * @param newLocalDirection Defines the new local direction
  112044. */
  112045. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  112046. private _updateDirection;
  112047. /** @hidden */
  112048. updateDistanceFromListener(): void;
  112049. /**
  112050. * Sets a new custom attenuation function for the sound.
  112051. * @param callback Defines the function used for the attenuation
  112052. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  112053. */
  112054. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  112055. /**
  112056. * Play the sound
  112057. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  112058. * @param offset (optional) Start the sound at a specific time in seconds
  112059. * @param length (optional) Sound duration (in seconds)
  112060. */
  112061. play(time?: number, offset?: number, length?: number): void;
  112062. private _onended;
  112063. /**
  112064. * Stop the sound
  112065. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  112066. */
  112067. stop(time?: number): void;
  112068. /**
  112069. * Put the sound in pause
  112070. */
  112071. pause(): void;
  112072. /**
  112073. * Sets a dedicated volume for this sounds
  112074. * @param newVolume Define the new volume of the sound
  112075. * @param time Define time for gradual change to new volume
  112076. */
  112077. setVolume(newVolume: number, time?: number): void;
  112078. /**
  112079. * Set the sound play back rate
  112080. * @param newPlaybackRate Define the playback rate the sound should be played at
  112081. */
  112082. setPlaybackRate(newPlaybackRate: number): void;
  112083. /**
  112084. * Gets the volume of the sound.
  112085. * @returns the volume of the sound
  112086. */
  112087. getVolume(): number;
  112088. /**
  112089. * Attach the sound to a dedicated mesh
  112090. * @param transformNode The transform node to connect the sound with
  112091. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  112092. */
  112093. attachToMesh(transformNode: TransformNode): void;
  112094. /**
  112095. * Detach the sound from the previously attached mesh
  112096. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  112097. */
  112098. detachFromMesh(): void;
  112099. private _onRegisterAfterWorldMatrixUpdate;
  112100. /**
  112101. * Clone the current sound in the scene.
  112102. * @returns the new sound clone
  112103. */
  112104. clone(): Nullable<Sound>;
  112105. /**
  112106. * Gets the current underlying audio buffer containing the data
  112107. * @returns the audio buffer
  112108. */
  112109. getAudioBuffer(): Nullable<AudioBuffer>;
  112110. /**
  112111. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  112112. * @returns the source node
  112113. */
  112114. getSoundSource(): Nullable<AudioBufferSourceNode>;
  112115. /**
  112116. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  112117. * @returns the gain node
  112118. */
  112119. getSoundGain(): Nullable<GainNode>;
  112120. /**
  112121. * Serializes the Sound in a JSON representation
  112122. * @returns the JSON representation of the sound
  112123. */
  112124. serialize(): any;
  112125. /**
  112126. * Parse a JSON representation of a sound to innstantiate in a given scene
  112127. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  112128. * @param scene Define the scene the new parsed sound should be created in
  112129. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  112130. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  112131. * @returns the newly parsed sound
  112132. */
  112133. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  112134. }
  112135. }
  112136. declare module BABYLON {
  112137. /**
  112138. * This defines an action helpful to play a defined sound on a triggered action.
  112139. */
  112140. export class PlaySoundAction extends Action {
  112141. private _sound;
  112142. /**
  112143. * Instantiate the action
  112144. * @param triggerOptions defines the trigger options
  112145. * @param sound defines the sound to play
  112146. * @param condition defines the trigger related conditions
  112147. */
  112148. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  112149. /** @hidden */
  112150. _prepare(): void;
  112151. /**
  112152. * Execute the action and play the sound.
  112153. */
  112154. execute(): void;
  112155. /**
  112156. * Serializes the actions and its related information.
  112157. * @param parent defines the object to serialize in
  112158. * @returns the serialized object
  112159. */
  112160. serialize(parent: any): any;
  112161. }
  112162. /**
  112163. * This defines an action helpful to stop a defined sound on a triggered action.
  112164. */
  112165. export class StopSoundAction extends Action {
  112166. private _sound;
  112167. /**
  112168. * Instantiate the action
  112169. * @param triggerOptions defines the trigger options
  112170. * @param sound defines the sound to stop
  112171. * @param condition defines the trigger related conditions
  112172. */
  112173. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  112174. /** @hidden */
  112175. _prepare(): void;
  112176. /**
  112177. * Execute the action and stop the sound.
  112178. */
  112179. execute(): void;
  112180. /**
  112181. * Serializes the actions and its related information.
  112182. * @param parent defines the object to serialize in
  112183. * @returns the serialized object
  112184. */
  112185. serialize(parent: any): any;
  112186. }
  112187. }
  112188. declare module BABYLON {
  112189. /**
  112190. * This defines an action responsible to change the value of a property
  112191. * by interpolating between its current value and the newly set one once triggered.
  112192. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  112193. */
  112194. export class InterpolateValueAction extends Action {
  112195. /**
  112196. * Defines the path of the property where the value should be interpolated
  112197. */
  112198. propertyPath: string;
  112199. /**
  112200. * Defines the target value at the end of the interpolation.
  112201. */
  112202. value: any;
  112203. /**
  112204. * Defines the time it will take for the property to interpolate to the value.
  112205. */
  112206. duration: number;
  112207. /**
  112208. * Defines if the other scene animations should be stopped when the action has been triggered
  112209. */
  112210. stopOtherAnimations?: boolean;
  112211. /**
  112212. * Defines a callback raised once the interpolation animation has been done.
  112213. */
  112214. onInterpolationDone?: () => void;
  112215. /**
  112216. * Observable triggered once the interpolation animation has been done.
  112217. */
  112218. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  112219. private _target;
  112220. private _effectiveTarget;
  112221. private _property;
  112222. /**
  112223. * Instantiate the action
  112224. * @param triggerOptions defines the trigger options
  112225. * @param target defines the object containing the value to interpolate
  112226. * @param propertyPath defines the path to the property in the target object
  112227. * @param value defines the target value at the end of the interpolation
  112228. * @param duration deines the time it will take for the property to interpolate to the value.
  112229. * @param condition defines the trigger related conditions
  112230. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  112231. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  112232. */
  112233. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  112234. /** @hidden */
  112235. _prepare(): void;
  112236. /**
  112237. * Execute the action starts the value interpolation.
  112238. */
  112239. execute(): void;
  112240. /**
  112241. * Serializes the actions and its related information.
  112242. * @param parent defines the object to serialize in
  112243. * @returns the serialized object
  112244. */
  112245. serialize(parent: any): any;
  112246. }
  112247. }
  112248. declare module BABYLON {
  112249. /**
  112250. * Options allowed during the creation of a sound track.
  112251. */
  112252. export interface ISoundTrackOptions {
  112253. /**
  112254. * The volume the sound track should take during creation
  112255. */
  112256. volume?: number;
  112257. /**
  112258. * Define if the sound track is the main sound track of the scene
  112259. */
  112260. mainTrack?: boolean;
  112261. }
  112262. /**
  112263. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  112264. * It will be also used in a future release to apply effects on a specific track.
  112265. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  112266. */
  112267. export class SoundTrack {
  112268. /**
  112269. * The unique identifier of the sound track in the scene.
  112270. */
  112271. id: number;
  112272. /**
  112273. * The list of sounds included in the sound track.
  112274. */
  112275. soundCollection: Array<Sound>;
  112276. private _outputAudioNode;
  112277. private _scene;
  112278. private _connectedAnalyser;
  112279. private _options;
  112280. private _isInitialized;
  112281. /**
  112282. * Creates a new sound track.
  112283. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  112284. * @param scene Define the scene the sound track belongs to
  112285. * @param options
  112286. */
  112287. constructor(scene: Scene, options?: ISoundTrackOptions);
  112288. private _initializeSoundTrackAudioGraph;
  112289. /**
  112290. * Release the sound track and its associated resources
  112291. */
  112292. dispose(): void;
  112293. /**
  112294. * Adds a sound to this sound track
  112295. * @param sound define the cound to add
  112296. * @ignoreNaming
  112297. */
  112298. AddSound(sound: Sound): void;
  112299. /**
  112300. * Removes a sound to this sound track
  112301. * @param sound define the cound to remove
  112302. * @ignoreNaming
  112303. */
  112304. RemoveSound(sound: Sound): void;
  112305. /**
  112306. * Set a global volume for the full sound track.
  112307. * @param newVolume Define the new volume of the sound track
  112308. */
  112309. setVolume(newVolume: number): void;
  112310. /**
  112311. * Switch the panning model to HRTF:
  112312. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  112313. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  112314. */
  112315. switchPanningModelToHRTF(): void;
  112316. /**
  112317. * Switch the panning model to Equal Power:
  112318. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  112319. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  112320. */
  112321. switchPanningModelToEqualPower(): void;
  112322. /**
  112323. * Connect the sound track to an audio analyser allowing some amazing
  112324. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  112325. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  112326. * @param analyser The analyser to connect to the engine
  112327. */
  112328. connectToAnalyser(analyser: Analyser): void;
  112329. }
  112330. }
  112331. declare module BABYLON {
  112332. interface AbstractScene {
  112333. /**
  112334. * The list of sounds used in the scene.
  112335. */
  112336. sounds: Nullable<Array<Sound>>;
  112337. }
  112338. interface Scene {
  112339. /**
  112340. * @hidden
  112341. * Backing field
  112342. */
  112343. _mainSoundTrack: SoundTrack;
  112344. /**
  112345. * The main sound track played by the scene.
  112346. * It cotains your primary collection of sounds.
  112347. */
  112348. mainSoundTrack: SoundTrack;
  112349. /**
  112350. * The list of sound tracks added to the scene
  112351. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  112352. */
  112353. soundTracks: Nullable<Array<SoundTrack>>;
  112354. /**
  112355. * Gets a sound using a given name
  112356. * @param name defines the name to search for
  112357. * @return the found sound or null if not found at all.
  112358. */
  112359. getSoundByName(name: string): Nullable<Sound>;
  112360. /**
  112361. * Gets or sets if audio support is enabled
  112362. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  112363. */
  112364. audioEnabled: boolean;
  112365. /**
  112366. * Gets or sets if audio will be output to headphones
  112367. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  112368. */
  112369. headphone: boolean;
  112370. /**
  112371. * Gets or sets custom audio listener position provider
  112372. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  112373. */
  112374. audioListenerPositionProvider: Nullable<() => Vector3>;
  112375. /**
  112376. * Gets or sets a refresh rate when using 3D audio positioning
  112377. */
  112378. audioPositioningRefreshRate: number;
  112379. }
  112380. /**
  112381. * Defines the sound scene component responsible to manage any sounds
  112382. * in a given scene.
  112383. */
  112384. export class AudioSceneComponent implements ISceneSerializableComponent {
  112385. /**
  112386. * The component name helpfull to identify the component in the list of scene components.
  112387. */
  112388. readonly name: string;
  112389. /**
  112390. * The scene the component belongs to.
  112391. */
  112392. scene: Scene;
  112393. private _audioEnabled;
  112394. /**
  112395. * Gets whether audio is enabled or not.
  112396. * Please use related enable/disable method to switch state.
  112397. */
  112398. get audioEnabled(): boolean;
  112399. private _headphone;
  112400. /**
  112401. * Gets whether audio is outputing to headphone or not.
  112402. * Please use the according Switch methods to change output.
  112403. */
  112404. get headphone(): boolean;
  112405. /**
  112406. * Gets or sets a refresh rate when using 3D audio positioning
  112407. */
  112408. audioPositioningRefreshRate: number;
  112409. private _audioListenerPositionProvider;
  112410. /**
  112411. * Gets the current audio listener position provider
  112412. */
  112413. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  112414. /**
  112415. * Sets a custom listener position for all sounds in the scene
  112416. * By default, this is the position of the first active camera
  112417. */
  112418. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  112419. /**
  112420. * Creates a new instance of the component for the given scene
  112421. * @param scene Defines the scene to register the component in
  112422. */
  112423. constructor(scene: Scene);
  112424. /**
  112425. * Registers the component in a given scene
  112426. */
  112427. register(): void;
  112428. /**
  112429. * Rebuilds the elements related to this component in case of
  112430. * context lost for instance.
  112431. */
  112432. rebuild(): void;
  112433. /**
  112434. * Serializes the component data to the specified json object
  112435. * @param serializationObject The object to serialize to
  112436. */
  112437. serialize(serializationObject: any): void;
  112438. /**
  112439. * Adds all the elements from the container to the scene
  112440. * @param container the container holding the elements
  112441. */
  112442. addFromContainer(container: AbstractScene): void;
  112443. /**
  112444. * Removes all the elements in the container from the scene
  112445. * @param container contains the elements to remove
  112446. * @param dispose if the removed element should be disposed (default: false)
  112447. */
  112448. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  112449. /**
  112450. * Disposes the component and the associated ressources.
  112451. */
  112452. dispose(): void;
  112453. /**
  112454. * Disables audio in the associated scene.
  112455. */
  112456. disableAudio(): void;
  112457. /**
  112458. * Enables audio in the associated scene.
  112459. */
  112460. enableAudio(): void;
  112461. /**
  112462. * Switch audio to headphone output.
  112463. */
  112464. switchAudioModeForHeadphones(): void;
  112465. /**
  112466. * Switch audio to normal speakers.
  112467. */
  112468. switchAudioModeForNormalSpeakers(): void;
  112469. private _cachedCameraDirection;
  112470. private _cachedCameraPosition;
  112471. private _lastCheck;
  112472. private _afterRender;
  112473. }
  112474. }
  112475. declare module BABYLON {
  112476. /**
  112477. * Wraps one or more Sound objects and selects one with random weight for playback.
  112478. */
  112479. export class WeightedSound {
  112480. /** When true a Sound will be selected and played when the current playing Sound completes. */
  112481. loop: boolean;
  112482. private _coneInnerAngle;
  112483. private _coneOuterAngle;
  112484. private _volume;
  112485. /** A Sound is currently playing. */
  112486. isPlaying: boolean;
  112487. /** A Sound is currently paused. */
  112488. isPaused: boolean;
  112489. private _sounds;
  112490. private _weights;
  112491. private _currentIndex?;
  112492. /**
  112493. * Creates a new WeightedSound from the list of sounds given.
  112494. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  112495. * @param sounds Array of Sounds that will be selected from.
  112496. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  112497. */
  112498. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  112499. /**
  112500. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  112501. */
  112502. get directionalConeInnerAngle(): number;
  112503. /**
  112504. * The size of cone in degress for a directional sound in which there will be no attenuation.
  112505. */
  112506. set directionalConeInnerAngle(value: number);
  112507. /**
  112508. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  112509. * Listener angles between innerAngle and outerAngle will falloff linearly.
  112510. */
  112511. get directionalConeOuterAngle(): number;
  112512. /**
  112513. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  112514. * Listener angles between innerAngle and outerAngle will falloff linearly.
  112515. */
  112516. set directionalConeOuterAngle(value: number);
  112517. /**
  112518. * Playback volume.
  112519. */
  112520. get volume(): number;
  112521. /**
  112522. * Playback volume.
  112523. */
  112524. set volume(value: number);
  112525. private _onended;
  112526. /**
  112527. * Suspend playback
  112528. */
  112529. pause(): void;
  112530. /**
  112531. * Stop playback
  112532. */
  112533. stop(): void;
  112534. /**
  112535. * Start playback.
  112536. * @param startOffset Position the clip head at a specific time in seconds.
  112537. */
  112538. play(startOffset?: number): void;
  112539. }
  112540. }
  112541. declare module BABYLON {
  112542. /**
  112543. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  112544. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  112545. */
  112546. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  112547. /**
  112548. * Gets the name of the behavior.
  112549. */
  112550. get name(): string;
  112551. /**
  112552. * The easing function used by animations
  112553. */
  112554. static EasingFunction: BackEase;
  112555. /**
  112556. * The easing mode used by animations
  112557. */
  112558. static EasingMode: number;
  112559. /**
  112560. * The duration of the animation, in milliseconds
  112561. */
  112562. transitionDuration: number;
  112563. /**
  112564. * Length of the distance animated by the transition when lower radius is reached
  112565. */
  112566. lowerRadiusTransitionRange: number;
  112567. /**
  112568. * Length of the distance animated by the transition when upper radius is reached
  112569. */
  112570. upperRadiusTransitionRange: number;
  112571. private _autoTransitionRange;
  112572. /**
  112573. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  112574. */
  112575. get autoTransitionRange(): boolean;
  112576. /**
  112577. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  112578. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  112579. */
  112580. set autoTransitionRange(value: boolean);
  112581. private _attachedCamera;
  112582. private _onAfterCheckInputsObserver;
  112583. private _onMeshTargetChangedObserver;
  112584. /**
  112585. * Initializes the behavior.
  112586. */
  112587. init(): void;
  112588. /**
  112589. * Attaches the behavior to its arc rotate camera.
  112590. * @param camera Defines the camera to attach the behavior to
  112591. */
  112592. attach(camera: ArcRotateCamera): void;
  112593. /**
  112594. * Detaches the behavior from its current arc rotate camera.
  112595. */
  112596. detach(): void;
  112597. private _radiusIsAnimating;
  112598. private _radiusBounceTransition;
  112599. private _animatables;
  112600. private _cachedWheelPrecision;
  112601. /**
  112602. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  112603. * @param radiusLimit The limit to check against.
  112604. * @return Bool to indicate if at limit.
  112605. */
  112606. private _isRadiusAtLimit;
  112607. /**
  112608. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  112609. * @param radiusDelta The delta by which to animate to. Can be negative.
  112610. */
  112611. private _applyBoundRadiusAnimation;
  112612. /**
  112613. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  112614. */
  112615. protected _clearAnimationLocks(): void;
  112616. /**
  112617. * Stops and removes all animations that have been applied to the camera
  112618. */
  112619. stopAllAnimations(): void;
  112620. }
  112621. }
  112622. declare module BABYLON {
  112623. /**
  112624. * 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.
  112625. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  112626. */
  112627. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  112628. /**
  112629. * Gets the name of the behavior.
  112630. */
  112631. get name(): string;
  112632. private _mode;
  112633. private _radiusScale;
  112634. private _positionScale;
  112635. private _defaultElevation;
  112636. private _elevationReturnTime;
  112637. private _elevationReturnWaitTime;
  112638. private _zoomStopsAnimation;
  112639. private _framingTime;
  112640. /**
  112641. * The easing function used by animations
  112642. */
  112643. static EasingFunction: ExponentialEase;
  112644. /**
  112645. * The easing mode used by animations
  112646. */
  112647. static EasingMode: number;
  112648. /**
  112649. * Sets the current mode used by the behavior
  112650. */
  112651. set mode(mode: number);
  112652. /**
  112653. * Gets current mode used by the behavior.
  112654. */
  112655. get mode(): number;
  112656. /**
  112657. * Sets the scale applied to the radius (1 by default)
  112658. */
  112659. set radiusScale(radius: number);
  112660. /**
  112661. * Gets the scale applied to the radius
  112662. */
  112663. get radiusScale(): number;
  112664. /**
  112665. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  112666. */
  112667. set positionScale(scale: number);
  112668. /**
  112669. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  112670. */
  112671. get positionScale(): number;
  112672. /**
  112673. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  112674. * behaviour is triggered, in radians.
  112675. */
  112676. set defaultElevation(elevation: number);
  112677. /**
  112678. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  112679. * behaviour is triggered, in radians.
  112680. */
  112681. get defaultElevation(): number;
  112682. /**
  112683. * Sets the time (in milliseconds) taken to return to the default beta position.
  112684. * Negative value indicates camera should not return to default.
  112685. */
  112686. set elevationReturnTime(speed: number);
  112687. /**
  112688. * Gets the time (in milliseconds) taken to return to the default beta position.
  112689. * Negative value indicates camera should not return to default.
  112690. */
  112691. get elevationReturnTime(): number;
  112692. /**
  112693. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  112694. */
  112695. set elevationReturnWaitTime(time: number);
  112696. /**
  112697. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  112698. */
  112699. get elevationReturnWaitTime(): number;
  112700. /**
  112701. * Sets the flag that indicates if user zooming should stop animation.
  112702. */
  112703. set zoomStopsAnimation(flag: boolean);
  112704. /**
  112705. * Gets the flag that indicates if user zooming should stop animation.
  112706. */
  112707. get zoomStopsAnimation(): boolean;
  112708. /**
  112709. * Sets the transition time when framing the mesh, in milliseconds
  112710. */
  112711. set framingTime(time: number);
  112712. /**
  112713. * Gets the transition time when framing the mesh, in milliseconds
  112714. */
  112715. get framingTime(): number;
  112716. /**
  112717. * Define if the behavior should automatically change the configured
  112718. * camera limits and sensibilities.
  112719. */
  112720. autoCorrectCameraLimitsAndSensibility: boolean;
  112721. private _onPrePointerObservableObserver;
  112722. private _onAfterCheckInputsObserver;
  112723. private _onMeshTargetChangedObserver;
  112724. private _attachedCamera;
  112725. private _isPointerDown;
  112726. private _lastInteractionTime;
  112727. /**
  112728. * Initializes the behavior.
  112729. */
  112730. init(): void;
  112731. /**
  112732. * Attaches the behavior to its arc rotate camera.
  112733. * @param camera Defines the camera to attach the behavior to
  112734. */
  112735. attach(camera: ArcRotateCamera): void;
  112736. /**
  112737. * Detaches the behavior from its current arc rotate camera.
  112738. */
  112739. detach(): void;
  112740. private _animatables;
  112741. private _betaIsAnimating;
  112742. private _betaTransition;
  112743. private _radiusTransition;
  112744. private _vectorTransition;
  112745. /**
  112746. * Targets the given mesh and updates zoom level accordingly.
  112747. * @param mesh The mesh to target.
  112748. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  112749. * @param onAnimationEnd Callback triggered at the end of the framing animation
  112750. */
  112751. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  112752. /**
  112753. * Targets the given mesh with its children and updates zoom level accordingly.
  112754. * @param mesh The mesh to target.
  112755. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  112756. * @param onAnimationEnd Callback triggered at the end of the framing animation
  112757. */
  112758. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  112759. /**
  112760. * Targets the given meshes with their children and updates zoom level accordingly.
  112761. * @param meshes The mesh to target.
  112762. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  112763. * @param onAnimationEnd Callback triggered at the end of the framing animation
  112764. */
  112765. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  112766. /**
  112767. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  112768. * @param minimumWorld Determines the smaller position of the bounding box extend
  112769. * @param maximumWorld Determines the bigger position of the bounding box extend
  112770. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  112771. * @param onAnimationEnd Callback triggered at the end of the framing animation
  112772. */
  112773. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  112774. /**
  112775. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  112776. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  112777. * frustum width.
  112778. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  112779. * to fully enclose the mesh in the viewing frustum.
  112780. */
  112781. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  112782. /**
  112783. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  112784. * is automatically returned to its default position (expected to be above ground plane).
  112785. */
  112786. private _maintainCameraAboveGround;
  112787. /**
  112788. * Returns the frustum slope based on the canvas ratio and camera FOV
  112789. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  112790. */
  112791. private _getFrustumSlope;
  112792. /**
  112793. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  112794. */
  112795. private _clearAnimationLocks;
  112796. /**
  112797. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  112798. */
  112799. private _applyUserInteraction;
  112800. /**
  112801. * Stops and removes all animations that have been applied to the camera
  112802. */
  112803. stopAllAnimations(): void;
  112804. /**
  112805. * Gets a value indicating if the user is moving the camera
  112806. */
  112807. get isUserIsMoving(): boolean;
  112808. /**
  112809. * The camera can move all the way towards the mesh.
  112810. */
  112811. static IgnoreBoundsSizeMode: number;
  112812. /**
  112813. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  112814. */
  112815. static FitFrustumSidesMode: number;
  112816. }
  112817. }
  112818. declare module BABYLON {
  112819. /**
  112820. * Base class for Camera Pointer Inputs.
  112821. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  112822. * for example usage.
  112823. */
  112824. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  112825. /**
  112826. * Defines the camera the input is attached to.
  112827. */
  112828. abstract camera: Camera;
  112829. /**
  112830. * Whether keyboard modifier keys are pressed at time of last mouse event.
  112831. */
  112832. protected _altKey: boolean;
  112833. protected _ctrlKey: boolean;
  112834. protected _metaKey: boolean;
  112835. protected _shiftKey: boolean;
  112836. /**
  112837. * Which mouse buttons were pressed at time of last mouse event.
  112838. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  112839. */
  112840. protected _buttonsPressed: number;
  112841. /**
  112842. * Defines the buttons associated with the input to handle camera move.
  112843. */
  112844. buttons: number[];
  112845. /**
  112846. * Attach the input controls to a specific dom element to get the input from.
  112847. * @param element Defines the element the controls should be listened from
  112848. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  112849. */
  112850. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  112851. /**
  112852. * Detach the current controls from the specified dom element.
  112853. * @param element Defines the element to stop listening the inputs from
  112854. */
  112855. detachControl(element: Nullable<HTMLElement>): void;
  112856. /**
  112857. * Gets the class name of the current input.
  112858. * @returns the class name
  112859. */
  112860. getClassName(): string;
  112861. /**
  112862. * Get the friendly name associated with the input class.
  112863. * @returns the input friendly name
  112864. */
  112865. getSimpleName(): string;
  112866. /**
  112867. * Called on pointer POINTERDOUBLETAP event.
  112868. * Override this method to provide functionality on POINTERDOUBLETAP event.
  112869. */
  112870. protected onDoubleTap(type: string): void;
  112871. /**
  112872. * Called on pointer POINTERMOVE event if only a single touch is active.
  112873. * Override this method to provide functionality.
  112874. */
  112875. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  112876. /**
  112877. * Called on pointer POINTERMOVE event if multiple touches are active.
  112878. * Override this method to provide functionality.
  112879. */
  112880. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  112881. /**
  112882. * Called on JS contextmenu event.
  112883. * Override this method to provide functionality.
  112884. */
  112885. protected onContextMenu(evt: PointerEvent): void;
  112886. /**
  112887. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  112888. * press.
  112889. * Override this method to provide functionality.
  112890. */
  112891. protected onButtonDown(evt: PointerEvent): void;
  112892. /**
  112893. * Called each time a new POINTERUP event occurs. Ie, for each button
  112894. * release.
  112895. * Override this method to provide functionality.
  112896. */
  112897. protected onButtonUp(evt: PointerEvent): void;
  112898. /**
  112899. * Called when window becomes inactive.
  112900. * Override this method to provide functionality.
  112901. */
  112902. protected onLostFocus(): void;
  112903. private _pointerInput;
  112904. private _observer;
  112905. private _onLostFocus;
  112906. private pointA;
  112907. private pointB;
  112908. }
  112909. }
  112910. declare module BABYLON {
  112911. /**
  112912. * Manage the pointers inputs to control an arc rotate camera.
  112913. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  112914. */
  112915. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  112916. /**
  112917. * Defines the camera the input is attached to.
  112918. */
  112919. camera: ArcRotateCamera;
  112920. /**
  112921. * Gets the class name of the current input.
  112922. * @returns the class name
  112923. */
  112924. getClassName(): string;
  112925. /**
  112926. * Defines the buttons associated with the input to handle camera move.
  112927. */
  112928. buttons: number[];
  112929. /**
  112930. * Defines the pointer angular sensibility along the X axis or how fast is
  112931. * the camera rotating.
  112932. */
  112933. angularSensibilityX: number;
  112934. /**
  112935. * Defines the pointer angular sensibility along the Y axis or how fast is
  112936. * the camera rotating.
  112937. */
  112938. angularSensibilityY: number;
  112939. /**
  112940. * Defines the pointer pinch precision or how fast is the camera zooming.
  112941. */
  112942. pinchPrecision: number;
  112943. /**
  112944. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  112945. * from 0.
  112946. * It defines the percentage of current camera.radius to use as delta when
  112947. * pinch zoom is used.
  112948. */
  112949. pinchDeltaPercentage: number;
  112950. /**
  112951. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  112952. * that any object in the plane at the camera's target point will scale
  112953. * perfectly with finger motion.
  112954. * Overrides pinchDeltaPercentage and pinchPrecision.
  112955. */
  112956. useNaturalPinchZoom: boolean;
  112957. /**
  112958. * Defines the pointer panning sensibility or how fast is the camera moving.
  112959. */
  112960. panningSensibility: number;
  112961. /**
  112962. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  112963. */
  112964. multiTouchPanning: boolean;
  112965. /**
  112966. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  112967. * zoom (pinch) through multitouch.
  112968. */
  112969. multiTouchPanAndZoom: boolean;
  112970. /**
  112971. * Revers pinch action direction.
  112972. */
  112973. pinchInwards: boolean;
  112974. private _isPanClick;
  112975. private _twoFingerActivityCount;
  112976. private _isPinching;
  112977. /**
  112978. * Called on pointer POINTERMOVE event if only a single touch is active.
  112979. */
  112980. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  112981. /**
  112982. * Called on pointer POINTERDOUBLETAP event.
  112983. */
  112984. protected onDoubleTap(type: string): void;
  112985. /**
  112986. * Called on pointer POINTERMOVE event if multiple touches are active.
  112987. */
  112988. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  112989. /**
  112990. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  112991. * press.
  112992. */
  112993. protected onButtonDown(evt: PointerEvent): void;
  112994. /**
  112995. * Called each time a new POINTERUP event occurs. Ie, for each button
  112996. * release.
  112997. */
  112998. protected onButtonUp(evt: PointerEvent): void;
  112999. /**
  113000. * Called when window becomes inactive.
  113001. */
  113002. protected onLostFocus(): void;
  113003. }
  113004. }
  113005. declare module BABYLON {
  113006. /**
  113007. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  113008. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113009. */
  113010. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  113011. /**
  113012. * Defines the camera the input is attached to.
  113013. */
  113014. camera: ArcRotateCamera;
  113015. /**
  113016. * Defines the list of key codes associated with the up action (increase alpha)
  113017. */
  113018. keysUp: number[];
  113019. /**
  113020. * Defines the list of key codes associated with the down action (decrease alpha)
  113021. */
  113022. keysDown: number[];
  113023. /**
  113024. * Defines the list of key codes associated with the left action (increase beta)
  113025. */
  113026. keysLeft: number[];
  113027. /**
  113028. * Defines the list of key codes associated with the right action (decrease beta)
  113029. */
  113030. keysRight: number[];
  113031. /**
  113032. * Defines the list of key codes associated with the reset action.
  113033. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  113034. */
  113035. keysReset: number[];
  113036. /**
  113037. * Defines the panning sensibility of the inputs.
  113038. * (How fast is the camera panning)
  113039. */
  113040. panningSensibility: number;
  113041. /**
  113042. * Defines the zooming sensibility of the inputs.
  113043. * (How fast is the camera zooming)
  113044. */
  113045. zoomingSensibility: number;
  113046. /**
  113047. * Defines whether maintaining the alt key down switch the movement mode from
  113048. * orientation to zoom.
  113049. */
  113050. useAltToZoom: boolean;
  113051. /**
  113052. * Rotation speed of the camera
  113053. */
  113054. angularSpeed: number;
  113055. private _keys;
  113056. private _ctrlPressed;
  113057. private _altPressed;
  113058. private _onCanvasBlurObserver;
  113059. private _onKeyboardObserver;
  113060. private _engine;
  113061. private _scene;
  113062. /**
  113063. * Attach the input controls to a specific dom element to get the input from.
  113064. * @param element Defines the element the controls should be listened from
  113065. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  113066. */
  113067. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113068. /**
  113069. * Detach the current controls from the specified dom element.
  113070. * @param element Defines the element to stop listening the inputs from
  113071. */
  113072. detachControl(element: Nullable<HTMLElement>): void;
  113073. /**
  113074. * Update the current camera state depending on the inputs that have been used this frame.
  113075. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  113076. */
  113077. checkInputs(): void;
  113078. /**
  113079. * Gets the class name of the current intput.
  113080. * @returns the class name
  113081. */
  113082. getClassName(): string;
  113083. /**
  113084. * Get the friendly name associated with the input class.
  113085. * @returns the input friendly name
  113086. */
  113087. getSimpleName(): string;
  113088. }
  113089. }
  113090. declare module BABYLON {
  113091. /**
  113092. * Manage the mouse wheel inputs to control an arc rotate camera.
  113093. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113094. */
  113095. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  113096. /**
  113097. * Defines the camera the input is attached to.
  113098. */
  113099. camera: ArcRotateCamera;
  113100. /**
  113101. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  113102. */
  113103. wheelPrecision: number;
  113104. /**
  113105. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  113106. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  113107. */
  113108. wheelDeltaPercentage: number;
  113109. private _wheel;
  113110. private _observer;
  113111. private computeDeltaFromMouseWheelLegacyEvent;
  113112. /**
  113113. * Attach the input controls to a specific dom element to get the input from.
  113114. * @param element Defines the element the controls should be listened from
  113115. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  113116. */
  113117. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113118. /**
  113119. * Detach the current controls from the specified dom element.
  113120. * @param element Defines the element to stop listening the inputs from
  113121. */
  113122. detachControl(element: Nullable<HTMLElement>): void;
  113123. /**
  113124. * Gets the class name of the current intput.
  113125. * @returns the class name
  113126. */
  113127. getClassName(): string;
  113128. /**
  113129. * Get the friendly name associated with the input class.
  113130. * @returns the input friendly name
  113131. */
  113132. getSimpleName(): string;
  113133. }
  113134. }
  113135. declare module BABYLON {
  113136. /**
  113137. * Default Inputs manager for the ArcRotateCamera.
  113138. * It groups all the default supported inputs for ease of use.
  113139. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113140. */
  113141. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  113142. /**
  113143. * Instantiates a new ArcRotateCameraInputsManager.
  113144. * @param camera Defines the camera the inputs belong to
  113145. */
  113146. constructor(camera: ArcRotateCamera);
  113147. /**
  113148. * Add mouse wheel input support to the input manager.
  113149. * @returns the current input manager
  113150. */
  113151. addMouseWheel(): ArcRotateCameraInputsManager;
  113152. /**
  113153. * Add pointers input support to the input manager.
  113154. * @returns the current input manager
  113155. */
  113156. addPointers(): ArcRotateCameraInputsManager;
  113157. /**
  113158. * Add keyboard input support to the input manager.
  113159. * @returns the current input manager
  113160. */
  113161. addKeyboard(): ArcRotateCameraInputsManager;
  113162. }
  113163. }
  113164. declare module BABYLON {
  113165. /**
  113166. * This represents an orbital type of camera.
  113167. *
  113168. * 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.
  113169. * 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.
  113170. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  113171. */
  113172. export class ArcRotateCamera extends TargetCamera {
  113173. /**
  113174. * Defines the rotation angle of the camera along the longitudinal axis.
  113175. */
  113176. alpha: number;
  113177. /**
  113178. * Defines the rotation angle of the camera along the latitudinal axis.
  113179. */
  113180. beta: number;
  113181. /**
  113182. * Defines the radius of the camera from it s target point.
  113183. */
  113184. radius: number;
  113185. protected _target: Vector3;
  113186. protected _targetHost: Nullable<AbstractMesh>;
  113187. /**
  113188. * Defines the target point of the camera.
  113189. * The camera looks towards it form the radius distance.
  113190. */
  113191. get target(): Vector3;
  113192. set target(value: Vector3);
  113193. /**
  113194. * Define the current local position of the camera in the scene
  113195. */
  113196. get position(): Vector3;
  113197. set position(newPosition: Vector3);
  113198. protected _upVector: Vector3;
  113199. protected _upToYMatrix: Matrix;
  113200. protected _YToUpMatrix: Matrix;
  113201. /**
  113202. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  113203. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  113204. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  113205. */
  113206. set upVector(vec: Vector3);
  113207. get upVector(): Vector3;
  113208. /**
  113209. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  113210. */
  113211. setMatUp(): void;
  113212. /**
  113213. * Current inertia value on the longitudinal axis.
  113214. * The bigger this number the longer it will take for the camera to stop.
  113215. */
  113216. inertialAlphaOffset: number;
  113217. /**
  113218. * Current inertia value on the latitudinal axis.
  113219. * The bigger this number the longer it will take for the camera to stop.
  113220. */
  113221. inertialBetaOffset: number;
  113222. /**
  113223. * Current inertia value on the radius axis.
  113224. * The bigger this number the longer it will take for the camera to stop.
  113225. */
  113226. inertialRadiusOffset: number;
  113227. /**
  113228. * Minimum allowed angle on the longitudinal axis.
  113229. * This can help limiting how the Camera is able to move in the scene.
  113230. */
  113231. lowerAlphaLimit: Nullable<number>;
  113232. /**
  113233. * Maximum allowed angle on the longitudinal axis.
  113234. * This can help limiting how the Camera is able to move in the scene.
  113235. */
  113236. upperAlphaLimit: Nullable<number>;
  113237. /**
  113238. * Minimum allowed angle on the latitudinal axis.
  113239. * This can help limiting how the Camera is able to move in the scene.
  113240. */
  113241. lowerBetaLimit: number;
  113242. /**
  113243. * Maximum allowed angle on the latitudinal axis.
  113244. * This can help limiting how the Camera is able to move in the scene.
  113245. */
  113246. upperBetaLimit: number;
  113247. /**
  113248. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  113249. * This can help limiting how the Camera is able to move in the scene.
  113250. */
  113251. lowerRadiusLimit: Nullable<number>;
  113252. /**
  113253. * Maximum allowed distance of the camera to the target (The camera can not get further).
  113254. * This can help limiting how the Camera is able to move in the scene.
  113255. */
  113256. upperRadiusLimit: Nullable<number>;
  113257. /**
  113258. * Defines the current inertia value used during panning of the camera along the X axis.
  113259. */
  113260. inertialPanningX: number;
  113261. /**
  113262. * Defines the current inertia value used during panning of the camera along the Y axis.
  113263. */
  113264. inertialPanningY: number;
  113265. /**
  113266. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  113267. * Basically if your fingers moves away from more than this distance you will be considered
  113268. * in pinch mode.
  113269. */
  113270. pinchToPanMaxDistance: number;
  113271. /**
  113272. * Defines the maximum distance the camera can pan.
  113273. * This could help keeping the cammera always in your scene.
  113274. */
  113275. panningDistanceLimit: Nullable<number>;
  113276. /**
  113277. * Defines the target of the camera before paning.
  113278. */
  113279. panningOriginTarget: Vector3;
  113280. /**
  113281. * Defines the value of the inertia used during panning.
  113282. * 0 would mean stop inertia and one would mean no decelleration at all.
  113283. */
  113284. panningInertia: number;
  113285. /**
  113286. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  113287. */
  113288. get angularSensibilityX(): number;
  113289. set angularSensibilityX(value: number);
  113290. /**
  113291. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  113292. */
  113293. get angularSensibilityY(): number;
  113294. set angularSensibilityY(value: number);
  113295. /**
  113296. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  113297. */
  113298. get pinchPrecision(): number;
  113299. set pinchPrecision(value: number);
  113300. /**
  113301. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  113302. * It will be used instead of pinchDeltaPrecision if different from 0.
  113303. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  113304. */
  113305. get pinchDeltaPercentage(): number;
  113306. set pinchDeltaPercentage(value: number);
  113307. /**
  113308. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  113309. * and pinch delta percentage.
  113310. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  113311. * that any object in the plane at the camera's target point will scale
  113312. * perfectly with finger motion.
  113313. */
  113314. get useNaturalPinchZoom(): boolean;
  113315. set useNaturalPinchZoom(value: boolean);
  113316. /**
  113317. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  113318. */
  113319. get panningSensibility(): number;
  113320. set panningSensibility(value: number);
  113321. /**
  113322. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  113323. */
  113324. get keysUp(): number[];
  113325. set keysUp(value: number[]);
  113326. /**
  113327. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  113328. */
  113329. get keysDown(): number[];
  113330. set keysDown(value: number[]);
  113331. /**
  113332. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  113333. */
  113334. get keysLeft(): number[];
  113335. set keysLeft(value: number[]);
  113336. /**
  113337. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  113338. */
  113339. get keysRight(): number[];
  113340. set keysRight(value: number[]);
  113341. /**
  113342. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  113343. */
  113344. get wheelPrecision(): number;
  113345. set wheelPrecision(value: number);
  113346. /**
  113347. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  113348. * It will be used instead of pinchDeltaPrecision if different from 0.
  113349. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  113350. */
  113351. get wheelDeltaPercentage(): number;
  113352. set wheelDeltaPercentage(value: number);
  113353. /**
  113354. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  113355. */
  113356. zoomOnFactor: number;
  113357. /**
  113358. * Defines a screen offset for the camera position.
  113359. */
  113360. targetScreenOffset: Vector2;
  113361. /**
  113362. * Allows the camera to be completely reversed.
  113363. * If false the camera can not arrive upside down.
  113364. */
  113365. allowUpsideDown: boolean;
  113366. /**
  113367. * Define if double tap/click is used to restore the previously saved state of the camera.
  113368. */
  113369. useInputToRestoreState: boolean;
  113370. /** @hidden */
  113371. _viewMatrix: Matrix;
  113372. /** @hidden */
  113373. _useCtrlForPanning: boolean;
  113374. /** @hidden */
  113375. _panningMouseButton: number;
  113376. /**
  113377. * Defines the input associated to the camera.
  113378. */
  113379. inputs: ArcRotateCameraInputsManager;
  113380. /** @hidden */
  113381. _reset: () => void;
  113382. /**
  113383. * Defines the allowed panning axis.
  113384. */
  113385. panningAxis: Vector3;
  113386. protected _localDirection: Vector3;
  113387. protected _transformedDirection: Vector3;
  113388. private _bouncingBehavior;
  113389. /**
  113390. * Gets the bouncing behavior of the camera if it has been enabled.
  113391. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  113392. */
  113393. get bouncingBehavior(): Nullable<BouncingBehavior>;
  113394. /**
  113395. * Defines if the bouncing behavior of the camera is enabled on the camera.
  113396. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  113397. */
  113398. get useBouncingBehavior(): boolean;
  113399. set useBouncingBehavior(value: boolean);
  113400. private _framingBehavior;
  113401. /**
  113402. * Gets the framing behavior of the camera if it has been enabled.
  113403. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  113404. */
  113405. get framingBehavior(): Nullable<FramingBehavior>;
  113406. /**
  113407. * Defines if the framing behavior of the camera is enabled on the camera.
  113408. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  113409. */
  113410. get useFramingBehavior(): boolean;
  113411. set useFramingBehavior(value: boolean);
  113412. private _autoRotationBehavior;
  113413. /**
  113414. * Gets the auto rotation behavior of the camera if it has been enabled.
  113415. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  113416. */
  113417. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  113418. /**
  113419. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  113420. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  113421. */
  113422. get useAutoRotationBehavior(): boolean;
  113423. set useAutoRotationBehavior(value: boolean);
  113424. /**
  113425. * Observable triggered when the mesh target has been changed on the camera.
  113426. */
  113427. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  113428. /**
  113429. * Event raised when the camera is colliding with a mesh.
  113430. */
  113431. onCollide: (collidedMesh: AbstractMesh) => void;
  113432. /**
  113433. * Defines whether the camera should check collision with the objects oh the scene.
  113434. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  113435. */
  113436. checkCollisions: boolean;
  113437. /**
  113438. * Defines the collision radius of the camera.
  113439. * This simulates a sphere around the camera.
  113440. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  113441. */
  113442. collisionRadius: Vector3;
  113443. protected _collider: Collider;
  113444. protected _previousPosition: Vector3;
  113445. protected _collisionVelocity: Vector3;
  113446. protected _newPosition: Vector3;
  113447. protected _previousAlpha: number;
  113448. protected _previousBeta: number;
  113449. protected _previousRadius: number;
  113450. protected _collisionTriggered: boolean;
  113451. protected _targetBoundingCenter: Nullable<Vector3>;
  113452. private _computationVector;
  113453. /**
  113454. * Instantiates a new ArcRotateCamera in a given scene
  113455. * @param name Defines the name of the camera
  113456. * @param alpha Defines the camera rotation along the logitudinal axis
  113457. * @param beta Defines the camera rotation along the latitudinal axis
  113458. * @param radius Defines the camera distance from its target
  113459. * @param target Defines the camera target
  113460. * @param scene Defines the scene the camera belongs to
  113461. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  113462. */
  113463. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  113464. /** @hidden */
  113465. _initCache(): void;
  113466. /** @hidden */
  113467. _updateCache(ignoreParentClass?: boolean): void;
  113468. protected _getTargetPosition(): Vector3;
  113469. private _storedAlpha;
  113470. private _storedBeta;
  113471. private _storedRadius;
  113472. private _storedTarget;
  113473. private _storedTargetScreenOffset;
  113474. /**
  113475. * Stores the current state of the camera (alpha, beta, radius and target)
  113476. * @returns the camera itself
  113477. */
  113478. storeState(): Camera;
  113479. /**
  113480. * @hidden
  113481. * Restored camera state. You must call storeState() first
  113482. */
  113483. _restoreStateValues(): boolean;
  113484. /** @hidden */
  113485. _isSynchronizedViewMatrix(): boolean;
  113486. /**
  113487. * Attached controls to the current camera.
  113488. * @param element Defines the element the controls should be listened from
  113489. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  113490. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  113491. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  113492. */
  113493. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  113494. /**
  113495. * Detach the current controls from the camera.
  113496. * The camera will stop reacting to inputs.
  113497. * @param element Defines the element to stop listening the inputs from
  113498. */
  113499. detachControl(element: HTMLElement): void;
  113500. /** @hidden */
  113501. _checkInputs(): void;
  113502. protected _checkLimits(): void;
  113503. /**
  113504. * Rebuilds angles (alpha, beta) and radius from the give position and target
  113505. */
  113506. rebuildAnglesAndRadius(): void;
  113507. /**
  113508. * Use a position to define the current camera related information like alpha, beta and radius
  113509. * @param position Defines the position to set the camera at
  113510. */
  113511. setPosition(position: Vector3): void;
  113512. /**
  113513. * Defines the target the camera should look at.
  113514. * This will automatically adapt alpha beta and radius to fit within the new target.
  113515. * @param target Defines the new target as a Vector or a mesh
  113516. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  113517. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  113518. */
  113519. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  113520. /** @hidden */
  113521. _getViewMatrix(): Matrix;
  113522. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  113523. /**
  113524. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  113525. * @param meshes Defines the mesh to zoom on
  113526. * @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)
  113527. */
  113528. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  113529. /**
  113530. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  113531. * The target will be changed but the radius
  113532. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  113533. * @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)
  113534. */
  113535. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  113536. min: Vector3;
  113537. max: Vector3;
  113538. distance: number;
  113539. }, doNotUpdateMaxZ?: boolean): void;
  113540. /**
  113541. * @override
  113542. * Override Camera.createRigCamera
  113543. */
  113544. createRigCamera(name: string, cameraIndex: number): Camera;
  113545. /**
  113546. * @hidden
  113547. * @override
  113548. * Override Camera._updateRigCameras
  113549. */
  113550. _updateRigCameras(): void;
  113551. /**
  113552. * Destroy the camera and release the current resources hold by it.
  113553. */
  113554. dispose(): void;
  113555. /**
  113556. * Gets the current object class name.
  113557. * @return the class name
  113558. */
  113559. getClassName(): string;
  113560. }
  113561. }
  113562. declare module BABYLON {
  113563. /**
  113564. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  113565. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  113566. */
  113567. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  113568. /**
  113569. * Gets the name of the behavior.
  113570. */
  113571. get name(): string;
  113572. private _zoomStopsAnimation;
  113573. private _idleRotationSpeed;
  113574. private _idleRotationWaitTime;
  113575. private _idleRotationSpinupTime;
  113576. /**
  113577. * Sets the flag that indicates if user zooming should stop animation.
  113578. */
  113579. set zoomStopsAnimation(flag: boolean);
  113580. /**
  113581. * Gets the flag that indicates if user zooming should stop animation.
  113582. */
  113583. get zoomStopsAnimation(): boolean;
  113584. /**
  113585. * Sets the default speed at which the camera rotates around the model.
  113586. */
  113587. set idleRotationSpeed(speed: number);
  113588. /**
  113589. * Gets the default speed at which the camera rotates around the model.
  113590. */
  113591. get idleRotationSpeed(): number;
  113592. /**
  113593. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  113594. */
  113595. set idleRotationWaitTime(time: number);
  113596. /**
  113597. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  113598. */
  113599. get idleRotationWaitTime(): number;
  113600. /**
  113601. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  113602. */
  113603. set idleRotationSpinupTime(time: number);
  113604. /**
  113605. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  113606. */
  113607. get idleRotationSpinupTime(): number;
  113608. /**
  113609. * Gets a value indicating if the camera is currently rotating because of this behavior
  113610. */
  113611. get rotationInProgress(): boolean;
  113612. private _onPrePointerObservableObserver;
  113613. private _onAfterCheckInputsObserver;
  113614. private _attachedCamera;
  113615. private _isPointerDown;
  113616. private _lastFrameTime;
  113617. private _lastInteractionTime;
  113618. private _cameraRotationSpeed;
  113619. /**
  113620. * Initializes the behavior.
  113621. */
  113622. init(): void;
  113623. /**
  113624. * Attaches the behavior to its arc rotate camera.
  113625. * @param camera Defines the camera to attach the behavior to
  113626. */
  113627. attach(camera: ArcRotateCamera): void;
  113628. /**
  113629. * Detaches the behavior from its current arc rotate camera.
  113630. */
  113631. detach(): void;
  113632. /**
  113633. * Returns true if user is scrolling.
  113634. * @return true if user is scrolling.
  113635. */
  113636. private _userIsZooming;
  113637. private _lastFrameRadius;
  113638. private _shouldAnimationStopForInteraction;
  113639. /**
  113640. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  113641. */
  113642. private _applyUserInteraction;
  113643. private _userIsMoving;
  113644. }
  113645. }
  113646. declare module BABYLON {
  113647. /**
  113648. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  113649. */
  113650. export class AttachToBoxBehavior implements Behavior<Mesh> {
  113651. private ui;
  113652. /**
  113653. * The name of the behavior
  113654. */
  113655. name: string;
  113656. /**
  113657. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  113658. */
  113659. distanceAwayFromFace: number;
  113660. /**
  113661. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  113662. */
  113663. distanceAwayFromBottomOfFace: number;
  113664. private _faceVectors;
  113665. private _target;
  113666. private _scene;
  113667. private _onRenderObserver;
  113668. private _tmpMatrix;
  113669. private _tmpVector;
  113670. /**
  113671. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  113672. * @param ui The transform node that should be attched to the mesh
  113673. */
  113674. constructor(ui: TransformNode);
  113675. /**
  113676. * Initializes the behavior
  113677. */
  113678. init(): void;
  113679. private _closestFace;
  113680. private _zeroVector;
  113681. private _lookAtTmpMatrix;
  113682. private _lookAtToRef;
  113683. /**
  113684. * Attaches the AttachToBoxBehavior to the passed in mesh
  113685. * @param target The mesh that the specified node will be attached to
  113686. */
  113687. attach(target: Mesh): void;
  113688. /**
  113689. * Detaches the behavior from the mesh
  113690. */
  113691. detach(): void;
  113692. }
  113693. }
  113694. declare module BABYLON {
  113695. /**
  113696. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  113697. */
  113698. export class FadeInOutBehavior implements Behavior<Mesh> {
  113699. /**
  113700. * Time in milliseconds to delay before fading in (Default: 0)
  113701. */
  113702. delay: number;
  113703. /**
  113704. * Time in milliseconds for the mesh to fade in (Default: 300)
  113705. */
  113706. fadeInTime: number;
  113707. private _millisecondsPerFrame;
  113708. private _hovered;
  113709. private _hoverValue;
  113710. private _ownerNode;
  113711. /**
  113712. * Instatiates the FadeInOutBehavior
  113713. */
  113714. constructor();
  113715. /**
  113716. * The name of the behavior
  113717. */
  113718. get name(): string;
  113719. /**
  113720. * Initializes the behavior
  113721. */
  113722. init(): void;
  113723. /**
  113724. * Attaches the fade behavior on the passed in mesh
  113725. * @param ownerNode The mesh that will be faded in/out once attached
  113726. */
  113727. attach(ownerNode: Mesh): void;
  113728. /**
  113729. * Detaches the behavior from the mesh
  113730. */
  113731. detach(): void;
  113732. /**
  113733. * Triggers the mesh to begin fading in or out
  113734. * @param value if the object should fade in or out (true to fade in)
  113735. */
  113736. fadeIn(value: boolean): void;
  113737. private _update;
  113738. private _setAllVisibility;
  113739. }
  113740. }
  113741. declare module BABYLON {
  113742. /**
  113743. * Class containing a set of static utilities functions for managing Pivots
  113744. * @hidden
  113745. */
  113746. export class PivotTools {
  113747. private static _PivotCached;
  113748. private static _OldPivotPoint;
  113749. private static _PivotTranslation;
  113750. private static _PivotTmpVector;
  113751. /** @hidden */
  113752. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  113753. /** @hidden */
  113754. static _RestorePivotPoint(mesh: AbstractMesh): void;
  113755. }
  113756. }
  113757. declare module BABYLON {
  113758. /**
  113759. * Class containing static functions to help procedurally build meshes
  113760. */
  113761. export class PlaneBuilder {
  113762. /**
  113763. * Creates a plane mesh
  113764. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  113765. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  113766. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  113767. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  113768. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  113769. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  113770. * @param name defines the name of the mesh
  113771. * @param options defines the options used to create the mesh
  113772. * @param scene defines the hosting scene
  113773. * @returns the plane mesh
  113774. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  113775. */
  113776. static CreatePlane(name: string, options: {
  113777. size?: number;
  113778. width?: number;
  113779. height?: number;
  113780. sideOrientation?: number;
  113781. frontUVs?: Vector4;
  113782. backUVs?: Vector4;
  113783. updatable?: boolean;
  113784. sourcePlane?: Plane;
  113785. }, scene?: Nullable<Scene>): Mesh;
  113786. }
  113787. }
  113788. declare module BABYLON {
  113789. /**
  113790. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  113791. */
  113792. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  113793. private static _AnyMouseID;
  113794. /**
  113795. * Abstract mesh the behavior is set on
  113796. */
  113797. attachedNode: AbstractMesh;
  113798. private _dragPlane;
  113799. private _scene;
  113800. private _pointerObserver;
  113801. private _beforeRenderObserver;
  113802. private static _planeScene;
  113803. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  113804. /**
  113805. * 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)
  113806. */
  113807. maxDragAngle: number;
  113808. /**
  113809. * @hidden
  113810. */
  113811. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  113812. /**
  113813. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  113814. */
  113815. currentDraggingPointerID: number;
  113816. /**
  113817. * The last position where the pointer hit the drag plane in world space
  113818. */
  113819. lastDragPosition: Vector3;
  113820. /**
  113821. * If the behavior is currently in a dragging state
  113822. */
  113823. dragging: boolean;
  113824. /**
  113825. * 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)
  113826. */
  113827. dragDeltaRatio: number;
  113828. /**
  113829. * If the drag plane orientation should be updated during the dragging (Default: true)
  113830. */
  113831. updateDragPlane: boolean;
  113832. private _debugMode;
  113833. private _moving;
  113834. /**
  113835. * Fires each time the attached mesh is dragged with the pointer
  113836. * * delta between last drag position and current drag position in world space
  113837. * * dragDistance along the drag axis
  113838. * * dragPlaneNormal normal of the current drag plane used during the drag
  113839. * * dragPlanePoint in world space where the drag intersects the drag plane
  113840. */
  113841. onDragObservable: Observable<{
  113842. delta: Vector3;
  113843. dragPlanePoint: Vector3;
  113844. dragPlaneNormal: Vector3;
  113845. dragDistance: number;
  113846. pointerId: number;
  113847. }>;
  113848. /**
  113849. * Fires each time a drag begins (eg. mouse down on mesh)
  113850. */
  113851. onDragStartObservable: Observable<{
  113852. dragPlanePoint: Vector3;
  113853. pointerId: number;
  113854. }>;
  113855. /**
  113856. * Fires each time a drag ends (eg. mouse release after drag)
  113857. */
  113858. onDragEndObservable: Observable<{
  113859. dragPlanePoint: Vector3;
  113860. pointerId: number;
  113861. }>;
  113862. /**
  113863. * If the attached mesh should be moved when dragged
  113864. */
  113865. moveAttached: boolean;
  113866. /**
  113867. * If the drag behavior will react to drag events (Default: true)
  113868. */
  113869. enabled: boolean;
  113870. /**
  113871. * If pointer events should start and release the drag (Default: true)
  113872. */
  113873. startAndReleaseDragOnPointerEvents: boolean;
  113874. /**
  113875. * If camera controls should be detached during the drag
  113876. */
  113877. detachCameraControls: boolean;
  113878. /**
  113879. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  113880. */
  113881. useObjectOrientationForDragging: boolean;
  113882. private _options;
  113883. /**
  113884. * Gets the options used by the behavior
  113885. */
  113886. get options(): {
  113887. dragAxis?: Vector3;
  113888. dragPlaneNormal?: Vector3;
  113889. };
  113890. /**
  113891. * Sets the options used by the behavior
  113892. */
  113893. set options(options: {
  113894. dragAxis?: Vector3;
  113895. dragPlaneNormal?: Vector3;
  113896. });
  113897. /**
  113898. * Creates a pointer drag behavior that can be attached to a mesh
  113899. * @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)
  113900. */
  113901. constructor(options?: {
  113902. dragAxis?: Vector3;
  113903. dragPlaneNormal?: Vector3;
  113904. });
  113905. /**
  113906. * Predicate to determine if it is valid to move the object to a new position when it is moved
  113907. */
  113908. validateDrag: (targetPosition: Vector3) => boolean;
  113909. /**
  113910. * The name of the behavior
  113911. */
  113912. get name(): string;
  113913. /**
  113914. * Initializes the behavior
  113915. */
  113916. init(): void;
  113917. private _tmpVector;
  113918. private _alternatePickedPoint;
  113919. private _worldDragAxis;
  113920. private _targetPosition;
  113921. private _attachedElement;
  113922. /**
  113923. * Attaches the drag behavior the passed in mesh
  113924. * @param ownerNode The mesh that will be dragged around once attached
  113925. * @param predicate Predicate to use for pick filtering
  113926. */
  113927. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  113928. /**
  113929. * Force relase the drag action by code.
  113930. */
  113931. releaseDrag(): void;
  113932. private _startDragRay;
  113933. private _lastPointerRay;
  113934. /**
  113935. * Simulates the start of a pointer drag event on the behavior
  113936. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  113937. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  113938. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  113939. */
  113940. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  113941. private _startDrag;
  113942. private _dragDelta;
  113943. private _moveDrag;
  113944. private _pickWithRayOnDragPlane;
  113945. private _pointA;
  113946. private _pointB;
  113947. private _pointC;
  113948. private _lineA;
  113949. private _lineB;
  113950. private _localAxis;
  113951. private _lookAt;
  113952. private _updateDragPlanePosition;
  113953. /**
  113954. * Detaches the behavior from the mesh
  113955. */
  113956. detach(): void;
  113957. }
  113958. }
  113959. declare module BABYLON {
  113960. /**
  113961. * A behavior that when attached to a mesh will allow the mesh to be scaled
  113962. */
  113963. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  113964. private _dragBehaviorA;
  113965. private _dragBehaviorB;
  113966. private _startDistance;
  113967. private _initialScale;
  113968. private _targetScale;
  113969. private _ownerNode;
  113970. private _sceneRenderObserver;
  113971. /**
  113972. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  113973. */
  113974. constructor();
  113975. /**
  113976. * The name of the behavior
  113977. */
  113978. get name(): string;
  113979. /**
  113980. * Initializes the behavior
  113981. */
  113982. init(): void;
  113983. private _getCurrentDistance;
  113984. /**
  113985. * Attaches the scale behavior the passed in mesh
  113986. * @param ownerNode The mesh that will be scaled around once attached
  113987. */
  113988. attach(ownerNode: Mesh): void;
  113989. /**
  113990. * Detaches the behavior from the mesh
  113991. */
  113992. detach(): void;
  113993. }
  113994. }
  113995. declare module BABYLON {
  113996. /**
  113997. * 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
  113998. */
  113999. export class SixDofDragBehavior implements Behavior<Mesh> {
  114000. private static _virtualScene;
  114001. private _ownerNode;
  114002. private _sceneRenderObserver;
  114003. private _scene;
  114004. private _targetPosition;
  114005. private _virtualOriginMesh;
  114006. private _virtualDragMesh;
  114007. private _pointerObserver;
  114008. private _moving;
  114009. private _startingOrientation;
  114010. private _attachedElement;
  114011. /**
  114012. * 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)
  114013. */
  114014. private zDragFactor;
  114015. /**
  114016. * If the object should rotate to face the drag origin
  114017. */
  114018. rotateDraggedObject: boolean;
  114019. /**
  114020. * If the behavior is currently in a dragging state
  114021. */
  114022. dragging: boolean;
  114023. /**
  114024. * 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)
  114025. */
  114026. dragDeltaRatio: number;
  114027. /**
  114028. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  114029. */
  114030. currentDraggingPointerID: number;
  114031. /**
  114032. * If camera controls should be detached during the drag
  114033. */
  114034. detachCameraControls: boolean;
  114035. /**
  114036. * Fires each time a drag starts
  114037. */
  114038. onDragStartObservable: Observable<{}>;
  114039. /**
  114040. * Fires each time a drag ends (eg. mouse release after drag)
  114041. */
  114042. onDragEndObservable: Observable<{}>;
  114043. /**
  114044. * 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
  114045. */
  114046. constructor();
  114047. /**
  114048. * The name of the behavior
  114049. */
  114050. get name(): string;
  114051. /**
  114052. * Initializes the behavior
  114053. */
  114054. init(): void;
  114055. /**
  114056. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  114057. */
  114058. private get _pointerCamera();
  114059. /**
  114060. * Attaches the scale behavior the passed in mesh
  114061. * @param ownerNode The mesh that will be scaled around once attached
  114062. */
  114063. attach(ownerNode: Mesh): void;
  114064. /**
  114065. * Detaches the behavior from the mesh
  114066. */
  114067. detach(): void;
  114068. }
  114069. }
  114070. declare module BABYLON {
  114071. /**
  114072. * Class used to apply inverse kinematics to bones
  114073. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  114074. */
  114075. export class BoneIKController {
  114076. private static _tmpVecs;
  114077. private static _tmpQuat;
  114078. private static _tmpMats;
  114079. /**
  114080. * Gets or sets the target mesh
  114081. */
  114082. targetMesh: AbstractMesh;
  114083. /** Gets or sets the mesh used as pole */
  114084. poleTargetMesh: AbstractMesh;
  114085. /**
  114086. * Gets or sets the bone used as pole
  114087. */
  114088. poleTargetBone: Nullable<Bone>;
  114089. /**
  114090. * Gets or sets the target position
  114091. */
  114092. targetPosition: Vector3;
  114093. /**
  114094. * Gets or sets the pole target position
  114095. */
  114096. poleTargetPosition: Vector3;
  114097. /**
  114098. * Gets or sets the pole target local offset
  114099. */
  114100. poleTargetLocalOffset: Vector3;
  114101. /**
  114102. * Gets or sets the pole angle
  114103. */
  114104. poleAngle: number;
  114105. /**
  114106. * Gets or sets the mesh associated with the controller
  114107. */
  114108. mesh: AbstractMesh;
  114109. /**
  114110. * 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)
  114111. */
  114112. slerpAmount: number;
  114113. private _bone1Quat;
  114114. private _bone1Mat;
  114115. private _bone2Ang;
  114116. private _bone1;
  114117. private _bone2;
  114118. private _bone1Length;
  114119. private _bone2Length;
  114120. private _maxAngle;
  114121. private _maxReach;
  114122. private _rightHandedSystem;
  114123. private _bendAxis;
  114124. private _slerping;
  114125. private _adjustRoll;
  114126. /**
  114127. * Gets or sets maximum allowed angle
  114128. */
  114129. get maxAngle(): number;
  114130. set maxAngle(value: number);
  114131. /**
  114132. * Creates a new BoneIKController
  114133. * @param mesh defines the mesh to control
  114134. * @param bone defines the bone to control
  114135. * @param options defines options to set up the controller
  114136. */
  114137. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  114138. targetMesh?: AbstractMesh;
  114139. poleTargetMesh?: AbstractMesh;
  114140. poleTargetBone?: Bone;
  114141. poleTargetLocalOffset?: Vector3;
  114142. poleAngle?: number;
  114143. bendAxis?: Vector3;
  114144. maxAngle?: number;
  114145. slerpAmount?: number;
  114146. });
  114147. private _setMaxAngle;
  114148. /**
  114149. * Force the controller to update the bones
  114150. */
  114151. update(): void;
  114152. }
  114153. }
  114154. declare module BABYLON {
  114155. /**
  114156. * Class used to make a bone look toward a point in space
  114157. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  114158. */
  114159. export class BoneLookController {
  114160. private static _tmpVecs;
  114161. private static _tmpQuat;
  114162. private static _tmpMats;
  114163. /**
  114164. * The target Vector3 that the bone will look at
  114165. */
  114166. target: Vector3;
  114167. /**
  114168. * The mesh that the bone is attached to
  114169. */
  114170. mesh: AbstractMesh;
  114171. /**
  114172. * The bone that will be looking to the target
  114173. */
  114174. bone: Bone;
  114175. /**
  114176. * The up axis of the coordinate system that is used when the bone is rotated
  114177. */
  114178. upAxis: Vector3;
  114179. /**
  114180. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  114181. */
  114182. upAxisSpace: Space;
  114183. /**
  114184. * Used to make an adjustment to the yaw of the bone
  114185. */
  114186. adjustYaw: number;
  114187. /**
  114188. * Used to make an adjustment to the pitch of the bone
  114189. */
  114190. adjustPitch: number;
  114191. /**
  114192. * Used to make an adjustment to the roll of the bone
  114193. */
  114194. adjustRoll: number;
  114195. /**
  114196. * 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)
  114197. */
  114198. slerpAmount: number;
  114199. private _minYaw;
  114200. private _maxYaw;
  114201. private _minPitch;
  114202. private _maxPitch;
  114203. private _minYawSin;
  114204. private _minYawCos;
  114205. private _maxYawSin;
  114206. private _maxYawCos;
  114207. private _midYawConstraint;
  114208. private _minPitchTan;
  114209. private _maxPitchTan;
  114210. private _boneQuat;
  114211. private _slerping;
  114212. private _transformYawPitch;
  114213. private _transformYawPitchInv;
  114214. private _firstFrameSkipped;
  114215. private _yawRange;
  114216. private _fowardAxis;
  114217. /**
  114218. * Gets or sets the minimum yaw angle that the bone can look to
  114219. */
  114220. get minYaw(): number;
  114221. set minYaw(value: number);
  114222. /**
  114223. * Gets or sets the maximum yaw angle that the bone can look to
  114224. */
  114225. get maxYaw(): number;
  114226. set maxYaw(value: number);
  114227. /**
  114228. * Gets or sets the minimum pitch angle that the bone can look to
  114229. */
  114230. get minPitch(): number;
  114231. set minPitch(value: number);
  114232. /**
  114233. * Gets or sets the maximum pitch angle that the bone can look to
  114234. */
  114235. get maxPitch(): number;
  114236. set maxPitch(value: number);
  114237. /**
  114238. * Create a BoneLookController
  114239. * @param mesh the mesh that the bone belongs to
  114240. * @param bone the bone that will be looking to the target
  114241. * @param target the target Vector3 to look at
  114242. * @param options optional settings:
  114243. * * maxYaw: the maximum angle the bone will yaw to
  114244. * * minYaw: the minimum angle the bone will yaw to
  114245. * * maxPitch: the maximum angle the bone will pitch to
  114246. * * minPitch: the minimum angle the bone will yaw to
  114247. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  114248. * * upAxis: the up axis of the coordinate system
  114249. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  114250. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  114251. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  114252. * * adjustYaw: used to make an adjustment to the yaw of the bone
  114253. * * adjustPitch: used to make an adjustment to the pitch of the bone
  114254. * * adjustRoll: used to make an adjustment to the roll of the bone
  114255. **/
  114256. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  114257. maxYaw?: number;
  114258. minYaw?: number;
  114259. maxPitch?: number;
  114260. minPitch?: number;
  114261. slerpAmount?: number;
  114262. upAxis?: Vector3;
  114263. upAxisSpace?: Space;
  114264. yawAxis?: Vector3;
  114265. pitchAxis?: Vector3;
  114266. adjustYaw?: number;
  114267. adjustPitch?: number;
  114268. adjustRoll?: number;
  114269. });
  114270. /**
  114271. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  114272. */
  114273. update(): void;
  114274. private _getAngleDiff;
  114275. private _getAngleBetween;
  114276. private _isAngleBetween;
  114277. }
  114278. }
  114279. declare module BABYLON {
  114280. /**
  114281. * Manage the gamepad inputs to control an arc rotate camera.
  114282. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  114283. */
  114284. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  114285. /**
  114286. * Defines the camera the input is attached to.
  114287. */
  114288. camera: ArcRotateCamera;
  114289. /**
  114290. * Defines the gamepad the input is gathering event from.
  114291. */
  114292. gamepad: Nullable<Gamepad>;
  114293. /**
  114294. * Defines the gamepad rotation sensiblity.
  114295. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  114296. */
  114297. gamepadRotationSensibility: number;
  114298. /**
  114299. * Defines the gamepad move sensiblity.
  114300. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  114301. */
  114302. gamepadMoveSensibility: number;
  114303. private _yAxisScale;
  114304. /**
  114305. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  114306. */
  114307. get invertYAxis(): boolean;
  114308. set invertYAxis(value: boolean);
  114309. private _onGamepadConnectedObserver;
  114310. private _onGamepadDisconnectedObserver;
  114311. /**
  114312. * Attach the input controls to a specific dom element to get the input from.
  114313. * @param element Defines the element the controls should be listened from
  114314. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  114315. */
  114316. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  114317. /**
  114318. * Detach the current controls from the specified dom element.
  114319. * @param element Defines the element to stop listening the inputs from
  114320. */
  114321. detachControl(element: Nullable<HTMLElement>): void;
  114322. /**
  114323. * Update the current camera state depending on the inputs that have been used this frame.
  114324. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  114325. */
  114326. checkInputs(): void;
  114327. /**
  114328. * Gets the class name of the current intput.
  114329. * @returns the class name
  114330. */
  114331. getClassName(): string;
  114332. /**
  114333. * Get the friendly name associated with the input class.
  114334. * @returns the input friendly name
  114335. */
  114336. getSimpleName(): string;
  114337. }
  114338. }
  114339. declare module BABYLON {
  114340. interface ArcRotateCameraInputsManager {
  114341. /**
  114342. * Add orientation input support to the input manager.
  114343. * @returns the current input manager
  114344. */
  114345. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  114346. }
  114347. /**
  114348. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  114349. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  114350. */
  114351. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  114352. /**
  114353. * Defines the camera the input is attached to.
  114354. */
  114355. camera: ArcRotateCamera;
  114356. /**
  114357. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  114358. */
  114359. alphaCorrection: number;
  114360. /**
  114361. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  114362. */
  114363. gammaCorrection: number;
  114364. private _alpha;
  114365. private _gamma;
  114366. private _dirty;
  114367. private _deviceOrientationHandler;
  114368. /**
  114369. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  114370. */
  114371. constructor();
  114372. /**
  114373. * Attach the input controls to a specific dom element to get the input from.
  114374. * @param element Defines the element the controls should be listened from
  114375. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  114376. */
  114377. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  114378. /** @hidden */
  114379. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  114380. /**
  114381. * Update the current camera state depending on the inputs that have been used this frame.
  114382. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  114383. */
  114384. checkInputs(): void;
  114385. /**
  114386. * Detach the current controls from the specified dom element.
  114387. * @param element Defines the element to stop listening the inputs from
  114388. */
  114389. detachControl(element: Nullable<HTMLElement>): void;
  114390. /**
  114391. * Gets the class name of the current intput.
  114392. * @returns the class name
  114393. */
  114394. getClassName(): string;
  114395. /**
  114396. * Get the friendly name associated with the input class.
  114397. * @returns the input friendly name
  114398. */
  114399. getSimpleName(): string;
  114400. }
  114401. }
  114402. declare module BABYLON {
  114403. /**
  114404. * Listen to mouse events to control the camera.
  114405. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  114406. */
  114407. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  114408. /**
  114409. * Defines the camera the input is attached to.
  114410. */
  114411. camera: FlyCamera;
  114412. /**
  114413. * Defines if touch is enabled. (Default is true.)
  114414. */
  114415. touchEnabled: boolean;
  114416. /**
  114417. * Defines the buttons associated with the input to handle camera rotation.
  114418. */
  114419. buttons: number[];
  114420. /**
  114421. * Assign buttons for Yaw control.
  114422. */
  114423. buttonsYaw: number[];
  114424. /**
  114425. * Assign buttons for Pitch control.
  114426. */
  114427. buttonsPitch: number[];
  114428. /**
  114429. * Assign buttons for Roll control.
  114430. */
  114431. buttonsRoll: number[];
  114432. /**
  114433. * Detect if any button is being pressed while mouse is moved.
  114434. * -1 = Mouse locked.
  114435. * 0 = Left button.
  114436. * 1 = Middle Button.
  114437. * 2 = Right Button.
  114438. */
  114439. activeButton: number;
  114440. /**
  114441. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  114442. * Higher values reduce its sensitivity.
  114443. */
  114444. angularSensibility: number;
  114445. private _mousemoveCallback;
  114446. private _observer;
  114447. private _rollObserver;
  114448. private previousPosition;
  114449. private noPreventDefault;
  114450. private element;
  114451. /**
  114452. * Listen to mouse events to control the camera.
  114453. * @param touchEnabled Define if touch is enabled. (Default is true.)
  114454. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  114455. */
  114456. constructor(touchEnabled?: boolean);
  114457. /**
  114458. * Attach the mouse control to the HTML DOM element.
  114459. * @param element Defines the element that listens to the input events.
  114460. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  114461. */
  114462. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  114463. /**
  114464. * Detach the current controls from the specified dom element.
  114465. * @param element Defines the element to stop listening the inputs from
  114466. */
  114467. detachControl(element: Nullable<HTMLElement>): void;
  114468. /**
  114469. * Gets the class name of the current input.
  114470. * @returns the class name.
  114471. */
  114472. getClassName(): string;
  114473. /**
  114474. * Get the friendly name associated with the input class.
  114475. * @returns the input's friendly name.
  114476. */
  114477. getSimpleName(): string;
  114478. private _pointerInput;
  114479. private _onMouseMove;
  114480. /**
  114481. * Rotate camera by mouse offset.
  114482. */
  114483. private rotateCamera;
  114484. }
  114485. }
  114486. declare module BABYLON {
  114487. /**
  114488. * Default Inputs manager for the FlyCamera.
  114489. * It groups all the default supported inputs for ease of use.
  114490. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  114491. */
  114492. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  114493. /**
  114494. * Instantiates a new FlyCameraInputsManager.
  114495. * @param camera Defines the camera the inputs belong to.
  114496. */
  114497. constructor(camera: FlyCamera);
  114498. /**
  114499. * Add keyboard input support to the input manager.
  114500. * @returns the new FlyCameraKeyboardMoveInput().
  114501. */
  114502. addKeyboard(): FlyCameraInputsManager;
  114503. /**
  114504. * Add mouse input support to the input manager.
  114505. * @param touchEnabled Enable touch screen support.
  114506. * @returns the new FlyCameraMouseInput().
  114507. */
  114508. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  114509. }
  114510. }
  114511. declare module BABYLON {
  114512. /**
  114513. * This is a flying camera, designed for 3D movement and rotation in all directions,
  114514. * such as in a 3D Space Shooter or a Flight Simulator.
  114515. */
  114516. export class FlyCamera extends TargetCamera {
  114517. /**
  114518. * Define the collision ellipsoid of the camera.
  114519. * This is helpful for simulating a camera body, like a player's body.
  114520. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  114521. */
  114522. ellipsoid: Vector3;
  114523. /**
  114524. * Define an offset for the position of the ellipsoid around the camera.
  114525. * This can be helpful if the camera is attached away from the player's body center,
  114526. * such as at its head.
  114527. */
  114528. ellipsoidOffset: Vector3;
  114529. /**
  114530. * Enable or disable collisions of the camera with the rest of the scene objects.
  114531. */
  114532. checkCollisions: boolean;
  114533. /**
  114534. * Enable or disable gravity on the camera.
  114535. */
  114536. applyGravity: boolean;
  114537. /**
  114538. * Define the current direction the camera is moving to.
  114539. */
  114540. cameraDirection: Vector3;
  114541. /**
  114542. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  114543. * This overrides and empties cameraRotation.
  114544. */
  114545. rotationQuaternion: Quaternion;
  114546. /**
  114547. * Track Roll to maintain the wanted Rolling when looking around.
  114548. */
  114549. _trackRoll: number;
  114550. /**
  114551. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  114552. */
  114553. rollCorrect: number;
  114554. /**
  114555. * Mimic a banked turn, Rolling the camera when Yawing.
  114556. * It's recommended to use rollCorrect = 10 for faster banking correction.
  114557. */
  114558. bankedTurn: boolean;
  114559. /**
  114560. * Limit in radians for how much Roll banking will add. (Default: 90°)
  114561. */
  114562. bankedTurnLimit: number;
  114563. /**
  114564. * Value of 0 disables the banked Roll.
  114565. * Value of 1 is equal to the Yaw angle in radians.
  114566. */
  114567. bankedTurnMultiplier: number;
  114568. /**
  114569. * The inputs manager loads all the input sources, such as keyboard and mouse.
  114570. */
  114571. inputs: FlyCameraInputsManager;
  114572. /**
  114573. * Gets the input sensibility for mouse input.
  114574. * Higher values reduce sensitivity.
  114575. */
  114576. get angularSensibility(): number;
  114577. /**
  114578. * Sets the input sensibility for a mouse input.
  114579. * Higher values reduce sensitivity.
  114580. */
  114581. set angularSensibility(value: number);
  114582. /**
  114583. * Get the keys for camera movement forward.
  114584. */
  114585. get keysForward(): number[];
  114586. /**
  114587. * Set the keys for camera movement forward.
  114588. */
  114589. set keysForward(value: number[]);
  114590. /**
  114591. * Get the keys for camera movement backward.
  114592. */
  114593. get keysBackward(): number[];
  114594. set keysBackward(value: number[]);
  114595. /**
  114596. * Get the keys for camera movement up.
  114597. */
  114598. get keysUp(): number[];
  114599. /**
  114600. * Set the keys for camera movement up.
  114601. */
  114602. set keysUp(value: number[]);
  114603. /**
  114604. * Get the keys for camera movement down.
  114605. */
  114606. get keysDown(): number[];
  114607. /**
  114608. * Set the keys for camera movement down.
  114609. */
  114610. set keysDown(value: number[]);
  114611. /**
  114612. * Get the keys for camera movement left.
  114613. */
  114614. get keysLeft(): number[];
  114615. /**
  114616. * Set the keys for camera movement left.
  114617. */
  114618. set keysLeft(value: number[]);
  114619. /**
  114620. * Set the keys for camera movement right.
  114621. */
  114622. get keysRight(): number[];
  114623. /**
  114624. * Set the keys for camera movement right.
  114625. */
  114626. set keysRight(value: number[]);
  114627. /**
  114628. * Event raised when the camera collides with a mesh in the scene.
  114629. */
  114630. onCollide: (collidedMesh: AbstractMesh) => void;
  114631. private _collider;
  114632. private _needMoveForGravity;
  114633. private _oldPosition;
  114634. private _diffPosition;
  114635. private _newPosition;
  114636. /** @hidden */
  114637. _localDirection: Vector3;
  114638. /** @hidden */
  114639. _transformedDirection: Vector3;
  114640. /**
  114641. * Instantiates a FlyCamera.
  114642. * This is a flying camera, designed for 3D movement and rotation in all directions,
  114643. * such as in a 3D Space Shooter or a Flight Simulator.
  114644. * @param name Define the name of the camera in the scene.
  114645. * @param position Define the starting position of the camera in the scene.
  114646. * @param scene Define the scene the camera belongs to.
  114647. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  114648. */
  114649. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  114650. /**
  114651. * Attach a control to the HTML DOM element.
  114652. * @param element Defines the element that listens to the input events.
  114653. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  114654. */
  114655. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  114656. /**
  114657. * Detach a control from the HTML DOM element.
  114658. * The camera will stop reacting to that input.
  114659. * @param element Defines the element that listens to the input events.
  114660. */
  114661. detachControl(element: HTMLElement): void;
  114662. private _collisionMask;
  114663. /**
  114664. * Get the mask that the camera ignores in collision events.
  114665. */
  114666. get collisionMask(): number;
  114667. /**
  114668. * Set the mask that the camera ignores in collision events.
  114669. */
  114670. set collisionMask(mask: number);
  114671. /** @hidden */
  114672. _collideWithWorld(displacement: Vector3): void;
  114673. /** @hidden */
  114674. private _onCollisionPositionChange;
  114675. /** @hidden */
  114676. _checkInputs(): void;
  114677. /** @hidden */
  114678. _decideIfNeedsToMove(): boolean;
  114679. /** @hidden */
  114680. _updatePosition(): void;
  114681. /**
  114682. * Restore the Roll to its target value at the rate specified.
  114683. * @param rate - Higher means slower restoring.
  114684. * @hidden
  114685. */
  114686. restoreRoll(rate: number): void;
  114687. /**
  114688. * Destroy the camera and release the current resources held by it.
  114689. */
  114690. dispose(): void;
  114691. /**
  114692. * Get the current object class name.
  114693. * @returns the class name.
  114694. */
  114695. getClassName(): string;
  114696. }
  114697. }
  114698. declare module BABYLON {
  114699. /**
  114700. * Listen to keyboard events to control the camera.
  114701. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  114702. */
  114703. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  114704. /**
  114705. * Defines the camera the input is attached to.
  114706. */
  114707. camera: FlyCamera;
  114708. /**
  114709. * The list of keyboard keys used to control the forward move of the camera.
  114710. */
  114711. keysForward: number[];
  114712. /**
  114713. * The list of keyboard keys used to control the backward move of the camera.
  114714. */
  114715. keysBackward: number[];
  114716. /**
  114717. * The list of keyboard keys used to control the forward move of the camera.
  114718. */
  114719. keysUp: number[];
  114720. /**
  114721. * The list of keyboard keys used to control the backward move of the camera.
  114722. */
  114723. keysDown: number[];
  114724. /**
  114725. * The list of keyboard keys used to control the right strafe move of the camera.
  114726. */
  114727. keysRight: number[];
  114728. /**
  114729. * The list of keyboard keys used to control the left strafe move of the camera.
  114730. */
  114731. keysLeft: number[];
  114732. private _keys;
  114733. private _onCanvasBlurObserver;
  114734. private _onKeyboardObserver;
  114735. private _engine;
  114736. private _scene;
  114737. /**
  114738. * Attach the input controls to a specific dom element to get the input from.
  114739. * @param element Defines the element the controls should be listened from
  114740. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  114741. */
  114742. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  114743. /**
  114744. * Detach the current controls from the specified dom element.
  114745. * @param element Defines the element to stop listening the inputs from
  114746. */
  114747. detachControl(element: Nullable<HTMLElement>): void;
  114748. /**
  114749. * Gets the class name of the current intput.
  114750. * @returns the class name
  114751. */
  114752. getClassName(): string;
  114753. /** @hidden */
  114754. _onLostFocus(e: FocusEvent): void;
  114755. /**
  114756. * Get the friendly name associated with the input class.
  114757. * @returns the input friendly name
  114758. */
  114759. getSimpleName(): string;
  114760. /**
  114761. * Update the current camera state depending on the inputs that have been used this frame.
  114762. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  114763. */
  114764. checkInputs(): void;
  114765. }
  114766. }
  114767. declare module BABYLON {
  114768. /**
  114769. * Manage the mouse wheel inputs to control a follow camera.
  114770. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  114771. */
  114772. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  114773. /**
  114774. * Defines the camera the input is attached to.
  114775. */
  114776. camera: FollowCamera;
  114777. /**
  114778. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  114779. */
  114780. axisControlRadius: boolean;
  114781. /**
  114782. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  114783. */
  114784. axisControlHeight: boolean;
  114785. /**
  114786. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  114787. */
  114788. axisControlRotation: boolean;
  114789. /**
  114790. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  114791. * relation to mouseWheel events.
  114792. */
  114793. wheelPrecision: number;
  114794. /**
  114795. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  114796. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  114797. */
  114798. wheelDeltaPercentage: number;
  114799. private _wheel;
  114800. private _observer;
  114801. /**
  114802. * Attach the input controls to a specific dom element to get the input from.
  114803. * @param element Defines the element the controls should be listened from
  114804. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  114805. */
  114806. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  114807. /**
  114808. * Detach the current controls from the specified dom element.
  114809. * @param element Defines the element to stop listening the inputs from
  114810. */
  114811. detachControl(element: Nullable<HTMLElement>): void;
  114812. /**
  114813. * Gets the class name of the current intput.
  114814. * @returns the class name
  114815. */
  114816. getClassName(): string;
  114817. /**
  114818. * Get the friendly name associated with the input class.
  114819. * @returns the input friendly name
  114820. */
  114821. getSimpleName(): string;
  114822. }
  114823. }
  114824. declare module BABYLON {
  114825. /**
  114826. * Manage the pointers inputs to control an follow camera.
  114827. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  114828. */
  114829. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  114830. /**
  114831. * Defines the camera the input is attached to.
  114832. */
  114833. camera: FollowCamera;
  114834. /**
  114835. * Gets the class name of the current input.
  114836. * @returns the class name
  114837. */
  114838. getClassName(): string;
  114839. /**
  114840. * Defines the pointer angular sensibility along the X axis or how fast is
  114841. * the camera rotating.
  114842. * A negative number will reverse the axis direction.
  114843. */
  114844. angularSensibilityX: number;
  114845. /**
  114846. * Defines the pointer angular sensibility along the Y axis or how fast is
  114847. * the camera rotating.
  114848. * A negative number will reverse the axis direction.
  114849. */
  114850. angularSensibilityY: number;
  114851. /**
  114852. * Defines the pointer pinch precision or how fast is the camera zooming.
  114853. * A negative number will reverse the axis direction.
  114854. */
  114855. pinchPrecision: number;
  114856. /**
  114857. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  114858. * from 0.
  114859. * It defines the percentage of current camera.radius to use as delta when
  114860. * pinch zoom is used.
  114861. */
  114862. pinchDeltaPercentage: number;
  114863. /**
  114864. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  114865. */
  114866. axisXControlRadius: boolean;
  114867. /**
  114868. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  114869. */
  114870. axisXControlHeight: boolean;
  114871. /**
  114872. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  114873. */
  114874. axisXControlRotation: boolean;
  114875. /**
  114876. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  114877. */
  114878. axisYControlRadius: boolean;
  114879. /**
  114880. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  114881. */
  114882. axisYControlHeight: boolean;
  114883. /**
  114884. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  114885. */
  114886. axisYControlRotation: boolean;
  114887. /**
  114888. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  114889. */
  114890. axisPinchControlRadius: boolean;
  114891. /**
  114892. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  114893. */
  114894. axisPinchControlHeight: boolean;
  114895. /**
  114896. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  114897. */
  114898. axisPinchControlRotation: boolean;
  114899. /**
  114900. * Log error messages if basic misconfiguration has occurred.
  114901. */
  114902. warningEnable: boolean;
  114903. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  114904. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  114905. private _warningCounter;
  114906. private _warning;
  114907. }
  114908. }
  114909. declare module BABYLON {
  114910. /**
  114911. * Default Inputs manager for the FollowCamera.
  114912. * It groups all the default supported inputs for ease of use.
  114913. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  114914. */
  114915. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  114916. /**
  114917. * Instantiates a new FollowCameraInputsManager.
  114918. * @param camera Defines the camera the inputs belong to
  114919. */
  114920. constructor(camera: FollowCamera);
  114921. /**
  114922. * Add keyboard input support to the input manager.
  114923. * @returns the current input manager
  114924. */
  114925. addKeyboard(): FollowCameraInputsManager;
  114926. /**
  114927. * Add mouse wheel input support to the input manager.
  114928. * @returns the current input manager
  114929. */
  114930. addMouseWheel(): FollowCameraInputsManager;
  114931. /**
  114932. * Add pointers input support to the input manager.
  114933. * @returns the current input manager
  114934. */
  114935. addPointers(): FollowCameraInputsManager;
  114936. /**
  114937. * Add orientation input support to the input manager.
  114938. * @returns the current input manager
  114939. */
  114940. addVRDeviceOrientation(): FollowCameraInputsManager;
  114941. }
  114942. }
  114943. declare module BABYLON {
  114944. /**
  114945. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  114946. * an arc rotate version arcFollowCamera are available.
  114947. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  114948. */
  114949. export class FollowCamera extends TargetCamera {
  114950. /**
  114951. * Distance the follow camera should follow an object at
  114952. */
  114953. radius: number;
  114954. /**
  114955. * Minimum allowed distance of the camera to the axis of rotation
  114956. * (The camera can not get closer).
  114957. * This can help limiting how the Camera is able to move in the scene.
  114958. */
  114959. lowerRadiusLimit: Nullable<number>;
  114960. /**
  114961. * Maximum allowed distance of the camera to the axis of rotation
  114962. * (The camera can not get further).
  114963. * This can help limiting how the Camera is able to move in the scene.
  114964. */
  114965. upperRadiusLimit: Nullable<number>;
  114966. /**
  114967. * Define a rotation offset between the camera and the object it follows
  114968. */
  114969. rotationOffset: number;
  114970. /**
  114971. * Minimum allowed angle to camera position relative to target object.
  114972. * This can help limiting how the Camera is able to move in the scene.
  114973. */
  114974. lowerRotationOffsetLimit: Nullable<number>;
  114975. /**
  114976. * Maximum allowed angle to camera position relative to target object.
  114977. * This can help limiting how the Camera is able to move in the scene.
  114978. */
  114979. upperRotationOffsetLimit: Nullable<number>;
  114980. /**
  114981. * Define a height offset between the camera and the object it follows.
  114982. * It can help following an object from the top (like a car chaing a plane)
  114983. */
  114984. heightOffset: number;
  114985. /**
  114986. * Minimum allowed height of camera position relative to target object.
  114987. * This can help limiting how the Camera is able to move in the scene.
  114988. */
  114989. lowerHeightOffsetLimit: Nullable<number>;
  114990. /**
  114991. * Maximum allowed height of camera position relative to target object.
  114992. * This can help limiting how the Camera is able to move in the scene.
  114993. */
  114994. upperHeightOffsetLimit: Nullable<number>;
  114995. /**
  114996. * Define how fast the camera can accelerate to follow it s target.
  114997. */
  114998. cameraAcceleration: number;
  114999. /**
  115000. * Define the speed limit of the camera following an object.
  115001. */
  115002. maxCameraSpeed: number;
  115003. /**
  115004. * Define the target of the camera.
  115005. */
  115006. lockedTarget: Nullable<AbstractMesh>;
  115007. /**
  115008. * Defines the input associated with the camera.
  115009. */
  115010. inputs: FollowCameraInputsManager;
  115011. /**
  115012. * Instantiates the follow camera.
  115013. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  115014. * @param name Define the name of the camera in the scene
  115015. * @param position Define the position of the camera
  115016. * @param scene Define the scene the camera belong to
  115017. * @param lockedTarget Define the target of the camera
  115018. */
  115019. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  115020. private _follow;
  115021. /**
  115022. * Attached controls to the current camera.
  115023. * @param element Defines the element the controls should be listened from
  115024. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  115025. */
  115026. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  115027. /**
  115028. * Detach the current controls from the camera.
  115029. * The camera will stop reacting to inputs.
  115030. * @param element Defines the element to stop listening the inputs from
  115031. */
  115032. detachControl(element: HTMLElement): void;
  115033. /** @hidden */
  115034. _checkInputs(): void;
  115035. private _checkLimits;
  115036. /**
  115037. * Gets the camera class name.
  115038. * @returns the class name
  115039. */
  115040. getClassName(): string;
  115041. }
  115042. /**
  115043. * Arc Rotate version of the follow camera.
  115044. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  115045. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  115046. */
  115047. export class ArcFollowCamera extends TargetCamera {
  115048. /** The longitudinal angle of the camera */
  115049. alpha: number;
  115050. /** The latitudinal angle of the camera */
  115051. beta: number;
  115052. /** The radius of the camera from its target */
  115053. radius: number;
  115054. /** Define the camera target (the messh it should follow) */
  115055. target: Nullable<AbstractMesh>;
  115056. private _cartesianCoordinates;
  115057. /**
  115058. * Instantiates a new ArcFollowCamera
  115059. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  115060. * @param name Define the name of the camera
  115061. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  115062. * @param beta Define the rotation angle of the camera around the elevation axis
  115063. * @param radius Define the radius of the camera from its target point
  115064. * @param target Define the target of the camera
  115065. * @param scene Define the scene the camera belongs to
  115066. */
  115067. constructor(name: string,
  115068. /** The longitudinal angle of the camera */
  115069. alpha: number,
  115070. /** The latitudinal angle of the camera */
  115071. beta: number,
  115072. /** The radius of the camera from its target */
  115073. radius: number,
  115074. /** Define the camera target (the messh it should follow) */
  115075. target: Nullable<AbstractMesh>, scene: Scene);
  115076. private _follow;
  115077. /** @hidden */
  115078. _checkInputs(): void;
  115079. /**
  115080. * Returns the class name of the object.
  115081. * It is mostly used internally for serialization purposes.
  115082. */
  115083. getClassName(): string;
  115084. }
  115085. }
  115086. declare module BABYLON {
  115087. /**
  115088. * Manage the keyboard inputs to control the movement of a follow camera.
  115089. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  115090. */
  115091. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  115092. /**
  115093. * Defines the camera the input is attached to.
  115094. */
  115095. camera: FollowCamera;
  115096. /**
  115097. * Defines the list of key codes associated with the up action (increase heightOffset)
  115098. */
  115099. keysHeightOffsetIncr: number[];
  115100. /**
  115101. * Defines the list of key codes associated with the down action (decrease heightOffset)
  115102. */
  115103. keysHeightOffsetDecr: number[];
  115104. /**
  115105. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  115106. */
  115107. keysHeightOffsetModifierAlt: boolean;
  115108. /**
  115109. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  115110. */
  115111. keysHeightOffsetModifierCtrl: boolean;
  115112. /**
  115113. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  115114. */
  115115. keysHeightOffsetModifierShift: boolean;
  115116. /**
  115117. * Defines the list of key codes associated with the left action (increase rotationOffset)
  115118. */
  115119. keysRotationOffsetIncr: number[];
  115120. /**
  115121. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  115122. */
  115123. keysRotationOffsetDecr: number[];
  115124. /**
  115125. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  115126. */
  115127. keysRotationOffsetModifierAlt: boolean;
  115128. /**
  115129. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  115130. */
  115131. keysRotationOffsetModifierCtrl: boolean;
  115132. /**
  115133. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  115134. */
  115135. keysRotationOffsetModifierShift: boolean;
  115136. /**
  115137. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  115138. */
  115139. keysRadiusIncr: number[];
  115140. /**
  115141. * Defines the list of key codes associated with the zoom-out action (increase radius)
  115142. */
  115143. keysRadiusDecr: number[];
  115144. /**
  115145. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  115146. */
  115147. keysRadiusModifierAlt: boolean;
  115148. /**
  115149. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  115150. */
  115151. keysRadiusModifierCtrl: boolean;
  115152. /**
  115153. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  115154. */
  115155. keysRadiusModifierShift: boolean;
  115156. /**
  115157. * Defines the rate of change of heightOffset.
  115158. */
  115159. heightSensibility: number;
  115160. /**
  115161. * Defines the rate of change of rotationOffset.
  115162. */
  115163. rotationSensibility: number;
  115164. /**
  115165. * Defines the rate of change of radius.
  115166. */
  115167. radiusSensibility: number;
  115168. private _keys;
  115169. private _ctrlPressed;
  115170. private _altPressed;
  115171. private _shiftPressed;
  115172. private _onCanvasBlurObserver;
  115173. private _onKeyboardObserver;
  115174. private _engine;
  115175. private _scene;
  115176. /**
  115177. * Attach the input controls to a specific dom element to get the input from.
  115178. * @param element Defines the element the controls should be listened from
  115179. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  115180. */
  115181. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  115182. /**
  115183. * Detach the current controls from the specified dom element.
  115184. * @param element Defines the element to stop listening the inputs from
  115185. */
  115186. detachControl(element: Nullable<HTMLElement>): void;
  115187. /**
  115188. * Update the current camera state depending on the inputs that have been used this frame.
  115189. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  115190. */
  115191. checkInputs(): void;
  115192. /**
  115193. * Gets the class name of the current input.
  115194. * @returns the class name
  115195. */
  115196. getClassName(): string;
  115197. /**
  115198. * Get the friendly name associated with the input class.
  115199. * @returns the input friendly name
  115200. */
  115201. getSimpleName(): string;
  115202. /**
  115203. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  115204. * allow modification of the heightOffset value.
  115205. */
  115206. private _modifierHeightOffset;
  115207. /**
  115208. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  115209. * allow modification of the rotationOffset value.
  115210. */
  115211. private _modifierRotationOffset;
  115212. /**
  115213. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  115214. * allow modification of the radius value.
  115215. */
  115216. private _modifierRadius;
  115217. }
  115218. }
  115219. declare module BABYLON {
  115220. interface FreeCameraInputsManager {
  115221. /**
  115222. * @hidden
  115223. */
  115224. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  115225. /**
  115226. * Add orientation input support to the input manager.
  115227. * @returns the current input manager
  115228. */
  115229. addDeviceOrientation(): FreeCameraInputsManager;
  115230. }
  115231. /**
  115232. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  115233. * Screen rotation is taken into account.
  115234. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  115235. */
  115236. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  115237. private _camera;
  115238. private _screenOrientationAngle;
  115239. private _constantTranform;
  115240. private _screenQuaternion;
  115241. private _alpha;
  115242. private _beta;
  115243. private _gamma;
  115244. /**
  115245. * Can be used to detect if a device orientation sensor is available on a device
  115246. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  115247. * @returns a promise that will resolve on orientation change
  115248. */
  115249. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  115250. /**
  115251. * @hidden
  115252. */
  115253. _onDeviceOrientationChangedObservable: Observable<void>;
  115254. /**
  115255. * Instantiates a new input
  115256. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  115257. */
  115258. constructor();
  115259. /**
  115260. * Define the camera controlled by the input.
  115261. */
  115262. get camera(): FreeCamera;
  115263. set camera(camera: FreeCamera);
  115264. /**
  115265. * Attach the input controls to a specific dom element to get the input from.
  115266. * @param element Defines the element the controls should be listened from
  115267. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  115268. */
  115269. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  115270. private _orientationChanged;
  115271. private _deviceOrientation;
  115272. /**
  115273. * Detach the current controls from the specified dom element.
  115274. * @param element Defines the element to stop listening the inputs from
  115275. */
  115276. detachControl(element: Nullable<HTMLElement>): void;
  115277. /**
  115278. * Update the current camera state depending on the inputs that have been used this frame.
  115279. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  115280. */
  115281. checkInputs(): void;
  115282. /**
  115283. * Gets the class name of the current intput.
  115284. * @returns the class name
  115285. */
  115286. getClassName(): string;
  115287. /**
  115288. * Get the friendly name associated with the input class.
  115289. * @returns the input friendly name
  115290. */
  115291. getSimpleName(): string;
  115292. }
  115293. }
  115294. declare module BABYLON {
  115295. /**
  115296. * Manage the gamepad inputs to control a free camera.
  115297. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  115298. */
  115299. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  115300. /**
  115301. * Define the camera the input is attached to.
  115302. */
  115303. camera: FreeCamera;
  115304. /**
  115305. * Define the Gamepad controlling the input
  115306. */
  115307. gamepad: Nullable<Gamepad>;
  115308. /**
  115309. * Defines the gamepad rotation sensiblity.
  115310. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  115311. */
  115312. gamepadAngularSensibility: number;
  115313. /**
  115314. * Defines the gamepad move sensiblity.
  115315. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  115316. */
  115317. gamepadMoveSensibility: number;
  115318. private _yAxisScale;
  115319. /**
  115320. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  115321. */
  115322. get invertYAxis(): boolean;
  115323. set invertYAxis(value: boolean);
  115324. private _onGamepadConnectedObserver;
  115325. private _onGamepadDisconnectedObserver;
  115326. private _cameraTransform;
  115327. private _deltaTransform;
  115328. private _vector3;
  115329. private _vector2;
  115330. /**
  115331. * Attach the input controls to a specific dom element to get the input from.
  115332. * @param element Defines the element the controls should be listened from
  115333. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  115334. */
  115335. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  115336. /**
  115337. * Detach the current controls from the specified dom element.
  115338. * @param element Defines the element to stop listening the inputs from
  115339. */
  115340. detachControl(element: Nullable<HTMLElement>): void;
  115341. /**
  115342. * Update the current camera state depending on the inputs that have been used this frame.
  115343. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  115344. */
  115345. checkInputs(): void;
  115346. /**
  115347. * Gets the class name of the current intput.
  115348. * @returns the class name
  115349. */
  115350. getClassName(): string;
  115351. /**
  115352. * Get the friendly name associated with the input class.
  115353. * @returns the input friendly name
  115354. */
  115355. getSimpleName(): string;
  115356. }
  115357. }
  115358. declare module BABYLON {
  115359. /**
  115360. * Defines the potential axis of a Joystick
  115361. */
  115362. export enum JoystickAxis {
  115363. /** X axis */
  115364. X = 0,
  115365. /** Y axis */
  115366. Y = 1,
  115367. /** Z axis */
  115368. Z = 2
  115369. }
  115370. /**
  115371. * Class used to define virtual joystick (used in touch mode)
  115372. */
  115373. export class VirtualJoystick {
  115374. /**
  115375. * Gets or sets a boolean indicating that left and right values must be inverted
  115376. */
  115377. reverseLeftRight: boolean;
  115378. /**
  115379. * Gets or sets a boolean indicating that up and down values must be inverted
  115380. */
  115381. reverseUpDown: boolean;
  115382. /**
  115383. * Gets the offset value for the position (ie. the change of the position value)
  115384. */
  115385. deltaPosition: Vector3;
  115386. /**
  115387. * Gets a boolean indicating if the virtual joystick was pressed
  115388. */
  115389. pressed: boolean;
  115390. /**
  115391. * Canvas the virtual joystick will render onto, default z-index of this is 5
  115392. */
  115393. static Canvas: Nullable<HTMLCanvasElement>;
  115394. private static _globalJoystickIndex;
  115395. private static vjCanvasContext;
  115396. private static vjCanvasWidth;
  115397. private static vjCanvasHeight;
  115398. private static halfWidth;
  115399. private _action;
  115400. private _axisTargetedByLeftAndRight;
  115401. private _axisTargetedByUpAndDown;
  115402. private _joystickSensibility;
  115403. private _inversedSensibility;
  115404. private _joystickPointerID;
  115405. private _joystickColor;
  115406. private _joystickPointerPos;
  115407. private _joystickPreviousPointerPos;
  115408. private _joystickPointerStartPos;
  115409. private _deltaJoystickVector;
  115410. private _leftJoystick;
  115411. private _touches;
  115412. private _onPointerDownHandlerRef;
  115413. private _onPointerMoveHandlerRef;
  115414. private _onPointerUpHandlerRef;
  115415. private _onResize;
  115416. /**
  115417. * Creates a new virtual joystick
  115418. * @param leftJoystick defines that the joystick is for left hand (false by default)
  115419. */
  115420. constructor(leftJoystick?: boolean);
  115421. /**
  115422. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  115423. * @param newJoystickSensibility defines the new sensibility
  115424. */
  115425. setJoystickSensibility(newJoystickSensibility: number): void;
  115426. private _onPointerDown;
  115427. private _onPointerMove;
  115428. private _onPointerUp;
  115429. /**
  115430. * Change the color of the virtual joystick
  115431. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  115432. */
  115433. setJoystickColor(newColor: string): void;
  115434. /**
  115435. * Defines a callback to call when the joystick is touched
  115436. * @param action defines the callback
  115437. */
  115438. setActionOnTouch(action: () => any): void;
  115439. /**
  115440. * Defines which axis you'd like to control for left & right
  115441. * @param axis defines the axis to use
  115442. */
  115443. setAxisForLeftRight(axis: JoystickAxis): void;
  115444. /**
  115445. * Defines which axis you'd like to control for up & down
  115446. * @param axis defines the axis to use
  115447. */
  115448. setAxisForUpDown(axis: JoystickAxis): void;
  115449. private _drawVirtualJoystick;
  115450. /**
  115451. * Release internal HTML canvas
  115452. */
  115453. releaseCanvas(): void;
  115454. }
  115455. }
  115456. declare module BABYLON {
  115457. interface FreeCameraInputsManager {
  115458. /**
  115459. * Add virtual joystick input support to the input manager.
  115460. * @returns the current input manager
  115461. */
  115462. addVirtualJoystick(): FreeCameraInputsManager;
  115463. }
  115464. /**
  115465. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  115466. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  115467. */
  115468. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  115469. /**
  115470. * Defines the camera the input is attached to.
  115471. */
  115472. camera: FreeCamera;
  115473. private _leftjoystick;
  115474. private _rightjoystick;
  115475. /**
  115476. * Gets the left stick of the virtual joystick.
  115477. * @returns The virtual Joystick
  115478. */
  115479. getLeftJoystick(): VirtualJoystick;
  115480. /**
  115481. * Gets the right stick of the virtual joystick.
  115482. * @returns The virtual Joystick
  115483. */
  115484. getRightJoystick(): VirtualJoystick;
  115485. /**
  115486. * Update the current camera state depending on the inputs that have been used this frame.
  115487. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  115488. */
  115489. checkInputs(): void;
  115490. /**
  115491. * Attach the input controls to a specific dom element to get the input from.
  115492. * @param element Defines the element the controls should be listened from
  115493. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  115494. */
  115495. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  115496. /**
  115497. * Detach the current controls from the specified dom element.
  115498. * @param element Defines the element to stop listening the inputs from
  115499. */
  115500. detachControl(element: Nullable<HTMLElement>): void;
  115501. /**
  115502. * Gets the class name of the current intput.
  115503. * @returns the class name
  115504. */
  115505. getClassName(): string;
  115506. /**
  115507. * Get the friendly name associated with the input class.
  115508. * @returns the input friendly name
  115509. */
  115510. getSimpleName(): string;
  115511. }
  115512. }
  115513. declare module BABYLON {
  115514. /**
  115515. * This represents a FPS type of camera controlled by touch.
  115516. * This is like a universal camera minus the Gamepad controls.
  115517. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  115518. */
  115519. export class TouchCamera extends FreeCamera {
  115520. /**
  115521. * Defines the touch sensibility for rotation.
  115522. * The higher the faster.
  115523. */
  115524. get touchAngularSensibility(): number;
  115525. set touchAngularSensibility(value: number);
  115526. /**
  115527. * Defines the touch sensibility for move.
  115528. * The higher the faster.
  115529. */
  115530. get touchMoveSensibility(): number;
  115531. set touchMoveSensibility(value: number);
  115532. /**
  115533. * Instantiates a new touch camera.
  115534. * This represents a FPS type of camera controlled by touch.
  115535. * This is like a universal camera minus the Gamepad controls.
  115536. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  115537. * @param name Define the name of the camera in the scene
  115538. * @param position Define the start position of the camera in the scene
  115539. * @param scene Define the scene the camera belongs to
  115540. */
  115541. constructor(name: string, position: Vector3, scene: Scene);
  115542. /**
  115543. * Gets the current object class name.
  115544. * @return the class name
  115545. */
  115546. getClassName(): string;
  115547. /** @hidden */
  115548. _setupInputs(): void;
  115549. }
  115550. }
  115551. declare module BABYLON {
  115552. /**
  115553. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  115554. * being tilted forward or back and left or right.
  115555. */
  115556. export class DeviceOrientationCamera extends FreeCamera {
  115557. private _initialQuaternion;
  115558. private _quaternionCache;
  115559. private _tmpDragQuaternion;
  115560. private _disablePointerInputWhenUsingDeviceOrientation;
  115561. /**
  115562. * Creates a new device orientation camera
  115563. * @param name The name of the camera
  115564. * @param position The start position camera
  115565. * @param scene The scene the camera belongs to
  115566. */
  115567. constructor(name: string, position: Vector3, scene: Scene);
  115568. /**
  115569. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  115570. */
  115571. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  115572. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  115573. private _dragFactor;
  115574. /**
  115575. * Enabled turning on the y axis when the orientation sensor is active
  115576. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  115577. */
  115578. enableHorizontalDragging(dragFactor?: number): void;
  115579. /**
  115580. * Gets the current instance class name ("DeviceOrientationCamera").
  115581. * This helps avoiding instanceof at run time.
  115582. * @returns the class name
  115583. */
  115584. getClassName(): string;
  115585. /**
  115586. * @hidden
  115587. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  115588. */
  115589. _checkInputs(): void;
  115590. /**
  115591. * Reset the camera to its default orientation on the specified axis only.
  115592. * @param axis The axis to reset
  115593. */
  115594. resetToCurrentRotation(axis?: Axis): void;
  115595. }
  115596. }
  115597. declare module BABYLON {
  115598. /**
  115599. * Defines supported buttons for XBox360 compatible gamepads
  115600. */
  115601. export enum Xbox360Button {
  115602. /** A */
  115603. A = 0,
  115604. /** B */
  115605. B = 1,
  115606. /** X */
  115607. X = 2,
  115608. /** Y */
  115609. Y = 3,
  115610. /** Left button */
  115611. LB = 4,
  115612. /** Right button */
  115613. RB = 5,
  115614. /** Back */
  115615. Back = 8,
  115616. /** Start */
  115617. Start = 9,
  115618. /** Left stick */
  115619. LeftStick = 10,
  115620. /** Right stick */
  115621. RightStick = 11
  115622. }
  115623. /** Defines values for XBox360 DPad */
  115624. export enum Xbox360Dpad {
  115625. /** Up */
  115626. Up = 12,
  115627. /** Down */
  115628. Down = 13,
  115629. /** Left */
  115630. Left = 14,
  115631. /** Right */
  115632. Right = 15
  115633. }
  115634. /**
  115635. * Defines a XBox360 gamepad
  115636. */
  115637. export class Xbox360Pad extends Gamepad {
  115638. private _leftTrigger;
  115639. private _rightTrigger;
  115640. private _onlefttriggerchanged;
  115641. private _onrighttriggerchanged;
  115642. private _onbuttondown;
  115643. private _onbuttonup;
  115644. private _ondpaddown;
  115645. private _ondpadup;
  115646. /** Observable raised when a button is pressed */
  115647. onButtonDownObservable: Observable<Xbox360Button>;
  115648. /** Observable raised when a button is released */
  115649. onButtonUpObservable: Observable<Xbox360Button>;
  115650. /** Observable raised when a pad is pressed */
  115651. onPadDownObservable: Observable<Xbox360Dpad>;
  115652. /** Observable raised when a pad is released */
  115653. onPadUpObservable: Observable<Xbox360Dpad>;
  115654. private _buttonA;
  115655. private _buttonB;
  115656. private _buttonX;
  115657. private _buttonY;
  115658. private _buttonBack;
  115659. private _buttonStart;
  115660. private _buttonLB;
  115661. private _buttonRB;
  115662. private _buttonLeftStick;
  115663. private _buttonRightStick;
  115664. private _dPadUp;
  115665. private _dPadDown;
  115666. private _dPadLeft;
  115667. private _dPadRight;
  115668. private _isXboxOnePad;
  115669. /**
  115670. * Creates a new XBox360 gamepad object
  115671. * @param id defines the id of this gamepad
  115672. * @param index defines its index
  115673. * @param gamepad defines the internal HTML gamepad object
  115674. * @param xboxOne defines if it is a XBox One gamepad
  115675. */
  115676. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  115677. /**
  115678. * Defines the callback to call when left trigger is pressed
  115679. * @param callback defines the callback to use
  115680. */
  115681. onlefttriggerchanged(callback: (value: number) => void): void;
  115682. /**
  115683. * Defines the callback to call when right trigger is pressed
  115684. * @param callback defines the callback to use
  115685. */
  115686. onrighttriggerchanged(callback: (value: number) => void): void;
  115687. /**
  115688. * Gets the left trigger value
  115689. */
  115690. get leftTrigger(): number;
  115691. /**
  115692. * Sets the left trigger value
  115693. */
  115694. set leftTrigger(newValue: number);
  115695. /**
  115696. * Gets the right trigger value
  115697. */
  115698. get rightTrigger(): number;
  115699. /**
  115700. * Sets the right trigger value
  115701. */
  115702. set rightTrigger(newValue: number);
  115703. /**
  115704. * Defines the callback to call when a button is pressed
  115705. * @param callback defines the callback to use
  115706. */
  115707. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  115708. /**
  115709. * Defines the callback to call when a button is released
  115710. * @param callback defines the callback to use
  115711. */
  115712. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  115713. /**
  115714. * Defines the callback to call when a pad is pressed
  115715. * @param callback defines the callback to use
  115716. */
  115717. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  115718. /**
  115719. * Defines the callback to call when a pad is released
  115720. * @param callback defines the callback to use
  115721. */
  115722. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  115723. private _setButtonValue;
  115724. private _setDPadValue;
  115725. /**
  115726. * Gets the value of the `A` button
  115727. */
  115728. get buttonA(): number;
  115729. /**
  115730. * Sets the value of the `A` button
  115731. */
  115732. set buttonA(value: number);
  115733. /**
  115734. * Gets the value of the `B` button
  115735. */
  115736. get buttonB(): number;
  115737. /**
  115738. * Sets the value of the `B` button
  115739. */
  115740. set buttonB(value: number);
  115741. /**
  115742. * Gets the value of the `X` button
  115743. */
  115744. get buttonX(): number;
  115745. /**
  115746. * Sets the value of the `X` button
  115747. */
  115748. set buttonX(value: number);
  115749. /**
  115750. * Gets the value of the `Y` button
  115751. */
  115752. get buttonY(): number;
  115753. /**
  115754. * Sets the value of the `Y` button
  115755. */
  115756. set buttonY(value: number);
  115757. /**
  115758. * Gets the value of the `Start` button
  115759. */
  115760. get buttonStart(): number;
  115761. /**
  115762. * Sets the value of the `Start` button
  115763. */
  115764. set buttonStart(value: number);
  115765. /**
  115766. * Gets the value of the `Back` button
  115767. */
  115768. get buttonBack(): number;
  115769. /**
  115770. * Sets the value of the `Back` button
  115771. */
  115772. set buttonBack(value: number);
  115773. /**
  115774. * Gets the value of the `Left` button
  115775. */
  115776. get buttonLB(): number;
  115777. /**
  115778. * Sets the value of the `Left` button
  115779. */
  115780. set buttonLB(value: number);
  115781. /**
  115782. * Gets the value of the `Right` button
  115783. */
  115784. get buttonRB(): number;
  115785. /**
  115786. * Sets the value of the `Right` button
  115787. */
  115788. set buttonRB(value: number);
  115789. /**
  115790. * Gets the value of the Left joystick
  115791. */
  115792. get buttonLeftStick(): number;
  115793. /**
  115794. * Sets the value of the Left joystick
  115795. */
  115796. set buttonLeftStick(value: number);
  115797. /**
  115798. * Gets the value of the Right joystick
  115799. */
  115800. get buttonRightStick(): number;
  115801. /**
  115802. * Sets the value of the Right joystick
  115803. */
  115804. set buttonRightStick(value: number);
  115805. /**
  115806. * Gets the value of D-pad up
  115807. */
  115808. get dPadUp(): number;
  115809. /**
  115810. * Sets the value of D-pad up
  115811. */
  115812. set dPadUp(value: number);
  115813. /**
  115814. * Gets the value of D-pad down
  115815. */
  115816. get dPadDown(): number;
  115817. /**
  115818. * Sets the value of D-pad down
  115819. */
  115820. set dPadDown(value: number);
  115821. /**
  115822. * Gets the value of D-pad left
  115823. */
  115824. get dPadLeft(): number;
  115825. /**
  115826. * Sets the value of D-pad left
  115827. */
  115828. set dPadLeft(value: number);
  115829. /**
  115830. * Gets the value of D-pad right
  115831. */
  115832. get dPadRight(): number;
  115833. /**
  115834. * Sets the value of D-pad right
  115835. */
  115836. set dPadRight(value: number);
  115837. /**
  115838. * Force the gamepad to synchronize with device values
  115839. */
  115840. update(): void;
  115841. /**
  115842. * Disposes the gamepad
  115843. */
  115844. dispose(): void;
  115845. }
  115846. }
  115847. declare module BABYLON {
  115848. /**
  115849. * Defines supported buttons for DualShock compatible gamepads
  115850. */
  115851. export enum DualShockButton {
  115852. /** Cross */
  115853. Cross = 0,
  115854. /** Circle */
  115855. Circle = 1,
  115856. /** Square */
  115857. Square = 2,
  115858. /** Triangle */
  115859. Triangle = 3,
  115860. /** L1 */
  115861. L1 = 4,
  115862. /** R1 */
  115863. R1 = 5,
  115864. /** Share */
  115865. Share = 8,
  115866. /** Options */
  115867. Options = 9,
  115868. /** Left stick */
  115869. LeftStick = 10,
  115870. /** Right stick */
  115871. RightStick = 11
  115872. }
  115873. /** Defines values for DualShock DPad */
  115874. export enum DualShockDpad {
  115875. /** Up */
  115876. Up = 12,
  115877. /** Down */
  115878. Down = 13,
  115879. /** Left */
  115880. Left = 14,
  115881. /** Right */
  115882. Right = 15
  115883. }
  115884. /**
  115885. * Defines a DualShock gamepad
  115886. */
  115887. export class DualShockPad extends Gamepad {
  115888. private _leftTrigger;
  115889. private _rightTrigger;
  115890. private _onlefttriggerchanged;
  115891. private _onrighttriggerchanged;
  115892. private _onbuttondown;
  115893. private _onbuttonup;
  115894. private _ondpaddown;
  115895. private _ondpadup;
  115896. /** Observable raised when a button is pressed */
  115897. onButtonDownObservable: Observable<DualShockButton>;
  115898. /** Observable raised when a button is released */
  115899. onButtonUpObservable: Observable<DualShockButton>;
  115900. /** Observable raised when a pad is pressed */
  115901. onPadDownObservable: Observable<DualShockDpad>;
  115902. /** Observable raised when a pad is released */
  115903. onPadUpObservable: Observable<DualShockDpad>;
  115904. private _buttonCross;
  115905. private _buttonCircle;
  115906. private _buttonSquare;
  115907. private _buttonTriangle;
  115908. private _buttonShare;
  115909. private _buttonOptions;
  115910. private _buttonL1;
  115911. private _buttonR1;
  115912. private _buttonLeftStick;
  115913. private _buttonRightStick;
  115914. private _dPadUp;
  115915. private _dPadDown;
  115916. private _dPadLeft;
  115917. private _dPadRight;
  115918. /**
  115919. * Creates a new DualShock gamepad object
  115920. * @param id defines the id of this gamepad
  115921. * @param index defines its index
  115922. * @param gamepad defines the internal HTML gamepad object
  115923. */
  115924. constructor(id: string, index: number, gamepad: any);
  115925. /**
  115926. * Defines the callback to call when left trigger is pressed
  115927. * @param callback defines the callback to use
  115928. */
  115929. onlefttriggerchanged(callback: (value: number) => void): void;
  115930. /**
  115931. * Defines the callback to call when right trigger is pressed
  115932. * @param callback defines the callback to use
  115933. */
  115934. onrighttriggerchanged(callback: (value: number) => void): void;
  115935. /**
  115936. * Gets the left trigger value
  115937. */
  115938. get leftTrigger(): number;
  115939. /**
  115940. * Sets the left trigger value
  115941. */
  115942. set leftTrigger(newValue: number);
  115943. /**
  115944. * Gets the right trigger value
  115945. */
  115946. get rightTrigger(): number;
  115947. /**
  115948. * Sets the right trigger value
  115949. */
  115950. set rightTrigger(newValue: number);
  115951. /**
  115952. * Defines the callback to call when a button is pressed
  115953. * @param callback defines the callback to use
  115954. */
  115955. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  115956. /**
  115957. * Defines the callback to call when a button is released
  115958. * @param callback defines the callback to use
  115959. */
  115960. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  115961. /**
  115962. * Defines the callback to call when a pad is pressed
  115963. * @param callback defines the callback to use
  115964. */
  115965. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  115966. /**
  115967. * Defines the callback to call when a pad is released
  115968. * @param callback defines the callback to use
  115969. */
  115970. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  115971. private _setButtonValue;
  115972. private _setDPadValue;
  115973. /**
  115974. * Gets the value of the `Cross` button
  115975. */
  115976. get buttonCross(): number;
  115977. /**
  115978. * Sets the value of the `Cross` button
  115979. */
  115980. set buttonCross(value: number);
  115981. /**
  115982. * Gets the value of the `Circle` button
  115983. */
  115984. get buttonCircle(): number;
  115985. /**
  115986. * Sets the value of the `Circle` button
  115987. */
  115988. set buttonCircle(value: number);
  115989. /**
  115990. * Gets the value of the `Square` button
  115991. */
  115992. get buttonSquare(): number;
  115993. /**
  115994. * Sets the value of the `Square` button
  115995. */
  115996. set buttonSquare(value: number);
  115997. /**
  115998. * Gets the value of the `Triangle` button
  115999. */
  116000. get buttonTriangle(): number;
  116001. /**
  116002. * Sets the value of the `Triangle` button
  116003. */
  116004. set buttonTriangle(value: number);
  116005. /**
  116006. * Gets the value of the `Options` button
  116007. */
  116008. get buttonOptions(): number;
  116009. /**
  116010. * Sets the value of the `Options` button
  116011. */
  116012. set buttonOptions(value: number);
  116013. /**
  116014. * Gets the value of the `Share` button
  116015. */
  116016. get buttonShare(): number;
  116017. /**
  116018. * Sets the value of the `Share` button
  116019. */
  116020. set buttonShare(value: number);
  116021. /**
  116022. * Gets the value of the `L1` button
  116023. */
  116024. get buttonL1(): number;
  116025. /**
  116026. * Sets the value of the `L1` button
  116027. */
  116028. set buttonL1(value: number);
  116029. /**
  116030. * Gets the value of the `R1` button
  116031. */
  116032. get buttonR1(): number;
  116033. /**
  116034. * Sets the value of the `R1` button
  116035. */
  116036. set buttonR1(value: number);
  116037. /**
  116038. * Gets the value of the Left joystick
  116039. */
  116040. get buttonLeftStick(): number;
  116041. /**
  116042. * Sets the value of the Left joystick
  116043. */
  116044. set buttonLeftStick(value: number);
  116045. /**
  116046. * Gets the value of the Right joystick
  116047. */
  116048. get buttonRightStick(): number;
  116049. /**
  116050. * Sets the value of the Right joystick
  116051. */
  116052. set buttonRightStick(value: number);
  116053. /**
  116054. * Gets the value of D-pad up
  116055. */
  116056. get dPadUp(): number;
  116057. /**
  116058. * Sets the value of D-pad up
  116059. */
  116060. set dPadUp(value: number);
  116061. /**
  116062. * Gets the value of D-pad down
  116063. */
  116064. get dPadDown(): number;
  116065. /**
  116066. * Sets the value of D-pad down
  116067. */
  116068. set dPadDown(value: number);
  116069. /**
  116070. * Gets the value of D-pad left
  116071. */
  116072. get dPadLeft(): number;
  116073. /**
  116074. * Sets the value of D-pad left
  116075. */
  116076. set dPadLeft(value: number);
  116077. /**
  116078. * Gets the value of D-pad right
  116079. */
  116080. get dPadRight(): number;
  116081. /**
  116082. * Sets the value of D-pad right
  116083. */
  116084. set dPadRight(value: number);
  116085. /**
  116086. * Force the gamepad to synchronize with device values
  116087. */
  116088. update(): void;
  116089. /**
  116090. * Disposes the gamepad
  116091. */
  116092. dispose(): void;
  116093. }
  116094. }
  116095. declare module BABYLON {
  116096. /**
  116097. * Manager for handling gamepads
  116098. */
  116099. export class GamepadManager {
  116100. private _scene?;
  116101. private _babylonGamepads;
  116102. private _oneGamepadConnected;
  116103. /** @hidden */
  116104. _isMonitoring: boolean;
  116105. private _gamepadEventSupported;
  116106. private _gamepadSupport?;
  116107. /**
  116108. * observable to be triggered when the gamepad controller has been connected
  116109. */
  116110. onGamepadConnectedObservable: Observable<Gamepad>;
  116111. /**
  116112. * observable to be triggered when the gamepad controller has been disconnected
  116113. */
  116114. onGamepadDisconnectedObservable: Observable<Gamepad>;
  116115. private _onGamepadConnectedEvent;
  116116. private _onGamepadDisconnectedEvent;
  116117. /**
  116118. * Initializes the gamepad manager
  116119. * @param _scene BabylonJS scene
  116120. */
  116121. constructor(_scene?: Scene | undefined);
  116122. /**
  116123. * The gamepads in the game pad manager
  116124. */
  116125. get gamepads(): Gamepad[];
  116126. /**
  116127. * Get the gamepad controllers based on type
  116128. * @param type The type of gamepad controller
  116129. * @returns Nullable gamepad
  116130. */
  116131. getGamepadByType(type?: number): Nullable<Gamepad>;
  116132. /**
  116133. * Disposes the gamepad manager
  116134. */
  116135. dispose(): void;
  116136. private _addNewGamepad;
  116137. private _startMonitoringGamepads;
  116138. private _stopMonitoringGamepads;
  116139. /** @hidden */
  116140. _checkGamepadsStatus(): void;
  116141. private _updateGamepadObjects;
  116142. }
  116143. }
  116144. declare module BABYLON {
  116145. interface Scene {
  116146. /** @hidden */
  116147. _gamepadManager: Nullable<GamepadManager>;
  116148. /**
  116149. * Gets the gamepad manager associated with the scene
  116150. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  116151. */
  116152. gamepadManager: GamepadManager;
  116153. }
  116154. /**
  116155. * Interface representing a free camera inputs manager
  116156. */
  116157. interface FreeCameraInputsManager {
  116158. /**
  116159. * Adds gamepad input support to the FreeCameraInputsManager.
  116160. * @returns the FreeCameraInputsManager
  116161. */
  116162. addGamepad(): FreeCameraInputsManager;
  116163. }
  116164. /**
  116165. * Interface representing an arc rotate camera inputs manager
  116166. */
  116167. interface ArcRotateCameraInputsManager {
  116168. /**
  116169. * Adds gamepad input support to the ArcRotateCamera InputManager.
  116170. * @returns the camera inputs manager
  116171. */
  116172. addGamepad(): ArcRotateCameraInputsManager;
  116173. }
  116174. /**
  116175. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  116176. */
  116177. export class GamepadSystemSceneComponent implements ISceneComponent {
  116178. /**
  116179. * The component name helpfull to identify the component in the list of scene components.
  116180. */
  116181. readonly name: string;
  116182. /**
  116183. * The scene the component belongs to.
  116184. */
  116185. scene: Scene;
  116186. /**
  116187. * Creates a new instance of the component for the given scene
  116188. * @param scene Defines the scene to register the component in
  116189. */
  116190. constructor(scene: Scene);
  116191. /**
  116192. * Registers the component in a given scene
  116193. */
  116194. register(): void;
  116195. /**
  116196. * Rebuilds the elements related to this component in case of
  116197. * context lost for instance.
  116198. */
  116199. rebuild(): void;
  116200. /**
  116201. * Disposes the component and the associated ressources
  116202. */
  116203. dispose(): void;
  116204. private _beforeCameraUpdate;
  116205. }
  116206. }
  116207. declare module BABYLON {
  116208. /**
  116209. * 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,
  116210. * which still works and will still be found in many Playgrounds.
  116211. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  116212. */
  116213. export class UniversalCamera extends TouchCamera {
  116214. /**
  116215. * Defines the gamepad rotation sensiblity.
  116216. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  116217. */
  116218. get gamepadAngularSensibility(): number;
  116219. set gamepadAngularSensibility(value: number);
  116220. /**
  116221. * Defines the gamepad move sensiblity.
  116222. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  116223. */
  116224. get gamepadMoveSensibility(): number;
  116225. set gamepadMoveSensibility(value: number);
  116226. /**
  116227. * 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,
  116228. * which still works and will still be found in many Playgrounds.
  116229. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  116230. * @param name Define the name of the camera in the scene
  116231. * @param position Define the start position of the camera in the scene
  116232. * @param scene Define the scene the camera belongs to
  116233. */
  116234. constructor(name: string, position: Vector3, scene: Scene);
  116235. /**
  116236. * Gets the current object class name.
  116237. * @return the class name
  116238. */
  116239. getClassName(): string;
  116240. }
  116241. }
  116242. declare module BABYLON {
  116243. /**
  116244. * This represents a FPS type of camera. This is only here for back compat purpose.
  116245. * Please use the UniversalCamera instead as both are identical.
  116246. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  116247. */
  116248. export class GamepadCamera extends UniversalCamera {
  116249. /**
  116250. * Instantiates a new Gamepad Camera
  116251. * This represents a FPS type of camera. This is only here for back compat purpose.
  116252. * Please use the UniversalCamera instead as both are identical.
  116253. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  116254. * @param name Define the name of the camera in the scene
  116255. * @param position Define the start position of the camera in the scene
  116256. * @param scene Define the scene the camera belongs to
  116257. */
  116258. constructor(name: string, position: Vector3, scene: Scene);
  116259. /**
  116260. * Gets the current object class name.
  116261. * @return the class name
  116262. */
  116263. getClassName(): string;
  116264. }
  116265. }
  116266. declare module BABYLON {
  116267. /** @hidden */
  116268. export var passPixelShader: {
  116269. name: string;
  116270. shader: string;
  116271. };
  116272. }
  116273. declare module BABYLON {
  116274. /** @hidden */
  116275. export var passCubePixelShader: {
  116276. name: string;
  116277. shader: string;
  116278. };
  116279. }
  116280. declare module BABYLON {
  116281. /**
  116282. * PassPostProcess which produces an output the same as it's input
  116283. */
  116284. export class PassPostProcess extends PostProcess {
  116285. /**
  116286. * Creates the PassPostProcess
  116287. * @param name The name of the effect.
  116288. * @param options The required width/height ratio to downsize to before computing the render pass.
  116289. * @param camera The camera to apply the render pass to.
  116290. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  116291. * @param engine The engine which the post process will be applied. (default: current engine)
  116292. * @param reusable If the post process can be reused on the same frame. (default: false)
  116293. * @param textureType The type of texture to be used when performing the post processing.
  116294. * @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)
  116295. */
  116296. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  116297. }
  116298. /**
  116299. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  116300. */
  116301. export class PassCubePostProcess extends PostProcess {
  116302. private _face;
  116303. /**
  116304. * Gets or sets the cube face to display.
  116305. * * 0 is +X
  116306. * * 1 is -X
  116307. * * 2 is +Y
  116308. * * 3 is -Y
  116309. * * 4 is +Z
  116310. * * 5 is -Z
  116311. */
  116312. get face(): number;
  116313. set face(value: number);
  116314. /**
  116315. * Creates the PassCubePostProcess
  116316. * @param name The name of the effect.
  116317. * @param options The required width/height ratio to downsize to before computing the render pass.
  116318. * @param camera The camera to apply the render pass to.
  116319. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  116320. * @param engine The engine which the post process will be applied. (default: current engine)
  116321. * @param reusable If the post process can be reused on the same frame. (default: false)
  116322. * @param textureType The type of texture to be used when performing the post processing.
  116323. * @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)
  116324. */
  116325. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  116326. }
  116327. }
  116328. declare module BABYLON {
  116329. /** @hidden */
  116330. export var anaglyphPixelShader: {
  116331. name: string;
  116332. shader: string;
  116333. };
  116334. }
  116335. declare module BABYLON {
  116336. /**
  116337. * Postprocess used to generate anaglyphic rendering
  116338. */
  116339. export class AnaglyphPostProcess extends PostProcess {
  116340. private _passedProcess;
  116341. /**
  116342. * Creates a new AnaglyphPostProcess
  116343. * @param name defines postprocess name
  116344. * @param options defines creation options or target ratio scale
  116345. * @param rigCameras defines cameras using this postprocess
  116346. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  116347. * @param engine defines hosting engine
  116348. * @param reusable defines if the postprocess will be reused multiple times per frame
  116349. */
  116350. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  116351. }
  116352. }
  116353. declare module BABYLON {
  116354. /**
  116355. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  116356. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  116357. */
  116358. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  116359. /**
  116360. * Creates a new AnaglyphArcRotateCamera
  116361. * @param name defines camera name
  116362. * @param alpha defines alpha angle (in radians)
  116363. * @param beta defines beta angle (in radians)
  116364. * @param radius defines radius
  116365. * @param target defines camera target
  116366. * @param interaxialDistance defines distance between each color axis
  116367. * @param scene defines the hosting scene
  116368. */
  116369. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  116370. /**
  116371. * Gets camera class name
  116372. * @returns AnaglyphArcRotateCamera
  116373. */
  116374. getClassName(): string;
  116375. }
  116376. }
  116377. declare module BABYLON {
  116378. /**
  116379. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  116380. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  116381. */
  116382. export class AnaglyphFreeCamera extends FreeCamera {
  116383. /**
  116384. * Creates a new AnaglyphFreeCamera
  116385. * @param name defines camera name
  116386. * @param position defines initial position
  116387. * @param interaxialDistance defines distance between each color axis
  116388. * @param scene defines the hosting scene
  116389. */
  116390. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  116391. /**
  116392. * Gets camera class name
  116393. * @returns AnaglyphFreeCamera
  116394. */
  116395. getClassName(): string;
  116396. }
  116397. }
  116398. declare module BABYLON {
  116399. /**
  116400. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  116401. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  116402. */
  116403. export class AnaglyphGamepadCamera extends GamepadCamera {
  116404. /**
  116405. * Creates a new AnaglyphGamepadCamera
  116406. * @param name defines camera name
  116407. * @param position defines initial position
  116408. * @param interaxialDistance defines distance between each color axis
  116409. * @param scene defines the hosting scene
  116410. */
  116411. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  116412. /**
  116413. * Gets camera class name
  116414. * @returns AnaglyphGamepadCamera
  116415. */
  116416. getClassName(): string;
  116417. }
  116418. }
  116419. declare module BABYLON {
  116420. /**
  116421. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  116422. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  116423. */
  116424. export class AnaglyphUniversalCamera extends UniversalCamera {
  116425. /**
  116426. * Creates a new AnaglyphUniversalCamera
  116427. * @param name defines camera name
  116428. * @param position defines initial position
  116429. * @param interaxialDistance defines distance between each color axis
  116430. * @param scene defines the hosting scene
  116431. */
  116432. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  116433. /**
  116434. * Gets camera class name
  116435. * @returns AnaglyphUniversalCamera
  116436. */
  116437. getClassName(): string;
  116438. }
  116439. }
  116440. declare module BABYLON {
  116441. /** @hidden */
  116442. export var stereoscopicInterlacePixelShader: {
  116443. name: string;
  116444. shader: string;
  116445. };
  116446. }
  116447. declare module BABYLON {
  116448. /**
  116449. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  116450. */
  116451. export class StereoscopicInterlacePostProcessI extends PostProcess {
  116452. private _stepSize;
  116453. private _passedProcess;
  116454. /**
  116455. * Initializes a StereoscopicInterlacePostProcessI
  116456. * @param name The name of the effect.
  116457. * @param rigCameras The rig cameras to be appled to the post process
  116458. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  116459. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  116460. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  116461. * @param engine The engine which the post process will be applied. (default: current engine)
  116462. * @param reusable If the post process can be reused on the same frame. (default: false)
  116463. */
  116464. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  116465. }
  116466. /**
  116467. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  116468. */
  116469. export class StereoscopicInterlacePostProcess extends PostProcess {
  116470. private _stepSize;
  116471. private _passedProcess;
  116472. /**
  116473. * Initializes a StereoscopicInterlacePostProcess
  116474. * @param name The name of the effect.
  116475. * @param rigCameras The rig cameras to be appled to the post process
  116476. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  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, samplingMode?: number, engine?: Engine, reusable?: boolean);
  116482. }
  116483. }
  116484. declare module BABYLON {
  116485. /**
  116486. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  116487. * @see http://doc.babylonjs.com/features/cameras
  116488. */
  116489. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  116490. /**
  116491. * Creates a new StereoscopicArcRotateCamera
  116492. * @param name defines camera name
  116493. * @param alpha defines alpha angle (in radians)
  116494. * @param beta defines beta angle (in radians)
  116495. * @param radius defines radius
  116496. * @param target defines camera target
  116497. * @param interaxialDistance defines distance between each color axis
  116498. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  116499. * @param scene defines the hosting scene
  116500. */
  116501. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  116502. /**
  116503. * Gets camera class name
  116504. * @returns StereoscopicArcRotateCamera
  116505. */
  116506. getClassName(): string;
  116507. }
  116508. }
  116509. declare module BABYLON {
  116510. /**
  116511. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  116512. * @see http://doc.babylonjs.com/features/cameras
  116513. */
  116514. export class StereoscopicFreeCamera extends FreeCamera {
  116515. /**
  116516. * Creates a new StereoscopicFreeCamera
  116517. * @param name defines camera name
  116518. * @param position defines initial position
  116519. * @param interaxialDistance defines distance between each color axis
  116520. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  116521. * @param scene defines the hosting scene
  116522. */
  116523. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  116524. /**
  116525. * Gets camera class name
  116526. * @returns StereoscopicFreeCamera
  116527. */
  116528. getClassName(): string;
  116529. }
  116530. }
  116531. declare module BABYLON {
  116532. /**
  116533. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  116534. * @see http://doc.babylonjs.com/features/cameras
  116535. */
  116536. export class StereoscopicGamepadCamera extends GamepadCamera {
  116537. /**
  116538. * Creates a new StereoscopicGamepadCamera
  116539. * @param name defines camera name
  116540. * @param position defines initial position
  116541. * @param interaxialDistance defines distance between each color axis
  116542. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  116543. * @param scene defines the hosting scene
  116544. */
  116545. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  116546. /**
  116547. * Gets camera class name
  116548. * @returns StereoscopicGamepadCamera
  116549. */
  116550. getClassName(): string;
  116551. }
  116552. }
  116553. declare module BABYLON {
  116554. /**
  116555. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  116556. * @see http://doc.babylonjs.com/features/cameras
  116557. */
  116558. export class StereoscopicUniversalCamera extends UniversalCamera {
  116559. /**
  116560. * Creates a new StereoscopicUniversalCamera
  116561. * @param name defines camera name
  116562. * @param position defines initial position
  116563. * @param interaxialDistance defines distance between each color axis
  116564. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  116565. * @param scene defines the hosting scene
  116566. */
  116567. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  116568. /**
  116569. * Gets camera class name
  116570. * @returns StereoscopicUniversalCamera
  116571. */
  116572. getClassName(): string;
  116573. }
  116574. }
  116575. declare module BABYLON {
  116576. /**
  116577. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  116578. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  116579. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  116580. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  116581. */
  116582. export class VirtualJoysticksCamera extends FreeCamera {
  116583. /**
  116584. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  116585. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  116586. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  116587. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  116588. * @param name Define the name of the camera in the scene
  116589. * @param position Define the start position of the camera in the scene
  116590. * @param scene Define the scene the camera belongs to
  116591. */
  116592. constructor(name: string, position: Vector3, scene: Scene);
  116593. /**
  116594. * Gets the current object class name.
  116595. * @return the class name
  116596. */
  116597. getClassName(): string;
  116598. }
  116599. }
  116600. declare module BABYLON {
  116601. /**
  116602. * This represents all the required metrics to create a VR camera.
  116603. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  116604. */
  116605. export class VRCameraMetrics {
  116606. /**
  116607. * Define the horizontal resolution off the screen.
  116608. */
  116609. hResolution: number;
  116610. /**
  116611. * Define the vertical resolution off the screen.
  116612. */
  116613. vResolution: number;
  116614. /**
  116615. * Define the horizontal screen size.
  116616. */
  116617. hScreenSize: number;
  116618. /**
  116619. * Define the vertical screen size.
  116620. */
  116621. vScreenSize: number;
  116622. /**
  116623. * Define the vertical screen center position.
  116624. */
  116625. vScreenCenter: number;
  116626. /**
  116627. * Define the distance of the eyes to the screen.
  116628. */
  116629. eyeToScreenDistance: number;
  116630. /**
  116631. * Define the distance between both lenses
  116632. */
  116633. lensSeparationDistance: number;
  116634. /**
  116635. * Define the distance between both viewer's eyes.
  116636. */
  116637. interpupillaryDistance: number;
  116638. /**
  116639. * Define the distortion factor of the VR postprocess.
  116640. * Please, touch with care.
  116641. */
  116642. distortionK: number[];
  116643. /**
  116644. * Define the chromatic aberration correction factors for the VR post process.
  116645. */
  116646. chromaAbCorrection: number[];
  116647. /**
  116648. * Define the scale factor of the post process.
  116649. * The smaller the better but the slower.
  116650. */
  116651. postProcessScaleFactor: number;
  116652. /**
  116653. * Define an offset for the lens center.
  116654. */
  116655. lensCenterOffset: number;
  116656. /**
  116657. * Define if the current vr camera should compensate the distortion of the lense or not.
  116658. */
  116659. compensateDistortion: boolean;
  116660. /**
  116661. * Defines if multiview should be enabled when rendering (Default: false)
  116662. */
  116663. multiviewEnabled: boolean;
  116664. /**
  116665. * Gets the rendering aspect ratio based on the provided resolutions.
  116666. */
  116667. get aspectRatio(): number;
  116668. /**
  116669. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  116670. */
  116671. get aspectRatioFov(): number;
  116672. /**
  116673. * @hidden
  116674. */
  116675. get leftHMatrix(): Matrix;
  116676. /**
  116677. * @hidden
  116678. */
  116679. get rightHMatrix(): Matrix;
  116680. /**
  116681. * @hidden
  116682. */
  116683. get leftPreViewMatrix(): Matrix;
  116684. /**
  116685. * @hidden
  116686. */
  116687. get rightPreViewMatrix(): Matrix;
  116688. /**
  116689. * Get the default VRMetrics based on the most generic setup.
  116690. * @returns the default vr metrics
  116691. */
  116692. static GetDefault(): VRCameraMetrics;
  116693. }
  116694. }
  116695. declare module BABYLON {
  116696. /** @hidden */
  116697. export var vrDistortionCorrectionPixelShader: {
  116698. name: string;
  116699. shader: string;
  116700. };
  116701. }
  116702. declare module BABYLON {
  116703. /**
  116704. * VRDistortionCorrectionPostProcess used for mobile VR
  116705. */
  116706. export class VRDistortionCorrectionPostProcess extends PostProcess {
  116707. private _isRightEye;
  116708. private _distortionFactors;
  116709. private _postProcessScaleFactor;
  116710. private _lensCenterOffset;
  116711. private _scaleIn;
  116712. private _scaleFactor;
  116713. private _lensCenter;
  116714. /**
  116715. * Initializes the VRDistortionCorrectionPostProcess
  116716. * @param name The name of the effect.
  116717. * @param camera The camera to apply the render pass to.
  116718. * @param isRightEye If this is for the right eye distortion
  116719. * @param vrMetrics All the required metrics for the VR camera
  116720. */
  116721. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  116722. }
  116723. }
  116724. declare module BABYLON {
  116725. /**
  116726. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  116727. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  116728. */
  116729. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  116730. /**
  116731. * Creates a new VRDeviceOrientationArcRotateCamera
  116732. * @param name defines camera name
  116733. * @param alpha defines the camera rotation along the logitudinal axis
  116734. * @param beta defines the camera rotation along the latitudinal axis
  116735. * @param radius defines the camera distance from its target
  116736. * @param target defines the camera target
  116737. * @param scene defines the scene the camera belongs to
  116738. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  116739. * @param vrCameraMetrics defines the vr metrics associated to the camera
  116740. */
  116741. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  116742. /**
  116743. * Gets camera class name
  116744. * @returns VRDeviceOrientationArcRotateCamera
  116745. */
  116746. getClassName(): string;
  116747. }
  116748. }
  116749. declare module BABYLON {
  116750. /**
  116751. * Camera used to simulate VR rendering (based on FreeCamera)
  116752. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  116753. */
  116754. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  116755. /**
  116756. * Creates a new VRDeviceOrientationFreeCamera
  116757. * @param name defines camera name
  116758. * @param position defines the start position of the camera
  116759. * @param scene defines the scene the camera belongs to
  116760. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  116761. * @param vrCameraMetrics defines the vr metrics associated to the camera
  116762. */
  116763. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  116764. /**
  116765. * Gets camera class name
  116766. * @returns VRDeviceOrientationFreeCamera
  116767. */
  116768. getClassName(): string;
  116769. }
  116770. }
  116771. declare module BABYLON {
  116772. /**
  116773. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  116774. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  116775. */
  116776. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  116777. /**
  116778. * Creates a new VRDeviceOrientationGamepadCamera
  116779. * @param name defines camera name
  116780. * @param position defines the start position of the camera
  116781. * @param scene defines the scene the camera belongs to
  116782. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  116783. * @param vrCameraMetrics defines the vr metrics associated to the camera
  116784. */
  116785. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  116786. /**
  116787. * Gets camera class name
  116788. * @returns VRDeviceOrientationGamepadCamera
  116789. */
  116790. getClassName(): string;
  116791. }
  116792. }
  116793. declare module BABYLON {
  116794. /** @hidden */
  116795. export var imageProcessingPixelShader: {
  116796. name: string;
  116797. shader: string;
  116798. };
  116799. }
  116800. declare module BABYLON {
  116801. /**
  116802. * ImageProcessingPostProcess
  116803. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  116804. */
  116805. export class ImageProcessingPostProcess extends PostProcess {
  116806. /**
  116807. * Default configuration related to image processing available in the PBR Material.
  116808. */
  116809. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  116810. /**
  116811. * Gets the image processing configuration used either in this material.
  116812. */
  116813. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  116814. /**
  116815. * Sets the Default image processing configuration used either in the this material.
  116816. *
  116817. * If sets to null, the scene one is in use.
  116818. */
  116819. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  116820. /**
  116821. * Keep track of the image processing observer to allow dispose and replace.
  116822. */
  116823. private _imageProcessingObserver;
  116824. /**
  116825. * Attaches a new image processing configuration to the PBR Material.
  116826. * @param configuration
  116827. */
  116828. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  116829. /**
  116830. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  116831. */
  116832. get colorCurves(): Nullable<ColorCurves>;
  116833. /**
  116834. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  116835. */
  116836. set colorCurves(value: Nullable<ColorCurves>);
  116837. /**
  116838. * Gets wether the color curves effect is enabled.
  116839. */
  116840. get colorCurvesEnabled(): boolean;
  116841. /**
  116842. * Sets wether the color curves effect is enabled.
  116843. */
  116844. set colorCurvesEnabled(value: boolean);
  116845. /**
  116846. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  116847. */
  116848. get colorGradingTexture(): Nullable<BaseTexture>;
  116849. /**
  116850. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  116851. */
  116852. set colorGradingTexture(value: Nullable<BaseTexture>);
  116853. /**
  116854. * Gets wether the color grading effect is enabled.
  116855. */
  116856. get colorGradingEnabled(): boolean;
  116857. /**
  116858. * Gets wether the color grading effect is enabled.
  116859. */
  116860. set colorGradingEnabled(value: boolean);
  116861. /**
  116862. * Gets exposure used in the effect.
  116863. */
  116864. get exposure(): number;
  116865. /**
  116866. * Sets exposure used in the effect.
  116867. */
  116868. set exposure(value: number);
  116869. /**
  116870. * Gets wether tonemapping is enabled or not.
  116871. */
  116872. get toneMappingEnabled(): boolean;
  116873. /**
  116874. * Sets wether tonemapping is enabled or not
  116875. */
  116876. set toneMappingEnabled(value: boolean);
  116877. /**
  116878. * Gets the type of tone mapping effect.
  116879. */
  116880. get toneMappingType(): number;
  116881. /**
  116882. * Sets the type of tone mapping effect.
  116883. */
  116884. set toneMappingType(value: number);
  116885. /**
  116886. * Gets contrast used in the effect.
  116887. */
  116888. get contrast(): number;
  116889. /**
  116890. * Sets contrast used in the effect.
  116891. */
  116892. set contrast(value: number);
  116893. /**
  116894. * Gets Vignette stretch size.
  116895. */
  116896. get vignetteStretch(): number;
  116897. /**
  116898. * Sets Vignette stretch size.
  116899. */
  116900. set vignetteStretch(value: number);
  116901. /**
  116902. * Gets Vignette centre X Offset.
  116903. */
  116904. get vignetteCentreX(): number;
  116905. /**
  116906. * Sets Vignette centre X Offset.
  116907. */
  116908. set vignetteCentreX(value: number);
  116909. /**
  116910. * Gets Vignette centre Y Offset.
  116911. */
  116912. get vignetteCentreY(): number;
  116913. /**
  116914. * Sets Vignette centre Y Offset.
  116915. */
  116916. set vignetteCentreY(value: number);
  116917. /**
  116918. * Gets Vignette weight or intensity of the vignette effect.
  116919. */
  116920. get vignetteWeight(): number;
  116921. /**
  116922. * Sets Vignette weight or intensity of the vignette effect.
  116923. */
  116924. set vignetteWeight(value: number);
  116925. /**
  116926. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  116927. * if vignetteEnabled is set to true.
  116928. */
  116929. get vignetteColor(): Color4;
  116930. /**
  116931. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  116932. * if vignetteEnabled is set to true.
  116933. */
  116934. set vignetteColor(value: Color4);
  116935. /**
  116936. * Gets Camera field of view used by the Vignette effect.
  116937. */
  116938. get vignetteCameraFov(): number;
  116939. /**
  116940. * Sets Camera field of view used by the Vignette effect.
  116941. */
  116942. set vignetteCameraFov(value: number);
  116943. /**
  116944. * Gets the vignette blend mode allowing different kind of effect.
  116945. */
  116946. get vignetteBlendMode(): number;
  116947. /**
  116948. * Sets the vignette blend mode allowing different kind of effect.
  116949. */
  116950. set vignetteBlendMode(value: number);
  116951. /**
  116952. * Gets wether the vignette effect is enabled.
  116953. */
  116954. get vignetteEnabled(): boolean;
  116955. /**
  116956. * Sets wether the vignette effect is enabled.
  116957. */
  116958. set vignetteEnabled(value: boolean);
  116959. private _fromLinearSpace;
  116960. /**
  116961. * Gets wether the input of the processing is in Gamma or Linear Space.
  116962. */
  116963. get fromLinearSpace(): boolean;
  116964. /**
  116965. * Sets wether the input of the processing is in Gamma or Linear Space.
  116966. */
  116967. set fromLinearSpace(value: boolean);
  116968. /**
  116969. * Defines cache preventing GC.
  116970. */
  116971. private _defines;
  116972. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  116973. /**
  116974. * "ImageProcessingPostProcess"
  116975. * @returns "ImageProcessingPostProcess"
  116976. */
  116977. getClassName(): string;
  116978. protected _updateParameters(): void;
  116979. dispose(camera?: Camera): void;
  116980. }
  116981. }
  116982. declare module BABYLON {
  116983. /**
  116984. * Class containing static functions to help procedurally build meshes
  116985. */
  116986. export class GroundBuilder {
  116987. /**
  116988. * Creates a ground mesh
  116989. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  116990. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  116991. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116992. * @param name defines the name of the mesh
  116993. * @param options defines the options used to create the mesh
  116994. * @param scene defines the hosting scene
  116995. * @returns the ground mesh
  116996. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  116997. */
  116998. static CreateGround(name: string, options: {
  116999. width?: number;
  117000. height?: number;
  117001. subdivisions?: number;
  117002. subdivisionsX?: number;
  117003. subdivisionsY?: number;
  117004. updatable?: boolean;
  117005. }, scene: any): Mesh;
  117006. /**
  117007. * Creates a tiled ground mesh
  117008. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  117009. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  117010. * * 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
  117011. * * 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
  117012. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  117013. * @param name defines the name of the mesh
  117014. * @param options defines the options used to create the mesh
  117015. * @param scene defines the hosting scene
  117016. * @returns the tiled ground mesh
  117017. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  117018. */
  117019. static CreateTiledGround(name: string, options: {
  117020. xmin: number;
  117021. zmin: number;
  117022. xmax: number;
  117023. zmax: number;
  117024. subdivisions?: {
  117025. w: number;
  117026. h: number;
  117027. };
  117028. precision?: {
  117029. w: number;
  117030. h: number;
  117031. };
  117032. updatable?: boolean;
  117033. }, scene?: Nullable<Scene>): Mesh;
  117034. /**
  117035. * Creates a ground mesh from a height map
  117036. * * The parameter `url` sets the URL of the height map image resource.
  117037. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  117038. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  117039. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  117040. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  117041. * * 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.
  117042. * * 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).
  117043. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  117044. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  117045. * @param name defines the name of the mesh
  117046. * @param url defines the url to the height map
  117047. * @param options defines the options used to create the mesh
  117048. * @param scene defines the hosting scene
  117049. * @returns the ground mesh
  117050. * @see https://doc.babylonjs.com/babylon101/height_map
  117051. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  117052. */
  117053. static CreateGroundFromHeightMap(name: string, url: string, options: {
  117054. width?: number;
  117055. height?: number;
  117056. subdivisions?: number;
  117057. minHeight?: number;
  117058. maxHeight?: number;
  117059. colorFilter?: Color3;
  117060. alphaFilter?: number;
  117061. updatable?: boolean;
  117062. onReady?: (mesh: GroundMesh) => void;
  117063. }, scene?: Nullable<Scene>): GroundMesh;
  117064. }
  117065. }
  117066. declare module BABYLON {
  117067. /**
  117068. * Class containing static functions to help procedurally build meshes
  117069. */
  117070. export class TorusBuilder {
  117071. /**
  117072. * Creates a torus mesh
  117073. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  117074. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  117075. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  117076. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117077. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117078. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  117079. * @param name defines the name of the mesh
  117080. * @param options defines the options used to create the mesh
  117081. * @param scene defines the hosting scene
  117082. * @returns the torus mesh
  117083. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  117084. */
  117085. static CreateTorus(name: string, options: {
  117086. diameter?: number;
  117087. thickness?: number;
  117088. tessellation?: number;
  117089. updatable?: boolean;
  117090. sideOrientation?: number;
  117091. frontUVs?: Vector4;
  117092. backUVs?: Vector4;
  117093. }, scene: any): Mesh;
  117094. }
  117095. }
  117096. declare module BABYLON {
  117097. /**
  117098. * Class containing static functions to help procedurally build meshes
  117099. */
  117100. export class CylinderBuilder {
  117101. /**
  117102. * Creates a cylinder or a cone mesh
  117103. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  117104. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  117105. * * 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.
  117106. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  117107. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  117108. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  117109. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  117110. * * 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).
  117111. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  117112. * * 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).
  117113. * * 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
  117114. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  117115. * * 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
  117116. * * 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.
  117117. * * If `enclose` is false, a ring surface is one element.
  117118. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  117119. * * 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
  117120. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117121. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117122. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  117123. * @param name defines the name of the mesh
  117124. * @param options defines the options used to create the mesh
  117125. * @param scene defines the hosting scene
  117126. * @returns the cylinder mesh
  117127. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  117128. */
  117129. static CreateCylinder(name: string, options: {
  117130. height?: number;
  117131. diameterTop?: number;
  117132. diameterBottom?: number;
  117133. diameter?: number;
  117134. tessellation?: number;
  117135. subdivisions?: number;
  117136. arc?: number;
  117137. faceColors?: Color4[];
  117138. faceUV?: Vector4[];
  117139. updatable?: boolean;
  117140. hasRings?: boolean;
  117141. enclose?: boolean;
  117142. cap?: number;
  117143. sideOrientation?: number;
  117144. frontUVs?: Vector4;
  117145. backUVs?: Vector4;
  117146. }, scene: any): Mesh;
  117147. }
  117148. }
  117149. declare module BABYLON {
  117150. /**
  117151. * States of the webXR experience
  117152. */
  117153. export enum WebXRState {
  117154. /**
  117155. * Transitioning to being in XR mode
  117156. */
  117157. ENTERING_XR = 0,
  117158. /**
  117159. * Transitioning to non XR mode
  117160. */
  117161. EXITING_XR = 1,
  117162. /**
  117163. * In XR mode and presenting
  117164. */
  117165. IN_XR = 2,
  117166. /**
  117167. * Not entered XR mode
  117168. */
  117169. NOT_IN_XR = 3
  117170. }
  117171. /**
  117172. * Abstraction of the XR render target
  117173. */
  117174. export interface WebXRRenderTarget extends IDisposable {
  117175. /**
  117176. * xrpresent context of the canvas which can be used to display/mirror xr content
  117177. */
  117178. canvasContext: WebGLRenderingContext;
  117179. /**
  117180. * xr layer for the canvas
  117181. */
  117182. xrLayer: Nullable<XRWebGLLayer>;
  117183. /**
  117184. * Initializes the xr layer for the session
  117185. * @param xrSession xr session
  117186. * @returns a promise that will resolve once the XR Layer has been created
  117187. */
  117188. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  117189. }
  117190. }
  117191. declare module BABYLON {
  117192. /**
  117193. * COnfiguration object for WebXR output canvas
  117194. */
  117195. export class WebXRManagedOutputCanvasOptions {
  117196. /**
  117197. * An optional canvas in case you wish to create it yourself and provide it here.
  117198. * If not provided, a new canvas will be created
  117199. */
  117200. canvasElement?: HTMLCanvasElement;
  117201. /**
  117202. * Options for this XR Layer output
  117203. */
  117204. canvasOptions?: XRWebGLLayerOptions;
  117205. /**
  117206. * CSS styling for a newly created canvas (if not provided)
  117207. */
  117208. newCanvasCssStyle?: string;
  117209. /**
  117210. * Get the default values of the configuration object
  117211. * @returns default values of this configuration object
  117212. */
  117213. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  117214. }
  117215. /**
  117216. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  117217. */
  117218. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  117219. private _options;
  117220. private _canvas;
  117221. private _engine;
  117222. /**
  117223. * Rendering context of the canvas which can be used to display/mirror xr content
  117224. */
  117225. canvasContext: WebGLRenderingContext;
  117226. /**
  117227. * xr layer for the canvas
  117228. */
  117229. xrLayer: Nullable<XRWebGLLayer>;
  117230. /**
  117231. * Initializes the canvas to be added/removed upon entering/exiting xr
  117232. * @param _xrSessionManager The XR Session manager
  117233. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  117234. */
  117235. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  117236. /**
  117237. * Disposes of the object
  117238. */
  117239. dispose(): void;
  117240. /**
  117241. * Initializes the xr layer for the session
  117242. * @param xrSession xr session
  117243. * @returns a promise that will resolve once the XR Layer has been created
  117244. */
  117245. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  117246. private _addCanvas;
  117247. private _removeCanvas;
  117248. private _setManagedOutputCanvas;
  117249. }
  117250. }
  117251. declare module BABYLON {
  117252. /**
  117253. * Manages an XRSession to work with Babylon's engine
  117254. * @see https://doc.babylonjs.com/how_to/webxr
  117255. */
  117256. export class WebXRSessionManager implements IDisposable {
  117257. /** The scene which the session should be created for */
  117258. scene: Scene;
  117259. private _referenceSpace;
  117260. private _rttProvider;
  117261. private _sessionEnded;
  117262. private _xrNavigator;
  117263. private baseLayer;
  117264. /**
  117265. * The base reference space from which the session started. good if you want to reset your
  117266. * reference space
  117267. */
  117268. baseReferenceSpace: XRReferenceSpace;
  117269. /**
  117270. * Current XR frame
  117271. */
  117272. currentFrame: Nullable<XRFrame>;
  117273. /** WebXR timestamp updated every frame */
  117274. currentTimestamp: number;
  117275. /**
  117276. * Used just in case of a failure to initialize an immersive session.
  117277. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  117278. */
  117279. defaultHeightCompensation: number;
  117280. /**
  117281. * Fires every time a new xrFrame arrives which can be used to update the camera
  117282. */
  117283. onXRFrameObservable: Observable<XRFrame>;
  117284. /**
  117285. * Fires when the reference space changed
  117286. */
  117287. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  117288. /**
  117289. * Fires when the xr session is ended either by the device or manually done
  117290. */
  117291. onXRSessionEnded: Observable<any>;
  117292. /**
  117293. * Fires when the xr session is ended either by the device or manually done
  117294. */
  117295. onXRSessionInit: Observable<XRSession>;
  117296. /**
  117297. * Underlying xr session
  117298. */
  117299. session: XRSession;
  117300. /**
  117301. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  117302. * or get the offset the player is currently at.
  117303. */
  117304. viewerReferenceSpace: XRReferenceSpace;
  117305. /**
  117306. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  117307. * @param scene The scene which the session should be created for
  117308. */
  117309. constructor(
  117310. /** The scene which the session should be created for */
  117311. scene: Scene);
  117312. /**
  117313. * The current reference space used in this session. This reference space can constantly change!
  117314. * It is mainly used to offset the camera's position.
  117315. */
  117316. get referenceSpace(): XRReferenceSpace;
  117317. /**
  117318. * Set a new reference space and triggers the observable
  117319. */
  117320. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  117321. /**
  117322. * Disposes of the session manager
  117323. */
  117324. dispose(): void;
  117325. /**
  117326. * Stops the xrSession and restores the render loop
  117327. * @returns Promise which resolves after it exits XR
  117328. */
  117329. exitXRAsync(): Promise<void>;
  117330. /**
  117331. * Gets the correct render target texture to be rendered this frame for this eye
  117332. * @param eye the eye for which to get the render target
  117333. * @returns the render target for the specified eye
  117334. */
  117335. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  117336. /**
  117337. * Creates a WebXRRenderTarget object for the XR session
  117338. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  117339. * @param options optional options to provide when creating a new render target
  117340. * @returns a WebXR render target to which the session can render
  117341. */
  117342. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  117343. /**
  117344. * Initializes the manager
  117345. * After initialization enterXR can be called to start an XR session
  117346. * @returns Promise which resolves after it is initialized
  117347. */
  117348. initializeAsync(): Promise<void>;
  117349. /**
  117350. * Initializes an xr session
  117351. * @param xrSessionMode mode to initialize
  117352. * @param xrSessionInit defines optional and required values to pass to the session builder
  117353. * @returns a promise which will resolve once the session has been initialized
  117354. */
  117355. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  117356. /**
  117357. * Checks if a session would be supported for the creation options specified
  117358. * @param sessionMode session mode to check if supported eg. immersive-vr
  117359. * @returns A Promise that resolves to true if supported and false if not
  117360. */
  117361. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  117362. /**
  117363. * Resets the reference space to the one started the session
  117364. */
  117365. resetReferenceSpace(): void;
  117366. /**
  117367. * Starts rendering to the xr layer
  117368. */
  117369. runXRRenderLoop(): void;
  117370. /**
  117371. * Sets the reference space on the xr session
  117372. * @param referenceSpaceType space to set
  117373. * @returns a promise that will resolve once the reference space has been set
  117374. */
  117375. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  117376. /**
  117377. * Updates the render state of the session
  117378. * @param state state to set
  117379. * @returns a promise that resolves once the render state has been updated
  117380. */
  117381. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  117382. /**
  117383. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  117384. * @param sessionMode defines the session to test
  117385. * @returns a promise with boolean as final value
  117386. */
  117387. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  117388. private _createRenderTargetTexture;
  117389. }
  117390. }
  117391. declare module BABYLON {
  117392. /**
  117393. * WebXR Camera which holds the views for the xrSession
  117394. * @see https://doc.babylonjs.com/how_to/webxr_camera
  117395. */
  117396. export class WebXRCamera extends FreeCamera {
  117397. private _xrSessionManager;
  117398. private _firstFrame;
  117399. private _referenceQuaternion;
  117400. private _referencedPosition;
  117401. private _xrInvPositionCache;
  117402. private _xrInvQuaternionCache;
  117403. /**
  117404. * Should position compensation execute on first frame.
  117405. * This is used when copying the position from a native (non XR) camera
  117406. */
  117407. compensateOnFirstFrame: boolean;
  117408. /**
  117409. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  117410. * @param name the name of the camera
  117411. * @param scene the scene to add the camera to
  117412. * @param _xrSessionManager a constructed xr session manager
  117413. */
  117414. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  117415. /**
  117416. * Return the user's height, unrelated to the current ground.
  117417. * This will be the y position of this camera, when ground level is 0.
  117418. */
  117419. get realWorldHeight(): number;
  117420. /** @hidden */
  117421. _updateForDualEyeDebugging(): void;
  117422. /**
  117423. * Sets this camera's transformation based on a non-vr camera
  117424. * @param otherCamera the non-vr camera to copy the transformation from
  117425. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  117426. */
  117427. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  117428. /**
  117429. * Gets the current instance class name ("WebXRCamera").
  117430. * @returns the class name
  117431. */
  117432. getClassName(): string;
  117433. private _updateFromXRSession;
  117434. private _updateNumberOfRigCameras;
  117435. private _updateReferenceSpace;
  117436. private _updateReferenceSpaceOffset;
  117437. }
  117438. }
  117439. declare module BABYLON {
  117440. /**
  117441. * Defining the interface required for a (webxr) feature
  117442. */
  117443. export interface IWebXRFeature extends IDisposable {
  117444. /**
  117445. * Is this feature attached
  117446. */
  117447. attached: boolean;
  117448. /**
  117449. * Should auto-attach be disabled?
  117450. */
  117451. disableAutoAttach: boolean;
  117452. /**
  117453. * Attach the feature to the session
  117454. * Will usually be called by the features manager
  117455. *
  117456. * @param force should attachment be forced (even when already attached)
  117457. * @returns true if successful.
  117458. */
  117459. attach(force?: boolean): boolean;
  117460. /**
  117461. * Detach the feature from the session
  117462. * Will usually be called by the features manager
  117463. *
  117464. * @returns true if successful.
  117465. */
  117466. detach(): boolean;
  117467. }
  117468. /**
  117469. * A list of the currently available features without referencing them
  117470. */
  117471. export class WebXRFeatureName {
  117472. /**
  117473. * The name of the anchor system feature
  117474. */
  117475. static ANCHOR_SYSTEM: string;
  117476. /**
  117477. * The name of the background remover feature
  117478. */
  117479. static BACKGROUND_REMOVER: string;
  117480. /**
  117481. * The name of the hit test feature
  117482. */
  117483. static HIT_TEST: string;
  117484. /**
  117485. * physics impostors for xr controllers feature
  117486. */
  117487. static PHYSICS_CONTROLLERS: string;
  117488. /**
  117489. * The name of the plane detection feature
  117490. */
  117491. static PLANE_DETECTION: string;
  117492. /**
  117493. * The name of the pointer selection feature
  117494. */
  117495. static POINTER_SELECTION: string;
  117496. /**
  117497. * The name of the teleportation feature
  117498. */
  117499. static TELEPORTATION: string;
  117500. }
  117501. /**
  117502. * Defining the constructor of a feature. Used to register the modules.
  117503. */
  117504. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  117505. /**
  117506. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  117507. * It is mainly used in AR sessions.
  117508. *
  117509. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  117510. */
  117511. export class WebXRFeaturesManager implements IDisposable {
  117512. private _xrSessionManager;
  117513. private static readonly _AvailableFeatures;
  117514. private _features;
  117515. /**
  117516. * constructs a new features manages.
  117517. *
  117518. * @param _xrSessionManager an instance of WebXRSessionManager
  117519. */
  117520. constructor(_xrSessionManager: WebXRSessionManager);
  117521. /**
  117522. * Used to register a module. After calling this function a developer can use this feature in the scene.
  117523. * Mainly used internally.
  117524. *
  117525. * @param featureName the name of the feature to register
  117526. * @param constructorFunction the function used to construct the module
  117527. * @param version the (babylon) version of the module
  117528. * @param stable is that a stable version of this module
  117529. */
  117530. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  117531. /**
  117532. * Returns a constructor of a specific feature.
  117533. *
  117534. * @param featureName the name of the feature to construct
  117535. * @param version the version of the feature to load
  117536. * @param xrSessionManager the xrSessionManager. Used to construct the module
  117537. * @param options optional options provided to the module.
  117538. * @returns a function that, when called, will return a new instance of this feature
  117539. */
  117540. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  117541. /**
  117542. * Can be used to return the list of features currently registered
  117543. *
  117544. * @returns an Array of available features
  117545. */
  117546. static GetAvailableFeatures(): string[];
  117547. /**
  117548. * Gets the versions available for a specific feature
  117549. * @param featureName the name of the feature
  117550. * @returns an array with the available versions
  117551. */
  117552. static GetAvailableVersions(featureName: string): string[];
  117553. /**
  117554. * Return the latest unstable version of this feature
  117555. * @param featureName the name of the feature to search
  117556. * @returns the version number. if not found will return -1
  117557. */
  117558. static GetLatestVersionOfFeature(featureName: string): number;
  117559. /**
  117560. * Return the latest stable version of this feature
  117561. * @param featureName the name of the feature to search
  117562. * @returns the version number. if not found will return -1
  117563. */
  117564. static GetStableVersionOfFeature(featureName: string): number;
  117565. /**
  117566. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  117567. * Can be used during a session to start a feature
  117568. * @param featureName the name of feature to attach
  117569. */
  117570. attachFeature(featureName: string): void;
  117571. /**
  117572. * Can be used inside a session or when the session ends to detach a specific feature
  117573. * @param featureName the name of the feature to detach
  117574. */
  117575. detachFeature(featureName: string): void;
  117576. /**
  117577. * Used to disable an already-enabled feature
  117578. * The feature will be disposed and will be recreated once enabled.
  117579. * @param featureName the feature to disable
  117580. * @returns true if disable was successful
  117581. */
  117582. disableFeature(featureName: string | {
  117583. Name: string;
  117584. }): boolean;
  117585. /**
  117586. * dispose this features manager
  117587. */
  117588. dispose(): void;
  117589. /**
  117590. * 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.
  117591. * 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.
  117592. *
  117593. * @param featureName the name of the feature to load or the class of the feature
  117594. * @param version optional version to load. if not provided the latest version will be enabled
  117595. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  117596. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  117597. * @returns a new constructed feature or throws an error if feature not found.
  117598. */
  117599. enableFeature(featureName: string | {
  117600. Name: string;
  117601. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  117602. /**
  117603. * get the implementation of an enabled feature.
  117604. * @param featureName the name of the feature to load
  117605. * @returns the feature class, if found
  117606. */
  117607. getEnabledFeature(featureName: string): IWebXRFeature;
  117608. /**
  117609. * Get the list of enabled features
  117610. * @returns an array of enabled features
  117611. */
  117612. getEnabledFeatures(): string[];
  117613. }
  117614. }
  117615. declare module BABYLON {
  117616. /**
  117617. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  117618. * @see https://doc.babylonjs.com/how_to/webxr
  117619. */
  117620. export class WebXRExperienceHelper implements IDisposable {
  117621. private scene;
  117622. private _nonVRCamera;
  117623. private _originalSceneAutoClear;
  117624. private _supported;
  117625. /**
  117626. * Camera used to render xr content
  117627. */
  117628. camera: WebXRCamera;
  117629. /** A features manager for this xr session */
  117630. featuresManager: WebXRFeaturesManager;
  117631. /**
  117632. * Observers registered here will be triggered after the camera's initial transformation is set
  117633. * This can be used to set a different ground level or an extra rotation.
  117634. *
  117635. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  117636. * to the position set after this observable is done executing.
  117637. */
  117638. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  117639. /**
  117640. * Fires when the state of the experience helper has changed
  117641. */
  117642. onStateChangedObservable: Observable<WebXRState>;
  117643. /** Session manager used to keep track of xr session */
  117644. sessionManager: WebXRSessionManager;
  117645. /**
  117646. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  117647. */
  117648. state: WebXRState;
  117649. /**
  117650. * Creates a WebXRExperienceHelper
  117651. * @param scene The scene the helper should be created in
  117652. */
  117653. private constructor();
  117654. /**
  117655. * Creates the experience helper
  117656. * @param scene the scene to attach the experience helper to
  117657. * @returns a promise for the experience helper
  117658. */
  117659. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  117660. /**
  117661. * Disposes of the experience helper
  117662. */
  117663. dispose(): void;
  117664. /**
  117665. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  117666. * @param sessionMode options for the XR session
  117667. * @param referenceSpaceType frame of reference of the XR session
  117668. * @param renderTarget the output canvas that will be used to enter XR mode
  117669. * @returns promise that resolves after xr mode has entered
  117670. */
  117671. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget): Promise<WebXRSessionManager>;
  117672. /**
  117673. * Exits XR mode and returns the scene to its original state
  117674. * @returns promise that resolves after xr mode has exited
  117675. */
  117676. exitXRAsync(): Promise<void>;
  117677. private _nonXRToXRCamera;
  117678. private _setState;
  117679. }
  117680. }
  117681. declare module BABYLON {
  117682. /**
  117683. * X-Y values for axes in WebXR
  117684. */
  117685. export interface IWebXRMotionControllerAxesValue {
  117686. /**
  117687. * The value of the x axis
  117688. */
  117689. x: number;
  117690. /**
  117691. * The value of the y-axis
  117692. */
  117693. y: number;
  117694. }
  117695. /**
  117696. * changed / previous values for the values of this component
  117697. */
  117698. export interface IWebXRMotionControllerComponentChangesValues<T> {
  117699. /**
  117700. * current (this frame) value
  117701. */
  117702. current: T;
  117703. /**
  117704. * previous (last change) value
  117705. */
  117706. previous: T;
  117707. }
  117708. /**
  117709. * Represents changes in the component between current frame and last values recorded
  117710. */
  117711. export interface IWebXRMotionControllerComponentChanges {
  117712. /**
  117713. * will be populated with previous and current values if axes changed
  117714. */
  117715. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  117716. /**
  117717. * will be populated with previous and current values if pressed changed
  117718. */
  117719. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  117720. /**
  117721. * will be populated with previous and current values if touched changed
  117722. */
  117723. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  117724. /**
  117725. * will be populated with previous and current values if value changed
  117726. */
  117727. value?: IWebXRMotionControllerComponentChangesValues<number>;
  117728. }
  117729. /**
  117730. * This class represents a single component (for example button or thumbstick) of a motion controller
  117731. */
  117732. export class WebXRControllerComponent implements IDisposable {
  117733. /**
  117734. * the id of this component
  117735. */
  117736. id: string;
  117737. /**
  117738. * the type of the component
  117739. */
  117740. type: MotionControllerComponentType;
  117741. private _buttonIndex;
  117742. private _axesIndices;
  117743. private _axes;
  117744. private _changes;
  117745. private _currentValue;
  117746. private _hasChanges;
  117747. private _pressed;
  117748. private _touched;
  117749. /**
  117750. * button component type
  117751. */
  117752. static BUTTON_TYPE: MotionControllerComponentType;
  117753. /**
  117754. * squeeze component type
  117755. */
  117756. static SQUEEZE_TYPE: MotionControllerComponentType;
  117757. /**
  117758. * Thumbstick component type
  117759. */
  117760. static THUMBSTICK_TYPE: MotionControllerComponentType;
  117761. /**
  117762. * Touchpad component type
  117763. */
  117764. static TOUCHPAD_TYPE: MotionControllerComponentType;
  117765. /**
  117766. * trigger component type
  117767. */
  117768. static TRIGGER_TYPE: MotionControllerComponentType;
  117769. /**
  117770. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  117771. * the axes data changes
  117772. */
  117773. onAxisValueChangedObservable: Observable<{
  117774. x: number;
  117775. y: number;
  117776. }>;
  117777. /**
  117778. * Observers registered here will be triggered when the state of a button changes
  117779. * State change is either pressed / touched / value
  117780. */
  117781. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  117782. /**
  117783. * Creates a new component for a motion controller.
  117784. * It is created by the motion controller itself
  117785. *
  117786. * @param id the id of this component
  117787. * @param type the type of the component
  117788. * @param _buttonIndex index in the buttons array of the gamepad
  117789. * @param _axesIndices indices of the values in the axes array of the gamepad
  117790. */
  117791. constructor(
  117792. /**
  117793. * the id of this component
  117794. */
  117795. id: string,
  117796. /**
  117797. * the type of the component
  117798. */
  117799. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  117800. /**
  117801. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  117802. */
  117803. get axes(): IWebXRMotionControllerAxesValue;
  117804. /**
  117805. * Get the changes. Elements will be populated only if they changed with their previous and current value
  117806. */
  117807. get changes(): IWebXRMotionControllerComponentChanges;
  117808. /**
  117809. * Return whether or not the component changed the last frame
  117810. */
  117811. get hasChanges(): boolean;
  117812. /**
  117813. * is the button currently pressed
  117814. */
  117815. get pressed(): boolean;
  117816. /**
  117817. * is the button currently touched
  117818. */
  117819. get touched(): boolean;
  117820. /**
  117821. * Get the current value of this component
  117822. */
  117823. get value(): number;
  117824. /**
  117825. * Dispose this component
  117826. */
  117827. dispose(): void;
  117828. /**
  117829. * Are there axes correlating to this component
  117830. * @return true is axes data is available
  117831. */
  117832. isAxes(): boolean;
  117833. /**
  117834. * Is this component a button (hence - pressable)
  117835. * @returns true if can be pressed
  117836. */
  117837. isButton(): boolean;
  117838. /**
  117839. * update this component using the gamepad object it is in. Called on every frame
  117840. * @param nativeController the native gamepad controller object
  117841. */
  117842. update(nativeController: IMinimalMotionControllerObject): void;
  117843. }
  117844. }
  117845. declare module BABYLON {
  117846. /**
  117847. * Class used to represent data loading progression
  117848. */
  117849. export class SceneLoaderProgressEvent {
  117850. /** defines if data length to load can be evaluated */
  117851. readonly lengthComputable: boolean;
  117852. /** defines the loaded data length */
  117853. readonly loaded: number;
  117854. /** defines the data length to load */
  117855. readonly total: number;
  117856. /**
  117857. * Create a new progress event
  117858. * @param lengthComputable defines if data length to load can be evaluated
  117859. * @param loaded defines the loaded data length
  117860. * @param total defines the data length to load
  117861. */
  117862. constructor(
  117863. /** defines if data length to load can be evaluated */
  117864. lengthComputable: boolean,
  117865. /** defines the loaded data length */
  117866. loaded: number,
  117867. /** defines the data length to load */
  117868. total: number);
  117869. /**
  117870. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  117871. * @param event defines the source event
  117872. * @returns a new SceneLoaderProgressEvent
  117873. */
  117874. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  117875. }
  117876. /**
  117877. * Interface used by SceneLoader plugins to define supported file extensions
  117878. */
  117879. export interface ISceneLoaderPluginExtensions {
  117880. /**
  117881. * Defines the list of supported extensions
  117882. */
  117883. [extension: string]: {
  117884. isBinary: boolean;
  117885. };
  117886. }
  117887. /**
  117888. * Interface used by SceneLoader plugin factory
  117889. */
  117890. export interface ISceneLoaderPluginFactory {
  117891. /**
  117892. * Defines the name of the factory
  117893. */
  117894. name: string;
  117895. /**
  117896. * Function called to create a new plugin
  117897. * @return the new plugin
  117898. */
  117899. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  117900. /**
  117901. * The callback that returns true if the data can be directly loaded.
  117902. * @param data string containing the file data
  117903. * @returns if the data can be loaded directly
  117904. */
  117905. canDirectLoad?(data: string): boolean;
  117906. }
  117907. /**
  117908. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  117909. */
  117910. export interface ISceneLoaderPluginBase {
  117911. /**
  117912. * The friendly name of this plugin.
  117913. */
  117914. name: string;
  117915. /**
  117916. * The file extensions supported by this plugin.
  117917. */
  117918. extensions: string | ISceneLoaderPluginExtensions;
  117919. /**
  117920. * The callback called when loading from a url.
  117921. * @param scene scene loading this url
  117922. * @param url url to load
  117923. * @param onSuccess callback called when the file successfully loads
  117924. * @param onProgress callback called while file is loading (if the server supports this mode)
  117925. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  117926. * @param onError callback called when the file fails to load
  117927. * @returns a file request object
  117928. */
  117929. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  117930. /**
  117931. * The callback called when loading from a file object.
  117932. * @param scene scene loading this file
  117933. * @param file defines the file to load
  117934. * @param onSuccess defines the callback to call when data is loaded
  117935. * @param onProgress defines the callback to call during loading process
  117936. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  117937. * @param onError defines the callback to call when an error occurs
  117938. * @returns a file request object
  117939. */
  117940. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  117941. /**
  117942. * The callback that returns true if the data can be directly loaded.
  117943. * @param data string containing the file data
  117944. * @returns if the data can be loaded directly
  117945. */
  117946. canDirectLoad?(data: string): boolean;
  117947. /**
  117948. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  117949. * @param scene scene loading this data
  117950. * @param data string containing the data
  117951. * @returns data to pass to the plugin
  117952. */
  117953. directLoad?(scene: Scene, data: string): any;
  117954. /**
  117955. * The callback that allows custom handling of the root url based on the response url.
  117956. * @param rootUrl the original root url
  117957. * @param responseURL the response url if available
  117958. * @returns the new root url
  117959. */
  117960. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  117961. }
  117962. /**
  117963. * Interface used to define a SceneLoader plugin
  117964. */
  117965. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  117966. /**
  117967. * Import meshes into a scene.
  117968. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  117969. * @param scene The scene to import into
  117970. * @param data The data to import
  117971. * @param rootUrl The root url for scene and resources
  117972. * @param meshes The meshes array to import into
  117973. * @param particleSystems The particle systems array to import into
  117974. * @param skeletons The skeletons array to import into
  117975. * @param onError The callback when import fails
  117976. * @returns True if successful or false otherwise
  117977. */
  117978. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  117979. /**
  117980. * Load into a scene.
  117981. * @param scene The scene to load into
  117982. * @param data The data to import
  117983. * @param rootUrl The root url for scene and resources
  117984. * @param onError The callback when import fails
  117985. * @returns True if successful or false otherwise
  117986. */
  117987. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  117988. /**
  117989. * Load into an asset container.
  117990. * @param scene The scene to load into
  117991. * @param data The data to import
  117992. * @param rootUrl The root url for scene and resources
  117993. * @param onError The callback when import fails
  117994. * @returns The loaded asset container
  117995. */
  117996. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  117997. }
  117998. /**
  117999. * Interface used to define an async SceneLoader plugin
  118000. */
  118001. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  118002. /**
  118003. * Import meshes into a scene.
  118004. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  118005. * @param scene The scene to import into
  118006. * @param data The data to import
  118007. * @param rootUrl The root url for scene and resources
  118008. * @param onProgress The callback when the load progresses
  118009. * @param fileName Defines the name of the file to load
  118010. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  118011. */
  118012. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  118013. meshes: AbstractMesh[];
  118014. particleSystems: IParticleSystem[];
  118015. skeletons: Skeleton[];
  118016. animationGroups: AnimationGroup[];
  118017. }>;
  118018. /**
  118019. * Load into a scene.
  118020. * @param scene The scene to load into
  118021. * @param data The data to import
  118022. * @param rootUrl The root url for scene and resources
  118023. * @param onProgress The callback when the load progresses
  118024. * @param fileName Defines the name of the file to load
  118025. * @returns Nothing
  118026. */
  118027. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  118028. /**
  118029. * Load into an asset container.
  118030. * @param scene The scene to load into
  118031. * @param data The data to import
  118032. * @param rootUrl The root url for scene and resources
  118033. * @param onProgress The callback when the load progresses
  118034. * @param fileName Defines the name of the file to load
  118035. * @returns The loaded asset container
  118036. */
  118037. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  118038. }
  118039. /**
  118040. * Mode that determines how to handle old animation groups before loading new ones.
  118041. */
  118042. export enum SceneLoaderAnimationGroupLoadingMode {
  118043. /**
  118044. * Reset all old animations to initial state then dispose them.
  118045. */
  118046. Clean = 0,
  118047. /**
  118048. * Stop all old animations.
  118049. */
  118050. Stop = 1,
  118051. /**
  118052. * Restart old animations from first frame.
  118053. */
  118054. Sync = 2,
  118055. /**
  118056. * Old animations remains untouched.
  118057. */
  118058. NoSync = 3
  118059. }
  118060. /**
  118061. * Class used to load scene from various file formats using registered plugins
  118062. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  118063. */
  118064. export class SceneLoader {
  118065. /**
  118066. * No logging while loading
  118067. */
  118068. static readonly NO_LOGGING: number;
  118069. /**
  118070. * Minimal logging while loading
  118071. */
  118072. static readonly MINIMAL_LOGGING: number;
  118073. /**
  118074. * Summary logging while loading
  118075. */
  118076. static readonly SUMMARY_LOGGING: number;
  118077. /**
  118078. * Detailled logging while loading
  118079. */
  118080. static readonly DETAILED_LOGGING: number;
  118081. /**
  118082. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  118083. */
  118084. static get ForceFullSceneLoadingForIncremental(): boolean;
  118085. static set ForceFullSceneLoadingForIncremental(value: boolean);
  118086. /**
  118087. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  118088. */
  118089. static get ShowLoadingScreen(): boolean;
  118090. static set ShowLoadingScreen(value: boolean);
  118091. /**
  118092. * Defines the current logging level (while loading the scene)
  118093. * @ignorenaming
  118094. */
  118095. static get loggingLevel(): number;
  118096. static set loggingLevel(value: number);
  118097. /**
  118098. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  118099. */
  118100. static get CleanBoneMatrixWeights(): boolean;
  118101. static set CleanBoneMatrixWeights(value: boolean);
  118102. /**
  118103. * Event raised when a plugin is used to load a scene
  118104. */
  118105. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  118106. private static _registeredPlugins;
  118107. private static _getDefaultPlugin;
  118108. private static _getPluginForExtension;
  118109. private static _getPluginForDirectLoad;
  118110. private static _getPluginForFilename;
  118111. private static _getDirectLoad;
  118112. private static _loadData;
  118113. private static _getFileInfo;
  118114. /**
  118115. * Gets a plugin that can load the given extension
  118116. * @param extension defines the extension to load
  118117. * @returns a plugin or null if none works
  118118. */
  118119. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  118120. /**
  118121. * Gets a boolean indicating that the given extension can be loaded
  118122. * @param extension defines the extension to load
  118123. * @returns true if the extension is supported
  118124. */
  118125. static IsPluginForExtensionAvailable(extension: string): boolean;
  118126. /**
  118127. * Adds a new plugin to the list of registered plugins
  118128. * @param plugin defines the plugin to add
  118129. */
  118130. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  118131. /**
  118132. * Import meshes into a scene
  118133. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  118134. * @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)
  118135. * @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)
  118136. * @param scene the instance of BABYLON.Scene to append to
  118137. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  118138. * @param onProgress a callback with a progress event for each file being loaded
  118139. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  118140. * @param pluginExtension the extension used to determine the plugin
  118141. * @returns The loaded plugin
  118142. */
  118143. 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>;
  118144. /**
  118145. * Import meshes into a scene
  118146. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  118147. * @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)
  118148. * @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)
  118149. * @param scene the instance of BABYLON.Scene to append to
  118150. * @param onProgress a callback with a progress event for each file being loaded
  118151. * @param pluginExtension the extension used to determine the plugin
  118152. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  118153. */
  118154. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  118155. meshes: AbstractMesh[];
  118156. particleSystems: IParticleSystem[];
  118157. skeletons: Skeleton[];
  118158. animationGroups: AnimationGroup[];
  118159. }>;
  118160. /**
  118161. * Load a scene
  118162. * @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)
  118163. * @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)
  118164. * @param engine is the instance of BABYLON.Engine to use to create the scene
  118165. * @param onSuccess a callback with the scene when import succeeds
  118166. * @param onProgress a callback with a progress event for each file being loaded
  118167. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  118168. * @param pluginExtension the extension used to determine the plugin
  118169. * @returns The loaded plugin
  118170. */
  118171. 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>;
  118172. /**
  118173. * Load a scene
  118174. * @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)
  118175. * @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)
  118176. * @param engine is the instance of BABYLON.Engine to use to create the scene
  118177. * @param onProgress a callback with a progress event for each file being loaded
  118178. * @param pluginExtension the extension used to determine the plugin
  118179. * @returns The loaded scene
  118180. */
  118181. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  118182. /**
  118183. * Append a scene
  118184. * @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)
  118185. * @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)
  118186. * @param scene is the instance of BABYLON.Scene to append to
  118187. * @param onSuccess a callback with the scene when import succeeds
  118188. * @param onProgress a callback with a progress event for each file being loaded
  118189. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  118190. * @param pluginExtension the extension used to determine the plugin
  118191. * @returns The loaded plugin
  118192. */
  118193. 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>;
  118194. /**
  118195. * Append a scene
  118196. * @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)
  118197. * @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)
  118198. * @param scene is the instance of BABYLON.Scene to append to
  118199. * @param onProgress a callback with a progress event for each file being loaded
  118200. * @param pluginExtension the extension used to determine the plugin
  118201. * @returns The given scene
  118202. */
  118203. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  118204. /**
  118205. * Load a scene into an asset container
  118206. * @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)
  118207. * @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)
  118208. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  118209. * @param onSuccess a callback with the scene when import succeeds
  118210. * @param onProgress a callback with a progress event for each file being loaded
  118211. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  118212. * @param pluginExtension the extension used to determine the plugin
  118213. * @returns The loaded plugin
  118214. */
  118215. 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>;
  118216. /**
  118217. * Load a scene into an asset container
  118218. * @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)
  118219. * @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)
  118220. * @param scene is the instance of Scene to append to
  118221. * @param onProgress a callback with a progress event for each file being loaded
  118222. * @param pluginExtension the extension used to determine the plugin
  118223. * @returns The loaded asset container
  118224. */
  118225. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  118226. /**
  118227. * Import animations from a file into a scene
  118228. * @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)
  118229. * @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)
  118230. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  118231. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  118232. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  118233. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  118234. * @param onSuccess a callback with the scene when import succeeds
  118235. * @param onProgress a callback with a progress event for each file being loaded
  118236. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  118237. */
  118238. 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;
  118239. /**
  118240. * Import animations from a file into a scene
  118241. * @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)
  118242. * @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)
  118243. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  118244. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  118245. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  118246. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  118247. * @param onSuccess a callback with the scene when import succeeds
  118248. * @param onProgress a callback with a progress event for each file being loaded
  118249. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  118250. * @returns the updated scene with imported animations
  118251. */
  118252. 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>;
  118253. }
  118254. }
  118255. declare module BABYLON {
  118256. /**
  118257. * Handness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  118258. */
  118259. export type MotionControllerHandness = "none" | "left" | "right";
  118260. /**
  118261. * The type of components available in motion controllers.
  118262. * This is not the name of the component.
  118263. */
  118264. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  118265. /**
  118266. * The state of a controller component
  118267. */
  118268. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  118269. /**
  118270. * The schema of motion controller layout.
  118271. * No object will be initialized using this interface
  118272. * This is used just to define the profile.
  118273. */
  118274. export interface IMotionControllerLayout {
  118275. /**
  118276. * Path to load the assets. Usually relative to the base path
  118277. */
  118278. assetPath: string;
  118279. /**
  118280. * Available components (unsorted)
  118281. */
  118282. components: {
  118283. /**
  118284. * A map of component Ids
  118285. */
  118286. [componentId: string]: {
  118287. /**
  118288. * The type of input the component outputs
  118289. */
  118290. type: MotionControllerComponentType;
  118291. /**
  118292. * The indices of this component in the gamepad object
  118293. */
  118294. gamepadIndices: {
  118295. /**
  118296. * Index of button
  118297. */
  118298. button?: number;
  118299. /**
  118300. * If available, index of x-axis
  118301. */
  118302. xAxis?: number;
  118303. /**
  118304. * If available, index of y-axis
  118305. */
  118306. yAxis?: number;
  118307. };
  118308. /**
  118309. * The mesh's root node name
  118310. */
  118311. rootNodeName: string;
  118312. /**
  118313. * Animation definitions for this model
  118314. */
  118315. visualResponses: {
  118316. [stateKey: string]: {
  118317. /**
  118318. * What property will be animated
  118319. */
  118320. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  118321. /**
  118322. * What states influence this visual response
  118323. */
  118324. states: MotionControllerComponentStateType[];
  118325. /**
  118326. * Type of animation - movement or visibility
  118327. */
  118328. valueNodeProperty: "transform" | "visibility";
  118329. /**
  118330. * Base node name to move. Its position will be calculated according to the min and max nodes
  118331. */
  118332. valueNodeName?: string;
  118333. /**
  118334. * Minimum movement node
  118335. */
  118336. minNodeName?: string;
  118337. /**
  118338. * Max movement node
  118339. */
  118340. maxNodeName?: string;
  118341. };
  118342. };
  118343. /**
  118344. * If touch enabled, what is the name of node to display user feedback
  118345. */
  118346. touchPointNodeName?: string;
  118347. };
  118348. };
  118349. /**
  118350. * Is it xr standard mapping or not
  118351. */
  118352. gamepadMapping: "" | "xr-standard";
  118353. /**
  118354. * Base root node of this entire model
  118355. */
  118356. rootNodeName: string;
  118357. /**
  118358. * Defines the main button component id
  118359. */
  118360. selectComponentId: string;
  118361. }
  118362. /**
  118363. * A definition for the layout map in the input profile
  118364. */
  118365. export interface IMotionControllerLayoutMap {
  118366. /**
  118367. * Layouts with handness type as a key
  118368. */
  118369. [handness: string]: IMotionControllerLayout;
  118370. }
  118371. /**
  118372. * The XR Input profile schema
  118373. * Profiles can be found here:
  118374. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  118375. */
  118376. export interface IMotionControllerProfile {
  118377. /**
  118378. * fallback profiles for this profileId
  118379. */
  118380. fallbackProfileIds: string[];
  118381. /**
  118382. * The layout map, with handness as key
  118383. */
  118384. layouts: IMotionControllerLayoutMap;
  118385. /**
  118386. * The id of this profile
  118387. * correlates to the profile(s) in the xrInput.profiles array
  118388. */
  118389. profileId: string;
  118390. }
  118391. /**
  118392. * A helper-interface for the 3 meshes needed for controller button animation
  118393. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  118394. */
  118395. export interface IMotionControllerButtonMeshMap {
  118396. /**
  118397. * the mesh that defines the pressed value mesh position.
  118398. * This is used to find the max-position of this button
  118399. */
  118400. pressedMesh: AbstractMesh;
  118401. /**
  118402. * the mesh that defines the unpressed value mesh position.
  118403. * This is used to find the min (or initial) position of this button
  118404. */
  118405. unpressedMesh: AbstractMesh;
  118406. /**
  118407. * The mesh that will be changed when value changes
  118408. */
  118409. valueMesh: AbstractMesh;
  118410. }
  118411. /**
  118412. * A helper-interface for the 3 meshes needed for controller axis animation.
  118413. * This will be expanded when touchpad animations are fully supported
  118414. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  118415. */
  118416. export interface IMotionControllerMeshMap {
  118417. /**
  118418. * the mesh that defines the maximum value mesh position.
  118419. */
  118420. maxMesh?: AbstractMesh;
  118421. /**
  118422. * the mesh that defines the minimum value mesh position.
  118423. */
  118424. minMesh?: AbstractMesh;
  118425. /**
  118426. * The mesh that will be changed when axis value changes
  118427. */
  118428. valueMesh: AbstractMesh;
  118429. }
  118430. /**
  118431. * The elements needed for change-detection of the gamepad objects in motion controllers
  118432. */
  118433. export interface IMinimalMotionControllerObject {
  118434. /**
  118435. * Available axes of this controller
  118436. */
  118437. axes: number[];
  118438. /**
  118439. * An array of available buttons
  118440. */
  118441. buttons: Array<{
  118442. /**
  118443. * Value of the button/trigger
  118444. */
  118445. value: number;
  118446. /**
  118447. * If the button/trigger is currently touched
  118448. */
  118449. touched: boolean;
  118450. /**
  118451. * If the button/trigger is currently pressed
  118452. */
  118453. pressed: boolean;
  118454. }>;
  118455. }
  118456. /**
  118457. * An Abstract Motion controller
  118458. * This class receives an xrInput and a profile layout and uses those to initialize the components
  118459. * Each component has an observable to check for changes in value and state
  118460. */
  118461. export abstract class WebXRAbstractMotionController implements IDisposable {
  118462. protected scene: Scene;
  118463. protected layout: IMotionControllerLayout;
  118464. /**
  118465. * The gamepad object correlating to this controller
  118466. */
  118467. gamepadObject: IMinimalMotionControllerObject;
  118468. /**
  118469. * handness (left/right/none) of this controller
  118470. */
  118471. handness: MotionControllerHandness;
  118472. private _initComponent;
  118473. private _modelReady;
  118474. /**
  118475. * A map of components (WebXRControllerComponent) in this motion controller
  118476. * Components have a ComponentType and can also have both button and axis definitions
  118477. */
  118478. readonly components: {
  118479. [id: string]: WebXRControllerComponent;
  118480. };
  118481. /**
  118482. * Disable the model's animation. Can be set at any time.
  118483. */
  118484. disableAnimation: boolean;
  118485. /**
  118486. * Observers registered here will be triggered when the model of this controller is done loading
  118487. */
  118488. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  118489. /**
  118490. * The profile id of this motion controller
  118491. */
  118492. abstract profileId: string;
  118493. /**
  118494. * The root mesh of the model. It is null if the model was not yet initialized
  118495. */
  118496. rootMesh: Nullable<AbstractMesh>;
  118497. /**
  118498. * constructs a new abstract motion controller
  118499. * @param scene the scene to which the model of the controller will be added
  118500. * @param layout The profile layout to load
  118501. * @param gamepadObject The gamepad object correlating to this controller
  118502. * @param handness handness (left/right/none) of this controller
  118503. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  118504. */
  118505. constructor(scene: Scene, layout: IMotionControllerLayout,
  118506. /**
  118507. * The gamepad object correlating to this controller
  118508. */
  118509. gamepadObject: IMinimalMotionControllerObject,
  118510. /**
  118511. * handness (left/right/none) of this controller
  118512. */
  118513. handness: MotionControllerHandness, _doNotLoadControllerMesh?: boolean);
  118514. /**
  118515. * Dispose this controller, the model mesh and all its components
  118516. */
  118517. dispose(): void;
  118518. /**
  118519. * Returns all components of specific type
  118520. * @param type the type to search for
  118521. * @return an array of components with this type
  118522. */
  118523. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  118524. /**
  118525. * get a component based an its component id as defined in layout.components
  118526. * @param id the id of the component
  118527. * @returns the component correlates to the id or undefined if not found
  118528. */
  118529. getComponent(id: string): WebXRControllerComponent;
  118530. /**
  118531. * Get the list of components available in this motion controller
  118532. * @returns an array of strings correlating to available components
  118533. */
  118534. getComponentIds(): string[];
  118535. /**
  118536. * Get the first component of specific type
  118537. * @param type type of component to find
  118538. * @return a controller component or null if not found
  118539. */
  118540. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  118541. /**
  118542. * Get the main (Select) component of this controller as defined in the layout
  118543. * @returns the main component of this controller
  118544. */
  118545. getMainComponent(): WebXRControllerComponent;
  118546. /**
  118547. * Loads the model correlating to this controller
  118548. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  118549. * @returns A promise fulfilled with the result of the model loading
  118550. */
  118551. loadModel(): Promise<boolean>;
  118552. /**
  118553. * Update this model using the current XRFrame
  118554. * @param xrFrame the current xr frame to use and update the model
  118555. */
  118556. updateFromXRFrame(xrFrame: XRFrame): void;
  118557. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  118558. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  118559. /**
  118560. * Moves the axis on the controller mesh based on its current state
  118561. * @param axis the index of the axis
  118562. * @param axisValue the value of the axis which determines the meshes new position
  118563. * @hidden
  118564. */
  118565. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  118566. /**
  118567. * Update the model itself with the current frame data
  118568. * @param xrFrame the frame to use for updating the model mesh
  118569. */
  118570. protected updateModel(xrFrame: XRFrame): void;
  118571. /**
  118572. * Get the filename and path for this controller's model
  118573. * @returns a map of filename and path
  118574. */
  118575. protected abstract _getFilenameAndPath(): {
  118576. filename: string;
  118577. path: string;
  118578. };
  118579. /**
  118580. * This function is called before the mesh is loaded. It checks for loading constraints.
  118581. * For example, this function can check if the GLB loader is available
  118582. * If this function returns false, the generic controller will be loaded instead
  118583. * @returns Is the client ready to load the mesh
  118584. */
  118585. protected abstract _getModelLoadingConstraints(): boolean;
  118586. /**
  118587. * This function will be called after the model was successfully loaded and can be used
  118588. * for mesh transformations before it is available for the user
  118589. * @param meshes the loaded meshes
  118590. */
  118591. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  118592. /**
  118593. * Set the root mesh for this controller. Important for the WebXR controller class
  118594. * @param meshes the loaded meshes
  118595. */
  118596. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  118597. /**
  118598. * A function executed each frame that updates the mesh (if needed)
  118599. * @param xrFrame the current xrFrame
  118600. */
  118601. protected abstract _updateModel(xrFrame: XRFrame): void;
  118602. private _getGenericFilenameAndPath;
  118603. private _getGenericParentMesh;
  118604. }
  118605. }
  118606. declare module BABYLON {
  118607. /**
  118608. * A generic trigger-only motion controller for WebXR
  118609. */
  118610. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  118611. /**
  118612. * Static version of the profile id of this controller
  118613. */
  118614. static ProfileId: string;
  118615. profileId: string;
  118616. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  118617. protected _getFilenameAndPath(): {
  118618. filename: string;
  118619. path: string;
  118620. };
  118621. protected _getModelLoadingConstraints(): boolean;
  118622. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  118623. protected _setRootMesh(meshes: AbstractMesh[]): void;
  118624. protected _updateModel(): void;
  118625. }
  118626. }
  118627. declare module BABYLON {
  118628. /**
  118629. * Class containing static functions to help procedurally build meshes
  118630. */
  118631. export class SphereBuilder {
  118632. /**
  118633. * Creates a sphere mesh
  118634. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  118635. * * 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`)
  118636. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  118637. * * 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
  118638. * * 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)
  118639. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  118640. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  118641. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118642. * @param name defines the name of the mesh
  118643. * @param options defines the options used to create the mesh
  118644. * @param scene defines the hosting scene
  118645. * @returns the sphere mesh
  118646. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  118647. */
  118648. static CreateSphere(name: string, options: {
  118649. segments?: number;
  118650. diameter?: number;
  118651. diameterX?: number;
  118652. diameterY?: number;
  118653. diameterZ?: number;
  118654. arc?: number;
  118655. slice?: number;
  118656. sideOrientation?: number;
  118657. frontUVs?: Vector4;
  118658. backUVs?: Vector4;
  118659. updatable?: boolean;
  118660. }, scene?: Nullable<Scene>): Mesh;
  118661. }
  118662. }
  118663. declare module BABYLON {
  118664. /**
  118665. * A profiled motion controller has its profile loaded from an online repository.
  118666. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  118667. */
  118668. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  118669. private _repositoryUrl;
  118670. private _buttonMeshMapping;
  118671. private _touchDots;
  118672. /**
  118673. * The profile ID of this controller. Will be populated when the controller initializes.
  118674. */
  118675. profileId: string;
  118676. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  118677. dispose(): void;
  118678. protected _getFilenameAndPath(): {
  118679. filename: string;
  118680. path: string;
  118681. };
  118682. protected _getModelLoadingConstraints(): boolean;
  118683. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  118684. protected _setRootMesh(meshes: AbstractMesh[]): void;
  118685. protected _updateModel(_xrFrame: XRFrame): void;
  118686. }
  118687. }
  118688. declare module BABYLON {
  118689. /**
  118690. * A construction function type to create a new controller based on an xrInput object
  118691. */
  118692. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  118693. /**
  118694. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  118695. *
  118696. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  118697. * it should be replaced with auto-loaded controllers.
  118698. *
  118699. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  118700. */
  118701. export class WebXRMotionControllerManager {
  118702. private static _AvailableControllers;
  118703. private static _Fallbacks;
  118704. private static _ProfileLoadingPromises;
  118705. private static _ProfilesList;
  118706. /**
  118707. * The base URL of the online controller repository. Can be changed at any time.
  118708. */
  118709. static BaseRepositoryUrl: string;
  118710. /**
  118711. * Which repository gets priority - local or online
  118712. */
  118713. static PrioritizeOnlineRepository: boolean;
  118714. /**
  118715. * Use the online repository, or use only locally-defined controllers
  118716. */
  118717. static UseOnlineRepository: boolean;
  118718. /**
  118719. * Clear the cache used for profile loading and reload when requested again
  118720. */
  118721. static ClearProfilesCache(): void;
  118722. /**
  118723. * Register the default fallbacks.
  118724. * This function is called automatically when this file is imported.
  118725. */
  118726. static DefaultFallbacks(): void;
  118727. /**
  118728. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  118729. * @param profileId the profile to which a fallback needs to be found
  118730. * @return an array with corresponding fallback profiles
  118731. */
  118732. static FindFallbackWithProfileId(profileId: string): string[];
  118733. /**
  118734. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  118735. * The order of search:
  118736. *
  118737. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  118738. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  118739. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  118740. * 4) return the generic trigger controller if none were found
  118741. *
  118742. * @param xrInput the xrInput to which a new controller is initialized
  118743. * @param scene the scene to which the model will be added
  118744. * @param forceProfile force a certain profile for this controller
  118745. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  118746. */
  118747. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  118748. /**
  118749. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  118750. *
  118751. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  118752. *
  118753. * @param type the profile type to register
  118754. * @param constructFunction the function to be called when loading this profile
  118755. */
  118756. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  118757. /**
  118758. * Register a fallback to a specific profile.
  118759. * @param profileId the profileId that will receive the fallbacks
  118760. * @param fallbacks A list of fallback profiles
  118761. */
  118762. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  118763. /**
  118764. * Will update the list of profiles available in the repository
  118765. * @return a promise that resolves to a map of profiles available online
  118766. */
  118767. static UpdateProfilesList(): Promise<{
  118768. [profile: string]: string;
  118769. }>;
  118770. private static _LoadProfileFromRepository;
  118771. private static _LoadProfilesFromAvailableControllers;
  118772. }
  118773. }
  118774. declare module BABYLON {
  118775. /**
  118776. * Configuration options for the WebXR controller creation
  118777. */
  118778. export interface IWebXRControllerOptions {
  118779. /**
  118780. * Should the controller mesh be animated when a user interacts with it
  118781. * The pressed buttons / thumbstick and touchpad animations will be disabled
  118782. */
  118783. disableMotionControllerAnimation?: boolean;
  118784. /**
  118785. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  118786. */
  118787. doNotLoadControllerMesh?: boolean;
  118788. /**
  118789. * Force a specific controller type for this controller.
  118790. * This can be used when creating your own profile or when testing different controllers
  118791. */
  118792. forceControllerProfile?: string;
  118793. }
  118794. /**
  118795. * Represents an XR controller
  118796. */
  118797. export class WebXRInputSource {
  118798. private _scene;
  118799. /** The underlying input source for the controller */
  118800. inputSource: XRInputSource;
  118801. private _options;
  118802. private _tmpQuaternion;
  118803. private _tmpVector;
  118804. private _uniqueId;
  118805. /**
  118806. * 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
  118807. */
  118808. grip?: AbstractMesh;
  118809. /**
  118810. * If available, this is the gamepad object related to this controller.
  118811. * Using this object it is possible to get click events and trackpad changes of the
  118812. * webxr controller that is currently being used.
  118813. */
  118814. motionController?: WebXRAbstractMotionController;
  118815. /**
  118816. * Event that fires when the controller is removed/disposed.
  118817. * The object provided as event data is this controller, after associated assets were disposed.
  118818. * uniqueId is still available.
  118819. */
  118820. onDisposeObservable: Observable<WebXRInputSource>;
  118821. /**
  118822. * Will be triggered when the mesh associated with the motion controller is done loading.
  118823. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  118824. * A shortened version of controller -> motion controller -> on mesh loaded.
  118825. */
  118826. onMeshLoadedObservable: Observable<AbstractMesh>;
  118827. /**
  118828. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  118829. */
  118830. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  118831. /**
  118832. * Pointer which can be used to select objects or attach a visible laser to
  118833. */
  118834. pointer: AbstractMesh;
  118835. /**
  118836. * Creates the controller
  118837. * @see https://doc.babylonjs.com/how_to/webxr
  118838. * @param _scene the scene which the controller should be associated to
  118839. * @param inputSource the underlying input source for the controller
  118840. * @param _options options for this controller creation
  118841. */
  118842. constructor(_scene: Scene,
  118843. /** The underlying input source for the controller */
  118844. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  118845. /**
  118846. * Get this controllers unique id
  118847. */
  118848. get uniqueId(): string;
  118849. /**
  118850. * Disposes of the object
  118851. */
  118852. dispose(): void;
  118853. /**
  118854. * Gets a world space ray coming from the pointer or grip
  118855. * @param result the resulting ray
  118856. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  118857. */
  118858. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  118859. /**
  118860. * Updates the controller pose based on the given XRFrame
  118861. * @param xrFrame xr frame to update the pose with
  118862. * @param referenceSpace reference space to use
  118863. */
  118864. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  118865. }
  118866. }
  118867. declare module BABYLON {
  118868. /**
  118869. * The schema for initialization options of the XR Input class
  118870. */
  118871. export interface IWebXRInputOptions {
  118872. /**
  118873. * If set to true no model will be automatically loaded
  118874. */
  118875. doNotLoadControllerMeshes?: boolean;
  118876. /**
  118877. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  118878. * If not found, the xr input profile data will be used.
  118879. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  118880. */
  118881. forceInputProfile?: string;
  118882. /**
  118883. * Do not send a request to the controller repository to load the profile.
  118884. *
  118885. * Instead, use the controllers available in babylon itself.
  118886. */
  118887. disableOnlineControllerRepository?: boolean;
  118888. /**
  118889. * A custom URL for the controllers repository
  118890. */
  118891. customControllersRepositoryURL?: string;
  118892. /**
  118893. * Should the controller model's components not move according to the user input
  118894. */
  118895. disableControllerAnimation?: boolean;
  118896. }
  118897. /**
  118898. * XR input used to track XR inputs such as controllers/rays
  118899. */
  118900. export class WebXRInput implements IDisposable {
  118901. /**
  118902. * the xr session manager for this session
  118903. */
  118904. xrSessionManager: WebXRSessionManager;
  118905. /**
  118906. * the WebXR camera for this session. Mainly used for teleportation
  118907. */
  118908. xrCamera: WebXRCamera;
  118909. private readonly options;
  118910. /**
  118911. * XR controllers being tracked
  118912. */
  118913. controllers: Array<WebXRInputSource>;
  118914. private _frameObserver;
  118915. private _sessionEndedObserver;
  118916. private _sessionInitObserver;
  118917. /**
  118918. * Event when a controller has been connected/added
  118919. */
  118920. onControllerAddedObservable: Observable<WebXRInputSource>;
  118921. /**
  118922. * Event when a controller has been removed/disconnected
  118923. */
  118924. onControllerRemovedObservable: Observable<WebXRInputSource>;
  118925. /**
  118926. * Initializes the WebXRInput
  118927. * @param xrSessionManager the xr session manager for this session
  118928. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  118929. * @param options = initialization options for this xr input
  118930. */
  118931. constructor(
  118932. /**
  118933. * the xr session manager for this session
  118934. */
  118935. xrSessionManager: WebXRSessionManager,
  118936. /**
  118937. * the WebXR camera for this session. Mainly used for teleportation
  118938. */
  118939. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  118940. private _onInputSourcesChange;
  118941. private _addAndRemoveControllers;
  118942. /**
  118943. * Disposes of the object
  118944. */
  118945. dispose(): void;
  118946. }
  118947. }
  118948. declare module BABYLON {
  118949. /**
  118950. * This is the base class for all WebXR features.
  118951. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  118952. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  118953. */
  118954. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  118955. protected _xrSessionManager: WebXRSessionManager;
  118956. private _attached;
  118957. private _removeOnDetach;
  118958. /**
  118959. * Should auto-attach be disabled?
  118960. */
  118961. disableAutoAttach: boolean;
  118962. /**
  118963. * Construct a new (abstract) WebXR feature
  118964. * @param _xrSessionManager the xr session manager for this feature
  118965. */
  118966. constructor(_xrSessionManager: WebXRSessionManager);
  118967. /**
  118968. * Is this feature attached
  118969. */
  118970. get attached(): boolean;
  118971. /**
  118972. * attach this feature
  118973. *
  118974. * @param force should attachment be forced (even when already attached)
  118975. * @returns true if successful, false is failed or already attached
  118976. */
  118977. attach(force?: boolean): boolean;
  118978. /**
  118979. * detach this feature.
  118980. *
  118981. * @returns true if successful, false if failed or already detached
  118982. */
  118983. detach(): boolean;
  118984. /**
  118985. * Dispose this feature and all of the resources attached
  118986. */
  118987. dispose(): void;
  118988. /**
  118989. * This is used to register callbacks that will automatically be removed when detach is called.
  118990. * @param observable the observable to which the observer will be attached
  118991. * @param callback the callback to register
  118992. */
  118993. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  118994. /**
  118995. * Code in this function will be executed on each xrFrame received from the browser.
  118996. * This function will not execute after the feature is detached.
  118997. * @param _xrFrame the current frame
  118998. */
  118999. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  119000. }
  119001. }
  119002. declare module BABYLON {
  119003. /**
  119004. * Renders a layer on top of an existing scene
  119005. */
  119006. export class UtilityLayerRenderer implements IDisposable {
  119007. /** the original scene that will be rendered on top of */
  119008. originalScene: Scene;
  119009. private _pointerCaptures;
  119010. private _lastPointerEvents;
  119011. private static _DefaultUtilityLayer;
  119012. private static _DefaultKeepDepthUtilityLayer;
  119013. private _sharedGizmoLight;
  119014. private _renderCamera;
  119015. /**
  119016. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  119017. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  119018. * @returns the camera that is used when rendering the utility layer
  119019. */
  119020. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  119021. /**
  119022. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  119023. * @param cam the camera that should be used when rendering the utility layer
  119024. */
  119025. setRenderCamera(cam: Nullable<Camera>): void;
  119026. /**
  119027. * @hidden
  119028. * Light which used by gizmos to get light shading
  119029. */
  119030. _getSharedGizmoLight(): HemisphericLight;
  119031. /**
  119032. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  119033. */
  119034. pickUtilitySceneFirst: boolean;
  119035. /**
  119036. * 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)
  119037. */
  119038. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  119039. /**
  119040. * 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)
  119041. */
  119042. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  119043. /**
  119044. * The scene that is rendered on top of the original scene
  119045. */
  119046. utilityLayerScene: Scene;
  119047. /**
  119048. * If the utility layer should automatically be rendered on top of existing scene
  119049. */
  119050. shouldRender: boolean;
  119051. /**
  119052. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  119053. */
  119054. onlyCheckPointerDownEvents: boolean;
  119055. /**
  119056. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  119057. */
  119058. processAllEvents: boolean;
  119059. /**
  119060. * Observable raised when the pointer move from the utility layer scene to the main scene
  119061. */
  119062. onPointerOutObservable: Observable<number>;
  119063. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  119064. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  119065. private _afterRenderObserver;
  119066. private _sceneDisposeObserver;
  119067. private _originalPointerObserver;
  119068. /**
  119069. * Instantiates a UtilityLayerRenderer
  119070. * @param originalScene the original scene that will be rendered on top of
  119071. * @param handleEvents boolean indicating if the utility layer should handle events
  119072. */
  119073. constructor(
  119074. /** the original scene that will be rendered on top of */
  119075. originalScene: Scene, handleEvents?: boolean);
  119076. private _notifyObservers;
  119077. /**
  119078. * Renders the utility layers scene on top of the original scene
  119079. */
  119080. render(): void;
  119081. /**
  119082. * Disposes of the renderer
  119083. */
  119084. dispose(): void;
  119085. private _updateCamera;
  119086. }
  119087. }
  119088. declare module BABYLON {
  119089. /**
  119090. * Options interface for the pointer selection module
  119091. */
  119092. export interface IWebXRControllerPointerSelectionOptions {
  119093. /**
  119094. * if provided, this scene will be used to render meshes.
  119095. */
  119096. customUtilityLayerScene?: Scene;
  119097. /**
  119098. * 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)
  119099. * If not disabled, the last picked point will be used to execute a pointer up event
  119100. * If disabled, pointer up event will be triggered right after the pointer down event.
  119101. * Used in screen and gaze target ray mode only
  119102. */
  119103. disablePointerUpOnTouchOut: boolean;
  119104. /**
  119105. * For gaze mode (time to select instead of press)
  119106. */
  119107. forceGazeMode: boolean;
  119108. /**
  119109. * 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
  119110. * to start a new countdown to the pointer down event.
  119111. * Defaults to 1.
  119112. */
  119113. gazeModePointerMovedFactor?: number;
  119114. /**
  119115. * Different button type to use instead of the main component
  119116. */
  119117. overrideButtonId?: string;
  119118. /**
  119119. * use this rendering group id for the meshes (optional)
  119120. */
  119121. renderingGroupId?: number;
  119122. /**
  119123. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  119124. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  119125. * 3000 means 3 seconds between pointing at something and selecting it
  119126. */
  119127. timeToSelect?: number;
  119128. /**
  119129. * Should meshes created here be added to a utility layer or the main scene
  119130. */
  119131. useUtilityLayer?: boolean;
  119132. /**
  119133. * the xr input to use with this pointer selection
  119134. */
  119135. xrInput: WebXRInput;
  119136. }
  119137. /**
  119138. * A module that will enable pointer selection for motion controllers of XR Input Sources
  119139. */
  119140. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  119141. private readonly _options;
  119142. private static _idCounter;
  119143. private _attachController;
  119144. private _controllers;
  119145. private _scene;
  119146. private _tmpVectorForPickCompare;
  119147. /**
  119148. * The module's name
  119149. */
  119150. static readonly Name: string;
  119151. /**
  119152. * The (Babylon) version of this module.
  119153. * This is an integer representing the implementation version.
  119154. * This number does not correspond to the WebXR specs version
  119155. */
  119156. static readonly Version: number;
  119157. /**
  119158. * Disable lighting on the laser pointer (so it will always be visible)
  119159. */
  119160. disablePointerLighting: boolean;
  119161. /**
  119162. * Disable lighting on the selection mesh (so it will always be visible)
  119163. */
  119164. disableSelectionMeshLighting: boolean;
  119165. /**
  119166. * Should the laser pointer be displayed
  119167. */
  119168. displayLaserPointer: boolean;
  119169. /**
  119170. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  119171. */
  119172. displaySelectionMesh: boolean;
  119173. /**
  119174. * This color will be set to the laser pointer when selection is triggered
  119175. */
  119176. laserPointerPickedColor: Color3;
  119177. /**
  119178. * Default color of the laser pointer
  119179. */
  119180. lasterPointerDefaultColor: Color3;
  119181. /**
  119182. * default color of the selection ring
  119183. */
  119184. selectionMeshDefaultColor: Color3;
  119185. /**
  119186. * This color will be applied to the selection ring when selection is triggered
  119187. */
  119188. selectionMeshPickedColor: Color3;
  119189. /**
  119190. * Optional filter to be used for ray selection. This predicate shares behavior with
  119191. * scene.pointerMovePredicate which takes priority if it is also assigned.
  119192. */
  119193. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  119194. /**
  119195. * constructs a new background remover module
  119196. * @param _xrSessionManager the session manager for this module
  119197. * @param _options read-only options to be used in this module
  119198. */
  119199. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  119200. /**
  119201. * attach this feature
  119202. * Will usually be called by the features manager
  119203. *
  119204. * @returns true if successful.
  119205. */
  119206. attach(): boolean;
  119207. /**
  119208. * detach this feature.
  119209. * Will usually be called by the features manager
  119210. *
  119211. * @returns true if successful.
  119212. */
  119213. detach(): boolean;
  119214. /**
  119215. * Will get the mesh under a specific pointer.
  119216. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  119217. * @param controllerId the controllerId to check
  119218. * @returns The mesh under pointer or null if no mesh is under the pointer
  119219. */
  119220. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  119221. /**
  119222. * Get the xr controller that correlates to the pointer id in the pointer event
  119223. *
  119224. * @param id the pointer id to search for
  119225. * @returns the controller that correlates to this id or null if not found
  119226. */
  119227. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  119228. protected _onXRFrame(_xrFrame: XRFrame): void;
  119229. private _attachGazeMode;
  119230. private _attachScreenRayMode;
  119231. private _attachTrackedPointerRayMode;
  119232. private _convertNormalToDirectionOfRay;
  119233. private _detachController;
  119234. private _generateNewMeshPair;
  119235. private _pickingMoved;
  119236. private _updatePointerDistance;
  119237. }
  119238. }
  119239. declare module BABYLON {
  119240. /**
  119241. * Button which can be used to enter a different mode of XR
  119242. */
  119243. export class WebXREnterExitUIButton {
  119244. /** button element */
  119245. element: HTMLElement;
  119246. /** XR initialization options for the button */
  119247. sessionMode: XRSessionMode;
  119248. /** Reference space type */
  119249. referenceSpaceType: XRReferenceSpaceType;
  119250. /**
  119251. * Creates a WebXREnterExitUIButton
  119252. * @param element button element
  119253. * @param sessionMode XR initialization session mode
  119254. * @param referenceSpaceType the type of reference space to be used
  119255. */
  119256. constructor(
  119257. /** button element */
  119258. element: HTMLElement,
  119259. /** XR initialization options for the button */
  119260. sessionMode: XRSessionMode,
  119261. /** Reference space type */
  119262. referenceSpaceType: XRReferenceSpaceType);
  119263. /**
  119264. * Extendable function which can be used to update the button's visuals when the state changes
  119265. * @param activeButton the current active button in the UI
  119266. */
  119267. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  119268. }
  119269. /**
  119270. * Options to create the webXR UI
  119271. */
  119272. export class WebXREnterExitUIOptions {
  119273. /**
  119274. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  119275. */
  119276. customButtons?: Array<WebXREnterExitUIButton>;
  119277. /**
  119278. * A reference space type to use when creating the default button.
  119279. * Default is local-floor
  119280. */
  119281. referenceSpaceType?: XRReferenceSpaceType;
  119282. /**
  119283. * Context to enter xr with
  119284. */
  119285. renderTarget?: Nullable<WebXRRenderTarget>;
  119286. /**
  119287. * A session mode to use when creating the default button.
  119288. * Default is immersive-vr
  119289. */
  119290. sessionMode?: XRSessionMode;
  119291. }
  119292. /**
  119293. * UI to allow the user to enter/exit XR mode
  119294. */
  119295. export class WebXREnterExitUI implements IDisposable {
  119296. private scene;
  119297. /** version of the options passed to this UI */
  119298. options: WebXREnterExitUIOptions;
  119299. private _activeButton;
  119300. private _buttons;
  119301. private _overlay;
  119302. /**
  119303. * Fired every time the active button is changed.
  119304. *
  119305. * When xr is entered via a button that launches xr that button will be the callback parameter
  119306. *
  119307. * When exiting xr the callback parameter will be null)
  119308. */
  119309. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  119310. /**
  119311. *
  119312. * @param scene babylon scene object to use
  119313. * @param options (read-only) version of the options passed to this UI
  119314. */
  119315. private constructor();
  119316. /**
  119317. * Creates UI to allow the user to enter/exit XR mode
  119318. * @param scene the scene to add the ui to
  119319. * @param helper the xr experience helper to enter/exit xr with
  119320. * @param options options to configure the UI
  119321. * @returns the created ui
  119322. */
  119323. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  119324. /**
  119325. * Disposes of the XR UI component
  119326. */
  119327. dispose(): void;
  119328. private _updateButtons;
  119329. }
  119330. }
  119331. declare module BABYLON {
  119332. /**
  119333. * Class containing static functions to help procedurally build meshes
  119334. */
  119335. export class LinesBuilder {
  119336. /**
  119337. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  119338. * * 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
  119339. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  119340. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  119341. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  119342. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  119343. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  119344. * * 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
  119345. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  119346. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  119347. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  119348. * @param name defines the name of the new line system
  119349. * @param options defines the options used to create the line system
  119350. * @param scene defines the hosting scene
  119351. * @returns a new line system mesh
  119352. */
  119353. static CreateLineSystem(name: string, options: {
  119354. lines: Vector3[][];
  119355. updatable?: boolean;
  119356. instance?: Nullable<LinesMesh>;
  119357. colors?: Nullable<Color4[][]>;
  119358. useVertexAlpha?: boolean;
  119359. }, scene: Nullable<Scene>): LinesMesh;
  119360. /**
  119361. * Creates a line mesh
  119362. * 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
  119363. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  119364. * * The parameter `points` is an array successive Vector3
  119365. * * 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
  119366. * * The optional parameter `colors` is an array of successive Color4, one per line point
  119367. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  119368. * * When updating an instance, remember that only point positions can change, not the number of points
  119369. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  119370. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  119371. * @param name defines the name of the new line system
  119372. * @param options defines the options used to create the line system
  119373. * @param scene defines the hosting scene
  119374. * @returns a new line mesh
  119375. */
  119376. static CreateLines(name: string, options: {
  119377. points: Vector3[];
  119378. updatable?: boolean;
  119379. instance?: Nullable<LinesMesh>;
  119380. colors?: Color4[];
  119381. useVertexAlpha?: boolean;
  119382. }, scene?: Nullable<Scene>): LinesMesh;
  119383. /**
  119384. * Creates a dashed line mesh
  119385. * * 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
  119386. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  119387. * * The parameter `points` is an array successive Vector3
  119388. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  119389. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  119390. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  119391. * * 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
  119392. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  119393. * * When updating an instance, remember that only point positions can change, not the number of points
  119394. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  119395. * @param name defines the name of the mesh
  119396. * @param options defines the options used to create the mesh
  119397. * @param scene defines the hosting scene
  119398. * @returns the dashed line mesh
  119399. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  119400. */
  119401. static CreateDashedLines(name: string, options: {
  119402. points: Vector3[];
  119403. dashSize?: number;
  119404. gapSize?: number;
  119405. dashNb?: number;
  119406. updatable?: boolean;
  119407. instance?: LinesMesh;
  119408. useVertexAlpha?: boolean;
  119409. }, scene?: Nullable<Scene>): LinesMesh;
  119410. }
  119411. }
  119412. declare module BABYLON {
  119413. /**
  119414. * The options container for the teleportation module
  119415. */
  119416. export interface IWebXRTeleportationOptions {
  119417. /**
  119418. * if provided, this scene will be used to render meshes.
  119419. */
  119420. customUtilityLayerScene?: Scene;
  119421. /**
  119422. * Values to configure the default target mesh
  119423. */
  119424. defaultTargetMeshOptions?: {
  119425. /**
  119426. * Fill color of the teleportation area
  119427. */
  119428. teleportationFillColor?: string;
  119429. /**
  119430. * Border color for the teleportation area
  119431. */
  119432. teleportationBorderColor?: string;
  119433. /**
  119434. * Disable the mesh's animation sequence
  119435. */
  119436. disableAnimation?: boolean;
  119437. /**
  119438. * Disable lighting on the material or the ring and arrow
  119439. */
  119440. disableLighting?: boolean;
  119441. /**
  119442. * Override the default material of the torus and arrow
  119443. */
  119444. torusArrowMaterial?: Material;
  119445. };
  119446. /**
  119447. * A list of meshes to use as floor meshes.
  119448. * Meshes can be added and removed after initializing the feature using the
  119449. * addFloorMesh and removeFloorMesh functions
  119450. * If empty, rotation will still work
  119451. */
  119452. floorMeshes?: AbstractMesh[];
  119453. /**
  119454. * use this rendering group id for the meshes (optional)
  119455. */
  119456. renderingGroupId?: number;
  119457. /**
  119458. * Should teleportation move only to snap points
  119459. */
  119460. snapPointsOnly?: boolean;
  119461. /**
  119462. * An array of points to which the teleportation will snap to.
  119463. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  119464. */
  119465. snapPositions?: Vector3[];
  119466. /**
  119467. * How close should the teleportation ray be in order to snap to position.
  119468. * Default to 0.8 units (meters)
  119469. */
  119470. snapToPositionRadius?: number;
  119471. /**
  119472. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  119473. * If you want to support rotation, make sure your mesh has a direction indicator.
  119474. *
  119475. * When left untouched, the default mesh will be initialized.
  119476. */
  119477. teleportationTargetMesh?: AbstractMesh;
  119478. /**
  119479. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  119480. */
  119481. timeToTeleport?: number;
  119482. /**
  119483. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  119484. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  119485. */
  119486. useMainComponentOnly?: boolean;
  119487. /**
  119488. * Should meshes created here be added to a utility layer or the main scene
  119489. */
  119490. useUtilityLayer?: boolean;
  119491. /**
  119492. * Babylon XR Input class for controller
  119493. */
  119494. xrInput: WebXRInput;
  119495. }
  119496. /**
  119497. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  119498. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  119499. * the input of the attached controllers.
  119500. */
  119501. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  119502. private _options;
  119503. private _controllers;
  119504. private _currentTeleportationControllerId;
  119505. private _floorMeshes;
  119506. private _quadraticBezierCurve;
  119507. private _selectionFeature;
  119508. private _snapToPositions;
  119509. private _snappedToPoint;
  119510. private _teleportationRingMaterial?;
  119511. private _tmpRay;
  119512. private _tmpVector;
  119513. /**
  119514. * The module's name
  119515. */
  119516. static readonly Name: string;
  119517. /**
  119518. * The (Babylon) version of this module.
  119519. * This is an integer representing the implementation version.
  119520. * This number does not correspond to the webxr specs version
  119521. */
  119522. static readonly Version: number;
  119523. /**
  119524. * Is movement backwards enabled
  119525. */
  119526. backwardsMovementEnabled: boolean;
  119527. /**
  119528. * Distance to travel when moving backwards
  119529. */
  119530. backwardsTeleportationDistance: number;
  119531. /**
  119532. * The distance from the user to the inspection point in the direction of the controller
  119533. * A higher number will allow the user to move further
  119534. * defaults to 5 (meters, in xr units)
  119535. */
  119536. parabolicCheckRadius: number;
  119537. /**
  119538. * Should the module support parabolic ray on top of direct ray
  119539. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  119540. * Very helpful when moving between floors / different heights
  119541. */
  119542. parabolicRayEnabled: boolean;
  119543. /**
  119544. * How much rotation should be applied when rotating right and left
  119545. */
  119546. rotationAngle: number;
  119547. /**
  119548. * Is rotation enabled when moving forward?
  119549. * Disabling this feature will prevent the user from deciding the direction when teleporting
  119550. */
  119551. rotationEnabled: boolean;
  119552. /**
  119553. * constructs a new anchor system
  119554. * @param _xrSessionManager an instance of WebXRSessionManager
  119555. * @param _options configuration object for this feature
  119556. */
  119557. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  119558. /**
  119559. * Get the snapPointsOnly flag
  119560. */
  119561. get snapPointsOnly(): boolean;
  119562. /**
  119563. * Sets the snapPointsOnly flag
  119564. * @param snapToPoints should teleportation be exclusively to snap points
  119565. */
  119566. set snapPointsOnly(snapToPoints: boolean);
  119567. /**
  119568. * Add a new mesh to the floor meshes array
  119569. * @param mesh the mesh to use as floor mesh
  119570. */
  119571. addFloorMesh(mesh: AbstractMesh): void;
  119572. /**
  119573. * Add a new snap-to point to fix teleportation to this position
  119574. * @param newSnapPoint The new Snap-To point
  119575. */
  119576. addSnapPoint(newSnapPoint: Vector3): void;
  119577. attach(): boolean;
  119578. detach(): boolean;
  119579. dispose(): void;
  119580. /**
  119581. * Remove a mesh from the floor meshes array
  119582. * @param mesh the mesh to remove
  119583. */
  119584. removeFloorMesh(mesh: AbstractMesh): void;
  119585. /**
  119586. * Remove a mesh from the floor meshes array using its name
  119587. * @param name the mesh name to remove
  119588. */
  119589. removeFloorMeshByName(name: string): void;
  119590. /**
  119591. * 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
  119592. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  119593. * @returns was the point found and removed or not
  119594. */
  119595. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  119596. /**
  119597. * This function sets a selection feature that will be disabled when
  119598. * the forward ray is shown and will be reattached when hidden.
  119599. * This is used to remove the selection rays when moving.
  119600. * @param selectionFeature the feature to disable when forward movement is enabled
  119601. */
  119602. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  119603. protected _onXRFrame(_xrFrame: XRFrame): void;
  119604. private _attachController;
  119605. private _createDefaultTargetMesh;
  119606. private _detachController;
  119607. private _findClosestSnapPointWithRadius;
  119608. private _setTargetMeshPosition;
  119609. private _setTargetMeshVisibility;
  119610. private _showParabolicPath;
  119611. private _teleportForward;
  119612. }
  119613. }
  119614. declare module BABYLON {
  119615. /**
  119616. * Options for the default xr helper
  119617. */
  119618. export class WebXRDefaultExperienceOptions {
  119619. /**
  119620. * Enable or disable default UI to enter XR
  119621. */
  119622. disableDefaultUI?: boolean;
  119623. /**
  119624. * Should teleportation not initialize. defaults to false.
  119625. */
  119626. disableTeleportation?: boolean;
  119627. /**
  119628. * Floor meshes that will be used for teleport
  119629. */
  119630. floorMeshes?: Array<AbstractMesh>;
  119631. /**
  119632. * If set to true, the first frame will not be used to reset position
  119633. * The first frame is mainly used when copying transformation from the old camera
  119634. * Mainly used in AR
  119635. */
  119636. ignoreNativeCameraTransformation?: boolean;
  119637. /**
  119638. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  119639. */
  119640. inputOptions?: IWebXRInputOptions;
  119641. /**
  119642. * optional configuration for the output canvas
  119643. */
  119644. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  119645. /**
  119646. * optional UI options. This can be used among other to change session mode and reference space type
  119647. */
  119648. uiOptions?: WebXREnterExitUIOptions;
  119649. /**
  119650. * When loading teleportation and pointer select, use stable versions instead of latest.
  119651. */
  119652. useStablePlugins?: boolean;
  119653. }
  119654. /**
  119655. * Default experience which provides a similar setup to the previous webVRExperience
  119656. */
  119657. export class WebXRDefaultExperience {
  119658. /**
  119659. * Base experience
  119660. */
  119661. baseExperience: WebXRExperienceHelper;
  119662. /**
  119663. * Enables ui for entering/exiting xr
  119664. */
  119665. enterExitUI: WebXREnterExitUI;
  119666. /**
  119667. * Input experience extension
  119668. */
  119669. input: WebXRInput;
  119670. /**
  119671. * Enables laser pointer and selection
  119672. */
  119673. pointerSelection: WebXRControllerPointerSelection;
  119674. /**
  119675. * Default target xr should render to
  119676. */
  119677. renderTarget: WebXRRenderTarget;
  119678. /**
  119679. * Enables teleportation
  119680. */
  119681. teleportation: WebXRMotionControllerTeleportation;
  119682. private constructor();
  119683. /**
  119684. * Creates the default xr experience
  119685. * @param scene scene
  119686. * @param options options for basic configuration
  119687. * @returns resulting WebXRDefaultExperience
  119688. */
  119689. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  119690. /**
  119691. * DIsposes of the experience helper
  119692. */
  119693. dispose(): void;
  119694. }
  119695. }
  119696. declare module BABYLON {
  119697. /**
  119698. * Options to modify the vr teleportation behavior.
  119699. */
  119700. export interface VRTeleportationOptions {
  119701. /**
  119702. * The name of the mesh which should be used as the teleportation floor. (default: null)
  119703. */
  119704. floorMeshName?: string;
  119705. /**
  119706. * A list of meshes to be used as the teleportation floor. (default: empty)
  119707. */
  119708. floorMeshes?: Mesh[];
  119709. /**
  119710. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  119711. */
  119712. teleportationMode?: number;
  119713. /**
  119714. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  119715. */
  119716. teleportationTime?: number;
  119717. /**
  119718. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  119719. */
  119720. teleportationSpeed?: number;
  119721. /**
  119722. * The easing function used in the animation or null for Linear. (default CircleEase)
  119723. */
  119724. easingFunction?: EasingFunction;
  119725. }
  119726. /**
  119727. * Options to modify the vr experience helper's behavior.
  119728. */
  119729. export interface VRExperienceHelperOptions extends WebVROptions {
  119730. /**
  119731. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  119732. */
  119733. createDeviceOrientationCamera?: boolean;
  119734. /**
  119735. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  119736. */
  119737. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  119738. /**
  119739. * Uses the main button on the controller to toggle the laser casted. (default: true)
  119740. */
  119741. laserToggle?: boolean;
  119742. /**
  119743. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  119744. */
  119745. floorMeshes?: Mesh[];
  119746. /**
  119747. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  119748. */
  119749. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  119750. /**
  119751. * Defines if WebXR should be used instead of WebVR (if available)
  119752. */
  119753. useXR?: boolean;
  119754. }
  119755. /**
  119756. * Event containing information after VR has been entered
  119757. */
  119758. export class OnAfterEnteringVRObservableEvent {
  119759. /**
  119760. * If entering vr was successful
  119761. */
  119762. success: boolean;
  119763. }
  119764. /**
  119765. * Helps to quickly add VR support to an existing scene.
  119766. * See http://doc.babylonjs.com/how_to/webvr_helper
  119767. */
  119768. export class VRExperienceHelper {
  119769. /** Options to modify the vr experience helper's behavior. */
  119770. webVROptions: VRExperienceHelperOptions;
  119771. private _scene;
  119772. private _position;
  119773. private _btnVR;
  119774. private _btnVRDisplayed;
  119775. private _webVRsupported;
  119776. private _webVRready;
  119777. private _webVRrequesting;
  119778. private _webVRpresenting;
  119779. private _hasEnteredVR;
  119780. private _fullscreenVRpresenting;
  119781. private _inputElement;
  119782. private _webVRCamera;
  119783. private _vrDeviceOrientationCamera;
  119784. private _deviceOrientationCamera;
  119785. private _existingCamera;
  119786. private _onKeyDown;
  119787. private _onVrDisplayPresentChange;
  119788. private _onVRDisplayChanged;
  119789. private _onVRRequestPresentStart;
  119790. private _onVRRequestPresentComplete;
  119791. /**
  119792. * 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)
  119793. */
  119794. enableGazeEvenWhenNoPointerLock: boolean;
  119795. /**
  119796. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  119797. */
  119798. exitVROnDoubleTap: boolean;
  119799. /**
  119800. * Observable raised right before entering VR.
  119801. */
  119802. onEnteringVRObservable: Observable<VRExperienceHelper>;
  119803. /**
  119804. * Observable raised when entering VR has completed.
  119805. */
  119806. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  119807. /**
  119808. * Observable raised when exiting VR.
  119809. */
  119810. onExitingVRObservable: Observable<VRExperienceHelper>;
  119811. /**
  119812. * Observable raised when controller mesh is loaded.
  119813. */
  119814. onControllerMeshLoadedObservable: Observable<WebVRController>;
  119815. /** Return this.onEnteringVRObservable
  119816. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  119817. */
  119818. get onEnteringVR(): Observable<VRExperienceHelper>;
  119819. /** Return this.onExitingVRObservable
  119820. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  119821. */
  119822. get onExitingVR(): Observable<VRExperienceHelper>;
  119823. /** Return this.onControllerMeshLoadedObservable
  119824. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  119825. */
  119826. get onControllerMeshLoaded(): Observable<WebVRController>;
  119827. private _rayLength;
  119828. private _useCustomVRButton;
  119829. private _teleportationRequested;
  119830. private _teleportActive;
  119831. private _floorMeshName;
  119832. private _floorMeshesCollection;
  119833. private _teleportationMode;
  119834. private _teleportationTime;
  119835. private _teleportationSpeed;
  119836. private _teleportationEasing;
  119837. private _rotationAllowed;
  119838. private _teleportBackwardsVector;
  119839. private _teleportationTarget;
  119840. private _isDefaultTeleportationTarget;
  119841. private _postProcessMove;
  119842. private _teleportationFillColor;
  119843. private _teleportationBorderColor;
  119844. private _rotationAngle;
  119845. private _haloCenter;
  119846. private _cameraGazer;
  119847. private _padSensibilityUp;
  119848. private _padSensibilityDown;
  119849. private _leftController;
  119850. private _rightController;
  119851. private _gazeColor;
  119852. private _laserColor;
  119853. private _pickedLaserColor;
  119854. private _pickedGazeColor;
  119855. /**
  119856. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  119857. */
  119858. onNewMeshSelected: Observable<AbstractMesh>;
  119859. /**
  119860. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  119861. * This observable will provide the mesh and the controller used to select the mesh
  119862. */
  119863. onMeshSelectedWithController: Observable<{
  119864. mesh: AbstractMesh;
  119865. controller: WebVRController;
  119866. }>;
  119867. /**
  119868. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  119869. */
  119870. onNewMeshPicked: Observable<PickingInfo>;
  119871. private _circleEase;
  119872. /**
  119873. * Observable raised before camera teleportation
  119874. */
  119875. onBeforeCameraTeleport: Observable<Vector3>;
  119876. /**
  119877. * Observable raised after camera teleportation
  119878. */
  119879. onAfterCameraTeleport: Observable<Vector3>;
  119880. /**
  119881. * Observable raised when current selected mesh gets unselected
  119882. */
  119883. onSelectedMeshUnselected: Observable<AbstractMesh>;
  119884. private _raySelectionPredicate;
  119885. /**
  119886. * To be optionaly changed by user to define custom ray selection
  119887. */
  119888. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  119889. /**
  119890. * To be optionaly changed by user to define custom selection logic (after ray selection)
  119891. */
  119892. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  119893. /**
  119894. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  119895. */
  119896. teleportationEnabled: boolean;
  119897. private _defaultHeight;
  119898. private _teleportationInitialized;
  119899. private _interactionsEnabled;
  119900. private _interactionsRequested;
  119901. private _displayGaze;
  119902. private _displayLaserPointer;
  119903. /**
  119904. * The mesh used to display where the user is going to teleport.
  119905. */
  119906. get teleportationTarget(): Mesh;
  119907. /**
  119908. * Sets the mesh to be used to display where the user is going to teleport.
  119909. */
  119910. set teleportationTarget(value: Mesh);
  119911. /**
  119912. * 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
  119913. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  119914. * See http://doc.babylonjs.com/resources/baking_transformations
  119915. */
  119916. get gazeTrackerMesh(): Mesh;
  119917. set gazeTrackerMesh(value: Mesh);
  119918. /**
  119919. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  119920. */
  119921. updateGazeTrackerScale: boolean;
  119922. /**
  119923. * If the gaze trackers color should be updated when selecting meshes
  119924. */
  119925. updateGazeTrackerColor: boolean;
  119926. /**
  119927. * If the controller laser color should be updated when selecting meshes
  119928. */
  119929. updateControllerLaserColor: boolean;
  119930. /**
  119931. * The gaze tracking mesh corresponding to the left controller
  119932. */
  119933. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  119934. /**
  119935. * The gaze tracking mesh corresponding to the right controller
  119936. */
  119937. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  119938. /**
  119939. * If the ray of the gaze should be displayed.
  119940. */
  119941. get displayGaze(): boolean;
  119942. /**
  119943. * Sets if the ray of the gaze should be displayed.
  119944. */
  119945. set displayGaze(value: boolean);
  119946. /**
  119947. * If the ray of the LaserPointer should be displayed.
  119948. */
  119949. get displayLaserPointer(): boolean;
  119950. /**
  119951. * Sets if the ray of the LaserPointer should be displayed.
  119952. */
  119953. set displayLaserPointer(value: boolean);
  119954. /**
  119955. * The deviceOrientationCamera used as the camera when not in VR.
  119956. */
  119957. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  119958. /**
  119959. * Based on the current WebVR support, returns the current VR camera used.
  119960. */
  119961. get currentVRCamera(): Nullable<Camera>;
  119962. /**
  119963. * The webVRCamera which is used when in VR.
  119964. */
  119965. get webVRCamera(): WebVRFreeCamera;
  119966. /**
  119967. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  119968. */
  119969. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  119970. /**
  119971. * The html button that is used to trigger entering into VR.
  119972. */
  119973. get vrButton(): Nullable<HTMLButtonElement>;
  119974. private get _teleportationRequestInitiated();
  119975. /**
  119976. * Defines whether or not Pointer lock should be requested when switching to
  119977. * full screen.
  119978. */
  119979. requestPointerLockOnFullScreen: boolean;
  119980. /**
  119981. * If asking to force XR, this will be populated with the default xr experience
  119982. */
  119983. xr: WebXRDefaultExperience;
  119984. /**
  119985. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  119986. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  119987. */
  119988. xrTestDone: boolean;
  119989. /**
  119990. * Instantiates a VRExperienceHelper.
  119991. * Helps to quickly add VR support to an existing scene.
  119992. * @param scene The scene the VRExperienceHelper belongs to.
  119993. * @param webVROptions Options to modify the vr experience helper's behavior.
  119994. */
  119995. constructor(scene: Scene,
  119996. /** Options to modify the vr experience helper's behavior. */
  119997. webVROptions?: VRExperienceHelperOptions);
  119998. private completeVRInit;
  119999. private _onDefaultMeshLoaded;
  120000. private _onResize;
  120001. private _onFullscreenChange;
  120002. /**
  120003. * Gets a value indicating if we are currently in VR mode.
  120004. */
  120005. get isInVRMode(): boolean;
  120006. private onVrDisplayPresentChange;
  120007. private onVRDisplayChanged;
  120008. private moveButtonToBottomRight;
  120009. private displayVRButton;
  120010. private updateButtonVisibility;
  120011. private _cachedAngularSensibility;
  120012. /**
  120013. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  120014. * Otherwise, will use the fullscreen API.
  120015. */
  120016. enterVR(): void;
  120017. /**
  120018. * Attempt to exit VR, or fullscreen.
  120019. */
  120020. exitVR(): void;
  120021. /**
  120022. * The position of the vr experience helper.
  120023. */
  120024. get position(): Vector3;
  120025. /**
  120026. * Sets the position of the vr experience helper.
  120027. */
  120028. set position(value: Vector3);
  120029. /**
  120030. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  120031. */
  120032. enableInteractions(): void;
  120033. private get _noControllerIsActive();
  120034. private beforeRender;
  120035. private _isTeleportationFloor;
  120036. /**
  120037. * Adds a floor mesh to be used for teleportation.
  120038. * @param floorMesh the mesh to be used for teleportation.
  120039. */
  120040. addFloorMesh(floorMesh: Mesh): void;
  120041. /**
  120042. * Removes a floor mesh from being used for teleportation.
  120043. * @param floorMesh the mesh to be removed.
  120044. */
  120045. removeFloorMesh(floorMesh: Mesh): void;
  120046. /**
  120047. * Enables interactions and teleportation using the VR controllers and gaze.
  120048. * @param vrTeleportationOptions options to modify teleportation behavior.
  120049. */
  120050. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  120051. private _onNewGamepadConnected;
  120052. private _tryEnableInteractionOnController;
  120053. private _onNewGamepadDisconnected;
  120054. private _enableInteractionOnController;
  120055. private _checkTeleportWithRay;
  120056. private _checkRotate;
  120057. private _checkTeleportBackwards;
  120058. private _enableTeleportationOnController;
  120059. private _createTeleportationCircles;
  120060. private _displayTeleportationTarget;
  120061. private _hideTeleportationTarget;
  120062. private _rotateCamera;
  120063. private _moveTeleportationSelectorTo;
  120064. private _workingVector;
  120065. private _workingQuaternion;
  120066. private _workingMatrix;
  120067. /**
  120068. * Time Constant Teleportation Mode
  120069. */
  120070. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  120071. /**
  120072. * Speed Constant Teleportation Mode
  120073. */
  120074. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  120075. /**
  120076. * Teleports the users feet to the desired location
  120077. * @param location The location where the user's feet should be placed
  120078. */
  120079. teleportCamera(location: Vector3): void;
  120080. private _convertNormalToDirectionOfRay;
  120081. private _castRayAndSelectObject;
  120082. private _notifySelectedMeshUnselected;
  120083. /**
  120084. * Permanently set new colors for the laser pointer
  120085. * @param color the new laser color
  120086. * @param pickedColor the new laser color when picked mesh detected
  120087. */
  120088. setLaserColor(color: Color3, pickedColor?: Color3): void;
  120089. /**
  120090. * Set lighting enabled / disabled on the laser pointer of both controllers
  120091. * @param enabled should the lighting be enabled on the laser pointer
  120092. */
  120093. setLaserLightingState(enabled?: boolean): void;
  120094. /**
  120095. * Permanently set new colors for the gaze pointer
  120096. * @param color the new gaze color
  120097. * @param pickedColor the new gaze color when picked mesh detected
  120098. */
  120099. setGazeColor(color: Color3, pickedColor?: Color3): void;
  120100. /**
  120101. * Sets the color of the laser ray from the vr controllers.
  120102. * @param color new color for the ray.
  120103. */
  120104. changeLaserColor(color: Color3): void;
  120105. /**
  120106. * Sets the color of the ray from the vr headsets gaze.
  120107. * @param color new color for the ray.
  120108. */
  120109. changeGazeColor(color: Color3): void;
  120110. /**
  120111. * Exits VR and disposes of the vr experience helper
  120112. */
  120113. dispose(): void;
  120114. /**
  120115. * Gets the name of the VRExperienceHelper class
  120116. * @returns "VRExperienceHelper"
  120117. */
  120118. getClassName(): string;
  120119. }
  120120. }
  120121. declare module BABYLON {
  120122. /**
  120123. * Contains an array of blocks representing the octree
  120124. */
  120125. export interface IOctreeContainer<T> {
  120126. /**
  120127. * Blocks within the octree
  120128. */
  120129. blocks: Array<OctreeBlock<T>>;
  120130. }
  120131. /**
  120132. * Class used to store a cell in an octree
  120133. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  120134. */
  120135. export class OctreeBlock<T> {
  120136. /**
  120137. * Gets the content of the current block
  120138. */
  120139. entries: T[];
  120140. /**
  120141. * Gets the list of block children
  120142. */
  120143. blocks: Array<OctreeBlock<T>>;
  120144. private _depth;
  120145. private _maxDepth;
  120146. private _capacity;
  120147. private _minPoint;
  120148. private _maxPoint;
  120149. private _boundingVectors;
  120150. private _creationFunc;
  120151. /**
  120152. * Creates a new block
  120153. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  120154. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  120155. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  120156. * @param depth defines the current depth of this block in the octree
  120157. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  120158. * @param creationFunc defines a callback to call when an element is added to the block
  120159. */
  120160. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  120161. /**
  120162. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  120163. */
  120164. get capacity(): number;
  120165. /**
  120166. * Gets the minimum vector (in world space) of the block's bounding box
  120167. */
  120168. get minPoint(): Vector3;
  120169. /**
  120170. * Gets the maximum vector (in world space) of the block's bounding box
  120171. */
  120172. get maxPoint(): Vector3;
  120173. /**
  120174. * Add a new element to this block
  120175. * @param entry defines the element to add
  120176. */
  120177. addEntry(entry: T): void;
  120178. /**
  120179. * Remove an element from this block
  120180. * @param entry defines the element to remove
  120181. */
  120182. removeEntry(entry: T): void;
  120183. /**
  120184. * Add an array of elements to this block
  120185. * @param entries defines the array of elements to add
  120186. */
  120187. addEntries(entries: T[]): void;
  120188. /**
  120189. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  120190. * @param frustumPlanes defines the frustum planes to test
  120191. * @param selection defines the array to store current content if selection is positive
  120192. * @param allowDuplicate defines if the selection array can contains duplicated entries
  120193. */
  120194. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  120195. /**
  120196. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  120197. * @param sphereCenter defines the bounding sphere center
  120198. * @param sphereRadius defines the bounding sphere radius
  120199. * @param selection defines the array to store current content if selection is positive
  120200. * @param allowDuplicate defines if the selection array can contains duplicated entries
  120201. */
  120202. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  120203. /**
  120204. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  120205. * @param ray defines the ray to test with
  120206. * @param selection defines the array to store current content if selection is positive
  120207. */
  120208. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  120209. /**
  120210. * Subdivide the content into child blocks (this block will then be empty)
  120211. */
  120212. createInnerBlocks(): void;
  120213. /**
  120214. * @hidden
  120215. */
  120216. 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;
  120217. }
  120218. }
  120219. declare module BABYLON {
  120220. /**
  120221. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  120222. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  120223. */
  120224. export class Octree<T> {
  120225. /** 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.) */
  120226. maxDepth: number;
  120227. /**
  120228. * Blocks within the octree containing objects
  120229. */
  120230. blocks: Array<OctreeBlock<T>>;
  120231. /**
  120232. * Content stored in the octree
  120233. */
  120234. dynamicContent: T[];
  120235. private _maxBlockCapacity;
  120236. private _selectionContent;
  120237. private _creationFunc;
  120238. /**
  120239. * Creates a octree
  120240. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  120241. * @param creationFunc function to be used to instatiate the octree
  120242. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  120243. * @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.)
  120244. */
  120245. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  120246. /** 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.) */
  120247. maxDepth?: number);
  120248. /**
  120249. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  120250. * @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);
  120251. * @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);
  120252. * @param entries meshes to be added to the octree blocks
  120253. */
  120254. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  120255. /**
  120256. * Adds a mesh to the octree
  120257. * @param entry Mesh to add to the octree
  120258. */
  120259. addMesh(entry: T): void;
  120260. /**
  120261. * Remove an element from the octree
  120262. * @param entry defines the element to remove
  120263. */
  120264. removeMesh(entry: T): void;
  120265. /**
  120266. * Selects an array of meshes within the frustum
  120267. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  120268. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  120269. * @returns array of meshes within the frustum
  120270. */
  120271. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  120272. /**
  120273. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  120274. * @param sphereCenter defines the bounding sphere center
  120275. * @param sphereRadius defines the bounding sphere radius
  120276. * @param allowDuplicate defines if the selection array can contains duplicated entries
  120277. * @returns an array of objects that intersect the sphere
  120278. */
  120279. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  120280. /**
  120281. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  120282. * @param ray defines the ray to test with
  120283. * @returns array of intersected objects
  120284. */
  120285. intersectsRay(ray: Ray): SmartArray<T>;
  120286. /**
  120287. * Adds a mesh into the octree block if it intersects the block
  120288. */
  120289. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  120290. /**
  120291. * Adds a submesh into the octree block if it intersects the block
  120292. */
  120293. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  120294. }
  120295. }
  120296. declare module BABYLON {
  120297. interface Scene {
  120298. /**
  120299. * @hidden
  120300. * Backing Filed
  120301. */
  120302. _selectionOctree: Octree<AbstractMesh>;
  120303. /**
  120304. * Gets the octree used to boost mesh selection (picking)
  120305. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  120306. */
  120307. selectionOctree: Octree<AbstractMesh>;
  120308. /**
  120309. * Creates or updates the octree used to boost selection (picking)
  120310. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  120311. * @param maxCapacity defines the maximum capacity per leaf
  120312. * @param maxDepth defines the maximum depth of the octree
  120313. * @returns an octree of AbstractMesh
  120314. */
  120315. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  120316. }
  120317. interface AbstractMesh {
  120318. /**
  120319. * @hidden
  120320. * Backing Field
  120321. */
  120322. _submeshesOctree: Octree<SubMesh>;
  120323. /**
  120324. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  120325. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  120326. * @param maxCapacity defines the maximum size of each block (64 by default)
  120327. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  120328. * @returns the new octree
  120329. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  120330. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  120331. */
  120332. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  120333. }
  120334. /**
  120335. * Defines the octree scene component responsible to manage any octrees
  120336. * in a given scene.
  120337. */
  120338. export class OctreeSceneComponent {
  120339. /**
  120340. * The component name help to identify the component in the list of scene components.
  120341. */
  120342. readonly name: string;
  120343. /**
  120344. * The scene the component belongs to.
  120345. */
  120346. scene: Scene;
  120347. /**
  120348. * Indicates if the meshes have been checked to make sure they are isEnabled()
  120349. */
  120350. readonly checksIsEnabled: boolean;
  120351. /**
  120352. * Creates a new instance of the component for the given scene
  120353. * @param scene Defines the scene to register the component in
  120354. */
  120355. constructor(scene: Scene);
  120356. /**
  120357. * Registers the component in a given scene
  120358. */
  120359. register(): void;
  120360. /**
  120361. * Return the list of active meshes
  120362. * @returns the list of active meshes
  120363. */
  120364. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  120365. /**
  120366. * Return the list of active sub meshes
  120367. * @param mesh The mesh to get the candidates sub meshes from
  120368. * @returns the list of active sub meshes
  120369. */
  120370. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  120371. private _tempRay;
  120372. /**
  120373. * Return the list of sub meshes intersecting with a given local ray
  120374. * @param mesh defines the mesh to find the submesh for
  120375. * @param localRay defines the ray in local space
  120376. * @returns the list of intersecting sub meshes
  120377. */
  120378. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  120379. /**
  120380. * Return the list of sub meshes colliding with a collider
  120381. * @param mesh defines the mesh to find the submesh for
  120382. * @param collider defines the collider to evaluate the collision against
  120383. * @returns the list of colliding sub meshes
  120384. */
  120385. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  120386. /**
  120387. * Rebuilds the elements related to this component in case of
  120388. * context lost for instance.
  120389. */
  120390. rebuild(): void;
  120391. /**
  120392. * Disposes the component and the associated ressources.
  120393. */
  120394. dispose(): void;
  120395. }
  120396. }
  120397. declare module BABYLON {
  120398. /**
  120399. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  120400. */
  120401. export class Gizmo implements IDisposable {
  120402. /** The utility layer the gizmo will be added to */
  120403. gizmoLayer: UtilityLayerRenderer;
  120404. /**
  120405. * The root mesh of the gizmo
  120406. */
  120407. _rootMesh: Mesh;
  120408. private _attachedMesh;
  120409. /**
  120410. * Ratio for the scale of the gizmo (Default: 1)
  120411. */
  120412. scaleRatio: number;
  120413. /**
  120414. * If a custom mesh has been set (Default: false)
  120415. */
  120416. protected _customMeshSet: boolean;
  120417. /**
  120418. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  120419. * * When set, interactions will be enabled
  120420. */
  120421. get attachedMesh(): Nullable<AbstractMesh>;
  120422. set attachedMesh(value: Nullable<AbstractMesh>);
  120423. /**
  120424. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  120425. * @param mesh The mesh to replace the default mesh of the gizmo
  120426. */
  120427. setCustomMesh(mesh: Mesh): void;
  120428. /**
  120429. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  120430. */
  120431. updateGizmoRotationToMatchAttachedMesh: boolean;
  120432. /**
  120433. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  120434. */
  120435. updateGizmoPositionToMatchAttachedMesh: boolean;
  120436. /**
  120437. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  120438. */
  120439. updateScale: boolean;
  120440. protected _interactionsEnabled: boolean;
  120441. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  120442. private _beforeRenderObserver;
  120443. private _tempVector;
  120444. /**
  120445. * Creates a gizmo
  120446. * @param gizmoLayer The utility layer the gizmo will be added to
  120447. */
  120448. constructor(
  120449. /** The utility layer the gizmo will be added to */
  120450. gizmoLayer?: UtilityLayerRenderer);
  120451. /**
  120452. * Updates the gizmo to match the attached mesh's position/rotation
  120453. */
  120454. protected _update(): void;
  120455. /**
  120456. * Disposes of the gizmo
  120457. */
  120458. dispose(): void;
  120459. }
  120460. }
  120461. declare module BABYLON {
  120462. /**
  120463. * Single plane drag gizmo
  120464. */
  120465. export class PlaneDragGizmo extends Gizmo {
  120466. /**
  120467. * Drag behavior responsible for the gizmos dragging interactions
  120468. */
  120469. dragBehavior: PointerDragBehavior;
  120470. private _pointerObserver;
  120471. /**
  120472. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  120473. */
  120474. snapDistance: number;
  120475. /**
  120476. * Event that fires each time the gizmo snaps to a new location.
  120477. * * snapDistance is the the change in distance
  120478. */
  120479. onSnapObservable: Observable<{
  120480. snapDistance: number;
  120481. }>;
  120482. private _plane;
  120483. private _coloredMaterial;
  120484. private _hoverMaterial;
  120485. private _isEnabled;
  120486. private _parent;
  120487. /** @hidden */
  120488. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  120489. /** @hidden */
  120490. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  120491. /**
  120492. * Creates a PlaneDragGizmo
  120493. * @param gizmoLayer The utility layer the gizmo will be added to
  120494. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  120495. * @param color The color of the gizmo
  120496. */
  120497. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  120498. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  120499. /**
  120500. * If the gizmo is enabled
  120501. */
  120502. set isEnabled(value: boolean);
  120503. get isEnabled(): boolean;
  120504. /**
  120505. * Disposes of the gizmo
  120506. */
  120507. dispose(): void;
  120508. }
  120509. }
  120510. declare module BABYLON {
  120511. /**
  120512. * Gizmo that enables dragging a mesh along 3 axis
  120513. */
  120514. export class PositionGizmo extends Gizmo {
  120515. /**
  120516. * Internal gizmo used for interactions on the x axis
  120517. */
  120518. xGizmo: AxisDragGizmo;
  120519. /**
  120520. * Internal gizmo used for interactions on the y axis
  120521. */
  120522. yGizmo: AxisDragGizmo;
  120523. /**
  120524. * Internal gizmo used for interactions on the z axis
  120525. */
  120526. zGizmo: AxisDragGizmo;
  120527. /**
  120528. * Internal gizmo used for interactions on the yz plane
  120529. */
  120530. xPlaneGizmo: PlaneDragGizmo;
  120531. /**
  120532. * Internal gizmo used for interactions on the xz plane
  120533. */
  120534. yPlaneGizmo: PlaneDragGizmo;
  120535. /**
  120536. * Internal gizmo used for interactions on the xy plane
  120537. */
  120538. zPlaneGizmo: PlaneDragGizmo;
  120539. /**
  120540. * private variables
  120541. */
  120542. private _meshAttached;
  120543. private _updateGizmoRotationToMatchAttachedMesh;
  120544. private _snapDistance;
  120545. private _scaleRatio;
  120546. /** Fires an event when any of it's sub gizmos are dragged */
  120547. onDragStartObservable: Observable<unknown>;
  120548. /** Fires an event when any of it's sub gizmos are released from dragging */
  120549. onDragEndObservable: Observable<unknown>;
  120550. /**
  120551. * If set to true, planar drag is enabled
  120552. */
  120553. private _planarGizmoEnabled;
  120554. get attachedMesh(): Nullable<AbstractMesh>;
  120555. set attachedMesh(mesh: Nullable<AbstractMesh>);
  120556. /**
  120557. * Creates a PositionGizmo
  120558. * @param gizmoLayer The utility layer the gizmo will be added to
  120559. */
  120560. constructor(gizmoLayer?: UtilityLayerRenderer);
  120561. /**
  120562. * If the planar drag gizmo is enabled
  120563. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  120564. */
  120565. set planarGizmoEnabled(value: boolean);
  120566. get planarGizmoEnabled(): boolean;
  120567. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  120568. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  120569. /**
  120570. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  120571. */
  120572. set snapDistance(value: number);
  120573. get snapDistance(): number;
  120574. /**
  120575. * Ratio for the scale of the gizmo (Default: 1)
  120576. */
  120577. set scaleRatio(value: number);
  120578. get scaleRatio(): number;
  120579. /**
  120580. * Disposes of the gizmo
  120581. */
  120582. dispose(): void;
  120583. /**
  120584. * CustomMeshes are not supported by this gizmo
  120585. * @param mesh The mesh to replace the default mesh of the gizmo
  120586. */
  120587. setCustomMesh(mesh: Mesh): void;
  120588. }
  120589. }
  120590. declare module BABYLON {
  120591. /**
  120592. * Single axis drag gizmo
  120593. */
  120594. export class AxisDragGizmo extends Gizmo {
  120595. /**
  120596. * Drag behavior responsible for the gizmos dragging interactions
  120597. */
  120598. dragBehavior: PointerDragBehavior;
  120599. private _pointerObserver;
  120600. /**
  120601. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  120602. */
  120603. snapDistance: number;
  120604. /**
  120605. * Event that fires each time the gizmo snaps to a new location.
  120606. * * snapDistance is the the change in distance
  120607. */
  120608. onSnapObservable: Observable<{
  120609. snapDistance: number;
  120610. }>;
  120611. private _isEnabled;
  120612. private _parent;
  120613. private _arrow;
  120614. private _coloredMaterial;
  120615. private _hoverMaterial;
  120616. /** @hidden */
  120617. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  120618. /** @hidden */
  120619. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  120620. /**
  120621. * Creates an AxisDragGizmo
  120622. * @param gizmoLayer The utility layer the gizmo will be added to
  120623. * @param dragAxis The axis which the gizmo will be able to drag on
  120624. * @param color The color of the gizmo
  120625. */
  120626. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  120627. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  120628. /**
  120629. * If the gizmo is enabled
  120630. */
  120631. set isEnabled(value: boolean);
  120632. get isEnabled(): boolean;
  120633. /**
  120634. * Disposes of the gizmo
  120635. */
  120636. dispose(): void;
  120637. }
  120638. }
  120639. declare module BABYLON.Debug {
  120640. /**
  120641. * The Axes viewer will show 3 axes in a specific point in space
  120642. */
  120643. export class AxesViewer {
  120644. private _xAxis;
  120645. private _yAxis;
  120646. private _zAxis;
  120647. private _scaleLinesFactor;
  120648. private _instanced;
  120649. /**
  120650. * Gets the hosting scene
  120651. */
  120652. scene: Scene;
  120653. /**
  120654. * Gets or sets a number used to scale line length
  120655. */
  120656. scaleLines: number;
  120657. /** Gets the node hierarchy used to render x-axis */
  120658. get xAxis(): TransformNode;
  120659. /** Gets the node hierarchy used to render y-axis */
  120660. get yAxis(): TransformNode;
  120661. /** Gets the node hierarchy used to render z-axis */
  120662. get zAxis(): TransformNode;
  120663. /**
  120664. * Creates a new AxesViewer
  120665. * @param scene defines the hosting scene
  120666. * @param scaleLines defines a number used to scale line length (1 by default)
  120667. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  120668. * @param xAxis defines the node hierarchy used to render the x-axis
  120669. * @param yAxis defines the node hierarchy used to render the y-axis
  120670. * @param zAxis defines the node hierarchy used to render the z-axis
  120671. */
  120672. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  120673. /**
  120674. * Force the viewer to update
  120675. * @param position defines the position of the viewer
  120676. * @param xaxis defines the x axis of the viewer
  120677. * @param yaxis defines the y axis of the viewer
  120678. * @param zaxis defines the z axis of the viewer
  120679. */
  120680. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  120681. /**
  120682. * Creates an instance of this axes viewer.
  120683. * @returns a new axes viewer with instanced meshes
  120684. */
  120685. createInstance(): AxesViewer;
  120686. /** Releases resources */
  120687. dispose(): void;
  120688. private static _SetRenderingGroupId;
  120689. }
  120690. }
  120691. declare module BABYLON.Debug {
  120692. /**
  120693. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  120694. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  120695. */
  120696. export class BoneAxesViewer extends AxesViewer {
  120697. /**
  120698. * Gets or sets the target mesh where to display the axes viewer
  120699. */
  120700. mesh: Nullable<Mesh>;
  120701. /**
  120702. * Gets or sets the target bone where to display the axes viewer
  120703. */
  120704. bone: Nullable<Bone>;
  120705. /** Gets current position */
  120706. pos: Vector3;
  120707. /** Gets direction of X axis */
  120708. xaxis: Vector3;
  120709. /** Gets direction of Y axis */
  120710. yaxis: Vector3;
  120711. /** Gets direction of Z axis */
  120712. zaxis: Vector3;
  120713. /**
  120714. * Creates a new BoneAxesViewer
  120715. * @param scene defines the hosting scene
  120716. * @param bone defines the target bone
  120717. * @param mesh defines the target mesh
  120718. * @param scaleLines defines a scaling factor for line length (1 by default)
  120719. */
  120720. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  120721. /**
  120722. * Force the viewer to update
  120723. */
  120724. update(): void;
  120725. /** Releases resources */
  120726. dispose(): void;
  120727. }
  120728. }
  120729. declare module BABYLON {
  120730. /**
  120731. * Interface used to define scene explorer extensibility option
  120732. */
  120733. export interface IExplorerExtensibilityOption {
  120734. /**
  120735. * Define the option label
  120736. */
  120737. label: string;
  120738. /**
  120739. * Defines the action to execute on click
  120740. */
  120741. action: (entity: any) => void;
  120742. }
  120743. /**
  120744. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  120745. */
  120746. export interface IExplorerExtensibilityGroup {
  120747. /**
  120748. * Defines a predicate to test if a given type mut be extended
  120749. */
  120750. predicate: (entity: any) => boolean;
  120751. /**
  120752. * Gets the list of options added to a type
  120753. */
  120754. entries: IExplorerExtensibilityOption[];
  120755. }
  120756. /**
  120757. * Interface used to define the options to use to create the Inspector
  120758. */
  120759. export interface IInspectorOptions {
  120760. /**
  120761. * Display in overlay mode (default: false)
  120762. */
  120763. overlay?: boolean;
  120764. /**
  120765. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  120766. */
  120767. globalRoot?: HTMLElement;
  120768. /**
  120769. * Display the Scene explorer
  120770. */
  120771. showExplorer?: boolean;
  120772. /**
  120773. * Display the property inspector
  120774. */
  120775. showInspector?: boolean;
  120776. /**
  120777. * Display in embed mode (both panes on the right)
  120778. */
  120779. embedMode?: boolean;
  120780. /**
  120781. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  120782. */
  120783. handleResize?: boolean;
  120784. /**
  120785. * Allow the panes to popup (default: true)
  120786. */
  120787. enablePopup?: boolean;
  120788. /**
  120789. * Allow the panes to be closed by users (default: true)
  120790. */
  120791. enableClose?: boolean;
  120792. /**
  120793. * Optional list of extensibility entries
  120794. */
  120795. explorerExtensibility?: IExplorerExtensibilityGroup[];
  120796. /**
  120797. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  120798. */
  120799. inspectorURL?: string;
  120800. /**
  120801. * Optional initial tab (default to DebugLayerTab.Properties)
  120802. */
  120803. initialTab?: DebugLayerTab;
  120804. }
  120805. interface Scene {
  120806. /**
  120807. * @hidden
  120808. * Backing field
  120809. */
  120810. _debugLayer: DebugLayer;
  120811. /**
  120812. * Gets the debug layer (aka Inspector) associated with the scene
  120813. * @see http://doc.babylonjs.com/features/playground_debuglayer
  120814. */
  120815. debugLayer: DebugLayer;
  120816. }
  120817. /**
  120818. * Enum of inspector action tab
  120819. */
  120820. export enum DebugLayerTab {
  120821. /**
  120822. * Properties tag (default)
  120823. */
  120824. Properties = 0,
  120825. /**
  120826. * Debug tab
  120827. */
  120828. Debug = 1,
  120829. /**
  120830. * Statistics tab
  120831. */
  120832. Statistics = 2,
  120833. /**
  120834. * Tools tab
  120835. */
  120836. Tools = 3,
  120837. /**
  120838. * Settings tab
  120839. */
  120840. Settings = 4
  120841. }
  120842. /**
  120843. * The debug layer (aka Inspector) is the go to tool in order to better understand
  120844. * what is happening in your scene
  120845. * @see http://doc.babylonjs.com/features/playground_debuglayer
  120846. */
  120847. export class DebugLayer {
  120848. /**
  120849. * Define the url to get the inspector script from.
  120850. * By default it uses the babylonjs CDN.
  120851. * @ignoreNaming
  120852. */
  120853. static InspectorURL: string;
  120854. private _scene;
  120855. private BJSINSPECTOR;
  120856. private _onPropertyChangedObservable?;
  120857. /**
  120858. * Observable triggered when a property is changed through the inspector.
  120859. */
  120860. get onPropertyChangedObservable(): any;
  120861. /**
  120862. * Instantiates a new debug layer.
  120863. * The debug layer (aka Inspector) is the go to tool in order to better understand
  120864. * what is happening in your scene
  120865. * @see http://doc.babylonjs.com/features/playground_debuglayer
  120866. * @param scene Defines the scene to inspect
  120867. */
  120868. constructor(scene: Scene);
  120869. /** Creates the inspector window. */
  120870. private _createInspector;
  120871. /**
  120872. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  120873. * @param entity defines the entity to select
  120874. * @param lineContainerTitle defines the specific block to highlight
  120875. */
  120876. select(entity: any, lineContainerTitle?: string): void;
  120877. /** Get the inspector from bundle or global */
  120878. private _getGlobalInspector;
  120879. /**
  120880. * Get if the inspector is visible or not.
  120881. * @returns true if visible otherwise, false
  120882. */
  120883. isVisible(): boolean;
  120884. /**
  120885. * Hide the inspector and close its window.
  120886. */
  120887. hide(): void;
  120888. /**
  120889. * Launch the debugLayer.
  120890. * @param config Define the configuration of the inspector
  120891. * @return a promise fulfilled when the debug layer is visible
  120892. */
  120893. show(config?: IInspectorOptions): Promise<DebugLayer>;
  120894. }
  120895. }
  120896. declare module BABYLON {
  120897. /**
  120898. * Class containing static functions to help procedurally build meshes
  120899. */
  120900. export class BoxBuilder {
  120901. /**
  120902. * Creates a box mesh
  120903. * * The parameter `size` sets the size (float) of each box side (default 1)
  120904. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  120905. * * 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)
  120906. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  120907. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  120908. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  120909. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  120910. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  120911. * @param name defines the name of the mesh
  120912. * @param options defines the options used to create the mesh
  120913. * @param scene defines the hosting scene
  120914. * @returns the box mesh
  120915. */
  120916. static CreateBox(name: string, options: {
  120917. size?: number;
  120918. width?: number;
  120919. height?: number;
  120920. depth?: number;
  120921. faceUV?: Vector4[];
  120922. faceColors?: Color4[];
  120923. sideOrientation?: number;
  120924. frontUVs?: Vector4;
  120925. backUVs?: Vector4;
  120926. wrap?: boolean;
  120927. topBaseAt?: number;
  120928. bottomBaseAt?: number;
  120929. updatable?: boolean;
  120930. }, scene?: Nullable<Scene>): Mesh;
  120931. }
  120932. }
  120933. declare module BABYLON.Debug {
  120934. /**
  120935. * Used to show the physics impostor around the specific mesh
  120936. */
  120937. export class PhysicsViewer {
  120938. /** @hidden */
  120939. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  120940. /** @hidden */
  120941. protected _meshes: Array<Nullable<AbstractMesh>>;
  120942. /** @hidden */
  120943. protected _scene: Nullable<Scene>;
  120944. /** @hidden */
  120945. protected _numMeshes: number;
  120946. /** @hidden */
  120947. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  120948. private _renderFunction;
  120949. private _utilityLayer;
  120950. private _debugBoxMesh;
  120951. private _debugSphereMesh;
  120952. private _debugCylinderMesh;
  120953. private _debugMaterial;
  120954. private _debugMeshMeshes;
  120955. /**
  120956. * Creates a new PhysicsViewer
  120957. * @param scene defines the hosting scene
  120958. */
  120959. constructor(scene: Scene);
  120960. /** @hidden */
  120961. protected _updateDebugMeshes(): void;
  120962. /**
  120963. * Renders a specified physic impostor
  120964. * @param impostor defines the impostor to render
  120965. * @param targetMesh defines the mesh represented by the impostor
  120966. * @returns the new debug mesh used to render the impostor
  120967. */
  120968. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  120969. /**
  120970. * Hides a specified physic impostor
  120971. * @param impostor defines the impostor to hide
  120972. */
  120973. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  120974. private _getDebugMaterial;
  120975. private _getDebugBoxMesh;
  120976. private _getDebugSphereMesh;
  120977. private _getDebugCylinderMesh;
  120978. private _getDebugMeshMesh;
  120979. private _getDebugMesh;
  120980. /** Releases all resources */
  120981. dispose(): void;
  120982. }
  120983. }
  120984. declare module BABYLON {
  120985. /**
  120986. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  120987. * in order to better appreciate the issue one might have.
  120988. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  120989. */
  120990. export class RayHelper {
  120991. /**
  120992. * Defines the ray we are currently tryin to visualize.
  120993. */
  120994. ray: Nullable<Ray>;
  120995. private _renderPoints;
  120996. private _renderLine;
  120997. private _renderFunction;
  120998. private _scene;
  120999. private _updateToMeshFunction;
  121000. private _attachedToMesh;
  121001. private _meshSpaceDirection;
  121002. private _meshSpaceOrigin;
  121003. /**
  121004. * Helper function to create a colored helper in a scene in one line.
  121005. * @param ray Defines the ray we are currently tryin to visualize
  121006. * @param scene Defines the scene the ray is used in
  121007. * @param color Defines the color we want to see the ray in
  121008. * @returns The newly created ray helper.
  121009. */
  121010. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  121011. /**
  121012. * Instantiate a new ray helper.
  121013. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  121014. * in order to better appreciate the issue one might have.
  121015. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  121016. * @param ray Defines the ray we are currently tryin to visualize
  121017. */
  121018. constructor(ray: Ray);
  121019. /**
  121020. * Shows the ray we are willing to debug.
  121021. * @param scene Defines the scene the ray needs to be rendered in
  121022. * @param color Defines the color the ray needs to be rendered in
  121023. */
  121024. show(scene: Scene, color?: Color3): void;
  121025. /**
  121026. * Hides the ray we are debugging.
  121027. */
  121028. hide(): void;
  121029. private _render;
  121030. /**
  121031. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  121032. * @param mesh Defines the mesh we want the helper attached to
  121033. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  121034. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  121035. * @param length Defines the length of the ray
  121036. */
  121037. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  121038. /**
  121039. * Detach the ray helper from the mesh it has previously been attached to.
  121040. */
  121041. detachFromMesh(): void;
  121042. private _updateToMesh;
  121043. /**
  121044. * Dispose the helper and release its associated resources.
  121045. */
  121046. dispose(): void;
  121047. }
  121048. }
  121049. declare module BABYLON.Debug {
  121050. /**
  121051. * Class used to render a debug view of a given skeleton
  121052. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  121053. */
  121054. export class SkeletonViewer {
  121055. /** defines the skeleton to render */
  121056. skeleton: Skeleton;
  121057. /** defines the mesh attached to the skeleton */
  121058. mesh: AbstractMesh;
  121059. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  121060. autoUpdateBonesMatrices: boolean;
  121061. /** defines the rendering group id to use with the viewer */
  121062. renderingGroupId: number;
  121063. /** Gets or sets the color used to render the skeleton */
  121064. color: Color3;
  121065. private _scene;
  121066. private _debugLines;
  121067. private _debugMesh;
  121068. private _isEnabled;
  121069. private _renderFunction;
  121070. private _utilityLayer;
  121071. /**
  121072. * Returns the mesh used to render the bones
  121073. */
  121074. get debugMesh(): Nullable<LinesMesh>;
  121075. /**
  121076. * Creates a new SkeletonViewer
  121077. * @param skeleton defines the skeleton to render
  121078. * @param mesh defines the mesh attached to the skeleton
  121079. * @param scene defines the hosting scene
  121080. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  121081. * @param renderingGroupId defines the rendering group id to use with the viewer
  121082. */
  121083. constructor(
  121084. /** defines the skeleton to render */
  121085. skeleton: Skeleton,
  121086. /** defines the mesh attached to the skeleton */
  121087. mesh: AbstractMesh, scene: Scene,
  121088. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  121089. autoUpdateBonesMatrices?: boolean,
  121090. /** defines the rendering group id to use with the viewer */
  121091. renderingGroupId?: number);
  121092. /** Gets or sets a boolean indicating if the viewer is enabled */
  121093. set isEnabled(value: boolean);
  121094. get isEnabled(): boolean;
  121095. private _getBonePosition;
  121096. private _getLinesForBonesWithLength;
  121097. private _getLinesForBonesNoLength;
  121098. /** Update the viewer to sync with current skeleton state */
  121099. update(): void;
  121100. /** Release associated resources */
  121101. dispose(): void;
  121102. }
  121103. }
  121104. declare module BABYLON {
  121105. /**
  121106. * Options to create the null engine
  121107. */
  121108. export class NullEngineOptions {
  121109. /**
  121110. * Render width (Default: 512)
  121111. */
  121112. renderWidth: number;
  121113. /**
  121114. * Render height (Default: 256)
  121115. */
  121116. renderHeight: number;
  121117. /**
  121118. * Texture size (Default: 512)
  121119. */
  121120. textureSize: number;
  121121. /**
  121122. * If delta time between frames should be constant
  121123. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  121124. */
  121125. deterministicLockstep: boolean;
  121126. /**
  121127. * Maximum about of steps between frames (Default: 4)
  121128. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  121129. */
  121130. lockstepMaxSteps: number;
  121131. }
  121132. /**
  121133. * The null engine class provides support for headless version of babylon.js.
  121134. * This can be used in server side scenario or for testing purposes
  121135. */
  121136. export class NullEngine extends Engine {
  121137. private _options;
  121138. /**
  121139. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  121140. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  121141. * @returns true if engine is in deterministic lock step mode
  121142. */
  121143. isDeterministicLockStep(): boolean;
  121144. /**
  121145. * Gets the max steps when engine is running in deterministic lock step
  121146. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  121147. * @returns the max steps
  121148. */
  121149. getLockstepMaxSteps(): number;
  121150. /**
  121151. * Gets the current hardware scaling level.
  121152. * By default the hardware scaling level is computed from the window device ratio.
  121153. * 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.
  121154. * @returns a number indicating the current hardware scaling level
  121155. */
  121156. getHardwareScalingLevel(): number;
  121157. constructor(options?: NullEngineOptions);
  121158. /**
  121159. * Creates a vertex buffer
  121160. * @param vertices the data for the vertex buffer
  121161. * @returns the new WebGL static buffer
  121162. */
  121163. createVertexBuffer(vertices: FloatArray): DataBuffer;
  121164. /**
  121165. * Creates a new index buffer
  121166. * @param indices defines the content of the index buffer
  121167. * @param updatable defines if the index buffer must be updatable
  121168. * @returns a new webGL buffer
  121169. */
  121170. createIndexBuffer(indices: IndicesArray): DataBuffer;
  121171. /**
  121172. * Clear the current render buffer or the current render target (if any is set up)
  121173. * @param color defines the color to use
  121174. * @param backBuffer defines if the back buffer must be cleared
  121175. * @param depth defines if the depth buffer must be cleared
  121176. * @param stencil defines if the stencil buffer must be cleared
  121177. */
  121178. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  121179. /**
  121180. * Gets the current render width
  121181. * @param useScreen defines if screen size must be used (or the current render target if any)
  121182. * @returns a number defining the current render width
  121183. */
  121184. getRenderWidth(useScreen?: boolean): number;
  121185. /**
  121186. * Gets the current render height
  121187. * @param useScreen defines if screen size must be used (or the current render target if any)
  121188. * @returns a number defining the current render height
  121189. */
  121190. getRenderHeight(useScreen?: boolean): number;
  121191. /**
  121192. * Set the WebGL's viewport
  121193. * @param viewport defines the viewport element to be used
  121194. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  121195. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  121196. */
  121197. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  121198. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  121199. /**
  121200. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  121201. * @param pipelineContext defines the pipeline context to use
  121202. * @param uniformsNames defines the list of uniform names
  121203. * @returns an array of webGL uniform locations
  121204. */
  121205. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  121206. /**
  121207. * Gets the lsit of active attributes for a given webGL program
  121208. * @param pipelineContext defines the pipeline context to use
  121209. * @param attributesNames defines the list of attribute names to get
  121210. * @returns an array of indices indicating the offset of each attribute
  121211. */
  121212. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  121213. /**
  121214. * Binds an effect to the webGL context
  121215. * @param effect defines the effect to bind
  121216. */
  121217. bindSamplers(effect: Effect): void;
  121218. /**
  121219. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  121220. * @param effect defines the effect to activate
  121221. */
  121222. enableEffect(effect: Effect): void;
  121223. /**
  121224. * Set various states to the webGL context
  121225. * @param culling defines backface culling state
  121226. * @param zOffset defines the value to apply to zOffset (0 by default)
  121227. * @param force defines if states must be applied even if cache is up to date
  121228. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  121229. */
  121230. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  121231. /**
  121232. * Set the value of an uniform to an array of int32
  121233. * @param uniform defines the webGL uniform location where to store the value
  121234. * @param array defines the array of int32 to store
  121235. */
  121236. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  121237. /**
  121238. * Set the value of an uniform to an array of int32 (stored as vec2)
  121239. * @param uniform defines the webGL uniform location where to store the value
  121240. * @param array defines the array of int32 to store
  121241. */
  121242. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  121243. /**
  121244. * Set the value of an uniform to an array of int32 (stored as vec3)
  121245. * @param uniform defines the webGL uniform location where to store the value
  121246. * @param array defines the array of int32 to store
  121247. */
  121248. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  121249. /**
  121250. * Set the value of an uniform to an array of int32 (stored as vec4)
  121251. * @param uniform defines the webGL uniform location where to store the value
  121252. * @param array defines the array of int32 to store
  121253. */
  121254. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  121255. /**
  121256. * Set the value of an uniform to an array of float32
  121257. * @param uniform defines the webGL uniform location where to store the value
  121258. * @param array defines the array of float32 to store
  121259. */
  121260. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  121261. /**
  121262. * Set the value of an uniform to an array of float32 (stored as vec2)
  121263. * @param uniform defines the webGL uniform location where to store the value
  121264. * @param array defines the array of float32 to store
  121265. */
  121266. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  121267. /**
  121268. * Set the value of an uniform to an array of float32 (stored as vec3)
  121269. * @param uniform defines the webGL uniform location where to store the value
  121270. * @param array defines the array of float32 to store
  121271. */
  121272. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  121273. /**
  121274. * Set the value of an uniform to an array of float32 (stored as vec4)
  121275. * @param uniform defines the webGL uniform location where to store the value
  121276. * @param array defines the array of float32 to store
  121277. */
  121278. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  121279. /**
  121280. * Set the value of an uniform to an array of number
  121281. * @param uniform defines the webGL uniform location where to store the value
  121282. * @param array defines the array of number to store
  121283. */
  121284. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  121285. /**
  121286. * Set the value of an uniform to an array of number (stored as vec2)
  121287. * @param uniform defines the webGL uniform location where to store the value
  121288. * @param array defines the array of number to store
  121289. */
  121290. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  121291. /**
  121292. * Set the value of an uniform to an array of number (stored as vec3)
  121293. * @param uniform defines the webGL uniform location where to store the value
  121294. * @param array defines the array of number to store
  121295. */
  121296. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  121297. /**
  121298. * Set the value of an uniform to an array of number (stored as vec4)
  121299. * @param uniform defines the webGL uniform location where to store the value
  121300. * @param array defines the array of number to store
  121301. */
  121302. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  121303. /**
  121304. * Set the value of an uniform to an array of float32 (stored as matrices)
  121305. * @param uniform defines the webGL uniform location where to store the value
  121306. * @param matrices defines the array of float32 to store
  121307. */
  121308. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  121309. /**
  121310. * Set the value of an uniform to a matrix (3x3)
  121311. * @param uniform defines the webGL uniform location where to store the value
  121312. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  121313. */
  121314. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  121315. /**
  121316. * Set the value of an uniform to a matrix (2x2)
  121317. * @param uniform defines the webGL uniform location where to store the value
  121318. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  121319. */
  121320. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  121321. /**
  121322. * Set the value of an uniform to a number (float)
  121323. * @param uniform defines the webGL uniform location where to store the value
  121324. * @param value defines the float number to store
  121325. */
  121326. setFloat(uniform: WebGLUniformLocation, value: number): void;
  121327. /**
  121328. * Set the value of an uniform to a vec2
  121329. * @param uniform defines the webGL uniform location where to store the value
  121330. * @param x defines the 1st component of the value
  121331. * @param y defines the 2nd component of the value
  121332. */
  121333. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  121334. /**
  121335. * Set the value of an uniform to a vec3
  121336. * @param uniform defines the webGL uniform location where to store the value
  121337. * @param x defines the 1st component of the value
  121338. * @param y defines the 2nd component of the value
  121339. * @param z defines the 3rd component of the value
  121340. */
  121341. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  121342. /**
  121343. * Set the value of an uniform to a boolean
  121344. * @param uniform defines the webGL uniform location where to store the value
  121345. * @param bool defines the boolean to store
  121346. */
  121347. setBool(uniform: WebGLUniformLocation, bool: number): void;
  121348. /**
  121349. * Set the value of an uniform to a vec4
  121350. * @param uniform defines the webGL uniform location where to store the value
  121351. * @param x defines the 1st component of the value
  121352. * @param y defines the 2nd component of the value
  121353. * @param z defines the 3rd component of the value
  121354. * @param w defines the 4th component of the value
  121355. */
  121356. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  121357. /**
  121358. * Sets the current alpha mode
  121359. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  121360. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  121361. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  121362. */
  121363. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  121364. /**
  121365. * Bind webGl buffers directly to the webGL context
  121366. * @param vertexBuffers defines the vertex buffer to bind
  121367. * @param indexBuffer defines the index buffer to bind
  121368. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  121369. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  121370. * @param effect defines the effect associated with the vertex buffer
  121371. */
  121372. bindBuffers(vertexBuffers: {
  121373. [key: string]: VertexBuffer;
  121374. }, indexBuffer: DataBuffer, effect: Effect): void;
  121375. /**
  121376. * Force the entire cache to be cleared
  121377. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  121378. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  121379. */
  121380. wipeCaches(bruteForce?: boolean): void;
  121381. /**
  121382. * Send a draw order
  121383. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  121384. * @param indexStart defines the starting index
  121385. * @param indexCount defines the number of index to draw
  121386. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  121387. */
  121388. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  121389. /**
  121390. * Draw a list of indexed primitives
  121391. * @param fillMode defines the primitive to use
  121392. * @param indexStart defines the starting index
  121393. * @param indexCount defines the number of index to draw
  121394. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  121395. */
  121396. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  121397. /**
  121398. * Draw a list of unindexed primitives
  121399. * @param fillMode defines the primitive to use
  121400. * @param verticesStart defines the index of first vertex to draw
  121401. * @param verticesCount defines the count of vertices to draw
  121402. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  121403. */
  121404. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  121405. /** @hidden */
  121406. _createTexture(): WebGLTexture;
  121407. /** @hidden */
  121408. _releaseTexture(texture: InternalTexture): void;
  121409. /**
  121410. * Usually called from Texture.ts.
  121411. * Passed information to create a WebGLTexture
  121412. * @param urlArg defines a value which contains one of the following:
  121413. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  121414. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  121415. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  121416. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  121417. * @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)
  121418. * @param scene needed for loading to the correct scene
  121419. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  121420. * @param onLoad optional callback to be called upon successful completion
  121421. * @param onError optional callback to be called upon failure
  121422. * @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
  121423. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  121424. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  121425. * @param forcedExtension defines the extension to use to pick the right loader
  121426. * @param mimeType defines an optional mime type
  121427. * @returns a InternalTexture for assignment back into BABYLON.Texture
  121428. */
  121429. 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;
  121430. /**
  121431. * Creates a new render target texture
  121432. * @param size defines the size of the texture
  121433. * @param options defines the options used to create the texture
  121434. * @returns a new render target texture stored in an InternalTexture
  121435. */
  121436. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  121437. /**
  121438. * Update the sampling mode of a given texture
  121439. * @param samplingMode defines the required sampling mode
  121440. * @param texture defines the texture to update
  121441. */
  121442. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  121443. /**
  121444. * Binds the frame buffer to the specified texture.
  121445. * @param texture The texture to render to or null for the default canvas
  121446. * @param faceIndex The face of the texture to render to in case of cube texture
  121447. * @param requiredWidth The width of the target to render to
  121448. * @param requiredHeight The height of the target to render to
  121449. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  121450. * @param lodLevel defines le lod level to bind to the frame buffer
  121451. */
  121452. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  121453. /**
  121454. * Unbind the current render target texture from the webGL context
  121455. * @param texture defines the render target texture to unbind
  121456. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  121457. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  121458. */
  121459. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  121460. /**
  121461. * Creates a dynamic vertex buffer
  121462. * @param vertices the data for the dynamic vertex buffer
  121463. * @returns the new WebGL dynamic buffer
  121464. */
  121465. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  121466. /**
  121467. * Update the content of a dynamic texture
  121468. * @param texture defines the texture to update
  121469. * @param canvas defines the canvas containing the source
  121470. * @param invertY defines if data must be stored with Y axis inverted
  121471. * @param premulAlpha defines if alpha is stored as premultiplied
  121472. * @param format defines the format of the data
  121473. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  121474. */
  121475. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  121476. /**
  121477. * Gets a boolean indicating if all created effects are ready
  121478. * @returns true if all effects are ready
  121479. */
  121480. areAllEffectsReady(): boolean;
  121481. /**
  121482. * @hidden
  121483. * Get the current error code of the webGL context
  121484. * @returns the error code
  121485. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  121486. */
  121487. getError(): number;
  121488. /** @hidden */
  121489. _getUnpackAlignement(): number;
  121490. /** @hidden */
  121491. _unpackFlipY(value: boolean): void;
  121492. /**
  121493. * Update a dynamic index buffer
  121494. * @param indexBuffer defines the target index buffer
  121495. * @param indices defines the data to update
  121496. * @param offset defines the offset in the target index buffer where update should start
  121497. */
  121498. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  121499. /**
  121500. * Updates a dynamic vertex buffer.
  121501. * @param vertexBuffer the vertex buffer to update
  121502. * @param vertices the data used to update the vertex buffer
  121503. * @param byteOffset the byte offset of the data (optional)
  121504. * @param byteLength the byte length of the data (optional)
  121505. */
  121506. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  121507. /** @hidden */
  121508. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  121509. /** @hidden */
  121510. _bindTexture(channel: number, texture: InternalTexture): void;
  121511. protected _deleteBuffer(buffer: WebGLBuffer): void;
  121512. /**
  121513. * 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
  121514. */
  121515. releaseEffects(): void;
  121516. displayLoadingUI(): void;
  121517. hideLoadingUI(): void;
  121518. /** @hidden */
  121519. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  121520. /** @hidden */
  121521. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  121522. /** @hidden */
  121523. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  121524. /** @hidden */
  121525. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  121526. }
  121527. }
  121528. declare module BABYLON {
  121529. /**
  121530. * @hidden
  121531. **/
  121532. export class _TimeToken {
  121533. _startTimeQuery: Nullable<WebGLQuery>;
  121534. _endTimeQuery: Nullable<WebGLQuery>;
  121535. _timeElapsedQuery: Nullable<WebGLQuery>;
  121536. _timeElapsedQueryEnded: boolean;
  121537. }
  121538. }
  121539. declare module BABYLON {
  121540. /** @hidden */
  121541. export class _OcclusionDataStorage {
  121542. /** @hidden */
  121543. occlusionInternalRetryCounter: number;
  121544. /** @hidden */
  121545. isOcclusionQueryInProgress: boolean;
  121546. /** @hidden */
  121547. isOccluded: boolean;
  121548. /** @hidden */
  121549. occlusionRetryCount: number;
  121550. /** @hidden */
  121551. occlusionType: number;
  121552. /** @hidden */
  121553. occlusionQueryAlgorithmType: number;
  121554. }
  121555. interface Engine {
  121556. /**
  121557. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  121558. * @return the new query
  121559. */
  121560. createQuery(): WebGLQuery;
  121561. /**
  121562. * Delete and release a webGL query
  121563. * @param query defines the query to delete
  121564. * @return the current engine
  121565. */
  121566. deleteQuery(query: WebGLQuery): Engine;
  121567. /**
  121568. * Check if a given query has resolved and got its value
  121569. * @param query defines the query to check
  121570. * @returns true if the query got its value
  121571. */
  121572. isQueryResultAvailable(query: WebGLQuery): boolean;
  121573. /**
  121574. * Gets the value of a given query
  121575. * @param query defines the query to check
  121576. * @returns the value of the query
  121577. */
  121578. getQueryResult(query: WebGLQuery): number;
  121579. /**
  121580. * Initiates an occlusion query
  121581. * @param algorithmType defines the algorithm to use
  121582. * @param query defines the query to use
  121583. * @returns the current engine
  121584. * @see http://doc.babylonjs.com/features/occlusionquery
  121585. */
  121586. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  121587. /**
  121588. * Ends an occlusion query
  121589. * @see http://doc.babylonjs.com/features/occlusionquery
  121590. * @param algorithmType defines the algorithm to use
  121591. * @returns the current engine
  121592. */
  121593. endOcclusionQuery(algorithmType: number): Engine;
  121594. /**
  121595. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  121596. * Please note that only one query can be issued at a time
  121597. * @returns a time token used to track the time span
  121598. */
  121599. startTimeQuery(): Nullable<_TimeToken>;
  121600. /**
  121601. * Ends a time query
  121602. * @param token defines the token used to measure the time span
  121603. * @returns the time spent (in ns)
  121604. */
  121605. endTimeQuery(token: _TimeToken): int;
  121606. /** @hidden */
  121607. _currentNonTimestampToken: Nullable<_TimeToken>;
  121608. /** @hidden */
  121609. _createTimeQuery(): WebGLQuery;
  121610. /** @hidden */
  121611. _deleteTimeQuery(query: WebGLQuery): void;
  121612. /** @hidden */
  121613. _getGlAlgorithmType(algorithmType: number): number;
  121614. /** @hidden */
  121615. _getTimeQueryResult(query: WebGLQuery): any;
  121616. /** @hidden */
  121617. _getTimeQueryAvailability(query: WebGLQuery): any;
  121618. }
  121619. interface AbstractMesh {
  121620. /**
  121621. * Backing filed
  121622. * @hidden
  121623. */
  121624. __occlusionDataStorage: _OcclusionDataStorage;
  121625. /**
  121626. * Access property
  121627. * @hidden
  121628. */
  121629. _occlusionDataStorage: _OcclusionDataStorage;
  121630. /**
  121631. * 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.
  121632. * The default value is -1 which means don't break the query and wait till the result
  121633. * @see http://doc.babylonjs.com/features/occlusionquery
  121634. */
  121635. occlusionRetryCount: number;
  121636. /**
  121637. * 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:
  121638. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  121639. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  121640. * * 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.
  121641. * @see http://doc.babylonjs.com/features/occlusionquery
  121642. */
  121643. occlusionType: number;
  121644. /**
  121645. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  121646. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  121647. * * 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.
  121648. * @see http://doc.babylonjs.com/features/occlusionquery
  121649. */
  121650. occlusionQueryAlgorithmType: number;
  121651. /**
  121652. * 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
  121653. * @see http://doc.babylonjs.com/features/occlusionquery
  121654. */
  121655. isOccluded: boolean;
  121656. /**
  121657. * Flag to check the progress status of the query
  121658. * @see http://doc.babylonjs.com/features/occlusionquery
  121659. */
  121660. isOcclusionQueryInProgress: boolean;
  121661. }
  121662. }
  121663. declare module BABYLON {
  121664. /** @hidden */
  121665. export var _forceTransformFeedbackToBundle: boolean;
  121666. interface Engine {
  121667. /**
  121668. * Creates a webGL transform feedback object
  121669. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  121670. * @returns the webGL transform feedback object
  121671. */
  121672. createTransformFeedback(): WebGLTransformFeedback;
  121673. /**
  121674. * Delete a webGL transform feedback object
  121675. * @param value defines the webGL transform feedback object to delete
  121676. */
  121677. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  121678. /**
  121679. * Bind a webGL transform feedback object to the webgl context
  121680. * @param value defines the webGL transform feedback object to bind
  121681. */
  121682. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  121683. /**
  121684. * Begins a transform feedback operation
  121685. * @param usePoints defines if points or triangles must be used
  121686. */
  121687. beginTransformFeedback(usePoints: boolean): void;
  121688. /**
  121689. * Ends a transform feedback operation
  121690. */
  121691. endTransformFeedback(): void;
  121692. /**
  121693. * Specify the varyings to use with transform feedback
  121694. * @param program defines the associated webGL program
  121695. * @param value defines the list of strings representing the varying names
  121696. */
  121697. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  121698. /**
  121699. * Bind a webGL buffer for a transform feedback operation
  121700. * @param value defines the webGL buffer to bind
  121701. */
  121702. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  121703. }
  121704. }
  121705. declare module BABYLON {
  121706. /**
  121707. * Creation options of the multi render target texture.
  121708. */
  121709. export interface IMultiRenderTargetOptions {
  121710. /**
  121711. * Define if the texture needs to create mip maps after render.
  121712. */
  121713. generateMipMaps?: boolean;
  121714. /**
  121715. * Define the types of all the draw buffers we want to create
  121716. */
  121717. types?: number[];
  121718. /**
  121719. * Define the sampling modes of all the draw buffers we want to create
  121720. */
  121721. samplingModes?: number[];
  121722. /**
  121723. * Define if a depth buffer is required
  121724. */
  121725. generateDepthBuffer?: boolean;
  121726. /**
  121727. * Define if a stencil buffer is required
  121728. */
  121729. generateStencilBuffer?: boolean;
  121730. /**
  121731. * Define if a depth texture is required instead of a depth buffer
  121732. */
  121733. generateDepthTexture?: boolean;
  121734. /**
  121735. * Define the number of desired draw buffers
  121736. */
  121737. textureCount?: number;
  121738. /**
  121739. * Define if aspect ratio should be adapted to the texture or stay the scene one
  121740. */
  121741. doNotChangeAspectRatio?: boolean;
  121742. /**
  121743. * Define the default type of the buffers we are creating
  121744. */
  121745. defaultType?: number;
  121746. }
  121747. /**
  121748. * A multi render target, like a render target provides the ability to render to a texture.
  121749. * Unlike the render target, it can render to several draw buffers in one draw.
  121750. * This is specially interesting in deferred rendering or for any effects requiring more than
  121751. * just one color from a single pass.
  121752. */
  121753. export class MultiRenderTarget extends RenderTargetTexture {
  121754. private _internalTextures;
  121755. private _textures;
  121756. private _multiRenderTargetOptions;
  121757. /**
  121758. * Get if draw buffers are currently supported by the used hardware and browser.
  121759. */
  121760. get isSupported(): boolean;
  121761. /**
  121762. * Get the list of textures generated by the multi render target.
  121763. */
  121764. get textures(): Texture[];
  121765. /**
  121766. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  121767. */
  121768. get depthTexture(): Texture;
  121769. /**
  121770. * Set the wrapping mode on U of all the textures we are rendering to.
  121771. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  121772. */
  121773. set wrapU(wrap: number);
  121774. /**
  121775. * Set the wrapping mode on V of all the textures we are rendering to.
  121776. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  121777. */
  121778. set wrapV(wrap: number);
  121779. /**
  121780. * Instantiate a new multi render target texture.
  121781. * A multi render target, like a render target provides the ability to render to a texture.
  121782. * Unlike the render target, it can render to several draw buffers in one draw.
  121783. * This is specially interesting in deferred rendering or for any effects requiring more than
  121784. * just one color from a single pass.
  121785. * @param name Define the name of the texture
  121786. * @param size Define the size of the buffers to render to
  121787. * @param count Define the number of target we are rendering into
  121788. * @param scene Define the scene the texture belongs to
  121789. * @param options Define the options used to create the multi render target
  121790. */
  121791. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  121792. /** @hidden */
  121793. _rebuild(): void;
  121794. private _createInternalTextures;
  121795. private _createTextures;
  121796. /**
  121797. * Define the number of samples used if MSAA is enabled.
  121798. */
  121799. get samples(): number;
  121800. set samples(value: number);
  121801. /**
  121802. * Resize all the textures in the multi render target.
  121803. * Be carrefull as it will recreate all the data in the new texture.
  121804. * @param size Define the new size
  121805. */
  121806. resize(size: any): void;
  121807. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  121808. /**
  121809. * Dispose the render targets and their associated resources
  121810. */
  121811. dispose(): void;
  121812. /**
  121813. * Release all the underlying texture used as draw buffers.
  121814. */
  121815. releaseInternalTextures(): void;
  121816. }
  121817. }
  121818. declare module BABYLON {
  121819. interface ThinEngine {
  121820. /**
  121821. * Unbind a list of render target textures from the webGL context
  121822. * This is used only when drawBuffer extension or webGL2 are active
  121823. * @param textures defines the render target textures to unbind
  121824. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  121825. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  121826. */
  121827. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  121828. /**
  121829. * Create a multi render target texture
  121830. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  121831. * @param size defines the size of the texture
  121832. * @param options defines the creation options
  121833. * @returns the cube texture as an InternalTexture
  121834. */
  121835. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  121836. /**
  121837. * Update the sample count for a given multiple render target texture
  121838. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  121839. * @param textures defines the textures to update
  121840. * @param samples defines the sample count to set
  121841. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  121842. */
  121843. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  121844. }
  121845. }
  121846. declare module BABYLON {
  121847. /**
  121848. * Class used to define an additional view for the engine
  121849. * @see https://doc.babylonjs.com/how_to/multi_canvases
  121850. */
  121851. export class EngineView {
  121852. /** Defines the canvas where to render the view */
  121853. target: HTMLCanvasElement;
  121854. /** Defines an optional camera used to render the view (will use active camera else) */
  121855. camera?: Camera;
  121856. }
  121857. interface Engine {
  121858. /**
  121859. * Gets or sets the HTML element to use for attaching events
  121860. */
  121861. inputElement: Nullable<HTMLElement>;
  121862. /**
  121863. * Gets the current engine view
  121864. * @see https://doc.babylonjs.com/how_to/multi_canvases
  121865. */
  121866. activeView: Nullable<EngineView>;
  121867. /** Gets or sets the list of views */
  121868. views: EngineView[];
  121869. /**
  121870. * Register a new child canvas
  121871. * @param canvas defines the canvas to register
  121872. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  121873. * @returns the associated view
  121874. */
  121875. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  121876. /**
  121877. * Remove a registered child canvas
  121878. * @param canvas defines the canvas to remove
  121879. * @returns the current engine
  121880. */
  121881. unRegisterView(canvas: HTMLCanvasElement): Engine;
  121882. }
  121883. }
  121884. declare module BABYLON {
  121885. interface Engine {
  121886. /** @hidden */
  121887. _excludedCompressedTextures: string[];
  121888. /** @hidden */
  121889. _textureFormatInUse: string;
  121890. /**
  121891. * Gets the list of texture formats supported
  121892. */
  121893. readonly texturesSupported: Array<string>;
  121894. /**
  121895. * Gets the texture format in use
  121896. */
  121897. readonly textureFormatInUse: Nullable<string>;
  121898. /**
  121899. * Set the compressed texture extensions or file names to skip.
  121900. *
  121901. * @param skippedFiles defines the list of those texture files you want to skip
  121902. * Example: [".dds", ".env", "myfile.png"]
  121903. */
  121904. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  121905. /**
  121906. * Set the compressed texture format to use, based on the formats you have, and the formats
  121907. * supported by the hardware / browser.
  121908. *
  121909. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  121910. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  121911. * to API arguments needed to compressed textures. This puts the burden on the container
  121912. * generator to house the arcane code for determining these for current & future formats.
  121913. *
  121914. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  121915. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  121916. *
  121917. * Note: The result of this call is not taken into account when a texture is base64.
  121918. *
  121919. * @param formatsAvailable defines the list of those format families you have created
  121920. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  121921. *
  121922. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  121923. * @returns The extension selected.
  121924. */
  121925. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  121926. }
  121927. }
  121928. declare module BABYLON {
  121929. /**
  121930. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  121931. */
  121932. export interface CubeMapInfo {
  121933. /**
  121934. * The pixel array for the front face.
  121935. * This is stored in format, left to right, up to down format.
  121936. */
  121937. front: Nullable<ArrayBufferView>;
  121938. /**
  121939. * The pixel array for the back face.
  121940. * This is stored in format, left to right, up to down format.
  121941. */
  121942. back: Nullable<ArrayBufferView>;
  121943. /**
  121944. * The pixel array for the left face.
  121945. * This is stored in format, left to right, up to down format.
  121946. */
  121947. left: Nullable<ArrayBufferView>;
  121948. /**
  121949. * The pixel array for the right face.
  121950. * This is stored in format, left to right, up to down format.
  121951. */
  121952. right: Nullable<ArrayBufferView>;
  121953. /**
  121954. * The pixel array for the up face.
  121955. * This is stored in format, left to right, up to down format.
  121956. */
  121957. up: Nullable<ArrayBufferView>;
  121958. /**
  121959. * The pixel array for the down face.
  121960. * This is stored in format, left to right, up to down format.
  121961. */
  121962. down: Nullable<ArrayBufferView>;
  121963. /**
  121964. * The size of the cubemap stored.
  121965. *
  121966. * Each faces will be size * size pixels.
  121967. */
  121968. size: number;
  121969. /**
  121970. * The format of the texture.
  121971. *
  121972. * RGBA, RGB.
  121973. */
  121974. format: number;
  121975. /**
  121976. * The type of the texture data.
  121977. *
  121978. * UNSIGNED_INT, FLOAT.
  121979. */
  121980. type: number;
  121981. /**
  121982. * Specifies whether the texture is in gamma space.
  121983. */
  121984. gammaSpace: boolean;
  121985. }
  121986. /**
  121987. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  121988. */
  121989. export class PanoramaToCubeMapTools {
  121990. private static FACE_FRONT;
  121991. private static FACE_BACK;
  121992. private static FACE_RIGHT;
  121993. private static FACE_LEFT;
  121994. private static FACE_DOWN;
  121995. private static FACE_UP;
  121996. /**
  121997. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  121998. *
  121999. * @param float32Array The source data.
  122000. * @param inputWidth The width of the input panorama.
  122001. * @param inputHeight The height of the input panorama.
  122002. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  122003. * @return The cubemap data
  122004. */
  122005. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  122006. private static CreateCubemapTexture;
  122007. private static CalcProjectionSpherical;
  122008. }
  122009. }
  122010. declare module BABYLON {
  122011. /**
  122012. * Helper class dealing with the extraction of spherical polynomial dataArray
  122013. * from a cube map.
  122014. */
  122015. export class CubeMapToSphericalPolynomialTools {
  122016. private static FileFaces;
  122017. /**
  122018. * Converts a texture to the according Spherical Polynomial data.
  122019. * This extracts the first 3 orders only as they are the only one used in the lighting.
  122020. *
  122021. * @param texture The texture to extract the information from.
  122022. * @return The Spherical Polynomial data.
  122023. */
  122024. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  122025. /**
  122026. * Converts a cubemap to the according Spherical Polynomial data.
  122027. * This extracts the first 3 orders only as they are the only one used in the lighting.
  122028. *
  122029. * @param cubeInfo The Cube map to extract the information from.
  122030. * @return The Spherical Polynomial data.
  122031. */
  122032. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  122033. }
  122034. }
  122035. declare module BABYLON {
  122036. interface BaseTexture {
  122037. /**
  122038. * Get the polynomial representation of the texture data.
  122039. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  122040. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  122041. */
  122042. sphericalPolynomial: Nullable<SphericalPolynomial>;
  122043. }
  122044. }
  122045. declare module BABYLON {
  122046. /** @hidden */
  122047. export var rgbdEncodePixelShader: {
  122048. name: string;
  122049. shader: string;
  122050. };
  122051. }
  122052. declare module BABYLON {
  122053. /** @hidden */
  122054. export var rgbdDecodePixelShader: {
  122055. name: string;
  122056. shader: string;
  122057. };
  122058. }
  122059. declare module BABYLON {
  122060. /**
  122061. * Raw texture data and descriptor sufficient for WebGL texture upload
  122062. */
  122063. export interface EnvironmentTextureInfo {
  122064. /**
  122065. * Version of the environment map
  122066. */
  122067. version: number;
  122068. /**
  122069. * Width of image
  122070. */
  122071. width: number;
  122072. /**
  122073. * Irradiance information stored in the file.
  122074. */
  122075. irradiance: any;
  122076. /**
  122077. * Specular information stored in the file.
  122078. */
  122079. specular: any;
  122080. }
  122081. /**
  122082. * Defines One Image in the file. It requires only the position in the file
  122083. * as well as the length.
  122084. */
  122085. interface BufferImageData {
  122086. /**
  122087. * Length of the image data.
  122088. */
  122089. length: number;
  122090. /**
  122091. * Position of the data from the null terminator delimiting the end of the JSON.
  122092. */
  122093. position: number;
  122094. }
  122095. /**
  122096. * Defines the specular data enclosed in the file.
  122097. * This corresponds to the version 1 of the data.
  122098. */
  122099. export interface EnvironmentTextureSpecularInfoV1 {
  122100. /**
  122101. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  122102. */
  122103. specularDataPosition?: number;
  122104. /**
  122105. * This contains all the images data needed to reconstruct the cubemap.
  122106. */
  122107. mipmaps: Array<BufferImageData>;
  122108. /**
  122109. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  122110. */
  122111. lodGenerationScale: number;
  122112. }
  122113. /**
  122114. * Sets of helpers addressing the serialization and deserialization of environment texture
  122115. * stored in a BabylonJS env file.
  122116. * Those files are usually stored as .env files.
  122117. */
  122118. export class EnvironmentTextureTools {
  122119. /**
  122120. * Magic number identifying the env file.
  122121. */
  122122. private static _MagicBytes;
  122123. /**
  122124. * Gets the environment info from an env file.
  122125. * @param data The array buffer containing the .env bytes.
  122126. * @returns the environment file info (the json header) if successfully parsed.
  122127. */
  122128. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  122129. /**
  122130. * Creates an environment texture from a loaded cube texture.
  122131. * @param texture defines the cube texture to convert in env file
  122132. * @return a promise containing the environment data if succesfull.
  122133. */
  122134. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  122135. /**
  122136. * Creates a JSON representation of the spherical data.
  122137. * @param texture defines the texture containing the polynomials
  122138. * @return the JSON representation of the spherical info
  122139. */
  122140. private static _CreateEnvTextureIrradiance;
  122141. /**
  122142. * Creates the ArrayBufferViews used for initializing environment texture image data.
  122143. * @param data the image data
  122144. * @param info parameters that determine what views will be created for accessing the underlying buffer
  122145. * @return the views described by info providing access to the underlying buffer
  122146. */
  122147. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  122148. /**
  122149. * Uploads the texture info contained in the env file to the GPU.
  122150. * @param texture defines the internal texture to upload to
  122151. * @param data defines the data to load
  122152. * @param info defines the texture info retrieved through the GetEnvInfo method
  122153. * @returns a promise
  122154. */
  122155. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  122156. private static _OnImageReadyAsync;
  122157. /**
  122158. * Uploads the levels of image data to the GPU.
  122159. * @param texture defines the internal texture to upload to
  122160. * @param imageData defines the array buffer views of image data [mipmap][face]
  122161. * @returns a promise
  122162. */
  122163. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  122164. /**
  122165. * Uploads spherical polynomials information to the texture.
  122166. * @param texture defines the texture we are trying to upload the information to
  122167. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  122168. */
  122169. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  122170. /** @hidden */
  122171. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  122172. }
  122173. }
  122174. declare module BABYLON {
  122175. /**
  122176. * Contains position and normal vectors for a vertex
  122177. */
  122178. export class PositionNormalVertex {
  122179. /** the position of the vertex (defaut: 0,0,0) */
  122180. position: Vector3;
  122181. /** the normal of the vertex (defaut: 0,1,0) */
  122182. normal: Vector3;
  122183. /**
  122184. * Creates a PositionNormalVertex
  122185. * @param position the position of the vertex (defaut: 0,0,0)
  122186. * @param normal the normal of the vertex (defaut: 0,1,0)
  122187. */
  122188. constructor(
  122189. /** the position of the vertex (defaut: 0,0,0) */
  122190. position?: Vector3,
  122191. /** the normal of the vertex (defaut: 0,1,0) */
  122192. normal?: Vector3);
  122193. /**
  122194. * Clones the PositionNormalVertex
  122195. * @returns the cloned PositionNormalVertex
  122196. */
  122197. clone(): PositionNormalVertex;
  122198. }
  122199. /**
  122200. * Contains position, normal and uv vectors for a vertex
  122201. */
  122202. export class PositionNormalTextureVertex {
  122203. /** the position of the vertex (defaut: 0,0,0) */
  122204. position: Vector3;
  122205. /** the normal of the vertex (defaut: 0,1,0) */
  122206. normal: Vector3;
  122207. /** the uv of the vertex (default: 0,0) */
  122208. uv: Vector2;
  122209. /**
  122210. * Creates a PositionNormalTextureVertex
  122211. * @param position the position of the vertex (defaut: 0,0,0)
  122212. * @param normal the normal of the vertex (defaut: 0,1,0)
  122213. * @param uv the uv of the vertex (default: 0,0)
  122214. */
  122215. constructor(
  122216. /** the position of the vertex (defaut: 0,0,0) */
  122217. position?: Vector3,
  122218. /** the normal of the vertex (defaut: 0,1,0) */
  122219. normal?: Vector3,
  122220. /** the uv of the vertex (default: 0,0) */
  122221. uv?: Vector2);
  122222. /**
  122223. * Clones the PositionNormalTextureVertex
  122224. * @returns the cloned PositionNormalTextureVertex
  122225. */
  122226. clone(): PositionNormalTextureVertex;
  122227. }
  122228. }
  122229. declare module BABYLON {
  122230. /** @hidden */
  122231. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  122232. private _genericAttributeLocation;
  122233. private _varyingLocationCount;
  122234. private _varyingLocationMap;
  122235. private _replacements;
  122236. private _textureCount;
  122237. private _uniforms;
  122238. lineProcessor(line: string): string;
  122239. attributeProcessor(attribute: string): string;
  122240. varyingProcessor(varying: string, isFragment: boolean): string;
  122241. uniformProcessor(uniform: string): string;
  122242. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  122243. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  122244. }
  122245. }
  122246. declare module BABYLON {
  122247. /**
  122248. * Container for accessors for natively-stored mesh data buffers.
  122249. */
  122250. class NativeDataBuffer extends DataBuffer {
  122251. /**
  122252. * Accessor value used to identify/retrieve a natively-stored index buffer.
  122253. */
  122254. nativeIndexBuffer?: any;
  122255. /**
  122256. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  122257. */
  122258. nativeVertexBuffer?: any;
  122259. }
  122260. /** @hidden */
  122261. class NativeTexture extends InternalTexture {
  122262. getInternalTexture(): InternalTexture;
  122263. getViewCount(): number;
  122264. }
  122265. /** @hidden */
  122266. export class NativeEngine extends Engine {
  122267. private readonly _native;
  122268. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  122269. private readonly INVALID_HANDLE;
  122270. getHardwareScalingLevel(): number;
  122271. constructor();
  122272. /**
  122273. * Can be used to override the current requestAnimationFrame requester.
  122274. * @hidden
  122275. */
  122276. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  122277. /**
  122278. * Override default engine behavior.
  122279. * @param color
  122280. * @param backBuffer
  122281. * @param depth
  122282. * @param stencil
  122283. */
  122284. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  122285. /**
  122286. * Gets host document
  122287. * @returns the host document object
  122288. */
  122289. getHostDocument(): Nullable<Document>;
  122290. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  122291. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  122292. createVertexBuffer(data: DataArray): NativeDataBuffer;
  122293. recordVertexArrayObject(vertexBuffers: {
  122294. [key: string]: VertexBuffer;
  122295. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  122296. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  122297. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  122298. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  122299. /**
  122300. * Draw a list of indexed primitives
  122301. * @param fillMode defines the primitive to use
  122302. * @param indexStart defines the starting index
  122303. * @param indexCount defines the number of index to draw
  122304. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  122305. */
  122306. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  122307. /**
  122308. * Draw a list of unindexed primitives
  122309. * @param fillMode defines the primitive to use
  122310. * @param verticesStart defines the index of first vertex to draw
  122311. * @param verticesCount defines the count of vertices to draw
  122312. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  122313. */
  122314. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  122315. createPipelineContext(): IPipelineContext;
  122316. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  122317. /** @hidden */
  122318. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  122319. /** @hidden */
  122320. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  122321. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  122322. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  122323. protected _setProgram(program: WebGLProgram): void;
  122324. _releaseEffect(effect: Effect): void;
  122325. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  122326. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  122327. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  122328. bindSamplers(effect: Effect): void;
  122329. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  122330. getRenderWidth(useScreen?: boolean): number;
  122331. getRenderHeight(useScreen?: boolean): number;
  122332. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  122333. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  122334. /**
  122335. * Set the z offset to apply to current rendering
  122336. * @param value defines the offset to apply
  122337. */
  122338. setZOffset(value: number): void;
  122339. /**
  122340. * Gets the current value of the zOffset
  122341. * @returns the current zOffset state
  122342. */
  122343. getZOffset(): number;
  122344. /**
  122345. * Enable or disable depth buffering
  122346. * @param enable defines the state to set
  122347. */
  122348. setDepthBuffer(enable: boolean): void;
  122349. /**
  122350. * Gets a boolean indicating if depth writing is enabled
  122351. * @returns the current depth writing state
  122352. */
  122353. getDepthWrite(): boolean;
  122354. /**
  122355. * Enable or disable depth writing
  122356. * @param enable defines the state to set
  122357. */
  122358. setDepthWrite(enable: boolean): void;
  122359. /**
  122360. * Enable or disable color writing
  122361. * @param enable defines the state to set
  122362. */
  122363. setColorWrite(enable: boolean): void;
  122364. /**
  122365. * Gets a boolean indicating if color writing is enabled
  122366. * @returns the current color writing state
  122367. */
  122368. getColorWrite(): boolean;
  122369. /**
  122370. * Sets alpha constants used by some alpha blending modes
  122371. * @param r defines the red component
  122372. * @param g defines the green component
  122373. * @param b defines the blue component
  122374. * @param a defines the alpha component
  122375. */
  122376. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  122377. /**
  122378. * Sets the current alpha mode
  122379. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  122380. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  122381. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  122382. */
  122383. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  122384. /**
  122385. * Gets the current alpha mode
  122386. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  122387. * @returns the current alpha mode
  122388. */
  122389. getAlphaMode(): number;
  122390. setInt(uniform: WebGLUniformLocation, int: number): void;
  122391. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  122392. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  122393. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  122394. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  122395. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  122396. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  122397. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  122398. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  122399. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  122400. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  122401. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  122402. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  122403. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  122404. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  122405. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  122406. setFloat(uniform: WebGLUniformLocation, value: number): void;
  122407. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  122408. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  122409. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  122410. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  122411. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  122412. wipeCaches(bruteForce?: boolean): void;
  122413. _createTexture(): WebGLTexture;
  122414. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  122415. /**
  122416. * Usually called from Texture.ts.
  122417. * Passed information to create a WebGLTexture
  122418. * @param urlArg defines a value which contains one of the following:
  122419. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  122420. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  122421. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  122422. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  122423. * @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)
  122424. * @param scene needed for loading to the correct scene
  122425. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  122426. * @param onLoad optional callback to be called upon successful completion
  122427. * @param onError optional callback to be called upon failure
  122428. * @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
  122429. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  122430. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  122431. * @param forcedExtension defines the extension to use to pick the right loader
  122432. * @param mimeType defines an optional mime type
  122433. * @returns a InternalTexture for assignment back into BABYLON.Texture
  122434. */
  122435. 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;
  122436. /**
  122437. * Creates a cube texture
  122438. * @param rootUrl defines the url where the files to load is located
  122439. * @param scene defines the current scene
  122440. * @param files defines the list of files to load (1 per face)
  122441. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  122442. * @param onLoad defines an optional callback raised when the texture is loaded
  122443. * @param onError defines an optional callback raised if there is an issue to load the texture
  122444. * @param format defines the format of the data
  122445. * @param forcedExtension defines the extension to use to pick the right loader
  122446. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  122447. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  122448. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  122449. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  122450. * @returns the cube texture as an InternalTexture
  122451. */
  122452. 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;
  122453. private _getSamplingFilter;
  122454. private static _GetNativeTextureFormat;
  122455. createRenderTargetTexture(size: number | {
  122456. width: number;
  122457. height: number;
  122458. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  122459. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  122460. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  122461. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  122462. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  122463. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  122464. /**
  122465. * Updates a dynamic vertex buffer.
  122466. * @param vertexBuffer the vertex buffer to update
  122467. * @param data the data used to update the vertex buffer
  122468. * @param byteOffset the byte offset of the data (optional)
  122469. * @param byteLength the byte length of the data (optional)
  122470. */
  122471. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  122472. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  122473. private _updateAnisotropicLevel;
  122474. private _getAddressMode;
  122475. /** @hidden */
  122476. _bindTexture(channel: number, texture: InternalTexture): void;
  122477. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  122478. releaseEffects(): void;
  122479. /** @hidden */
  122480. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  122481. /** @hidden */
  122482. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  122483. /** @hidden */
  122484. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  122485. /** @hidden */
  122486. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  122487. }
  122488. }
  122489. declare module BABYLON {
  122490. /**
  122491. * Gather the list of clipboard event types as constants.
  122492. */
  122493. export class ClipboardEventTypes {
  122494. /**
  122495. * The clipboard event is fired when a copy command is active (pressed).
  122496. */
  122497. static readonly COPY: number;
  122498. /**
  122499. * The clipboard event is fired when a cut command is active (pressed).
  122500. */
  122501. static readonly CUT: number;
  122502. /**
  122503. * The clipboard event is fired when a paste command is active (pressed).
  122504. */
  122505. static readonly PASTE: number;
  122506. }
  122507. /**
  122508. * This class is used to store clipboard related info for the onClipboardObservable event.
  122509. */
  122510. export class ClipboardInfo {
  122511. /**
  122512. * Defines the type of event (BABYLON.ClipboardEventTypes)
  122513. */
  122514. type: number;
  122515. /**
  122516. * Defines the related dom event
  122517. */
  122518. event: ClipboardEvent;
  122519. /**
  122520. *Creates an instance of ClipboardInfo.
  122521. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  122522. * @param event Defines the related dom event
  122523. */
  122524. constructor(
  122525. /**
  122526. * Defines the type of event (BABYLON.ClipboardEventTypes)
  122527. */
  122528. type: number,
  122529. /**
  122530. * Defines the related dom event
  122531. */
  122532. event: ClipboardEvent);
  122533. /**
  122534. * Get the clipboard event's type from the keycode.
  122535. * @param keyCode Defines the keyCode for the current keyboard event.
  122536. * @return {number}
  122537. */
  122538. static GetTypeFromCharacter(keyCode: number): number;
  122539. }
  122540. }
  122541. declare module BABYLON {
  122542. /**
  122543. * Google Daydream controller
  122544. */
  122545. export class DaydreamController extends WebVRController {
  122546. /**
  122547. * Base Url for the controller model.
  122548. */
  122549. static MODEL_BASE_URL: string;
  122550. /**
  122551. * File name for the controller model.
  122552. */
  122553. static MODEL_FILENAME: string;
  122554. /**
  122555. * Gamepad Id prefix used to identify Daydream Controller.
  122556. */
  122557. static readonly GAMEPAD_ID_PREFIX: string;
  122558. /**
  122559. * Creates a new DaydreamController from a gamepad
  122560. * @param vrGamepad the gamepad that the controller should be created from
  122561. */
  122562. constructor(vrGamepad: any);
  122563. /**
  122564. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  122565. * @param scene scene in which to add meshes
  122566. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  122567. */
  122568. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  122569. /**
  122570. * Called once for each button that changed state since the last frame
  122571. * @param buttonIdx Which button index changed
  122572. * @param state New state of the button
  122573. * @param changes Which properties on the state changed since last frame
  122574. */
  122575. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  122576. }
  122577. }
  122578. declare module BABYLON {
  122579. /**
  122580. * Gear VR Controller
  122581. */
  122582. export class GearVRController extends WebVRController {
  122583. /**
  122584. * Base Url for the controller model.
  122585. */
  122586. static MODEL_BASE_URL: string;
  122587. /**
  122588. * File name for the controller model.
  122589. */
  122590. static MODEL_FILENAME: string;
  122591. /**
  122592. * Gamepad Id prefix used to identify this controller.
  122593. */
  122594. static readonly GAMEPAD_ID_PREFIX: string;
  122595. private readonly _buttonIndexToObservableNameMap;
  122596. /**
  122597. * Creates a new GearVRController from a gamepad
  122598. * @param vrGamepad the gamepad that the controller should be created from
  122599. */
  122600. constructor(vrGamepad: any);
  122601. /**
  122602. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  122603. * @param scene scene in which to add meshes
  122604. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  122605. */
  122606. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  122607. /**
  122608. * Called once for each button that changed state since the last frame
  122609. * @param buttonIdx Which button index changed
  122610. * @param state New state of the button
  122611. * @param changes Which properties on the state changed since last frame
  122612. */
  122613. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  122614. }
  122615. }
  122616. declare module BABYLON {
  122617. /**
  122618. * Generic Controller
  122619. */
  122620. export class GenericController extends WebVRController {
  122621. /**
  122622. * Base Url for the controller model.
  122623. */
  122624. static readonly MODEL_BASE_URL: string;
  122625. /**
  122626. * File name for the controller model.
  122627. */
  122628. static readonly MODEL_FILENAME: string;
  122629. /**
  122630. * Creates a new GenericController from a gamepad
  122631. * @param vrGamepad the gamepad that the controller should be created from
  122632. */
  122633. constructor(vrGamepad: any);
  122634. /**
  122635. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  122636. * @param scene scene in which to add meshes
  122637. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  122638. */
  122639. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  122640. /**
  122641. * Called once for each button that changed state since the last frame
  122642. * @param buttonIdx Which button index changed
  122643. * @param state New state of the button
  122644. * @param changes Which properties on the state changed since last frame
  122645. */
  122646. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  122647. }
  122648. }
  122649. declare module BABYLON {
  122650. /**
  122651. * Oculus Touch Controller
  122652. */
  122653. export class OculusTouchController extends WebVRController {
  122654. /**
  122655. * Base Url for the controller model.
  122656. */
  122657. static MODEL_BASE_URL: string;
  122658. /**
  122659. * File name for the left controller model.
  122660. */
  122661. static MODEL_LEFT_FILENAME: string;
  122662. /**
  122663. * File name for the right controller model.
  122664. */
  122665. static MODEL_RIGHT_FILENAME: string;
  122666. /**
  122667. * Base Url for the Quest controller model.
  122668. */
  122669. static QUEST_MODEL_BASE_URL: string;
  122670. /**
  122671. * @hidden
  122672. * If the controllers are running on a device that needs the updated Quest controller models
  122673. */
  122674. static _IsQuest: boolean;
  122675. /**
  122676. * Fired when the secondary trigger on this controller is modified
  122677. */
  122678. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  122679. /**
  122680. * Fired when the thumb rest on this controller is modified
  122681. */
  122682. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  122683. /**
  122684. * Creates a new OculusTouchController from a gamepad
  122685. * @param vrGamepad the gamepad that the controller should be created from
  122686. */
  122687. constructor(vrGamepad: any);
  122688. /**
  122689. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  122690. * @param scene scene in which to add meshes
  122691. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  122692. */
  122693. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  122694. /**
  122695. * Fired when the A button on this controller is modified
  122696. */
  122697. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  122698. /**
  122699. * Fired when the B button on this controller is modified
  122700. */
  122701. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  122702. /**
  122703. * Fired when the X button on this controller is modified
  122704. */
  122705. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  122706. /**
  122707. * Fired when the Y button on this controller is modified
  122708. */
  122709. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  122710. /**
  122711. * Called once for each button that changed state since the last frame
  122712. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  122713. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  122714. * 2) secondary trigger (same)
  122715. * 3) A (right) X (left), touch, pressed = value
  122716. * 4) B / Y
  122717. * 5) thumb rest
  122718. * @param buttonIdx Which button index changed
  122719. * @param state New state of the button
  122720. * @param changes Which properties on the state changed since last frame
  122721. */
  122722. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  122723. }
  122724. }
  122725. declare module BABYLON {
  122726. /**
  122727. * Vive Controller
  122728. */
  122729. export class ViveController extends WebVRController {
  122730. /**
  122731. * Base Url for the controller model.
  122732. */
  122733. static MODEL_BASE_URL: string;
  122734. /**
  122735. * File name for the controller model.
  122736. */
  122737. static MODEL_FILENAME: string;
  122738. /**
  122739. * Creates a new ViveController from a gamepad
  122740. * @param vrGamepad the gamepad that the controller should be created from
  122741. */
  122742. constructor(vrGamepad: any);
  122743. /**
  122744. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  122745. * @param scene scene in which to add meshes
  122746. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  122747. */
  122748. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  122749. /**
  122750. * Fired when the left button on this controller is modified
  122751. */
  122752. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  122753. /**
  122754. * Fired when the right button on this controller is modified
  122755. */
  122756. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  122757. /**
  122758. * Fired when the menu button on this controller is modified
  122759. */
  122760. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  122761. /**
  122762. * Called once for each button that changed state since the last frame
  122763. * Vive mapping:
  122764. * 0: touchpad
  122765. * 1: trigger
  122766. * 2: left AND right buttons
  122767. * 3: menu button
  122768. * @param buttonIdx Which button index changed
  122769. * @param state New state of the button
  122770. * @param changes Which properties on the state changed since last frame
  122771. */
  122772. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  122773. }
  122774. }
  122775. declare module BABYLON {
  122776. /**
  122777. * Defines the WindowsMotionController object that the state of the windows motion controller
  122778. */
  122779. export class WindowsMotionController extends WebVRController {
  122780. /**
  122781. * The base url used to load the left and right controller models
  122782. */
  122783. static MODEL_BASE_URL: string;
  122784. /**
  122785. * The name of the left controller model file
  122786. */
  122787. static MODEL_LEFT_FILENAME: string;
  122788. /**
  122789. * The name of the right controller model file
  122790. */
  122791. static MODEL_RIGHT_FILENAME: string;
  122792. /**
  122793. * The controller name prefix for this controller type
  122794. */
  122795. static readonly GAMEPAD_ID_PREFIX: string;
  122796. /**
  122797. * The controller id pattern for this controller type
  122798. */
  122799. private static readonly GAMEPAD_ID_PATTERN;
  122800. private _loadedMeshInfo;
  122801. protected readonly _mapping: {
  122802. buttons: string[];
  122803. buttonMeshNames: {
  122804. trigger: string;
  122805. menu: string;
  122806. grip: string;
  122807. thumbstick: string;
  122808. trackpad: string;
  122809. };
  122810. buttonObservableNames: {
  122811. trigger: string;
  122812. menu: string;
  122813. grip: string;
  122814. thumbstick: string;
  122815. trackpad: string;
  122816. };
  122817. axisMeshNames: string[];
  122818. pointingPoseMeshName: string;
  122819. };
  122820. /**
  122821. * Fired when the trackpad on this controller is clicked
  122822. */
  122823. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  122824. /**
  122825. * Fired when the trackpad on this controller is modified
  122826. */
  122827. onTrackpadValuesChangedObservable: Observable<StickValues>;
  122828. /**
  122829. * The current x and y values of this controller's trackpad
  122830. */
  122831. trackpad: StickValues;
  122832. /**
  122833. * Creates a new WindowsMotionController from a gamepad
  122834. * @param vrGamepad the gamepad that the controller should be created from
  122835. */
  122836. constructor(vrGamepad: any);
  122837. /**
  122838. * Fired when the trigger on this controller is modified
  122839. */
  122840. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  122841. /**
  122842. * Fired when the menu button on this controller is modified
  122843. */
  122844. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  122845. /**
  122846. * Fired when the grip button on this controller is modified
  122847. */
  122848. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  122849. /**
  122850. * Fired when the thumbstick button on this controller is modified
  122851. */
  122852. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  122853. /**
  122854. * Fired when the touchpad button on this controller is modified
  122855. */
  122856. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  122857. /**
  122858. * Fired when the touchpad values on this controller are modified
  122859. */
  122860. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  122861. protected _updateTrackpad(): void;
  122862. /**
  122863. * Called once per frame by the engine.
  122864. */
  122865. update(): void;
  122866. /**
  122867. * Called once for each button that changed state since the last frame
  122868. * @param buttonIdx Which button index changed
  122869. * @param state New state of the button
  122870. * @param changes Which properties on the state changed since last frame
  122871. */
  122872. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  122873. /**
  122874. * Moves the buttons on the controller mesh based on their current state
  122875. * @param buttonName the name of the button to move
  122876. * @param buttonValue the value of the button which determines the buttons new position
  122877. */
  122878. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  122879. /**
  122880. * Moves the axis on the controller mesh based on its current state
  122881. * @param axis the index of the axis
  122882. * @param axisValue the value of the axis which determines the meshes new position
  122883. * @hidden
  122884. */
  122885. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  122886. /**
  122887. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  122888. * @param scene scene in which to add meshes
  122889. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  122890. */
  122891. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  122892. /**
  122893. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  122894. * can be transformed by button presses and axes values, based on this._mapping.
  122895. *
  122896. * @param scene scene in which the meshes exist
  122897. * @param meshes list of meshes that make up the controller model to process
  122898. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  122899. */
  122900. private processModel;
  122901. private createMeshInfo;
  122902. /**
  122903. * Gets the ray of the controller in the direction the controller is pointing
  122904. * @param length the length the resulting ray should be
  122905. * @returns a ray in the direction the controller is pointing
  122906. */
  122907. getForwardRay(length?: number): Ray;
  122908. /**
  122909. * Disposes of the controller
  122910. */
  122911. dispose(): void;
  122912. }
  122913. /**
  122914. * This class represents a new windows motion controller in XR.
  122915. */
  122916. export class XRWindowsMotionController extends WindowsMotionController {
  122917. /**
  122918. * Changing the original WIndowsMotionController mapping to fir the new mapping
  122919. */
  122920. protected readonly _mapping: {
  122921. buttons: string[];
  122922. buttonMeshNames: {
  122923. trigger: string;
  122924. menu: string;
  122925. grip: string;
  122926. thumbstick: string;
  122927. trackpad: string;
  122928. };
  122929. buttonObservableNames: {
  122930. trigger: string;
  122931. menu: string;
  122932. grip: string;
  122933. thumbstick: string;
  122934. trackpad: string;
  122935. };
  122936. axisMeshNames: string[];
  122937. pointingPoseMeshName: string;
  122938. };
  122939. /**
  122940. * Construct a new XR-Based windows motion controller
  122941. *
  122942. * @param gamepadInfo the gamepad object from the browser
  122943. */
  122944. constructor(gamepadInfo: any);
  122945. /**
  122946. * holds the thumbstick values (X,Y)
  122947. */
  122948. thumbstickValues: StickValues;
  122949. /**
  122950. * Fired when the thumbstick on this controller is clicked
  122951. */
  122952. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  122953. /**
  122954. * Fired when the thumbstick on this controller is modified
  122955. */
  122956. onThumbstickValuesChangedObservable: Observable<StickValues>;
  122957. /**
  122958. * Fired when the touchpad button on this controller is modified
  122959. */
  122960. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  122961. /**
  122962. * Fired when the touchpad values on this controller are modified
  122963. */
  122964. onTrackpadValuesChangedObservable: Observable<StickValues>;
  122965. /**
  122966. * Fired when the thumbstick button on this controller is modified
  122967. * here to prevent breaking changes
  122968. */
  122969. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  122970. /**
  122971. * updating the thumbstick(!) and not the trackpad.
  122972. * This is named this way due to the difference between WebVR and XR and to avoid
  122973. * changing the parent class.
  122974. */
  122975. protected _updateTrackpad(): void;
  122976. /**
  122977. * Disposes the class with joy
  122978. */
  122979. dispose(): void;
  122980. }
  122981. }
  122982. declare module BABYLON {
  122983. /**
  122984. * Class containing static functions to help procedurally build meshes
  122985. */
  122986. export class PolyhedronBuilder {
  122987. /**
  122988. * Creates a polyhedron mesh
  122989. * * 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
  122990. * * The parameter `size` (positive float, default 1) sets the polygon size
  122991. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  122992. * * 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`
  122993. * * 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
  122994. * * 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)`)
  122995. * * 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
  122996. * * 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
  122997. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  122998. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  122999. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123000. * @param name defines the name of the mesh
  123001. * @param options defines the options used to create the mesh
  123002. * @param scene defines the hosting scene
  123003. * @returns the polyhedron mesh
  123004. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  123005. */
  123006. static CreatePolyhedron(name: string, options: {
  123007. type?: number;
  123008. size?: number;
  123009. sizeX?: number;
  123010. sizeY?: number;
  123011. sizeZ?: number;
  123012. custom?: any;
  123013. faceUV?: Vector4[];
  123014. faceColors?: Color4[];
  123015. flat?: boolean;
  123016. updatable?: boolean;
  123017. sideOrientation?: number;
  123018. frontUVs?: Vector4;
  123019. backUVs?: Vector4;
  123020. }, scene?: Nullable<Scene>): Mesh;
  123021. }
  123022. }
  123023. declare module BABYLON {
  123024. /**
  123025. * Gizmo that enables scaling a mesh along 3 axis
  123026. */
  123027. export class ScaleGizmo extends Gizmo {
  123028. /**
  123029. * Internal gizmo used for interactions on the x axis
  123030. */
  123031. xGizmo: AxisScaleGizmo;
  123032. /**
  123033. * Internal gizmo used for interactions on the y axis
  123034. */
  123035. yGizmo: AxisScaleGizmo;
  123036. /**
  123037. * Internal gizmo used for interactions on the z axis
  123038. */
  123039. zGizmo: AxisScaleGizmo;
  123040. /**
  123041. * Internal gizmo used to scale all axis equally
  123042. */
  123043. uniformScaleGizmo: AxisScaleGizmo;
  123044. private _meshAttached;
  123045. private _updateGizmoRotationToMatchAttachedMesh;
  123046. private _snapDistance;
  123047. private _scaleRatio;
  123048. private _uniformScalingMesh;
  123049. private _octahedron;
  123050. private _sensitivity;
  123051. /** Fires an event when any of it's sub gizmos are dragged */
  123052. onDragStartObservable: Observable<unknown>;
  123053. /** Fires an event when any of it's sub gizmos are released from dragging */
  123054. onDragEndObservable: Observable<unknown>;
  123055. get attachedMesh(): Nullable<AbstractMesh>;
  123056. set attachedMesh(mesh: Nullable<AbstractMesh>);
  123057. /**
  123058. * Creates a ScaleGizmo
  123059. * @param gizmoLayer The utility layer the gizmo will be added to
  123060. */
  123061. constructor(gizmoLayer?: UtilityLayerRenderer);
  123062. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  123063. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  123064. /**
  123065. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  123066. */
  123067. set snapDistance(value: number);
  123068. get snapDistance(): number;
  123069. /**
  123070. * Ratio for the scale of the gizmo (Default: 1)
  123071. */
  123072. set scaleRatio(value: number);
  123073. get scaleRatio(): number;
  123074. /**
  123075. * Sensitivity factor for dragging (Default: 1)
  123076. */
  123077. set sensitivity(value: number);
  123078. get sensitivity(): number;
  123079. /**
  123080. * Disposes of the gizmo
  123081. */
  123082. dispose(): void;
  123083. }
  123084. }
  123085. declare module BABYLON {
  123086. /**
  123087. * Single axis scale gizmo
  123088. */
  123089. export class AxisScaleGizmo extends Gizmo {
  123090. /**
  123091. * Drag behavior responsible for the gizmos dragging interactions
  123092. */
  123093. dragBehavior: PointerDragBehavior;
  123094. private _pointerObserver;
  123095. /**
  123096. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  123097. */
  123098. snapDistance: number;
  123099. /**
  123100. * Event that fires each time the gizmo snaps to a new location.
  123101. * * snapDistance is the the change in distance
  123102. */
  123103. onSnapObservable: Observable<{
  123104. snapDistance: number;
  123105. }>;
  123106. /**
  123107. * If the scaling operation should be done on all axis (default: false)
  123108. */
  123109. uniformScaling: boolean;
  123110. /**
  123111. * Custom sensitivity value for the drag strength
  123112. */
  123113. sensitivity: number;
  123114. private _isEnabled;
  123115. private _parent;
  123116. private _arrow;
  123117. private _coloredMaterial;
  123118. private _hoverMaterial;
  123119. /**
  123120. * Creates an AxisScaleGizmo
  123121. * @param gizmoLayer The utility layer the gizmo will be added to
  123122. * @param dragAxis The axis which the gizmo will be able to scale on
  123123. * @param color The color of the gizmo
  123124. */
  123125. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  123126. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  123127. /**
  123128. * If the gizmo is enabled
  123129. */
  123130. set isEnabled(value: boolean);
  123131. get isEnabled(): boolean;
  123132. /**
  123133. * Disposes of the gizmo
  123134. */
  123135. dispose(): void;
  123136. /**
  123137. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  123138. * @param mesh The mesh to replace the default mesh of the gizmo
  123139. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  123140. */
  123141. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  123142. }
  123143. }
  123144. declare module BABYLON {
  123145. /**
  123146. * Bounding box gizmo
  123147. */
  123148. export class BoundingBoxGizmo extends Gizmo {
  123149. private _lineBoundingBox;
  123150. private _rotateSpheresParent;
  123151. private _scaleBoxesParent;
  123152. private _boundingDimensions;
  123153. private _renderObserver;
  123154. private _pointerObserver;
  123155. private _scaleDragSpeed;
  123156. private _tmpQuaternion;
  123157. private _tmpVector;
  123158. private _tmpRotationMatrix;
  123159. /**
  123160. * 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)
  123161. */
  123162. ignoreChildren: boolean;
  123163. /**
  123164. * 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)
  123165. */
  123166. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  123167. /**
  123168. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  123169. */
  123170. rotationSphereSize: number;
  123171. /**
  123172. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  123173. */
  123174. scaleBoxSize: number;
  123175. /**
  123176. * 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)
  123177. */
  123178. fixedDragMeshScreenSize: boolean;
  123179. /**
  123180. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  123181. */
  123182. fixedDragMeshScreenSizeDistanceFactor: number;
  123183. /**
  123184. * Fired when a rotation sphere or scale box is dragged
  123185. */
  123186. onDragStartObservable: Observable<{}>;
  123187. /**
  123188. * Fired when a scale box is dragged
  123189. */
  123190. onScaleBoxDragObservable: Observable<{}>;
  123191. /**
  123192. * Fired when a scale box drag is ended
  123193. */
  123194. onScaleBoxDragEndObservable: Observable<{}>;
  123195. /**
  123196. * Fired when a rotation sphere is dragged
  123197. */
  123198. onRotationSphereDragObservable: Observable<{}>;
  123199. /**
  123200. * Fired when a rotation sphere drag is ended
  123201. */
  123202. onRotationSphereDragEndObservable: Observable<{}>;
  123203. /**
  123204. * 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)
  123205. */
  123206. scalePivot: Nullable<Vector3>;
  123207. /**
  123208. * Mesh used as a pivot to rotate the attached mesh
  123209. */
  123210. private _anchorMesh;
  123211. private _existingMeshScale;
  123212. private _dragMesh;
  123213. private pointerDragBehavior;
  123214. private coloredMaterial;
  123215. private hoverColoredMaterial;
  123216. /**
  123217. * Sets the color of the bounding box gizmo
  123218. * @param color the color to set
  123219. */
  123220. setColor(color: Color3): void;
  123221. /**
  123222. * Creates an BoundingBoxGizmo
  123223. * @param gizmoLayer The utility layer the gizmo will be added to
  123224. * @param color The color of the gizmo
  123225. */
  123226. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  123227. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  123228. private _selectNode;
  123229. /**
  123230. * Updates the bounding box information for the Gizmo
  123231. */
  123232. updateBoundingBox(): void;
  123233. private _updateRotationSpheres;
  123234. private _updateScaleBoxes;
  123235. /**
  123236. * Enables rotation on the specified axis and disables rotation on the others
  123237. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  123238. */
  123239. setEnabledRotationAxis(axis: string): void;
  123240. /**
  123241. * Enables/disables scaling
  123242. * @param enable if scaling should be enabled
  123243. * @param homogeneousScaling defines if scaling should only be homogeneous
  123244. */
  123245. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  123246. private _updateDummy;
  123247. /**
  123248. * Enables a pointer drag behavior on the bounding box of the gizmo
  123249. */
  123250. enableDragBehavior(): void;
  123251. /**
  123252. * Disposes of the gizmo
  123253. */
  123254. dispose(): void;
  123255. /**
  123256. * 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)
  123257. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  123258. * @returns the bounding box mesh with the passed in mesh as a child
  123259. */
  123260. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  123261. /**
  123262. * CustomMeshes are not supported by this gizmo
  123263. * @param mesh The mesh to replace the default mesh of the gizmo
  123264. */
  123265. setCustomMesh(mesh: Mesh): void;
  123266. }
  123267. }
  123268. declare module BABYLON {
  123269. /**
  123270. * Single plane rotation gizmo
  123271. */
  123272. export class PlaneRotationGizmo extends Gizmo {
  123273. /**
  123274. * Drag behavior responsible for the gizmos dragging interactions
  123275. */
  123276. dragBehavior: PointerDragBehavior;
  123277. private _pointerObserver;
  123278. /**
  123279. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  123280. */
  123281. snapDistance: number;
  123282. /**
  123283. * Event that fires each time the gizmo snaps to a new location.
  123284. * * snapDistance is the the change in distance
  123285. */
  123286. onSnapObservable: Observable<{
  123287. snapDistance: number;
  123288. }>;
  123289. private _isEnabled;
  123290. private _parent;
  123291. /**
  123292. * Creates a PlaneRotationGizmo
  123293. * @param gizmoLayer The utility layer the gizmo will be added to
  123294. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  123295. * @param color The color of the gizmo
  123296. * @param tessellation Amount of tessellation to be used when creating rotation circles
  123297. * @param useEulerRotation Use and update Euler angle instead of quaternion
  123298. */
  123299. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  123300. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  123301. /**
  123302. * If the gizmo is enabled
  123303. */
  123304. set isEnabled(value: boolean);
  123305. get isEnabled(): boolean;
  123306. /**
  123307. * Disposes of the gizmo
  123308. */
  123309. dispose(): void;
  123310. }
  123311. }
  123312. declare module BABYLON {
  123313. /**
  123314. * Gizmo that enables rotating a mesh along 3 axis
  123315. */
  123316. export class RotationGizmo extends Gizmo {
  123317. /**
  123318. * Internal gizmo used for interactions on the x axis
  123319. */
  123320. xGizmo: PlaneRotationGizmo;
  123321. /**
  123322. * Internal gizmo used for interactions on the y axis
  123323. */
  123324. yGizmo: PlaneRotationGizmo;
  123325. /**
  123326. * Internal gizmo used for interactions on the z axis
  123327. */
  123328. zGizmo: PlaneRotationGizmo;
  123329. /** Fires an event when any of it's sub gizmos are dragged */
  123330. onDragStartObservable: Observable<unknown>;
  123331. /** Fires an event when any of it's sub gizmos are released from dragging */
  123332. onDragEndObservable: Observable<unknown>;
  123333. private _meshAttached;
  123334. get attachedMesh(): Nullable<AbstractMesh>;
  123335. set attachedMesh(mesh: Nullable<AbstractMesh>);
  123336. /**
  123337. * Creates a RotationGizmo
  123338. * @param gizmoLayer The utility layer the gizmo will be added to
  123339. * @param tessellation Amount of tessellation to be used when creating rotation circles
  123340. * @param useEulerRotation Use and update Euler angle instead of quaternion
  123341. */
  123342. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  123343. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  123344. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  123345. /**
  123346. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  123347. */
  123348. set snapDistance(value: number);
  123349. get snapDistance(): number;
  123350. /**
  123351. * Ratio for the scale of the gizmo (Default: 1)
  123352. */
  123353. set scaleRatio(value: number);
  123354. get scaleRatio(): number;
  123355. /**
  123356. * Disposes of the gizmo
  123357. */
  123358. dispose(): void;
  123359. /**
  123360. * CustomMeshes are not supported by this gizmo
  123361. * @param mesh The mesh to replace the default mesh of the gizmo
  123362. */
  123363. setCustomMesh(mesh: Mesh): void;
  123364. }
  123365. }
  123366. declare module BABYLON {
  123367. /**
  123368. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  123369. */
  123370. export class GizmoManager implements IDisposable {
  123371. private scene;
  123372. /**
  123373. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  123374. */
  123375. gizmos: {
  123376. positionGizmo: Nullable<PositionGizmo>;
  123377. rotationGizmo: Nullable<RotationGizmo>;
  123378. scaleGizmo: Nullable<ScaleGizmo>;
  123379. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  123380. };
  123381. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  123382. clearGizmoOnEmptyPointerEvent: boolean;
  123383. /** Fires an event when the manager is attached to a mesh */
  123384. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  123385. private _gizmosEnabled;
  123386. private _pointerObserver;
  123387. private _attachedMesh;
  123388. private _boundingBoxColor;
  123389. private _defaultUtilityLayer;
  123390. private _defaultKeepDepthUtilityLayer;
  123391. /**
  123392. * When bounding box gizmo is enabled, this can be used to track drag/end events
  123393. */
  123394. boundingBoxDragBehavior: SixDofDragBehavior;
  123395. /**
  123396. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  123397. */
  123398. attachableMeshes: Nullable<Array<AbstractMesh>>;
  123399. /**
  123400. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  123401. */
  123402. usePointerToAttachGizmos: boolean;
  123403. /**
  123404. * Utility layer that the bounding box gizmo belongs to
  123405. */
  123406. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  123407. /**
  123408. * Utility layer that all gizmos besides bounding box belong to
  123409. */
  123410. get utilityLayer(): UtilityLayerRenderer;
  123411. /**
  123412. * Instatiates a gizmo manager
  123413. * @param scene the scene to overlay the gizmos on top of
  123414. */
  123415. constructor(scene: Scene);
  123416. /**
  123417. * Attaches a set of gizmos to the specified mesh
  123418. * @param mesh The mesh the gizmo's should be attached to
  123419. */
  123420. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  123421. /**
  123422. * If the position gizmo is enabled
  123423. */
  123424. set positionGizmoEnabled(value: boolean);
  123425. get positionGizmoEnabled(): boolean;
  123426. /**
  123427. * If the rotation gizmo is enabled
  123428. */
  123429. set rotationGizmoEnabled(value: boolean);
  123430. get rotationGizmoEnabled(): boolean;
  123431. /**
  123432. * If the scale gizmo is enabled
  123433. */
  123434. set scaleGizmoEnabled(value: boolean);
  123435. get scaleGizmoEnabled(): boolean;
  123436. /**
  123437. * If the boundingBox gizmo is enabled
  123438. */
  123439. set boundingBoxGizmoEnabled(value: boolean);
  123440. get boundingBoxGizmoEnabled(): boolean;
  123441. /**
  123442. * Disposes of the gizmo manager
  123443. */
  123444. dispose(): void;
  123445. }
  123446. }
  123447. declare module BABYLON {
  123448. /**
  123449. * A directional light is defined by a direction (what a surprise!).
  123450. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  123451. * 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.
  123452. * Documentation: https://doc.babylonjs.com/babylon101/lights
  123453. */
  123454. export class DirectionalLight extends ShadowLight {
  123455. private _shadowFrustumSize;
  123456. /**
  123457. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  123458. */
  123459. get shadowFrustumSize(): number;
  123460. /**
  123461. * Specifies a fix frustum size for the shadow generation.
  123462. */
  123463. set shadowFrustumSize(value: number);
  123464. private _shadowOrthoScale;
  123465. /**
  123466. * Gets the shadow projection scale against the optimal computed one.
  123467. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  123468. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  123469. */
  123470. get shadowOrthoScale(): number;
  123471. /**
  123472. * Sets the shadow projection scale against the optimal computed one.
  123473. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  123474. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  123475. */
  123476. set shadowOrthoScale(value: number);
  123477. /**
  123478. * Automatically compute the projection matrix to best fit (including all the casters)
  123479. * on each frame.
  123480. */
  123481. autoUpdateExtends: boolean;
  123482. /**
  123483. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  123484. * on each frame. autoUpdateExtends must be set to true for this to work
  123485. */
  123486. autoCalcShadowZBounds: boolean;
  123487. private _orthoLeft;
  123488. private _orthoRight;
  123489. private _orthoTop;
  123490. private _orthoBottom;
  123491. /**
  123492. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  123493. * The directional light is emitted from everywhere in the given direction.
  123494. * It can cast shadows.
  123495. * Documentation : https://doc.babylonjs.com/babylon101/lights
  123496. * @param name The friendly name of the light
  123497. * @param direction The direction of the light
  123498. * @param scene The scene the light belongs to
  123499. */
  123500. constructor(name: string, direction: Vector3, scene: Scene);
  123501. /**
  123502. * Returns the string "DirectionalLight".
  123503. * @return The class name
  123504. */
  123505. getClassName(): string;
  123506. /**
  123507. * Returns the integer 1.
  123508. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  123509. */
  123510. getTypeID(): number;
  123511. /**
  123512. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  123513. * Returns the DirectionalLight Shadow projection matrix.
  123514. */
  123515. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  123516. /**
  123517. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  123518. * Returns the DirectionalLight Shadow projection matrix.
  123519. */
  123520. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  123521. /**
  123522. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  123523. * Returns the DirectionalLight Shadow projection matrix.
  123524. */
  123525. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  123526. protected _buildUniformLayout(): void;
  123527. /**
  123528. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  123529. * @param effect The effect to update
  123530. * @param lightIndex The index of the light in the effect to update
  123531. * @returns The directional light
  123532. */
  123533. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  123534. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  123535. /**
  123536. * Gets the minZ used for shadow according to both the scene and the light.
  123537. *
  123538. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  123539. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  123540. * @param activeCamera The camera we are returning the min for
  123541. * @returns the depth min z
  123542. */
  123543. getDepthMinZ(activeCamera: Camera): number;
  123544. /**
  123545. * Gets the maxZ used for shadow according to both the scene and the light.
  123546. *
  123547. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  123548. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  123549. * @param activeCamera The camera we are returning the max for
  123550. * @returns the depth max z
  123551. */
  123552. getDepthMaxZ(activeCamera: Camera): number;
  123553. /**
  123554. * Prepares the list of defines specific to the light type.
  123555. * @param defines the list of defines
  123556. * @param lightIndex defines the index of the light for the effect
  123557. */
  123558. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  123559. }
  123560. }
  123561. declare module BABYLON {
  123562. /**
  123563. * Class containing static functions to help procedurally build meshes
  123564. */
  123565. export class HemisphereBuilder {
  123566. /**
  123567. * Creates a hemisphere mesh
  123568. * @param name defines the name of the mesh
  123569. * @param options defines the options used to create the mesh
  123570. * @param scene defines the hosting scene
  123571. * @returns the hemisphere mesh
  123572. */
  123573. static CreateHemisphere(name: string, options: {
  123574. segments?: number;
  123575. diameter?: number;
  123576. sideOrientation?: number;
  123577. }, scene: any): Mesh;
  123578. }
  123579. }
  123580. declare module BABYLON {
  123581. /**
  123582. * A spot light is defined by a position, a direction, an angle, and an exponent.
  123583. * These values define a cone of light starting from the position, emitting toward the direction.
  123584. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  123585. * and the exponent defines the speed of the decay of the light with distance (reach).
  123586. * Documentation: https://doc.babylonjs.com/babylon101/lights
  123587. */
  123588. export class SpotLight extends ShadowLight {
  123589. private _angle;
  123590. private _innerAngle;
  123591. private _cosHalfAngle;
  123592. private _lightAngleScale;
  123593. private _lightAngleOffset;
  123594. /**
  123595. * Gets the cone angle of the spot light in Radians.
  123596. */
  123597. get angle(): number;
  123598. /**
  123599. * Sets the cone angle of the spot light in Radians.
  123600. */
  123601. set angle(value: number);
  123602. /**
  123603. * Only used in gltf falloff mode, this defines the angle where
  123604. * the directional falloff will start before cutting at angle which could be seen
  123605. * as outer angle.
  123606. */
  123607. get innerAngle(): number;
  123608. /**
  123609. * Only used in gltf falloff mode, this defines the angle where
  123610. * the directional falloff will start before cutting at angle which could be seen
  123611. * as outer angle.
  123612. */
  123613. set innerAngle(value: number);
  123614. private _shadowAngleScale;
  123615. /**
  123616. * Allows scaling the angle of the light for shadow generation only.
  123617. */
  123618. get shadowAngleScale(): number;
  123619. /**
  123620. * Allows scaling the angle of the light for shadow generation only.
  123621. */
  123622. set shadowAngleScale(value: number);
  123623. /**
  123624. * The light decay speed with the distance from the emission spot.
  123625. */
  123626. exponent: number;
  123627. private _projectionTextureMatrix;
  123628. /**
  123629. * Allows reading the projecton texture
  123630. */
  123631. get projectionTextureMatrix(): Matrix;
  123632. protected _projectionTextureLightNear: number;
  123633. /**
  123634. * Gets the near clip of the Spotlight for texture projection.
  123635. */
  123636. get projectionTextureLightNear(): number;
  123637. /**
  123638. * Sets the near clip of the Spotlight for texture projection.
  123639. */
  123640. set projectionTextureLightNear(value: number);
  123641. protected _projectionTextureLightFar: number;
  123642. /**
  123643. * Gets the far clip of the Spotlight for texture projection.
  123644. */
  123645. get projectionTextureLightFar(): number;
  123646. /**
  123647. * Sets the far clip of the Spotlight for texture projection.
  123648. */
  123649. set projectionTextureLightFar(value: number);
  123650. protected _projectionTextureUpDirection: Vector3;
  123651. /**
  123652. * Gets the Up vector of the Spotlight for texture projection.
  123653. */
  123654. get projectionTextureUpDirection(): Vector3;
  123655. /**
  123656. * Sets the Up vector of the Spotlight for texture projection.
  123657. */
  123658. set projectionTextureUpDirection(value: Vector3);
  123659. private _projectionTexture;
  123660. /**
  123661. * Gets the projection texture of the light.
  123662. */
  123663. get projectionTexture(): Nullable<BaseTexture>;
  123664. /**
  123665. * Sets the projection texture of the light.
  123666. */
  123667. set projectionTexture(value: Nullable<BaseTexture>);
  123668. private _projectionTextureViewLightDirty;
  123669. private _projectionTextureProjectionLightDirty;
  123670. private _projectionTextureDirty;
  123671. private _projectionTextureViewTargetVector;
  123672. private _projectionTextureViewLightMatrix;
  123673. private _projectionTextureProjectionLightMatrix;
  123674. private _projectionTextureScalingMatrix;
  123675. /**
  123676. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  123677. * It can cast shadows.
  123678. * Documentation : https://doc.babylonjs.com/babylon101/lights
  123679. * @param name The light friendly name
  123680. * @param position The position of the spot light in the scene
  123681. * @param direction The direction of the light in the scene
  123682. * @param angle The cone angle of the light in Radians
  123683. * @param exponent The light decay speed with the distance from the emission spot
  123684. * @param scene The scene the lights belongs to
  123685. */
  123686. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  123687. /**
  123688. * Returns the string "SpotLight".
  123689. * @returns the class name
  123690. */
  123691. getClassName(): string;
  123692. /**
  123693. * Returns the integer 2.
  123694. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  123695. */
  123696. getTypeID(): number;
  123697. /**
  123698. * Overrides the direction setter to recompute the projection texture view light Matrix.
  123699. */
  123700. protected _setDirection(value: Vector3): void;
  123701. /**
  123702. * Overrides the position setter to recompute the projection texture view light Matrix.
  123703. */
  123704. protected _setPosition(value: Vector3): void;
  123705. /**
  123706. * 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.
  123707. * Returns the SpotLight.
  123708. */
  123709. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  123710. protected _computeProjectionTextureViewLightMatrix(): void;
  123711. protected _computeProjectionTextureProjectionLightMatrix(): void;
  123712. /**
  123713. * Main function for light texture projection matrix computing.
  123714. */
  123715. protected _computeProjectionTextureMatrix(): void;
  123716. protected _buildUniformLayout(): void;
  123717. private _computeAngleValues;
  123718. /**
  123719. * Sets the passed Effect "effect" with the Light textures.
  123720. * @param effect The effect to update
  123721. * @param lightIndex The index of the light in the effect to update
  123722. * @returns The light
  123723. */
  123724. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  123725. /**
  123726. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  123727. * @param effect The effect to update
  123728. * @param lightIndex The index of the light in the effect to update
  123729. * @returns The spot light
  123730. */
  123731. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  123732. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  123733. /**
  123734. * Disposes the light and the associated resources.
  123735. */
  123736. dispose(): void;
  123737. /**
  123738. * Prepares the list of defines specific to the light type.
  123739. * @param defines the list of defines
  123740. * @param lightIndex defines the index of the light for the effect
  123741. */
  123742. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  123743. }
  123744. }
  123745. declare module BABYLON {
  123746. /**
  123747. * Gizmo that enables viewing a light
  123748. */
  123749. export class LightGizmo extends Gizmo {
  123750. private _lightMesh;
  123751. private _material;
  123752. private _cachedPosition;
  123753. private _cachedForward;
  123754. private _attachedMeshParent;
  123755. /**
  123756. * Creates a LightGizmo
  123757. * @param gizmoLayer The utility layer the gizmo will be added to
  123758. */
  123759. constructor(gizmoLayer?: UtilityLayerRenderer);
  123760. private _light;
  123761. /**
  123762. * The light that the gizmo is attached to
  123763. */
  123764. set light(light: Nullable<Light>);
  123765. get light(): Nullable<Light>;
  123766. /**
  123767. * Gets the material used to render the light gizmo
  123768. */
  123769. get material(): StandardMaterial;
  123770. /**
  123771. * @hidden
  123772. * Updates the gizmo to match the attached mesh's position/rotation
  123773. */
  123774. protected _update(): void;
  123775. private static _Scale;
  123776. /**
  123777. * Creates the lines for a light mesh
  123778. */
  123779. private static _CreateLightLines;
  123780. /**
  123781. * Disposes of the light gizmo
  123782. */
  123783. dispose(): void;
  123784. private static _CreateHemisphericLightMesh;
  123785. private static _CreatePointLightMesh;
  123786. private static _CreateSpotLightMesh;
  123787. private static _CreateDirectionalLightMesh;
  123788. }
  123789. }
  123790. declare module BABYLON {
  123791. /** @hidden */
  123792. export var backgroundFragmentDeclaration: {
  123793. name: string;
  123794. shader: string;
  123795. };
  123796. }
  123797. declare module BABYLON {
  123798. /** @hidden */
  123799. export var backgroundUboDeclaration: {
  123800. name: string;
  123801. shader: string;
  123802. };
  123803. }
  123804. declare module BABYLON {
  123805. /** @hidden */
  123806. export var backgroundPixelShader: {
  123807. name: string;
  123808. shader: string;
  123809. };
  123810. }
  123811. declare module BABYLON {
  123812. /** @hidden */
  123813. export var backgroundVertexDeclaration: {
  123814. name: string;
  123815. shader: string;
  123816. };
  123817. }
  123818. declare module BABYLON {
  123819. /** @hidden */
  123820. export var backgroundVertexShader: {
  123821. name: string;
  123822. shader: string;
  123823. };
  123824. }
  123825. declare module BABYLON {
  123826. /**
  123827. * Background material used to create an efficient environement around your scene.
  123828. */
  123829. export class BackgroundMaterial extends PushMaterial {
  123830. /**
  123831. * Standard reflectance value at parallel view angle.
  123832. */
  123833. static StandardReflectance0: number;
  123834. /**
  123835. * Standard reflectance value at grazing angle.
  123836. */
  123837. static StandardReflectance90: number;
  123838. protected _primaryColor: Color3;
  123839. /**
  123840. * Key light Color (multiply against the environement texture)
  123841. */
  123842. primaryColor: Color3;
  123843. protected __perceptualColor: Nullable<Color3>;
  123844. /**
  123845. * Experimental Internal Use Only.
  123846. *
  123847. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  123848. * This acts as a helper to set the primary color to a more "human friendly" value.
  123849. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  123850. * output color as close as possible from the chosen value.
  123851. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  123852. * part of lighting setup.)
  123853. */
  123854. get _perceptualColor(): Nullable<Color3>;
  123855. set _perceptualColor(value: Nullable<Color3>);
  123856. protected _primaryColorShadowLevel: float;
  123857. /**
  123858. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  123859. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  123860. */
  123861. get primaryColorShadowLevel(): float;
  123862. set primaryColorShadowLevel(value: float);
  123863. protected _primaryColorHighlightLevel: float;
  123864. /**
  123865. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  123866. * The primary color is used at the level chosen to define what the white area would look.
  123867. */
  123868. get primaryColorHighlightLevel(): float;
  123869. set primaryColorHighlightLevel(value: float);
  123870. protected _reflectionTexture: Nullable<BaseTexture>;
  123871. /**
  123872. * Reflection Texture used in the material.
  123873. * Should be author in a specific way for the best result (refer to the documentation).
  123874. */
  123875. reflectionTexture: Nullable<BaseTexture>;
  123876. protected _reflectionBlur: float;
  123877. /**
  123878. * Reflection Texture level of blur.
  123879. *
  123880. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  123881. * texture twice.
  123882. */
  123883. reflectionBlur: float;
  123884. protected _diffuseTexture: Nullable<BaseTexture>;
  123885. /**
  123886. * Diffuse Texture used in the material.
  123887. * Should be author in a specific way for the best result (refer to the documentation).
  123888. */
  123889. diffuseTexture: Nullable<BaseTexture>;
  123890. protected _shadowLights: Nullable<IShadowLight[]>;
  123891. /**
  123892. * Specify the list of lights casting shadow on the material.
  123893. * All scene shadow lights will be included if null.
  123894. */
  123895. shadowLights: Nullable<IShadowLight[]>;
  123896. protected _shadowLevel: float;
  123897. /**
  123898. * Helps adjusting the shadow to a softer level if required.
  123899. * 0 means black shadows and 1 means no shadows.
  123900. */
  123901. shadowLevel: float;
  123902. protected _sceneCenter: Vector3;
  123903. /**
  123904. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  123905. * It is usually zero but might be interesting to modify according to your setup.
  123906. */
  123907. sceneCenter: Vector3;
  123908. protected _opacityFresnel: boolean;
  123909. /**
  123910. * This helps specifying that the material is falling off to the sky box at grazing angle.
  123911. * This helps ensuring a nice transition when the camera goes under the ground.
  123912. */
  123913. opacityFresnel: boolean;
  123914. protected _reflectionFresnel: boolean;
  123915. /**
  123916. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  123917. * This helps adding a mirror texture on the ground.
  123918. */
  123919. reflectionFresnel: boolean;
  123920. protected _reflectionFalloffDistance: number;
  123921. /**
  123922. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  123923. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  123924. */
  123925. reflectionFalloffDistance: number;
  123926. protected _reflectionAmount: number;
  123927. /**
  123928. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  123929. */
  123930. reflectionAmount: number;
  123931. protected _reflectionReflectance0: number;
  123932. /**
  123933. * This specifies the weight of the reflection at grazing angle.
  123934. */
  123935. reflectionReflectance0: number;
  123936. protected _reflectionReflectance90: number;
  123937. /**
  123938. * This specifies the weight of the reflection at a perpendicular point of view.
  123939. */
  123940. reflectionReflectance90: number;
  123941. /**
  123942. * Sets the reflection reflectance fresnel values according to the default standard
  123943. * empirically know to work well :-)
  123944. */
  123945. set reflectionStandardFresnelWeight(value: number);
  123946. protected _useRGBColor: boolean;
  123947. /**
  123948. * Helps to directly use the maps channels instead of their level.
  123949. */
  123950. useRGBColor: boolean;
  123951. protected _enableNoise: boolean;
  123952. /**
  123953. * This helps reducing the banding effect that could occur on the background.
  123954. */
  123955. enableNoise: boolean;
  123956. /**
  123957. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  123958. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  123959. * Recommended to be keep at 1.0 except for special cases.
  123960. */
  123961. get fovMultiplier(): number;
  123962. set fovMultiplier(value: number);
  123963. private _fovMultiplier;
  123964. /**
  123965. * Enable the FOV adjustment feature controlled by fovMultiplier.
  123966. */
  123967. useEquirectangularFOV: boolean;
  123968. private _maxSimultaneousLights;
  123969. /**
  123970. * Number of Simultaneous lights allowed on the material.
  123971. */
  123972. maxSimultaneousLights: int;
  123973. /**
  123974. * Default configuration related to image processing available in the Background Material.
  123975. */
  123976. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  123977. /**
  123978. * Keep track of the image processing observer to allow dispose and replace.
  123979. */
  123980. private _imageProcessingObserver;
  123981. /**
  123982. * Attaches a new image processing configuration to the PBR Material.
  123983. * @param configuration (if null the scene configuration will be use)
  123984. */
  123985. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  123986. /**
  123987. * Gets the image processing configuration used either in this material.
  123988. */
  123989. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  123990. /**
  123991. * Sets the Default image processing configuration used either in the this material.
  123992. *
  123993. * If sets to null, the scene one is in use.
  123994. */
  123995. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  123996. /**
  123997. * Gets wether the color curves effect is enabled.
  123998. */
  123999. get cameraColorCurvesEnabled(): boolean;
  124000. /**
  124001. * Sets wether the color curves effect is enabled.
  124002. */
  124003. set cameraColorCurvesEnabled(value: boolean);
  124004. /**
  124005. * Gets wether the color grading effect is enabled.
  124006. */
  124007. get cameraColorGradingEnabled(): boolean;
  124008. /**
  124009. * Gets wether the color grading effect is enabled.
  124010. */
  124011. set cameraColorGradingEnabled(value: boolean);
  124012. /**
  124013. * Gets wether tonemapping is enabled or not.
  124014. */
  124015. get cameraToneMappingEnabled(): boolean;
  124016. /**
  124017. * Sets wether tonemapping is enabled or not
  124018. */
  124019. set cameraToneMappingEnabled(value: boolean);
  124020. /**
  124021. * The camera exposure used on this material.
  124022. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  124023. * This corresponds to a photographic exposure.
  124024. */
  124025. get cameraExposure(): float;
  124026. /**
  124027. * The camera exposure used on this material.
  124028. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  124029. * This corresponds to a photographic exposure.
  124030. */
  124031. set cameraExposure(value: float);
  124032. /**
  124033. * Gets The camera contrast used on this material.
  124034. */
  124035. get cameraContrast(): float;
  124036. /**
  124037. * Sets The camera contrast used on this material.
  124038. */
  124039. set cameraContrast(value: float);
  124040. /**
  124041. * Gets the Color Grading 2D Lookup Texture.
  124042. */
  124043. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  124044. /**
  124045. * Sets the Color Grading 2D Lookup Texture.
  124046. */
  124047. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  124048. /**
  124049. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  124050. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  124051. * 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;
  124052. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  124053. */
  124054. get cameraColorCurves(): Nullable<ColorCurves>;
  124055. /**
  124056. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  124057. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  124058. * 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;
  124059. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  124060. */
  124061. set cameraColorCurves(value: Nullable<ColorCurves>);
  124062. /**
  124063. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  124064. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  124065. */
  124066. switchToBGR: boolean;
  124067. private _renderTargets;
  124068. private _reflectionControls;
  124069. private _white;
  124070. private _primaryShadowColor;
  124071. private _primaryHighlightColor;
  124072. /**
  124073. * Instantiates a Background Material in the given scene
  124074. * @param name The friendly name of the material
  124075. * @param scene The scene to add the material to
  124076. */
  124077. constructor(name: string, scene: Scene);
  124078. /**
  124079. * Gets a boolean indicating that current material needs to register RTT
  124080. */
  124081. get hasRenderTargetTextures(): boolean;
  124082. /**
  124083. * The entire material has been created in order to prevent overdraw.
  124084. * @returns false
  124085. */
  124086. needAlphaTesting(): boolean;
  124087. /**
  124088. * The entire material has been created in order to prevent overdraw.
  124089. * @returns true if blending is enable
  124090. */
  124091. needAlphaBlending(): boolean;
  124092. /**
  124093. * Checks wether the material is ready to be rendered for a given mesh.
  124094. * @param mesh The mesh to render
  124095. * @param subMesh The submesh to check against
  124096. * @param useInstances Specify wether or not the material is used with instances
  124097. * @returns true if all the dependencies are ready (Textures, Effects...)
  124098. */
  124099. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  124100. /**
  124101. * Compute the primary color according to the chosen perceptual color.
  124102. */
  124103. private _computePrimaryColorFromPerceptualColor;
  124104. /**
  124105. * Compute the highlights and shadow colors according to their chosen levels.
  124106. */
  124107. private _computePrimaryColors;
  124108. /**
  124109. * Build the uniform buffer used in the material.
  124110. */
  124111. buildUniformLayout(): void;
  124112. /**
  124113. * Unbind the material.
  124114. */
  124115. unbind(): void;
  124116. /**
  124117. * Bind only the world matrix to the material.
  124118. * @param world The world matrix to bind.
  124119. */
  124120. bindOnlyWorldMatrix(world: Matrix): void;
  124121. /**
  124122. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  124123. * @param world The world matrix to bind.
  124124. * @param subMesh The submesh to bind for.
  124125. */
  124126. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  124127. /**
  124128. * Checks to see if a texture is used in the material.
  124129. * @param texture - Base texture to use.
  124130. * @returns - Boolean specifying if a texture is used in the material.
  124131. */
  124132. hasTexture(texture: BaseTexture): boolean;
  124133. /**
  124134. * Dispose the material.
  124135. * @param forceDisposeEffect Force disposal of the associated effect.
  124136. * @param forceDisposeTextures Force disposal of the associated textures.
  124137. */
  124138. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  124139. /**
  124140. * Clones the material.
  124141. * @param name The cloned name.
  124142. * @returns The cloned material.
  124143. */
  124144. clone(name: string): BackgroundMaterial;
  124145. /**
  124146. * Serializes the current material to its JSON representation.
  124147. * @returns The JSON representation.
  124148. */
  124149. serialize(): any;
  124150. /**
  124151. * Gets the class name of the material
  124152. * @returns "BackgroundMaterial"
  124153. */
  124154. getClassName(): string;
  124155. /**
  124156. * Parse a JSON input to create back a background material.
  124157. * @param source The JSON data to parse
  124158. * @param scene The scene to create the parsed material in
  124159. * @param rootUrl The root url of the assets the material depends upon
  124160. * @returns the instantiated BackgroundMaterial.
  124161. */
  124162. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  124163. }
  124164. }
  124165. declare module BABYLON {
  124166. /**
  124167. * Represents the different options available during the creation of
  124168. * a Environment helper.
  124169. *
  124170. * This can control the default ground, skybox and image processing setup of your scene.
  124171. */
  124172. export interface IEnvironmentHelperOptions {
  124173. /**
  124174. * Specifies whether or not to create a ground.
  124175. * True by default.
  124176. */
  124177. createGround: boolean;
  124178. /**
  124179. * Specifies the ground size.
  124180. * 15 by default.
  124181. */
  124182. groundSize: number;
  124183. /**
  124184. * The texture used on the ground for the main color.
  124185. * Comes from the BabylonJS CDN by default.
  124186. *
  124187. * Remarks: Can be either a texture or a url.
  124188. */
  124189. groundTexture: string | BaseTexture;
  124190. /**
  124191. * The color mixed in the ground texture by default.
  124192. * BabylonJS clearColor by default.
  124193. */
  124194. groundColor: Color3;
  124195. /**
  124196. * Specifies the ground opacity.
  124197. * 1 by default.
  124198. */
  124199. groundOpacity: number;
  124200. /**
  124201. * Enables the ground to receive shadows.
  124202. * True by default.
  124203. */
  124204. enableGroundShadow: boolean;
  124205. /**
  124206. * Helps preventing the shadow to be fully black on the ground.
  124207. * 0.5 by default.
  124208. */
  124209. groundShadowLevel: number;
  124210. /**
  124211. * Creates a mirror texture attach to the ground.
  124212. * false by default.
  124213. */
  124214. enableGroundMirror: boolean;
  124215. /**
  124216. * Specifies the ground mirror size ratio.
  124217. * 0.3 by default as the default kernel is 64.
  124218. */
  124219. groundMirrorSizeRatio: number;
  124220. /**
  124221. * Specifies the ground mirror blur kernel size.
  124222. * 64 by default.
  124223. */
  124224. groundMirrorBlurKernel: number;
  124225. /**
  124226. * Specifies the ground mirror visibility amount.
  124227. * 1 by default
  124228. */
  124229. groundMirrorAmount: number;
  124230. /**
  124231. * Specifies the ground mirror reflectance weight.
  124232. * This uses the standard weight of the background material to setup the fresnel effect
  124233. * of the mirror.
  124234. * 1 by default.
  124235. */
  124236. groundMirrorFresnelWeight: number;
  124237. /**
  124238. * Specifies the ground mirror Falloff distance.
  124239. * This can helps reducing the size of the reflection.
  124240. * 0 by Default.
  124241. */
  124242. groundMirrorFallOffDistance: number;
  124243. /**
  124244. * Specifies the ground mirror texture type.
  124245. * Unsigned Int by Default.
  124246. */
  124247. groundMirrorTextureType: number;
  124248. /**
  124249. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  124250. * the shown objects.
  124251. */
  124252. groundYBias: number;
  124253. /**
  124254. * Specifies whether or not to create a skybox.
  124255. * True by default.
  124256. */
  124257. createSkybox: boolean;
  124258. /**
  124259. * Specifies the skybox size.
  124260. * 20 by default.
  124261. */
  124262. skyboxSize: number;
  124263. /**
  124264. * The texture used on the skybox for the main color.
  124265. * Comes from the BabylonJS CDN by default.
  124266. *
  124267. * Remarks: Can be either a texture or a url.
  124268. */
  124269. skyboxTexture: string | BaseTexture;
  124270. /**
  124271. * The color mixed in the skybox texture by default.
  124272. * BabylonJS clearColor by default.
  124273. */
  124274. skyboxColor: Color3;
  124275. /**
  124276. * The background rotation around the Y axis of the scene.
  124277. * This helps aligning the key lights of your scene with the background.
  124278. * 0 by default.
  124279. */
  124280. backgroundYRotation: number;
  124281. /**
  124282. * Compute automatically the size of the elements to best fit with the scene.
  124283. */
  124284. sizeAuto: boolean;
  124285. /**
  124286. * Default position of the rootMesh if autoSize is not true.
  124287. */
  124288. rootPosition: Vector3;
  124289. /**
  124290. * Sets up the image processing in the scene.
  124291. * true by default.
  124292. */
  124293. setupImageProcessing: boolean;
  124294. /**
  124295. * The texture used as your environment texture in the scene.
  124296. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  124297. *
  124298. * Remarks: Can be either a texture or a url.
  124299. */
  124300. environmentTexture: string | BaseTexture;
  124301. /**
  124302. * The value of the exposure to apply to the scene.
  124303. * 0.6 by default if setupImageProcessing is true.
  124304. */
  124305. cameraExposure: number;
  124306. /**
  124307. * The value of the contrast to apply to the scene.
  124308. * 1.6 by default if setupImageProcessing is true.
  124309. */
  124310. cameraContrast: number;
  124311. /**
  124312. * Specifies whether or not tonemapping should be enabled in the scene.
  124313. * true by default if setupImageProcessing is true.
  124314. */
  124315. toneMappingEnabled: boolean;
  124316. }
  124317. /**
  124318. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  124319. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  124320. * It also helps with the default setup of your imageProcessing configuration.
  124321. */
  124322. export class EnvironmentHelper {
  124323. /**
  124324. * Default ground texture URL.
  124325. */
  124326. private static _groundTextureCDNUrl;
  124327. /**
  124328. * Default skybox texture URL.
  124329. */
  124330. private static _skyboxTextureCDNUrl;
  124331. /**
  124332. * Default environment texture URL.
  124333. */
  124334. private static _environmentTextureCDNUrl;
  124335. /**
  124336. * Creates the default options for the helper.
  124337. */
  124338. private static _getDefaultOptions;
  124339. private _rootMesh;
  124340. /**
  124341. * Gets the root mesh created by the helper.
  124342. */
  124343. get rootMesh(): Mesh;
  124344. private _skybox;
  124345. /**
  124346. * Gets the skybox created by the helper.
  124347. */
  124348. get skybox(): Nullable<Mesh>;
  124349. private _skyboxTexture;
  124350. /**
  124351. * Gets the skybox texture created by the helper.
  124352. */
  124353. get skyboxTexture(): Nullable<BaseTexture>;
  124354. private _skyboxMaterial;
  124355. /**
  124356. * Gets the skybox material created by the helper.
  124357. */
  124358. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  124359. private _ground;
  124360. /**
  124361. * Gets the ground mesh created by the helper.
  124362. */
  124363. get ground(): Nullable<Mesh>;
  124364. private _groundTexture;
  124365. /**
  124366. * Gets the ground texture created by the helper.
  124367. */
  124368. get groundTexture(): Nullable<BaseTexture>;
  124369. private _groundMirror;
  124370. /**
  124371. * Gets the ground mirror created by the helper.
  124372. */
  124373. get groundMirror(): Nullable<MirrorTexture>;
  124374. /**
  124375. * Gets the ground mirror render list to helps pushing the meshes
  124376. * you wish in the ground reflection.
  124377. */
  124378. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  124379. private _groundMaterial;
  124380. /**
  124381. * Gets the ground material created by the helper.
  124382. */
  124383. get groundMaterial(): Nullable<BackgroundMaterial>;
  124384. /**
  124385. * Stores the creation options.
  124386. */
  124387. private readonly _scene;
  124388. private _options;
  124389. /**
  124390. * This observable will be notified with any error during the creation of the environment,
  124391. * mainly texture creation errors.
  124392. */
  124393. onErrorObservable: Observable<{
  124394. message?: string;
  124395. exception?: any;
  124396. }>;
  124397. /**
  124398. * constructor
  124399. * @param options Defines the options we want to customize the helper
  124400. * @param scene The scene to add the material to
  124401. */
  124402. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  124403. /**
  124404. * Updates the background according to the new options
  124405. * @param options
  124406. */
  124407. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  124408. /**
  124409. * Sets the primary color of all the available elements.
  124410. * @param color the main color to affect to the ground and the background
  124411. */
  124412. setMainColor(color: Color3): void;
  124413. /**
  124414. * Setup the image processing according to the specified options.
  124415. */
  124416. private _setupImageProcessing;
  124417. /**
  124418. * Setup the environment texture according to the specified options.
  124419. */
  124420. private _setupEnvironmentTexture;
  124421. /**
  124422. * Setup the background according to the specified options.
  124423. */
  124424. private _setupBackground;
  124425. /**
  124426. * Get the scene sizes according to the setup.
  124427. */
  124428. private _getSceneSize;
  124429. /**
  124430. * Setup the ground according to the specified options.
  124431. */
  124432. private _setupGround;
  124433. /**
  124434. * Setup the ground material according to the specified options.
  124435. */
  124436. private _setupGroundMaterial;
  124437. /**
  124438. * Setup the ground diffuse texture according to the specified options.
  124439. */
  124440. private _setupGroundDiffuseTexture;
  124441. /**
  124442. * Setup the ground mirror texture according to the specified options.
  124443. */
  124444. private _setupGroundMirrorTexture;
  124445. /**
  124446. * Setup the ground to receive the mirror texture.
  124447. */
  124448. private _setupMirrorInGroundMaterial;
  124449. /**
  124450. * Setup the skybox according to the specified options.
  124451. */
  124452. private _setupSkybox;
  124453. /**
  124454. * Setup the skybox material according to the specified options.
  124455. */
  124456. private _setupSkyboxMaterial;
  124457. /**
  124458. * Setup the skybox reflection texture according to the specified options.
  124459. */
  124460. private _setupSkyboxReflectionTexture;
  124461. private _errorHandler;
  124462. /**
  124463. * Dispose all the elements created by the Helper.
  124464. */
  124465. dispose(): void;
  124466. }
  124467. }
  124468. declare module BABYLON {
  124469. /**
  124470. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  124471. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  124472. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  124473. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  124474. */
  124475. export class PhotoDome extends TransformNode {
  124476. /**
  124477. * Define the image as a Monoscopic panoramic 360 image.
  124478. */
  124479. static readonly MODE_MONOSCOPIC: number;
  124480. /**
  124481. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  124482. */
  124483. static readonly MODE_TOPBOTTOM: number;
  124484. /**
  124485. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  124486. */
  124487. static readonly MODE_SIDEBYSIDE: number;
  124488. private _useDirectMapping;
  124489. /**
  124490. * The texture being displayed on the sphere
  124491. */
  124492. protected _photoTexture: Texture;
  124493. /**
  124494. * Gets or sets the texture being displayed on the sphere
  124495. */
  124496. get photoTexture(): Texture;
  124497. set photoTexture(value: Texture);
  124498. /**
  124499. * Observable raised when an error occured while loading the 360 image
  124500. */
  124501. onLoadErrorObservable: Observable<string>;
  124502. /**
  124503. * The skybox material
  124504. */
  124505. protected _material: BackgroundMaterial;
  124506. /**
  124507. * The surface used for the skybox
  124508. */
  124509. protected _mesh: Mesh;
  124510. /**
  124511. * Gets the mesh used for the skybox.
  124512. */
  124513. get mesh(): Mesh;
  124514. /**
  124515. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  124516. * Also see the options.resolution property.
  124517. */
  124518. get fovMultiplier(): number;
  124519. set fovMultiplier(value: number);
  124520. private _imageMode;
  124521. /**
  124522. * Gets or set the current video mode for the video. It can be:
  124523. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  124524. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  124525. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  124526. */
  124527. get imageMode(): number;
  124528. set imageMode(value: number);
  124529. /**
  124530. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  124531. * @param name Element's name, child elements will append suffixes for their own names.
  124532. * @param urlsOfPhoto defines the url of the photo to display
  124533. * @param options defines an object containing optional or exposed sub element properties
  124534. * @param onError defines a callback called when an error occured while loading the texture
  124535. */
  124536. constructor(name: string, urlOfPhoto: string, options: {
  124537. resolution?: number;
  124538. size?: number;
  124539. useDirectMapping?: boolean;
  124540. faceForward?: boolean;
  124541. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  124542. private _onBeforeCameraRenderObserver;
  124543. private _changeImageMode;
  124544. /**
  124545. * Releases resources associated with this node.
  124546. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  124547. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  124548. */
  124549. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  124550. }
  124551. }
  124552. declare module BABYLON {
  124553. /**
  124554. * Class used to host RGBD texture specific utilities
  124555. */
  124556. export class RGBDTextureTools {
  124557. /**
  124558. * Expand the RGBD Texture from RGBD to Half Float if possible.
  124559. * @param texture the texture to expand.
  124560. */
  124561. static ExpandRGBDTexture(texture: Texture): void;
  124562. }
  124563. }
  124564. declare module BABYLON {
  124565. /**
  124566. * Class used to host texture specific utilities
  124567. */
  124568. export class BRDFTextureTools {
  124569. /**
  124570. * Prevents texture cache collision
  124571. */
  124572. private static _instanceNumber;
  124573. /**
  124574. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  124575. * @param scene defines the hosting scene
  124576. * @returns the environment BRDF texture
  124577. */
  124578. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  124579. private static _environmentBRDFBase64Texture;
  124580. }
  124581. }
  124582. declare module BABYLON {
  124583. /**
  124584. * @hidden
  124585. */
  124586. export interface IMaterialClearCoatDefines {
  124587. CLEARCOAT: boolean;
  124588. CLEARCOAT_DEFAULTIOR: boolean;
  124589. CLEARCOAT_TEXTURE: boolean;
  124590. CLEARCOAT_TEXTUREDIRECTUV: number;
  124591. CLEARCOAT_BUMP: boolean;
  124592. CLEARCOAT_BUMPDIRECTUV: number;
  124593. CLEARCOAT_TINT: boolean;
  124594. CLEARCOAT_TINT_TEXTURE: boolean;
  124595. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  124596. /** @hidden */
  124597. _areTexturesDirty: boolean;
  124598. }
  124599. /**
  124600. * Define the code related to the clear coat parameters of the pbr material.
  124601. */
  124602. export class PBRClearCoatConfiguration {
  124603. /**
  124604. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  124605. * The default fits with a polyurethane material.
  124606. */
  124607. private static readonly _DefaultIndexOfRefraction;
  124608. private _isEnabled;
  124609. /**
  124610. * Defines if the clear coat is enabled in the material.
  124611. */
  124612. isEnabled: boolean;
  124613. /**
  124614. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  124615. */
  124616. intensity: number;
  124617. /**
  124618. * Defines the clear coat layer roughness.
  124619. */
  124620. roughness: number;
  124621. private _indexOfRefraction;
  124622. /**
  124623. * Defines the index of refraction of the clear coat.
  124624. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  124625. * The default fits with a polyurethane material.
  124626. * Changing the default value is more performance intensive.
  124627. */
  124628. indexOfRefraction: number;
  124629. private _texture;
  124630. /**
  124631. * Stores the clear coat values in a texture.
  124632. */
  124633. texture: Nullable<BaseTexture>;
  124634. private _bumpTexture;
  124635. /**
  124636. * Define the clear coat specific bump texture.
  124637. */
  124638. bumpTexture: Nullable<BaseTexture>;
  124639. private _isTintEnabled;
  124640. /**
  124641. * Defines if the clear coat tint is enabled in the material.
  124642. */
  124643. isTintEnabled: boolean;
  124644. /**
  124645. * Defines the clear coat tint of the material.
  124646. * This is only use if tint is enabled
  124647. */
  124648. tintColor: Color3;
  124649. /**
  124650. * Defines the distance at which the tint color should be found in the
  124651. * clear coat media.
  124652. * This is only use if tint is enabled
  124653. */
  124654. tintColorAtDistance: number;
  124655. /**
  124656. * Defines the clear coat layer thickness.
  124657. * This is only use if tint is enabled
  124658. */
  124659. tintThickness: number;
  124660. private _tintTexture;
  124661. /**
  124662. * Stores the clear tint values in a texture.
  124663. * rgb is tint
  124664. * a is a thickness factor
  124665. */
  124666. tintTexture: Nullable<BaseTexture>;
  124667. /** @hidden */
  124668. private _internalMarkAllSubMeshesAsTexturesDirty;
  124669. /** @hidden */
  124670. _markAllSubMeshesAsTexturesDirty(): void;
  124671. /**
  124672. * Instantiate a new istance of clear coat configuration.
  124673. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  124674. */
  124675. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  124676. /**
  124677. * Gets wehter the submesh is ready to be used or not.
  124678. * @param defines the list of "defines" to update.
  124679. * @param scene defines the scene the material belongs to.
  124680. * @param engine defines the engine the material belongs to.
  124681. * @param disableBumpMap defines wether the material disables bump or not.
  124682. * @returns - boolean indicating that the submesh is ready or not.
  124683. */
  124684. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  124685. /**
  124686. * Checks to see if a texture is used in the material.
  124687. * @param defines the list of "defines" to update.
  124688. * @param scene defines the scene to the material belongs to.
  124689. */
  124690. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  124691. /**
  124692. * Binds the material data.
  124693. * @param uniformBuffer defines the Uniform buffer to fill in.
  124694. * @param scene defines the scene the material belongs to.
  124695. * @param engine defines the engine the material belongs to.
  124696. * @param disableBumpMap defines wether the material disables bump or not.
  124697. * @param isFrozen defines wether the material is frozen or not.
  124698. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  124699. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  124700. */
  124701. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  124702. /**
  124703. * Checks to see if a texture is used in the material.
  124704. * @param texture - Base texture to use.
  124705. * @returns - Boolean specifying if a texture is used in the material.
  124706. */
  124707. hasTexture(texture: BaseTexture): boolean;
  124708. /**
  124709. * Returns an array of the actively used textures.
  124710. * @param activeTextures Array of BaseTextures
  124711. */
  124712. getActiveTextures(activeTextures: BaseTexture[]): void;
  124713. /**
  124714. * Returns the animatable textures.
  124715. * @param animatables Array of animatable textures.
  124716. */
  124717. getAnimatables(animatables: IAnimatable[]): void;
  124718. /**
  124719. * Disposes the resources of the material.
  124720. * @param forceDisposeTextures - Forces the disposal of all textures.
  124721. */
  124722. dispose(forceDisposeTextures?: boolean): void;
  124723. /**
  124724. * Get the current class name of the texture useful for serialization or dynamic coding.
  124725. * @returns "PBRClearCoatConfiguration"
  124726. */
  124727. getClassName(): string;
  124728. /**
  124729. * Add fallbacks to the effect fallbacks list.
  124730. * @param defines defines the Base texture to use.
  124731. * @param fallbacks defines the current fallback list.
  124732. * @param currentRank defines the current fallback rank.
  124733. * @returns the new fallback rank.
  124734. */
  124735. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  124736. /**
  124737. * Add the required uniforms to the current list.
  124738. * @param uniforms defines the current uniform list.
  124739. */
  124740. static AddUniforms(uniforms: string[]): void;
  124741. /**
  124742. * Add the required samplers to the current list.
  124743. * @param samplers defines the current sampler list.
  124744. */
  124745. static AddSamplers(samplers: string[]): void;
  124746. /**
  124747. * Add the required uniforms to the current buffer.
  124748. * @param uniformBuffer defines the current uniform buffer.
  124749. */
  124750. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  124751. /**
  124752. * Makes a duplicate of the current configuration into another one.
  124753. * @param clearCoatConfiguration define the config where to copy the info
  124754. */
  124755. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  124756. /**
  124757. * Serializes this clear coat configuration.
  124758. * @returns - An object with the serialized config.
  124759. */
  124760. serialize(): any;
  124761. /**
  124762. * Parses a anisotropy Configuration from a serialized object.
  124763. * @param source - Serialized object.
  124764. * @param scene Defines the scene we are parsing for
  124765. * @param rootUrl Defines the rootUrl to load from
  124766. */
  124767. parse(source: any, scene: Scene, rootUrl: string): void;
  124768. }
  124769. }
  124770. declare module BABYLON {
  124771. /**
  124772. * @hidden
  124773. */
  124774. export interface IMaterialAnisotropicDefines {
  124775. ANISOTROPIC: boolean;
  124776. ANISOTROPIC_TEXTURE: boolean;
  124777. ANISOTROPIC_TEXTUREDIRECTUV: number;
  124778. MAINUV1: boolean;
  124779. _areTexturesDirty: boolean;
  124780. _needUVs: boolean;
  124781. }
  124782. /**
  124783. * Define the code related to the anisotropic parameters of the pbr material.
  124784. */
  124785. export class PBRAnisotropicConfiguration {
  124786. private _isEnabled;
  124787. /**
  124788. * Defines if the anisotropy is enabled in the material.
  124789. */
  124790. isEnabled: boolean;
  124791. /**
  124792. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  124793. */
  124794. intensity: number;
  124795. /**
  124796. * Defines if the effect is along the tangents, bitangents or in between.
  124797. * By default, the effect is "strectching" the highlights along the tangents.
  124798. */
  124799. direction: Vector2;
  124800. private _texture;
  124801. /**
  124802. * Stores the anisotropy values in a texture.
  124803. * rg is direction (like normal from -1 to 1)
  124804. * b is a intensity
  124805. */
  124806. texture: Nullable<BaseTexture>;
  124807. /** @hidden */
  124808. private _internalMarkAllSubMeshesAsTexturesDirty;
  124809. /** @hidden */
  124810. _markAllSubMeshesAsTexturesDirty(): void;
  124811. /**
  124812. * Instantiate a new istance of anisotropy configuration.
  124813. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  124814. */
  124815. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  124816. /**
  124817. * Specifies that the submesh is ready to be used.
  124818. * @param defines the list of "defines" to update.
  124819. * @param scene defines the scene the material belongs to.
  124820. * @returns - boolean indicating that the submesh is ready or not.
  124821. */
  124822. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  124823. /**
  124824. * Checks to see if a texture is used in the material.
  124825. * @param defines the list of "defines" to update.
  124826. * @param mesh the mesh we are preparing the defines for.
  124827. * @param scene defines the scene the material belongs to.
  124828. */
  124829. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  124830. /**
  124831. * Binds the material data.
  124832. * @param uniformBuffer defines the Uniform buffer to fill in.
  124833. * @param scene defines the scene the material belongs to.
  124834. * @param isFrozen defines wether the material is frozen or not.
  124835. */
  124836. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  124837. /**
  124838. * Checks to see if a texture is used in the material.
  124839. * @param texture - Base texture to use.
  124840. * @returns - Boolean specifying if a texture is used in the material.
  124841. */
  124842. hasTexture(texture: BaseTexture): boolean;
  124843. /**
  124844. * Returns an array of the actively used textures.
  124845. * @param activeTextures Array of BaseTextures
  124846. */
  124847. getActiveTextures(activeTextures: BaseTexture[]): void;
  124848. /**
  124849. * Returns the animatable textures.
  124850. * @param animatables Array of animatable textures.
  124851. */
  124852. getAnimatables(animatables: IAnimatable[]): void;
  124853. /**
  124854. * Disposes the resources of the material.
  124855. * @param forceDisposeTextures - Forces the disposal of all textures.
  124856. */
  124857. dispose(forceDisposeTextures?: boolean): void;
  124858. /**
  124859. * Get the current class name of the texture useful for serialization or dynamic coding.
  124860. * @returns "PBRAnisotropicConfiguration"
  124861. */
  124862. getClassName(): string;
  124863. /**
  124864. * Add fallbacks to the effect fallbacks list.
  124865. * @param defines defines the Base texture to use.
  124866. * @param fallbacks defines the current fallback list.
  124867. * @param currentRank defines the current fallback rank.
  124868. * @returns the new fallback rank.
  124869. */
  124870. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  124871. /**
  124872. * Add the required uniforms to the current list.
  124873. * @param uniforms defines the current uniform list.
  124874. */
  124875. static AddUniforms(uniforms: string[]): void;
  124876. /**
  124877. * Add the required uniforms to the current buffer.
  124878. * @param uniformBuffer defines the current uniform buffer.
  124879. */
  124880. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  124881. /**
  124882. * Add the required samplers to the current list.
  124883. * @param samplers defines the current sampler list.
  124884. */
  124885. static AddSamplers(samplers: string[]): void;
  124886. /**
  124887. * Makes a duplicate of the current configuration into another one.
  124888. * @param anisotropicConfiguration define the config where to copy the info
  124889. */
  124890. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  124891. /**
  124892. * Serializes this anisotropy configuration.
  124893. * @returns - An object with the serialized config.
  124894. */
  124895. serialize(): any;
  124896. /**
  124897. * Parses a anisotropy Configuration from a serialized object.
  124898. * @param source - Serialized object.
  124899. * @param scene Defines the scene we are parsing for
  124900. * @param rootUrl Defines the rootUrl to load from
  124901. */
  124902. parse(source: any, scene: Scene, rootUrl: string): void;
  124903. }
  124904. }
  124905. declare module BABYLON {
  124906. /**
  124907. * @hidden
  124908. */
  124909. export interface IMaterialBRDFDefines {
  124910. BRDF_V_HEIGHT_CORRELATED: boolean;
  124911. MS_BRDF_ENERGY_CONSERVATION: boolean;
  124912. SPHERICAL_HARMONICS: boolean;
  124913. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  124914. /** @hidden */
  124915. _areMiscDirty: boolean;
  124916. }
  124917. /**
  124918. * Define the code related to the BRDF parameters of the pbr material.
  124919. */
  124920. export class PBRBRDFConfiguration {
  124921. /**
  124922. * Default value used for the energy conservation.
  124923. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  124924. */
  124925. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  124926. /**
  124927. * Default value used for the Smith Visibility Height Correlated mode.
  124928. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  124929. */
  124930. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  124931. /**
  124932. * Default value used for the IBL diffuse part.
  124933. * This can help switching back to the polynomials mode globally which is a tiny bit
  124934. * less GPU intensive at the drawback of a lower quality.
  124935. */
  124936. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  124937. /**
  124938. * Default value used for activating energy conservation for the specular workflow.
  124939. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  124940. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  124941. */
  124942. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  124943. private _useEnergyConservation;
  124944. /**
  124945. * Defines if the material uses energy conservation.
  124946. */
  124947. useEnergyConservation: boolean;
  124948. private _useSmithVisibilityHeightCorrelated;
  124949. /**
  124950. * LEGACY Mode set to false
  124951. * Defines if the material uses height smith correlated visibility term.
  124952. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  124953. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  124954. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  124955. * Not relying on height correlated will also disable energy conservation.
  124956. */
  124957. useSmithVisibilityHeightCorrelated: boolean;
  124958. private _useSphericalHarmonics;
  124959. /**
  124960. * LEGACY Mode set to false
  124961. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  124962. * diffuse part of the IBL.
  124963. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  124964. * to the ground truth.
  124965. */
  124966. useSphericalHarmonics: boolean;
  124967. private _useSpecularGlossinessInputEnergyConservation;
  124968. /**
  124969. * Defines if the material uses energy conservation, when the specular workflow is active.
  124970. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  124971. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  124972. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  124973. */
  124974. useSpecularGlossinessInputEnergyConservation: boolean;
  124975. /** @hidden */
  124976. private _internalMarkAllSubMeshesAsMiscDirty;
  124977. /** @hidden */
  124978. _markAllSubMeshesAsMiscDirty(): void;
  124979. /**
  124980. * Instantiate a new istance of clear coat configuration.
  124981. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  124982. */
  124983. constructor(markAllSubMeshesAsMiscDirty: () => void);
  124984. /**
  124985. * Checks to see if a texture is used in the material.
  124986. * @param defines the list of "defines" to update.
  124987. */
  124988. prepareDefines(defines: IMaterialBRDFDefines): void;
  124989. /**
  124990. * Get the current class name of the texture useful for serialization or dynamic coding.
  124991. * @returns "PBRClearCoatConfiguration"
  124992. */
  124993. getClassName(): string;
  124994. /**
  124995. * Makes a duplicate of the current configuration into another one.
  124996. * @param brdfConfiguration define the config where to copy the info
  124997. */
  124998. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  124999. /**
  125000. * Serializes this BRDF configuration.
  125001. * @returns - An object with the serialized config.
  125002. */
  125003. serialize(): any;
  125004. /**
  125005. * Parses a anisotropy Configuration from a serialized object.
  125006. * @param source - Serialized object.
  125007. * @param scene Defines the scene we are parsing for
  125008. * @param rootUrl Defines the rootUrl to load from
  125009. */
  125010. parse(source: any, scene: Scene, rootUrl: string): void;
  125011. }
  125012. }
  125013. declare module BABYLON {
  125014. /**
  125015. * @hidden
  125016. */
  125017. export interface IMaterialSheenDefines {
  125018. SHEEN: boolean;
  125019. SHEEN_TEXTURE: boolean;
  125020. SHEEN_TEXTUREDIRECTUV: number;
  125021. SHEEN_LINKWITHALBEDO: boolean;
  125022. SHEEN_ROUGHNESS: boolean;
  125023. SHEEN_ALBEDOSCALING: boolean;
  125024. /** @hidden */
  125025. _areTexturesDirty: boolean;
  125026. }
  125027. /**
  125028. * Define the code related to the Sheen parameters of the pbr material.
  125029. */
  125030. export class PBRSheenConfiguration {
  125031. private _isEnabled;
  125032. /**
  125033. * Defines if the material uses sheen.
  125034. */
  125035. isEnabled: boolean;
  125036. private _linkSheenWithAlbedo;
  125037. /**
  125038. * Defines if the sheen is linked to the sheen color.
  125039. */
  125040. linkSheenWithAlbedo: boolean;
  125041. /**
  125042. * Defines the sheen intensity.
  125043. */
  125044. intensity: number;
  125045. /**
  125046. * Defines the sheen color.
  125047. */
  125048. color: Color3;
  125049. private _texture;
  125050. /**
  125051. * Stores the sheen tint values in a texture.
  125052. * rgb is tint
  125053. * a is a intensity
  125054. */
  125055. texture: Nullable<BaseTexture>;
  125056. private _roughness;
  125057. /**
  125058. * Defines the sheen roughness.
  125059. * It is not taken into account if linkSheenWithAlbedo is true.
  125060. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  125061. */
  125062. roughness: Nullable<number>;
  125063. private _albedoScaling;
  125064. /**
  125065. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  125066. * It allows the strength of the sheen effect to not depend on the base color of the material,
  125067. * making it easier to setup and tweak the effect
  125068. */
  125069. albedoScaling: boolean;
  125070. /** @hidden */
  125071. private _internalMarkAllSubMeshesAsTexturesDirty;
  125072. /** @hidden */
  125073. _markAllSubMeshesAsTexturesDirty(): void;
  125074. /**
  125075. * Instantiate a new istance of clear coat configuration.
  125076. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  125077. */
  125078. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  125079. /**
  125080. * Specifies that the submesh is ready to be used.
  125081. * @param defines the list of "defines" to update.
  125082. * @param scene defines the scene the material belongs to.
  125083. * @returns - boolean indicating that the submesh is ready or not.
  125084. */
  125085. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  125086. /**
  125087. * Checks to see if a texture is used in the material.
  125088. * @param defines the list of "defines" to update.
  125089. * @param scene defines the scene the material belongs to.
  125090. */
  125091. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  125092. /**
  125093. * Binds the material data.
  125094. * @param uniformBuffer defines the Uniform buffer to fill in.
  125095. * @param scene defines the scene the material belongs to.
  125096. * @param isFrozen defines wether the material is frozen or not.
  125097. */
  125098. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  125099. /**
  125100. * Checks to see if a texture is used in the material.
  125101. * @param texture - Base texture to use.
  125102. * @returns - Boolean specifying if a texture is used in the material.
  125103. */
  125104. hasTexture(texture: BaseTexture): boolean;
  125105. /**
  125106. * Returns an array of the actively used textures.
  125107. * @param activeTextures Array of BaseTextures
  125108. */
  125109. getActiveTextures(activeTextures: BaseTexture[]): void;
  125110. /**
  125111. * Returns the animatable textures.
  125112. * @param animatables Array of animatable textures.
  125113. */
  125114. getAnimatables(animatables: IAnimatable[]): void;
  125115. /**
  125116. * Disposes the resources of the material.
  125117. * @param forceDisposeTextures - Forces the disposal of all textures.
  125118. */
  125119. dispose(forceDisposeTextures?: boolean): void;
  125120. /**
  125121. * Get the current class name of the texture useful for serialization or dynamic coding.
  125122. * @returns "PBRSheenConfiguration"
  125123. */
  125124. getClassName(): string;
  125125. /**
  125126. * Add fallbacks to the effect fallbacks list.
  125127. * @param defines defines the Base texture to use.
  125128. * @param fallbacks defines the current fallback list.
  125129. * @param currentRank defines the current fallback rank.
  125130. * @returns the new fallback rank.
  125131. */
  125132. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  125133. /**
  125134. * Add the required uniforms to the current list.
  125135. * @param uniforms defines the current uniform list.
  125136. */
  125137. static AddUniforms(uniforms: string[]): void;
  125138. /**
  125139. * Add the required uniforms to the current buffer.
  125140. * @param uniformBuffer defines the current uniform buffer.
  125141. */
  125142. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  125143. /**
  125144. * Add the required samplers to the current list.
  125145. * @param samplers defines the current sampler list.
  125146. */
  125147. static AddSamplers(samplers: string[]): void;
  125148. /**
  125149. * Makes a duplicate of the current configuration into another one.
  125150. * @param sheenConfiguration define the config where to copy the info
  125151. */
  125152. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  125153. /**
  125154. * Serializes this BRDF configuration.
  125155. * @returns - An object with the serialized config.
  125156. */
  125157. serialize(): any;
  125158. /**
  125159. * Parses a anisotropy Configuration from a serialized object.
  125160. * @param source - Serialized object.
  125161. * @param scene Defines the scene we are parsing for
  125162. * @param rootUrl Defines the rootUrl to load from
  125163. */
  125164. parse(source: any, scene: Scene, rootUrl: string): void;
  125165. }
  125166. }
  125167. declare module BABYLON {
  125168. /**
  125169. * @hidden
  125170. */
  125171. export interface IMaterialSubSurfaceDefines {
  125172. SUBSURFACE: boolean;
  125173. SS_REFRACTION: boolean;
  125174. SS_TRANSLUCENCY: boolean;
  125175. SS_SCATERRING: boolean;
  125176. SS_THICKNESSANDMASK_TEXTURE: boolean;
  125177. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  125178. SS_REFRACTIONMAP_3D: boolean;
  125179. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  125180. SS_LODINREFRACTIONALPHA: boolean;
  125181. SS_GAMMAREFRACTION: boolean;
  125182. SS_RGBDREFRACTION: boolean;
  125183. SS_LINEARSPECULARREFRACTION: boolean;
  125184. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  125185. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  125186. /** @hidden */
  125187. _areTexturesDirty: boolean;
  125188. }
  125189. /**
  125190. * Define the code related to the sub surface parameters of the pbr material.
  125191. */
  125192. export class PBRSubSurfaceConfiguration {
  125193. private _isRefractionEnabled;
  125194. /**
  125195. * Defines if the refraction is enabled in the material.
  125196. */
  125197. isRefractionEnabled: boolean;
  125198. private _isTranslucencyEnabled;
  125199. /**
  125200. * Defines if the translucency is enabled in the material.
  125201. */
  125202. isTranslucencyEnabled: boolean;
  125203. private _isScatteringEnabled;
  125204. /**
  125205. * Defines the refraction intensity of the material.
  125206. * The refraction when enabled replaces the Diffuse part of the material.
  125207. * The intensity helps transitionning between diffuse and refraction.
  125208. */
  125209. refractionIntensity: number;
  125210. /**
  125211. * Defines the translucency intensity of the material.
  125212. * When translucency has been enabled, this defines how much of the "translucency"
  125213. * is addded to the diffuse part of the material.
  125214. */
  125215. translucencyIntensity: number;
  125216. /**
  125217. * Defines the scattering intensity of the material.
  125218. * When scattering has been enabled, this defines how much of the "scattered light"
  125219. * is addded to the diffuse part of the material.
  125220. */
  125221. scatteringIntensity: number;
  125222. private _thicknessTexture;
  125223. /**
  125224. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  125225. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  125226. * 0 would mean minimumThickness
  125227. * 1 would mean maximumThickness
  125228. * The other channels might be use as a mask to vary the different effects intensity.
  125229. */
  125230. thicknessTexture: Nullable<BaseTexture>;
  125231. private _refractionTexture;
  125232. /**
  125233. * Defines the texture to use for refraction.
  125234. */
  125235. refractionTexture: Nullable<BaseTexture>;
  125236. private _indexOfRefraction;
  125237. /**
  125238. * Defines the index of refraction used in the material.
  125239. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  125240. */
  125241. indexOfRefraction: number;
  125242. private _invertRefractionY;
  125243. /**
  125244. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  125245. */
  125246. invertRefractionY: boolean;
  125247. private _linkRefractionWithTransparency;
  125248. /**
  125249. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  125250. * Materials half opaque for instance using refraction could benefit from this control.
  125251. */
  125252. linkRefractionWithTransparency: boolean;
  125253. /**
  125254. * Defines the minimum thickness stored in the thickness map.
  125255. * If no thickness map is defined, this value will be used to simulate thickness.
  125256. */
  125257. minimumThickness: number;
  125258. /**
  125259. * Defines the maximum thickness stored in the thickness map.
  125260. */
  125261. maximumThickness: number;
  125262. /**
  125263. * Defines the volume tint of the material.
  125264. * This is used for both translucency and scattering.
  125265. */
  125266. tintColor: Color3;
  125267. /**
  125268. * Defines the distance at which the tint color should be found in the media.
  125269. * This is used for refraction only.
  125270. */
  125271. tintColorAtDistance: number;
  125272. /**
  125273. * Defines how far each channel transmit through the media.
  125274. * It is defined as a color to simplify it selection.
  125275. */
  125276. diffusionDistance: Color3;
  125277. private _useMaskFromThicknessTexture;
  125278. /**
  125279. * Stores the intensity of the different subsurface effects in the thickness texture.
  125280. * * the green channel is the translucency intensity.
  125281. * * the blue channel is the scattering intensity.
  125282. * * the alpha channel is the refraction intensity.
  125283. */
  125284. useMaskFromThicknessTexture: boolean;
  125285. /** @hidden */
  125286. private _internalMarkAllSubMeshesAsTexturesDirty;
  125287. /** @hidden */
  125288. _markAllSubMeshesAsTexturesDirty(): void;
  125289. /**
  125290. * Instantiate a new istance of sub surface configuration.
  125291. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  125292. */
  125293. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  125294. /**
  125295. * Gets wehter the submesh is ready to be used or not.
  125296. * @param defines the list of "defines" to update.
  125297. * @param scene defines the scene the material belongs to.
  125298. * @returns - boolean indicating that the submesh is ready or not.
  125299. */
  125300. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  125301. /**
  125302. * Checks to see if a texture is used in the material.
  125303. * @param defines the list of "defines" to update.
  125304. * @param scene defines the scene to the material belongs to.
  125305. */
  125306. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  125307. /**
  125308. * Binds the material data.
  125309. * @param uniformBuffer defines the Uniform buffer to fill in.
  125310. * @param scene defines the scene the material belongs to.
  125311. * @param engine defines the engine the material belongs to.
  125312. * @param isFrozen defines wether the material is frozen or not.
  125313. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  125314. */
  125315. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  125316. /**
  125317. * Unbinds the material from the mesh.
  125318. * @param activeEffect defines the effect that should be unbound from.
  125319. * @returns true if unbound, otherwise false
  125320. */
  125321. unbind(activeEffect: Effect): boolean;
  125322. /**
  125323. * Returns the texture used for refraction or null if none is used.
  125324. * @param scene defines the scene the material belongs to.
  125325. * @returns - Refraction texture if present. If no refraction texture and refraction
  125326. * is linked with transparency, returns environment texture. Otherwise, returns null.
  125327. */
  125328. private _getRefractionTexture;
  125329. /**
  125330. * Returns true if alpha blending should be disabled.
  125331. */
  125332. get disableAlphaBlending(): boolean;
  125333. /**
  125334. * Fills the list of render target textures.
  125335. * @param renderTargets the list of render targets to update
  125336. */
  125337. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  125338. /**
  125339. * Checks to see if a texture is used in the material.
  125340. * @param texture - Base texture to use.
  125341. * @returns - Boolean specifying if a texture is used in the material.
  125342. */
  125343. hasTexture(texture: BaseTexture): boolean;
  125344. /**
  125345. * Gets a boolean indicating that current material needs to register RTT
  125346. * @returns true if this uses a render target otherwise false.
  125347. */
  125348. hasRenderTargetTextures(): boolean;
  125349. /**
  125350. * Returns an array of the actively used textures.
  125351. * @param activeTextures Array of BaseTextures
  125352. */
  125353. getActiveTextures(activeTextures: BaseTexture[]): void;
  125354. /**
  125355. * Returns the animatable textures.
  125356. * @param animatables Array of animatable textures.
  125357. */
  125358. getAnimatables(animatables: IAnimatable[]): void;
  125359. /**
  125360. * Disposes the resources of the material.
  125361. * @param forceDisposeTextures - Forces the disposal of all textures.
  125362. */
  125363. dispose(forceDisposeTextures?: boolean): void;
  125364. /**
  125365. * Get the current class name of the texture useful for serialization or dynamic coding.
  125366. * @returns "PBRSubSurfaceConfiguration"
  125367. */
  125368. getClassName(): string;
  125369. /**
  125370. * Add fallbacks to the effect fallbacks list.
  125371. * @param defines defines the Base texture to use.
  125372. * @param fallbacks defines the current fallback list.
  125373. * @param currentRank defines the current fallback rank.
  125374. * @returns the new fallback rank.
  125375. */
  125376. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  125377. /**
  125378. * Add the required uniforms to the current list.
  125379. * @param uniforms defines the current uniform list.
  125380. */
  125381. static AddUniforms(uniforms: string[]): void;
  125382. /**
  125383. * Add the required samplers to the current list.
  125384. * @param samplers defines the current sampler list.
  125385. */
  125386. static AddSamplers(samplers: string[]): void;
  125387. /**
  125388. * Add the required uniforms to the current buffer.
  125389. * @param uniformBuffer defines the current uniform buffer.
  125390. */
  125391. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  125392. /**
  125393. * Makes a duplicate of the current configuration into another one.
  125394. * @param configuration define the config where to copy the info
  125395. */
  125396. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  125397. /**
  125398. * Serializes this Sub Surface configuration.
  125399. * @returns - An object with the serialized config.
  125400. */
  125401. serialize(): any;
  125402. /**
  125403. * Parses a anisotropy Configuration from a serialized object.
  125404. * @param source - Serialized object.
  125405. * @param scene Defines the scene we are parsing for
  125406. * @param rootUrl Defines the rootUrl to load from
  125407. */
  125408. parse(source: any, scene: Scene, rootUrl: string): void;
  125409. }
  125410. }
  125411. declare module BABYLON {
  125412. /** @hidden */
  125413. export var pbrFragmentDeclaration: {
  125414. name: string;
  125415. shader: string;
  125416. };
  125417. }
  125418. declare module BABYLON {
  125419. /** @hidden */
  125420. export var pbrUboDeclaration: {
  125421. name: string;
  125422. shader: string;
  125423. };
  125424. }
  125425. declare module BABYLON {
  125426. /** @hidden */
  125427. export var pbrFragmentExtraDeclaration: {
  125428. name: string;
  125429. shader: string;
  125430. };
  125431. }
  125432. declare module BABYLON {
  125433. /** @hidden */
  125434. export var pbrFragmentSamplersDeclaration: {
  125435. name: string;
  125436. shader: string;
  125437. };
  125438. }
  125439. declare module BABYLON {
  125440. /** @hidden */
  125441. export var pbrHelperFunctions: {
  125442. name: string;
  125443. shader: string;
  125444. };
  125445. }
  125446. declare module BABYLON {
  125447. /** @hidden */
  125448. export var harmonicsFunctions: {
  125449. name: string;
  125450. shader: string;
  125451. };
  125452. }
  125453. declare module BABYLON {
  125454. /** @hidden */
  125455. export var pbrDirectLightingSetupFunctions: {
  125456. name: string;
  125457. shader: string;
  125458. };
  125459. }
  125460. declare module BABYLON {
  125461. /** @hidden */
  125462. export var pbrDirectLightingFalloffFunctions: {
  125463. name: string;
  125464. shader: string;
  125465. };
  125466. }
  125467. declare module BABYLON {
  125468. /** @hidden */
  125469. export var pbrBRDFFunctions: {
  125470. name: string;
  125471. shader: string;
  125472. };
  125473. }
  125474. declare module BABYLON {
  125475. /** @hidden */
  125476. export var pbrDirectLightingFunctions: {
  125477. name: string;
  125478. shader: string;
  125479. };
  125480. }
  125481. declare module BABYLON {
  125482. /** @hidden */
  125483. export var pbrIBLFunctions: {
  125484. name: string;
  125485. shader: string;
  125486. };
  125487. }
  125488. declare module BABYLON {
  125489. /** @hidden */
  125490. export var pbrBlockAlbedoOpacity: {
  125491. name: string;
  125492. shader: string;
  125493. };
  125494. }
  125495. declare module BABYLON {
  125496. /** @hidden */
  125497. export var pbrBlockReflectivity: {
  125498. name: string;
  125499. shader: string;
  125500. };
  125501. }
  125502. declare module BABYLON {
  125503. /** @hidden */
  125504. export var pbrBlockAmbientOcclusion: {
  125505. name: string;
  125506. shader: string;
  125507. };
  125508. }
  125509. declare module BABYLON {
  125510. /** @hidden */
  125511. export var pbrBlockAlphaFresnel: {
  125512. name: string;
  125513. shader: string;
  125514. };
  125515. }
  125516. declare module BABYLON {
  125517. /** @hidden */
  125518. export var pbrBlockAnisotropic: {
  125519. name: string;
  125520. shader: string;
  125521. };
  125522. }
  125523. declare module BABYLON {
  125524. /** @hidden */
  125525. export var pbrBlockReflection: {
  125526. name: string;
  125527. shader: string;
  125528. };
  125529. }
  125530. declare module BABYLON {
  125531. /** @hidden */
  125532. export var pbrBlockSheen: {
  125533. name: string;
  125534. shader: string;
  125535. };
  125536. }
  125537. declare module BABYLON {
  125538. /** @hidden */
  125539. export var pbrBlockClearcoat: {
  125540. name: string;
  125541. shader: string;
  125542. };
  125543. }
  125544. declare module BABYLON {
  125545. /** @hidden */
  125546. export var pbrBlockSubSurface: {
  125547. name: string;
  125548. shader: string;
  125549. };
  125550. }
  125551. declare module BABYLON {
  125552. /** @hidden */
  125553. export var pbrBlockNormalGeometric: {
  125554. name: string;
  125555. shader: string;
  125556. };
  125557. }
  125558. declare module BABYLON {
  125559. /** @hidden */
  125560. export var pbrBlockNormalFinal: {
  125561. name: string;
  125562. shader: string;
  125563. };
  125564. }
  125565. declare module BABYLON {
  125566. /** @hidden */
  125567. export var pbrBlockGeometryInfo: {
  125568. name: string;
  125569. shader: string;
  125570. };
  125571. }
  125572. declare module BABYLON {
  125573. /** @hidden */
  125574. export var pbrBlockReflectance0: {
  125575. name: string;
  125576. shader: string;
  125577. };
  125578. }
  125579. declare module BABYLON {
  125580. /** @hidden */
  125581. export var pbrBlockReflectance: {
  125582. name: string;
  125583. shader: string;
  125584. };
  125585. }
  125586. declare module BABYLON {
  125587. /** @hidden */
  125588. export var pbrBlockDirectLighting: {
  125589. name: string;
  125590. shader: string;
  125591. };
  125592. }
  125593. declare module BABYLON {
  125594. /** @hidden */
  125595. export var pbrBlockFinalLitComponents: {
  125596. name: string;
  125597. shader: string;
  125598. };
  125599. }
  125600. declare module BABYLON {
  125601. /** @hidden */
  125602. export var pbrBlockFinalUnlitComponents: {
  125603. name: string;
  125604. shader: string;
  125605. };
  125606. }
  125607. declare module BABYLON {
  125608. /** @hidden */
  125609. export var pbrBlockFinalColorComposition: {
  125610. name: string;
  125611. shader: string;
  125612. };
  125613. }
  125614. declare module BABYLON {
  125615. /** @hidden */
  125616. export var pbrBlockImageProcessing: {
  125617. name: string;
  125618. shader: string;
  125619. };
  125620. }
  125621. declare module BABYLON {
  125622. /** @hidden */
  125623. export var pbrDebug: {
  125624. name: string;
  125625. shader: string;
  125626. };
  125627. }
  125628. declare module BABYLON {
  125629. /** @hidden */
  125630. export var pbrPixelShader: {
  125631. name: string;
  125632. shader: string;
  125633. };
  125634. }
  125635. declare module BABYLON {
  125636. /** @hidden */
  125637. export var pbrVertexDeclaration: {
  125638. name: string;
  125639. shader: string;
  125640. };
  125641. }
  125642. declare module BABYLON {
  125643. /** @hidden */
  125644. export var pbrVertexShader: {
  125645. name: string;
  125646. shader: string;
  125647. };
  125648. }
  125649. declare module BABYLON {
  125650. /**
  125651. * Manages the defines for the PBR Material.
  125652. * @hidden
  125653. */
  125654. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  125655. PBR: boolean;
  125656. MAINUV1: boolean;
  125657. MAINUV2: boolean;
  125658. UV1: boolean;
  125659. UV2: boolean;
  125660. ALBEDO: boolean;
  125661. GAMMAALBEDO: boolean;
  125662. ALBEDODIRECTUV: number;
  125663. VERTEXCOLOR: boolean;
  125664. AMBIENT: boolean;
  125665. AMBIENTDIRECTUV: number;
  125666. AMBIENTINGRAYSCALE: boolean;
  125667. OPACITY: boolean;
  125668. VERTEXALPHA: boolean;
  125669. OPACITYDIRECTUV: number;
  125670. OPACITYRGB: boolean;
  125671. ALPHATEST: boolean;
  125672. DEPTHPREPASS: boolean;
  125673. ALPHABLEND: boolean;
  125674. ALPHAFROMALBEDO: boolean;
  125675. ALPHATESTVALUE: string;
  125676. SPECULAROVERALPHA: boolean;
  125677. RADIANCEOVERALPHA: boolean;
  125678. ALPHAFRESNEL: boolean;
  125679. LINEARALPHAFRESNEL: boolean;
  125680. PREMULTIPLYALPHA: boolean;
  125681. EMISSIVE: boolean;
  125682. EMISSIVEDIRECTUV: number;
  125683. REFLECTIVITY: boolean;
  125684. REFLECTIVITYDIRECTUV: number;
  125685. SPECULARTERM: boolean;
  125686. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  125687. MICROSURFACEAUTOMATIC: boolean;
  125688. LODBASEDMICROSFURACE: boolean;
  125689. MICROSURFACEMAP: boolean;
  125690. MICROSURFACEMAPDIRECTUV: number;
  125691. METALLICWORKFLOW: boolean;
  125692. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  125693. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  125694. METALLNESSSTOREINMETALMAPBLUE: boolean;
  125695. AOSTOREINMETALMAPRED: boolean;
  125696. METALLICF0FACTORFROMMETALLICMAP: boolean;
  125697. ENVIRONMENTBRDF: boolean;
  125698. ENVIRONMENTBRDF_RGBD: boolean;
  125699. NORMAL: boolean;
  125700. TANGENT: boolean;
  125701. BUMP: boolean;
  125702. BUMPDIRECTUV: number;
  125703. OBJECTSPACE_NORMALMAP: boolean;
  125704. PARALLAX: boolean;
  125705. PARALLAXOCCLUSION: boolean;
  125706. NORMALXYSCALE: boolean;
  125707. LIGHTMAP: boolean;
  125708. LIGHTMAPDIRECTUV: number;
  125709. USELIGHTMAPASSHADOWMAP: boolean;
  125710. GAMMALIGHTMAP: boolean;
  125711. RGBDLIGHTMAP: boolean;
  125712. REFLECTION: boolean;
  125713. REFLECTIONMAP_3D: boolean;
  125714. REFLECTIONMAP_SPHERICAL: boolean;
  125715. REFLECTIONMAP_PLANAR: boolean;
  125716. REFLECTIONMAP_CUBIC: boolean;
  125717. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  125718. REFLECTIONMAP_PROJECTION: boolean;
  125719. REFLECTIONMAP_SKYBOX: boolean;
  125720. REFLECTIONMAP_EXPLICIT: boolean;
  125721. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  125722. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  125723. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  125724. INVERTCUBICMAP: boolean;
  125725. USESPHERICALFROMREFLECTIONMAP: boolean;
  125726. USEIRRADIANCEMAP: boolean;
  125727. SPHERICAL_HARMONICS: boolean;
  125728. USESPHERICALINVERTEX: boolean;
  125729. REFLECTIONMAP_OPPOSITEZ: boolean;
  125730. LODINREFLECTIONALPHA: boolean;
  125731. GAMMAREFLECTION: boolean;
  125732. RGBDREFLECTION: boolean;
  125733. LINEARSPECULARREFLECTION: boolean;
  125734. RADIANCEOCCLUSION: boolean;
  125735. HORIZONOCCLUSION: boolean;
  125736. INSTANCES: boolean;
  125737. NUM_BONE_INFLUENCERS: number;
  125738. BonesPerMesh: number;
  125739. BONETEXTURE: boolean;
  125740. NONUNIFORMSCALING: boolean;
  125741. MORPHTARGETS: boolean;
  125742. MORPHTARGETS_NORMAL: boolean;
  125743. MORPHTARGETS_TANGENT: boolean;
  125744. MORPHTARGETS_UV: boolean;
  125745. NUM_MORPH_INFLUENCERS: number;
  125746. IMAGEPROCESSING: boolean;
  125747. VIGNETTE: boolean;
  125748. VIGNETTEBLENDMODEMULTIPLY: boolean;
  125749. VIGNETTEBLENDMODEOPAQUE: boolean;
  125750. TONEMAPPING: boolean;
  125751. TONEMAPPING_ACES: boolean;
  125752. CONTRAST: boolean;
  125753. COLORCURVES: boolean;
  125754. COLORGRADING: boolean;
  125755. COLORGRADING3D: boolean;
  125756. SAMPLER3DGREENDEPTH: boolean;
  125757. SAMPLER3DBGRMAP: boolean;
  125758. IMAGEPROCESSINGPOSTPROCESS: boolean;
  125759. EXPOSURE: boolean;
  125760. MULTIVIEW: boolean;
  125761. USEPHYSICALLIGHTFALLOFF: boolean;
  125762. USEGLTFLIGHTFALLOFF: boolean;
  125763. TWOSIDEDLIGHTING: boolean;
  125764. SHADOWFLOAT: boolean;
  125765. CLIPPLANE: boolean;
  125766. CLIPPLANE2: boolean;
  125767. CLIPPLANE3: boolean;
  125768. CLIPPLANE4: boolean;
  125769. CLIPPLANE5: boolean;
  125770. CLIPPLANE6: boolean;
  125771. POINTSIZE: boolean;
  125772. FOG: boolean;
  125773. LOGARITHMICDEPTH: boolean;
  125774. FORCENORMALFORWARD: boolean;
  125775. SPECULARAA: boolean;
  125776. CLEARCOAT: boolean;
  125777. CLEARCOAT_DEFAULTIOR: boolean;
  125778. CLEARCOAT_TEXTURE: boolean;
  125779. CLEARCOAT_TEXTUREDIRECTUV: number;
  125780. CLEARCOAT_BUMP: boolean;
  125781. CLEARCOAT_BUMPDIRECTUV: number;
  125782. CLEARCOAT_TINT: boolean;
  125783. CLEARCOAT_TINT_TEXTURE: boolean;
  125784. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  125785. ANISOTROPIC: boolean;
  125786. ANISOTROPIC_TEXTURE: boolean;
  125787. ANISOTROPIC_TEXTUREDIRECTUV: number;
  125788. BRDF_V_HEIGHT_CORRELATED: boolean;
  125789. MS_BRDF_ENERGY_CONSERVATION: boolean;
  125790. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  125791. SHEEN: boolean;
  125792. SHEEN_TEXTURE: boolean;
  125793. SHEEN_TEXTUREDIRECTUV: number;
  125794. SHEEN_LINKWITHALBEDO: boolean;
  125795. SHEEN_ROUGHNESS: boolean;
  125796. SHEEN_ALBEDOSCALING: boolean;
  125797. SUBSURFACE: boolean;
  125798. SS_REFRACTION: boolean;
  125799. SS_TRANSLUCENCY: boolean;
  125800. SS_SCATERRING: boolean;
  125801. SS_THICKNESSANDMASK_TEXTURE: boolean;
  125802. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  125803. SS_REFRACTIONMAP_3D: boolean;
  125804. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  125805. SS_LODINREFRACTIONALPHA: boolean;
  125806. SS_GAMMAREFRACTION: boolean;
  125807. SS_RGBDREFRACTION: boolean;
  125808. SS_LINEARSPECULARREFRACTION: boolean;
  125809. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  125810. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  125811. UNLIT: boolean;
  125812. DEBUGMODE: number;
  125813. /**
  125814. * Initializes the PBR Material defines.
  125815. */
  125816. constructor();
  125817. /**
  125818. * Resets the PBR Material defines.
  125819. */
  125820. reset(): void;
  125821. }
  125822. /**
  125823. * The Physically based material base class of BJS.
  125824. *
  125825. * This offers the main features of a standard PBR material.
  125826. * For more information, please refer to the documentation :
  125827. * https://doc.babylonjs.com/how_to/physically_based_rendering
  125828. */
  125829. export abstract class PBRBaseMaterial extends PushMaterial {
  125830. /**
  125831. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  125832. */
  125833. static readonly PBRMATERIAL_OPAQUE: number;
  125834. /**
  125835. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  125836. */
  125837. static readonly PBRMATERIAL_ALPHATEST: number;
  125838. /**
  125839. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  125840. */
  125841. static readonly PBRMATERIAL_ALPHABLEND: number;
  125842. /**
  125843. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  125844. * They are also discarded below the alpha cutoff threshold to improve performances.
  125845. */
  125846. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  125847. /**
  125848. * Defines the default value of how much AO map is occluding the analytical lights
  125849. * (point spot...).
  125850. */
  125851. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  125852. /**
  125853. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  125854. */
  125855. static readonly LIGHTFALLOFF_PHYSICAL: number;
  125856. /**
  125857. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  125858. * to enhance interoperability with other engines.
  125859. */
  125860. static readonly LIGHTFALLOFF_GLTF: number;
  125861. /**
  125862. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  125863. * to enhance interoperability with other materials.
  125864. */
  125865. static readonly LIGHTFALLOFF_STANDARD: number;
  125866. /**
  125867. * Intensity of the direct lights e.g. the four lights available in your scene.
  125868. * This impacts both the direct diffuse and specular highlights.
  125869. */
  125870. protected _directIntensity: number;
  125871. /**
  125872. * Intensity of the emissive part of the material.
  125873. * This helps controlling the emissive effect without modifying the emissive color.
  125874. */
  125875. protected _emissiveIntensity: number;
  125876. /**
  125877. * Intensity of the environment e.g. how much the environment will light the object
  125878. * either through harmonics for rough material or through the refelction for shiny ones.
  125879. */
  125880. protected _environmentIntensity: number;
  125881. /**
  125882. * This is a special control allowing the reduction of the specular highlights coming from the
  125883. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  125884. */
  125885. protected _specularIntensity: number;
  125886. /**
  125887. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  125888. */
  125889. private _lightingInfos;
  125890. /**
  125891. * Debug Control allowing disabling the bump map on this material.
  125892. */
  125893. protected _disableBumpMap: boolean;
  125894. /**
  125895. * AKA Diffuse Texture in standard nomenclature.
  125896. */
  125897. protected _albedoTexture: Nullable<BaseTexture>;
  125898. /**
  125899. * AKA Occlusion Texture in other nomenclature.
  125900. */
  125901. protected _ambientTexture: Nullable<BaseTexture>;
  125902. /**
  125903. * AKA Occlusion Texture Intensity in other nomenclature.
  125904. */
  125905. protected _ambientTextureStrength: number;
  125906. /**
  125907. * Defines how much the AO map is occluding the analytical lights (point spot...).
  125908. * 1 means it completely occludes it
  125909. * 0 mean it has no impact
  125910. */
  125911. protected _ambientTextureImpactOnAnalyticalLights: number;
  125912. /**
  125913. * Stores the alpha values in a texture.
  125914. */
  125915. protected _opacityTexture: Nullable<BaseTexture>;
  125916. /**
  125917. * Stores the reflection values in a texture.
  125918. */
  125919. protected _reflectionTexture: Nullable<BaseTexture>;
  125920. /**
  125921. * Stores the emissive values in a texture.
  125922. */
  125923. protected _emissiveTexture: Nullable<BaseTexture>;
  125924. /**
  125925. * AKA Specular texture in other nomenclature.
  125926. */
  125927. protected _reflectivityTexture: Nullable<BaseTexture>;
  125928. /**
  125929. * Used to switch from specular/glossiness to metallic/roughness workflow.
  125930. */
  125931. protected _metallicTexture: Nullable<BaseTexture>;
  125932. /**
  125933. * Specifies the metallic scalar of the metallic/roughness workflow.
  125934. * Can also be used to scale the metalness values of the metallic texture.
  125935. */
  125936. protected _metallic: Nullable<number>;
  125937. /**
  125938. * Specifies the roughness scalar of the metallic/roughness workflow.
  125939. * Can also be used to scale the roughness values of the metallic texture.
  125940. */
  125941. protected _roughness: Nullable<number>;
  125942. /**
  125943. * Specifies the an F0 factor to help configuring the material F0.
  125944. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  125945. * to 0.5 the previously hard coded value stays the same.
  125946. * Can also be used to scale the F0 values of the metallic texture.
  125947. */
  125948. protected _metallicF0Factor: number;
  125949. /**
  125950. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  125951. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  125952. * your expectation as it multiplies with the texture data.
  125953. */
  125954. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  125955. /**
  125956. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  125957. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  125958. */
  125959. protected _microSurfaceTexture: Nullable<BaseTexture>;
  125960. /**
  125961. * Stores surface normal data used to displace a mesh in a texture.
  125962. */
  125963. protected _bumpTexture: Nullable<BaseTexture>;
  125964. /**
  125965. * Stores the pre-calculated light information of a mesh in a texture.
  125966. */
  125967. protected _lightmapTexture: Nullable<BaseTexture>;
  125968. /**
  125969. * The color of a material in ambient lighting.
  125970. */
  125971. protected _ambientColor: Color3;
  125972. /**
  125973. * AKA Diffuse Color in other nomenclature.
  125974. */
  125975. protected _albedoColor: Color3;
  125976. /**
  125977. * AKA Specular Color in other nomenclature.
  125978. */
  125979. protected _reflectivityColor: Color3;
  125980. /**
  125981. * The color applied when light is reflected from a material.
  125982. */
  125983. protected _reflectionColor: Color3;
  125984. /**
  125985. * The color applied when light is emitted from a material.
  125986. */
  125987. protected _emissiveColor: Color3;
  125988. /**
  125989. * AKA Glossiness in other nomenclature.
  125990. */
  125991. protected _microSurface: number;
  125992. /**
  125993. * Specifies that the material will use the light map as a show map.
  125994. */
  125995. protected _useLightmapAsShadowmap: boolean;
  125996. /**
  125997. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  125998. * makes the reflect vector face the model (under horizon).
  125999. */
  126000. protected _useHorizonOcclusion: boolean;
  126001. /**
  126002. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  126003. * too much the area relying on ambient texture to define their ambient occlusion.
  126004. */
  126005. protected _useRadianceOcclusion: boolean;
  126006. /**
  126007. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  126008. */
  126009. protected _useAlphaFromAlbedoTexture: boolean;
  126010. /**
  126011. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  126012. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  126013. */
  126014. protected _useSpecularOverAlpha: boolean;
  126015. /**
  126016. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  126017. */
  126018. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  126019. /**
  126020. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  126021. */
  126022. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  126023. /**
  126024. * Specifies if the metallic texture contains the roughness information in its green channel.
  126025. */
  126026. protected _useRoughnessFromMetallicTextureGreen: boolean;
  126027. /**
  126028. * Specifies if the metallic texture contains the metallness information in its blue channel.
  126029. */
  126030. protected _useMetallnessFromMetallicTextureBlue: boolean;
  126031. /**
  126032. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  126033. */
  126034. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  126035. /**
  126036. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  126037. */
  126038. protected _useAmbientInGrayScale: boolean;
  126039. /**
  126040. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  126041. * The material will try to infer what glossiness each pixel should be.
  126042. */
  126043. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  126044. /**
  126045. * Defines the falloff type used in this material.
  126046. * It by default is Physical.
  126047. */
  126048. protected _lightFalloff: number;
  126049. /**
  126050. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  126051. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  126052. */
  126053. protected _useRadianceOverAlpha: boolean;
  126054. /**
  126055. * Allows using an object space normal map (instead of tangent space).
  126056. */
  126057. protected _useObjectSpaceNormalMap: boolean;
  126058. /**
  126059. * Allows using the bump map in parallax mode.
  126060. */
  126061. protected _useParallax: boolean;
  126062. /**
  126063. * Allows using the bump map in parallax occlusion mode.
  126064. */
  126065. protected _useParallaxOcclusion: boolean;
  126066. /**
  126067. * Controls the scale bias of the parallax mode.
  126068. */
  126069. protected _parallaxScaleBias: number;
  126070. /**
  126071. * If sets to true, disables all the lights affecting the material.
  126072. */
  126073. protected _disableLighting: boolean;
  126074. /**
  126075. * Number of Simultaneous lights allowed on the material.
  126076. */
  126077. protected _maxSimultaneousLights: number;
  126078. /**
  126079. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  126080. */
  126081. protected _invertNormalMapX: boolean;
  126082. /**
  126083. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  126084. */
  126085. protected _invertNormalMapY: boolean;
  126086. /**
  126087. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  126088. */
  126089. protected _twoSidedLighting: boolean;
  126090. /**
  126091. * Defines the alpha limits in alpha test mode.
  126092. */
  126093. protected _alphaCutOff: number;
  126094. /**
  126095. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  126096. */
  126097. protected _forceAlphaTest: boolean;
  126098. /**
  126099. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  126100. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  126101. */
  126102. protected _useAlphaFresnel: boolean;
  126103. /**
  126104. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  126105. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  126106. */
  126107. protected _useLinearAlphaFresnel: boolean;
  126108. /**
  126109. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  126110. * from cos thetav and roughness:
  126111. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  126112. */
  126113. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  126114. /**
  126115. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  126116. */
  126117. protected _forceIrradianceInFragment: boolean;
  126118. /**
  126119. * Force normal to face away from face.
  126120. */
  126121. protected _forceNormalForward: boolean;
  126122. /**
  126123. * Enables specular anti aliasing in the PBR shader.
  126124. * It will both interacts on the Geometry for analytical and IBL lighting.
  126125. * It also prefilter the roughness map based on the bump values.
  126126. */
  126127. protected _enableSpecularAntiAliasing: boolean;
  126128. /**
  126129. * Default configuration related to image processing available in the PBR Material.
  126130. */
  126131. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  126132. /**
  126133. * Keep track of the image processing observer to allow dispose and replace.
  126134. */
  126135. private _imageProcessingObserver;
  126136. /**
  126137. * Attaches a new image processing configuration to the PBR Material.
  126138. * @param configuration
  126139. */
  126140. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  126141. /**
  126142. * Stores the available render targets.
  126143. */
  126144. private _renderTargets;
  126145. /**
  126146. * Sets the global ambient color for the material used in lighting calculations.
  126147. */
  126148. private _globalAmbientColor;
  126149. /**
  126150. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  126151. */
  126152. private _useLogarithmicDepth;
  126153. /**
  126154. * If set to true, no lighting calculations will be applied.
  126155. */
  126156. private _unlit;
  126157. private _debugMode;
  126158. /**
  126159. * @hidden
  126160. * This is reserved for the inspector.
  126161. * Defines the material debug mode.
  126162. * It helps seeing only some components of the material while troubleshooting.
  126163. */
  126164. debugMode: number;
  126165. /**
  126166. * @hidden
  126167. * This is reserved for the inspector.
  126168. * Specify from where on screen the debug mode should start.
  126169. * The value goes from -1 (full screen) to 1 (not visible)
  126170. * It helps with side by side comparison against the final render
  126171. * This defaults to -1
  126172. */
  126173. private debugLimit;
  126174. /**
  126175. * @hidden
  126176. * This is reserved for the inspector.
  126177. * As the default viewing range might not be enough (if the ambient is really small for instance)
  126178. * You can use the factor to better multiply the final value.
  126179. */
  126180. private debugFactor;
  126181. /**
  126182. * Defines the clear coat layer parameters for the material.
  126183. */
  126184. readonly clearCoat: PBRClearCoatConfiguration;
  126185. /**
  126186. * Defines the anisotropic parameters for the material.
  126187. */
  126188. readonly anisotropy: PBRAnisotropicConfiguration;
  126189. /**
  126190. * Defines the BRDF parameters for the material.
  126191. */
  126192. readonly brdf: PBRBRDFConfiguration;
  126193. /**
  126194. * Defines the Sheen parameters for the material.
  126195. */
  126196. readonly sheen: PBRSheenConfiguration;
  126197. /**
  126198. * Defines the SubSurface parameters for the material.
  126199. */
  126200. readonly subSurface: PBRSubSurfaceConfiguration;
  126201. /**
  126202. * Custom callback helping to override the default shader used in the material.
  126203. */
  126204. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines, attributes?: string[]) => string;
  126205. protected _rebuildInParallel: boolean;
  126206. /**
  126207. * Instantiates a new PBRMaterial instance.
  126208. *
  126209. * @param name The material name
  126210. * @param scene The scene the material will be use in.
  126211. */
  126212. constructor(name: string, scene: Scene);
  126213. /**
  126214. * Gets a boolean indicating that current material needs to register RTT
  126215. */
  126216. get hasRenderTargetTextures(): boolean;
  126217. /**
  126218. * Gets the name of the material class.
  126219. */
  126220. getClassName(): string;
  126221. /**
  126222. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  126223. */
  126224. get useLogarithmicDepth(): boolean;
  126225. /**
  126226. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  126227. */
  126228. set useLogarithmicDepth(value: boolean);
  126229. /**
  126230. * Returns true if alpha blending should be disabled.
  126231. */
  126232. protected get _disableAlphaBlending(): boolean;
  126233. /**
  126234. * Specifies whether or not this material should be rendered in alpha blend mode.
  126235. */
  126236. needAlphaBlending(): boolean;
  126237. /**
  126238. * Specifies whether or not this material should be rendered in alpha test mode.
  126239. */
  126240. needAlphaTesting(): boolean;
  126241. /**
  126242. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  126243. */
  126244. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  126245. /**
  126246. * Gets the texture used for the alpha test.
  126247. */
  126248. getAlphaTestTexture(): Nullable<BaseTexture>;
  126249. /**
  126250. * Specifies that the submesh is ready to be used.
  126251. * @param mesh - BJS mesh.
  126252. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  126253. * @param useInstances - Specifies that instances should be used.
  126254. * @returns - boolean indicating that the submesh is ready or not.
  126255. */
  126256. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  126257. /**
  126258. * Specifies if the material uses metallic roughness workflow.
  126259. * @returns boolean specifiying if the material uses metallic roughness workflow.
  126260. */
  126261. isMetallicWorkflow(): boolean;
  126262. private _prepareEffect;
  126263. private _prepareDefines;
  126264. /**
  126265. * Force shader compilation
  126266. */
  126267. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  126268. /**
  126269. * Initializes the uniform buffer layout for the shader.
  126270. */
  126271. buildUniformLayout(): void;
  126272. /**
  126273. * Unbinds the material from the mesh
  126274. */
  126275. unbind(): void;
  126276. /**
  126277. * Binds the submesh data.
  126278. * @param world - The world matrix.
  126279. * @param mesh - The BJS mesh.
  126280. * @param subMesh - A submesh of the BJS mesh.
  126281. */
  126282. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  126283. /**
  126284. * Returns the animatable textures.
  126285. * @returns - Array of animatable textures.
  126286. */
  126287. getAnimatables(): IAnimatable[];
  126288. /**
  126289. * Returns the texture used for reflections.
  126290. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  126291. */
  126292. private _getReflectionTexture;
  126293. /**
  126294. * Returns an array of the actively used textures.
  126295. * @returns - Array of BaseTextures
  126296. */
  126297. getActiveTextures(): BaseTexture[];
  126298. /**
  126299. * Checks to see if a texture is used in the material.
  126300. * @param texture - Base texture to use.
  126301. * @returns - Boolean specifying if a texture is used in the material.
  126302. */
  126303. hasTexture(texture: BaseTexture): boolean;
  126304. /**
  126305. * Disposes the resources of the material.
  126306. * @param forceDisposeEffect - Forces the disposal of effects.
  126307. * @param forceDisposeTextures - Forces the disposal of all textures.
  126308. */
  126309. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  126310. }
  126311. }
  126312. declare module BABYLON {
  126313. /**
  126314. * The Physically based material of BJS.
  126315. *
  126316. * This offers the main features of a standard PBR material.
  126317. * For more information, please refer to the documentation :
  126318. * https://doc.babylonjs.com/how_to/physically_based_rendering
  126319. */
  126320. export class PBRMaterial extends PBRBaseMaterial {
  126321. /**
  126322. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  126323. */
  126324. static readonly PBRMATERIAL_OPAQUE: number;
  126325. /**
  126326. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  126327. */
  126328. static readonly PBRMATERIAL_ALPHATEST: number;
  126329. /**
  126330. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  126331. */
  126332. static readonly PBRMATERIAL_ALPHABLEND: number;
  126333. /**
  126334. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  126335. * They are also discarded below the alpha cutoff threshold to improve performances.
  126336. */
  126337. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  126338. /**
  126339. * Defines the default value of how much AO map is occluding the analytical lights
  126340. * (point spot...).
  126341. */
  126342. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  126343. /**
  126344. * Intensity of the direct lights e.g. the four lights available in your scene.
  126345. * This impacts both the direct diffuse and specular highlights.
  126346. */
  126347. directIntensity: number;
  126348. /**
  126349. * Intensity of the emissive part of the material.
  126350. * This helps controlling the emissive effect without modifying the emissive color.
  126351. */
  126352. emissiveIntensity: number;
  126353. /**
  126354. * Intensity of the environment e.g. how much the environment will light the object
  126355. * either through harmonics for rough material or through the refelction for shiny ones.
  126356. */
  126357. environmentIntensity: number;
  126358. /**
  126359. * This is a special control allowing the reduction of the specular highlights coming from the
  126360. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  126361. */
  126362. specularIntensity: number;
  126363. /**
  126364. * Debug Control allowing disabling the bump map on this material.
  126365. */
  126366. disableBumpMap: boolean;
  126367. /**
  126368. * AKA Diffuse Texture in standard nomenclature.
  126369. */
  126370. albedoTexture: BaseTexture;
  126371. /**
  126372. * AKA Occlusion Texture in other nomenclature.
  126373. */
  126374. ambientTexture: BaseTexture;
  126375. /**
  126376. * AKA Occlusion Texture Intensity in other nomenclature.
  126377. */
  126378. ambientTextureStrength: number;
  126379. /**
  126380. * Defines how much the AO map is occluding the analytical lights (point spot...).
  126381. * 1 means it completely occludes it
  126382. * 0 mean it has no impact
  126383. */
  126384. ambientTextureImpactOnAnalyticalLights: number;
  126385. /**
  126386. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  126387. */
  126388. opacityTexture: BaseTexture;
  126389. /**
  126390. * Stores the reflection values in a texture.
  126391. */
  126392. reflectionTexture: Nullable<BaseTexture>;
  126393. /**
  126394. * Stores the emissive values in a texture.
  126395. */
  126396. emissiveTexture: BaseTexture;
  126397. /**
  126398. * AKA Specular texture in other nomenclature.
  126399. */
  126400. reflectivityTexture: BaseTexture;
  126401. /**
  126402. * Used to switch from specular/glossiness to metallic/roughness workflow.
  126403. */
  126404. metallicTexture: BaseTexture;
  126405. /**
  126406. * Specifies the metallic scalar of the metallic/roughness workflow.
  126407. * Can also be used to scale the metalness values of the metallic texture.
  126408. */
  126409. metallic: Nullable<number>;
  126410. /**
  126411. * Specifies the roughness scalar of the metallic/roughness workflow.
  126412. * Can also be used to scale the roughness values of the metallic texture.
  126413. */
  126414. roughness: Nullable<number>;
  126415. /**
  126416. * Specifies the an F0 factor to help configuring the material F0.
  126417. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  126418. * to 0.5 the previously hard coded value stays the same.
  126419. * Can also be used to scale the F0 values of the metallic texture.
  126420. */
  126421. metallicF0Factor: number;
  126422. /**
  126423. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  126424. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  126425. * your expectation as it multiplies with the texture data.
  126426. */
  126427. useMetallicF0FactorFromMetallicTexture: boolean;
  126428. /**
  126429. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  126430. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  126431. */
  126432. microSurfaceTexture: BaseTexture;
  126433. /**
  126434. * Stores surface normal data used to displace a mesh in a texture.
  126435. */
  126436. bumpTexture: BaseTexture;
  126437. /**
  126438. * Stores the pre-calculated light information of a mesh in a texture.
  126439. */
  126440. lightmapTexture: BaseTexture;
  126441. /**
  126442. * Stores the refracted light information in a texture.
  126443. */
  126444. get refractionTexture(): Nullable<BaseTexture>;
  126445. set refractionTexture(value: Nullable<BaseTexture>);
  126446. /**
  126447. * The color of a material in ambient lighting.
  126448. */
  126449. ambientColor: Color3;
  126450. /**
  126451. * AKA Diffuse Color in other nomenclature.
  126452. */
  126453. albedoColor: Color3;
  126454. /**
  126455. * AKA Specular Color in other nomenclature.
  126456. */
  126457. reflectivityColor: Color3;
  126458. /**
  126459. * The color reflected from the material.
  126460. */
  126461. reflectionColor: Color3;
  126462. /**
  126463. * The color emitted from the material.
  126464. */
  126465. emissiveColor: Color3;
  126466. /**
  126467. * AKA Glossiness in other nomenclature.
  126468. */
  126469. microSurface: number;
  126470. /**
  126471. * source material index of refraction (IOR)' / 'destination material IOR.
  126472. */
  126473. get indexOfRefraction(): number;
  126474. set indexOfRefraction(value: number);
  126475. /**
  126476. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  126477. */
  126478. get invertRefractionY(): boolean;
  126479. set invertRefractionY(value: boolean);
  126480. /**
  126481. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  126482. * Materials half opaque for instance using refraction could benefit from this control.
  126483. */
  126484. get linkRefractionWithTransparency(): boolean;
  126485. set linkRefractionWithTransparency(value: boolean);
  126486. /**
  126487. * If true, the light map contains occlusion information instead of lighting info.
  126488. */
  126489. useLightmapAsShadowmap: boolean;
  126490. /**
  126491. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  126492. */
  126493. useAlphaFromAlbedoTexture: boolean;
  126494. /**
  126495. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  126496. */
  126497. forceAlphaTest: boolean;
  126498. /**
  126499. * Defines the alpha limits in alpha test mode.
  126500. */
  126501. alphaCutOff: number;
  126502. /**
  126503. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  126504. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  126505. */
  126506. useSpecularOverAlpha: boolean;
  126507. /**
  126508. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  126509. */
  126510. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  126511. /**
  126512. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  126513. */
  126514. useRoughnessFromMetallicTextureAlpha: boolean;
  126515. /**
  126516. * Specifies if the metallic texture contains the roughness information in its green channel.
  126517. */
  126518. useRoughnessFromMetallicTextureGreen: boolean;
  126519. /**
  126520. * Specifies if the metallic texture contains the metallness information in its blue channel.
  126521. */
  126522. useMetallnessFromMetallicTextureBlue: boolean;
  126523. /**
  126524. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  126525. */
  126526. useAmbientOcclusionFromMetallicTextureRed: boolean;
  126527. /**
  126528. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  126529. */
  126530. useAmbientInGrayScale: boolean;
  126531. /**
  126532. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  126533. * The material will try to infer what glossiness each pixel should be.
  126534. */
  126535. useAutoMicroSurfaceFromReflectivityMap: boolean;
  126536. /**
  126537. * BJS is using an harcoded light falloff based on a manually sets up range.
  126538. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  126539. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  126540. */
  126541. get usePhysicalLightFalloff(): boolean;
  126542. /**
  126543. * BJS is using an harcoded light falloff based on a manually sets up range.
  126544. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  126545. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  126546. */
  126547. set usePhysicalLightFalloff(value: boolean);
  126548. /**
  126549. * In order to support the falloff compatibility with gltf, a special mode has been added
  126550. * to reproduce the gltf light falloff.
  126551. */
  126552. get useGLTFLightFalloff(): boolean;
  126553. /**
  126554. * In order to support the falloff compatibility with gltf, a special mode has been added
  126555. * to reproduce the gltf light falloff.
  126556. */
  126557. set useGLTFLightFalloff(value: boolean);
  126558. /**
  126559. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  126560. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  126561. */
  126562. useRadianceOverAlpha: boolean;
  126563. /**
  126564. * Allows using an object space normal map (instead of tangent space).
  126565. */
  126566. useObjectSpaceNormalMap: boolean;
  126567. /**
  126568. * Allows using the bump map in parallax mode.
  126569. */
  126570. useParallax: boolean;
  126571. /**
  126572. * Allows using the bump map in parallax occlusion mode.
  126573. */
  126574. useParallaxOcclusion: boolean;
  126575. /**
  126576. * Controls the scale bias of the parallax mode.
  126577. */
  126578. parallaxScaleBias: number;
  126579. /**
  126580. * If sets to true, disables all the lights affecting the material.
  126581. */
  126582. disableLighting: boolean;
  126583. /**
  126584. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  126585. */
  126586. forceIrradianceInFragment: boolean;
  126587. /**
  126588. * Number of Simultaneous lights allowed on the material.
  126589. */
  126590. maxSimultaneousLights: number;
  126591. /**
  126592. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  126593. */
  126594. invertNormalMapX: boolean;
  126595. /**
  126596. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  126597. */
  126598. invertNormalMapY: boolean;
  126599. /**
  126600. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  126601. */
  126602. twoSidedLighting: boolean;
  126603. /**
  126604. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  126605. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  126606. */
  126607. useAlphaFresnel: boolean;
  126608. /**
  126609. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  126610. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  126611. */
  126612. useLinearAlphaFresnel: boolean;
  126613. /**
  126614. * Let user defines the brdf lookup texture used for IBL.
  126615. * A default 8bit version is embedded but you could point at :
  126616. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  126617. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  126618. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  126619. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  126620. */
  126621. environmentBRDFTexture: Nullable<BaseTexture>;
  126622. /**
  126623. * Force normal to face away from face.
  126624. */
  126625. forceNormalForward: boolean;
  126626. /**
  126627. * Enables specular anti aliasing in the PBR shader.
  126628. * It will both interacts on the Geometry for analytical and IBL lighting.
  126629. * It also prefilter the roughness map based on the bump values.
  126630. */
  126631. enableSpecularAntiAliasing: boolean;
  126632. /**
  126633. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  126634. * makes the reflect vector face the model (under horizon).
  126635. */
  126636. useHorizonOcclusion: boolean;
  126637. /**
  126638. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  126639. * too much the area relying on ambient texture to define their ambient occlusion.
  126640. */
  126641. useRadianceOcclusion: boolean;
  126642. /**
  126643. * If set to true, no lighting calculations will be applied.
  126644. */
  126645. unlit: boolean;
  126646. /**
  126647. * Gets the image processing configuration used either in this material.
  126648. */
  126649. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  126650. /**
  126651. * Sets the Default image processing configuration used either in the this material.
  126652. *
  126653. * If sets to null, the scene one is in use.
  126654. */
  126655. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  126656. /**
  126657. * Gets wether the color curves effect is enabled.
  126658. */
  126659. get cameraColorCurvesEnabled(): boolean;
  126660. /**
  126661. * Sets wether the color curves effect is enabled.
  126662. */
  126663. set cameraColorCurvesEnabled(value: boolean);
  126664. /**
  126665. * Gets wether the color grading effect is enabled.
  126666. */
  126667. get cameraColorGradingEnabled(): boolean;
  126668. /**
  126669. * Gets wether the color grading effect is enabled.
  126670. */
  126671. set cameraColorGradingEnabled(value: boolean);
  126672. /**
  126673. * Gets wether tonemapping is enabled or not.
  126674. */
  126675. get cameraToneMappingEnabled(): boolean;
  126676. /**
  126677. * Sets wether tonemapping is enabled or not
  126678. */
  126679. set cameraToneMappingEnabled(value: boolean);
  126680. /**
  126681. * The camera exposure used on this material.
  126682. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  126683. * This corresponds to a photographic exposure.
  126684. */
  126685. get cameraExposure(): number;
  126686. /**
  126687. * The camera exposure used on this material.
  126688. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  126689. * This corresponds to a photographic exposure.
  126690. */
  126691. set cameraExposure(value: number);
  126692. /**
  126693. * Gets The camera contrast used on this material.
  126694. */
  126695. get cameraContrast(): number;
  126696. /**
  126697. * Sets The camera contrast used on this material.
  126698. */
  126699. set cameraContrast(value: number);
  126700. /**
  126701. * Gets the Color Grading 2D Lookup Texture.
  126702. */
  126703. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  126704. /**
  126705. * Sets the Color Grading 2D Lookup Texture.
  126706. */
  126707. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  126708. /**
  126709. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  126710. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  126711. * 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;
  126712. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  126713. */
  126714. get cameraColorCurves(): Nullable<ColorCurves>;
  126715. /**
  126716. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  126717. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  126718. * 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;
  126719. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  126720. */
  126721. set cameraColorCurves(value: Nullable<ColorCurves>);
  126722. /**
  126723. * Instantiates a new PBRMaterial instance.
  126724. *
  126725. * @param name The material name
  126726. * @param scene The scene the material will be use in.
  126727. */
  126728. constructor(name: string, scene: Scene);
  126729. /**
  126730. * Returns the name of this material class.
  126731. */
  126732. getClassName(): string;
  126733. /**
  126734. * Makes a duplicate of the current material.
  126735. * @param name - name to use for the new material.
  126736. */
  126737. clone(name: string): PBRMaterial;
  126738. /**
  126739. * Serializes this PBR Material.
  126740. * @returns - An object with the serialized material.
  126741. */
  126742. serialize(): any;
  126743. /**
  126744. * Parses a PBR Material from a serialized object.
  126745. * @param source - Serialized object.
  126746. * @param scene - BJS scene instance.
  126747. * @param rootUrl - url for the scene object
  126748. * @returns - PBRMaterial
  126749. */
  126750. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  126751. }
  126752. }
  126753. declare module BABYLON {
  126754. /**
  126755. * Direct draw surface info
  126756. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  126757. */
  126758. export interface DDSInfo {
  126759. /**
  126760. * Width of the texture
  126761. */
  126762. width: number;
  126763. /**
  126764. * Width of the texture
  126765. */
  126766. height: number;
  126767. /**
  126768. * Number of Mipmaps for the texture
  126769. * @see https://en.wikipedia.org/wiki/Mipmap
  126770. */
  126771. mipmapCount: number;
  126772. /**
  126773. * If the textures format is a known fourCC format
  126774. * @see https://www.fourcc.org/
  126775. */
  126776. isFourCC: boolean;
  126777. /**
  126778. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  126779. */
  126780. isRGB: boolean;
  126781. /**
  126782. * If the texture is a lumincance format
  126783. */
  126784. isLuminance: boolean;
  126785. /**
  126786. * If this is a cube texture
  126787. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  126788. */
  126789. isCube: boolean;
  126790. /**
  126791. * If the texture is a compressed format eg. FOURCC_DXT1
  126792. */
  126793. isCompressed: boolean;
  126794. /**
  126795. * The dxgiFormat of the texture
  126796. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  126797. */
  126798. dxgiFormat: number;
  126799. /**
  126800. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  126801. */
  126802. textureType: number;
  126803. /**
  126804. * Sphericle polynomial created for the dds texture
  126805. */
  126806. sphericalPolynomial?: SphericalPolynomial;
  126807. }
  126808. /**
  126809. * Class used to provide DDS decompression tools
  126810. */
  126811. export class DDSTools {
  126812. /**
  126813. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  126814. */
  126815. static StoreLODInAlphaChannel: boolean;
  126816. /**
  126817. * Gets DDS information from an array buffer
  126818. * @param data defines the array buffer view to read data from
  126819. * @returns the DDS information
  126820. */
  126821. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  126822. private static _FloatView;
  126823. private static _Int32View;
  126824. private static _ToHalfFloat;
  126825. private static _FromHalfFloat;
  126826. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  126827. private static _GetHalfFloatRGBAArrayBuffer;
  126828. private static _GetFloatRGBAArrayBuffer;
  126829. private static _GetFloatAsUIntRGBAArrayBuffer;
  126830. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  126831. private static _GetRGBAArrayBuffer;
  126832. private static _ExtractLongWordOrder;
  126833. private static _GetRGBArrayBuffer;
  126834. private static _GetLuminanceArrayBuffer;
  126835. /**
  126836. * Uploads DDS Levels to a Babylon Texture
  126837. * @hidden
  126838. */
  126839. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  126840. }
  126841. interface ThinEngine {
  126842. /**
  126843. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  126844. * @param rootUrl defines the url where the file to load is located
  126845. * @param scene defines the current scene
  126846. * @param lodScale defines scale to apply to the mip map selection
  126847. * @param lodOffset defines offset to apply to the mip map selection
  126848. * @param onLoad defines an optional callback raised when the texture is loaded
  126849. * @param onError defines an optional callback raised if there is an issue to load the texture
  126850. * @param format defines the format of the data
  126851. * @param forcedExtension defines the extension to use to pick the right loader
  126852. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  126853. * @returns the cube texture as an InternalTexture
  126854. */
  126855. 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;
  126856. }
  126857. }
  126858. declare module BABYLON {
  126859. /**
  126860. * Implementation of the DDS Texture Loader.
  126861. * @hidden
  126862. */
  126863. export class _DDSTextureLoader implements IInternalTextureLoader {
  126864. /**
  126865. * Defines wether the loader supports cascade loading the different faces.
  126866. */
  126867. readonly supportCascades: boolean;
  126868. /**
  126869. * This returns if the loader support the current file information.
  126870. * @param extension defines the file extension of the file being loaded
  126871. * @returns true if the loader can load the specified file
  126872. */
  126873. canLoad(extension: string): boolean;
  126874. /**
  126875. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  126876. * @param data contains the texture data
  126877. * @param texture defines the BabylonJS internal texture
  126878. * @param createPolynomials will be true if polynomials have been requested
  126879. * @param onLoad defines the callback to trigger once the texture is ready
  126880. * @param onError defines the callback to trigger in case of error
  126881. */
  126882. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  126883. /**
  126884. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  126885. * @param data contains the texture data
  126886. * @param texture defines the BabylonJS internal texture
  126887. * @param callback defines the method to call once ready to upload
  126888. */
  126889. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  126890. }
  126891. }
  126892. declare module BABYLON {
  126893. /**
  126894. * Implementation of the ENV Texture Loader.
  126895. * @hidden
  126896. */
  126897. export class _ENVTextureLoader implements IInternalTextureLoader {
  126898. /**
  126899. * Defines wether the loader supports cascade loading the different faces.
  126900. */
  126901. readonly supportCascades: boolean;
  126902. /**
  126903. * This returns if the loader support the current file information.
  126904. * @param extension defines the file extension of the file being loaded
  126905. * @returns true if the loader can load the specified file
  126906. */
  126907. canLoad(extension: string): boolean;
  126908. /**
  126909. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  126910. * @param data contains the texture data
  126911. * @param texture defines the BabylonJS internal texture
  126912. * @param createPolynomials will be true if polynomials have been requested
  126913. * @param onLoad defines the callback to trigger once the texture is ready
  126914. * @param onError defines the callback to trigger in case of error
  126915. */
  126916. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  126917. /**
  126918. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  126919. * @param data contains the texture data
  126920. * @param texture defines the BabylonJS internal texture
  126921. * @param callback defines the method to call once ready to upload
  126922. */
  126923. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  126924. }
  126925. }
  126926. declare module BABYLON {
  126927. /**
  126928. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  126929. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  126930. */
  126931. export class KhronosTextureContainer {
  126932. /** contents of the KTX container file */
  126933. data: ArrayBufferView;
  126934. private static HEADER_LEN;
  126935. private static COMPRESSED_2D;
  126936. private static COMPRESSED_3D;
  126937. private static TEX_2D;
  126938. private static TEX_3D;
  126939. /**
  126940. * Gets the openGL type
  126941. */
  126942. glType: number;
  126943. /**
  126944. * Gets the openGL type size
  126945. */
  126946. glTypeSize: number;
  126947. /**
  126948. * Gets the openGL format
  126949. */
  126950. glFormat: number;
  126951. /**
  126952. * Gets the openGL internal format
  126953. */
  126954. glInternalFormat: number;
  126955. /**
  126956. * Gets the base internal format
  126957. */
  126958. glBaseInternalFormat: number;
  126959. /**
  126960. * Gets image width in pixel
  126961. */
  126962. pixelWidth: number;
  126963. /**
  126964. * Gets image height in pixel
  126965. */
  126966. pixelHeight: number;
  126967. /**
  126968. * Gets image depth in pixels
  126969. */
  126970. pixelDepth: number;
  126971. /**
  126972. * Gets the number of array elements
  126973. */
  126974. numberOfArrayElements: number;
  126975. /**
  126976. * Gets the number of faces
  126977. */
  126978. numberOfFaces: number;
  126979. /**
  126980. * Gets the number of mipmap levels
  126981. */
  126982. numberOfMipmapLevels: number;
  126983. /**
  126984. * Gets the bytes of key value data
  126985. */
  126986. bytesOfKeyValueData: number;
  126987. /**
  126988. * Gets the load type
  126989. */
  126990. loadType: number;
  126991. /**
  126992. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  126993. */
  126994. isInvalid: boolean;
  126995. /**
  126996. * Creates a new KhronosTextureContainer
  126997. * @param data contents of the KTX container file
  126998. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  126999. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  127000. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  127001. */
  127002. constructor(
  127003. /** contents of the KTX container file */
  127004. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  127005. /**
  127006. * Uploads KTX content to a Babylon Texture.
  127007. * It is assumed that the texture has already been created & is currently bound
  127008. * @hidden
  127009. */
  127010. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  127011. private _upload2DCompressedLevels;
  127012. /**
  127013. * Checks if the given data starts with a KTX file identifier.
  127014. * @param data the data to check
  127015. * @returns true if the data is a KTX file or false otherwise
  127016. */
  127017. static IsValid(data: ArrayBufferView): boolean;
  127018. }
  127019. }
  127020. declare module BABYLON {
  127021. /**
  127022. * Class for loading KTX2 files
  127023. * !!! Experimental Extension Subject to Changes !!!
  127024. * @hidden
  127025. */
  127026. export class KhronosTextureContainer2 {
  127027. private static _ModulePromise;
  127028. private static _TranscodeFormat;
  127029. constructor(engine: ThinEngine);
  127030. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  127031. private _determineTranscodeFormat;
  127032. /**
  127033. * Checks if the given data starts with a KTX2 file identifier.
  127034. * @param data the data to check
  127035. * @returns true if the data is a KTX2 file or false otherwise
  127036. */
  127037. static IsValid(data: ArrayBufferView): boolean;
  127038. }
  127039. }
  127040. declare module BABYLON {
  127041. /**
  127042. * Implementation of the KTX Texture Loader.
  127043. * @hidden
  127044. */
  127045. export class _KTXTextureLoader implements IInternalTextureLoader {
  127046. /**
  127047. * Defines wether the loader supports cascade loading the different faces.
  127048. */
  127049. readonly supportCascades: boolean;
  127050. /**
  127051. * This returns if the loader support the current file information.
  127052. * @param extension defines the file extension of the file being loaded
  127053. * @returns true if the loader can load the specified file
  127054. */
  127055. canLoad(extension: string): boolean;
  127056. /**
  127057. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  127058. * @param data contains the texture data
  127059. * @param texture defines the BabylonJS internal texture
  127060. * @param createPolynomials will be true if polynomials have been requested
  127061. * @param onLoad defines the callback to trigger once the texture is ready
  127062. * @param onError defines the callback to trigger in case of error
  127063. */
  127064. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  127065. /**
  127066. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  127067. * @param data contains the texture data
  127068. * @param texture defines the BabylonJS internal texture
  127069. * @param callback defines the method to call once ready to upload
  127070. */
  127071. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  127072. }
  127073. }
  127074. declare module BABYLON {
  127075. /** @hidden */
  127076. export var _forceSceneHelpersToBundle: boolean;
  127077. interface Scene {
  127078. /**
  127079. * Creates a default light for the scene.
  127080. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  127081. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  127082. */
  127083. createDefaultLight(replace?: boolean): void;
  127084. /**
  127085. * Creates a default camera for the scene.
  127086. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  127087. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  127088. * @param replace has default false, when true replaces the active camera in the scene
  127089. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  127090. */
  127091. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  127092. /**
  127093. * Creates a default camera and a default light.
  127094. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  127095. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  127096. * @param replace has the default false, when true replaces the active camera/light in the scene
  127097. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  127098. */
  127099. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  127100. /**
  127101. * Creates a new sky box
  127102. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  127103. * @param environmentTexture defines the texture to use as environment texture
  127104. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  127105. * @param scale defines the overall scale of the skybox
  127106. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  127107. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  127108. * @returns a new mesh holding the sky box
  127109. */
  127110. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  127111. /**
  127112. * Creates a new environment
  127113. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  127114. * @param options defines the options you can use to configure the environment
  127115. * @returns the new EnvironmentHelper
  127116. */
  127117. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  127118. /**
  127119. * Creates a new VREXperienceHelper
  127120. * @see http://doc.babylonjs.com/how_to/webvr_helper
  127121. * @param webVROptions defines the options used to create the new VREXperienceHelper
  127122. * @returns a new VREXperienceHelper
  127123. */
  127124. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  127125. /**
  127126. * Creates a new WebXRDefaultExperience
  127127. * @see http://doc.babylonjs.com/how_to/webxr
  127128. * @param options experience options
  127129. * @returns a promise for a new WebXRDefaultExperience
  127130. */
  127131. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  127132. }
  127133. }
  127134. declare module BABYLON {
  127135. /**
  127136. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  127137. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  127138. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  127139. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  127140. */
  127141. export class VideoDome extends TransformNode {
  127142. /**
  127143. * Define the video source as a Monoscopic panoramic 360 video.
  127144. */
  127145. static readonly MODE_MONOSCOPIC: number;
  127146. /**
  127147. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  127148. */
  127149. static readonly MODE_TOPBOTTOM: number;
  127150. /**
  127151. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  127152. */
  127153. static readonly MODE_SIDEBYSIDE: number;
  127154. private _halfDome;
  127155. private _useDirectMapping;
  127156. /**
  127157. * The video texture being displayed on the sphere
  127158. */
  127159. protected _videoTexture: VideoTexture;
  127160. /**
  127161. * Gets the video texture being displayed on the sphere
  127162. */
  127163. get videoTexture(): VideoTexture;
  127164. /**
  127165. * The skybox material
  127166. */
  127167. protected _material: BackgroundMaterial;
  127168. /**
  127169. * The surface used for the skybox
  127170. */
  127171. protected _mesh: Mesh;
  127172. /**
  127173. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  127174. */
  127175. private _halfDomeMask;
  127176. /**
  127177. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  127178. * Also see the options.resolution property.
  127179. */
  127180. get fovMultiplier(): number;
  127181. set fovMultiplier(value: number);
  127182. private _videoMode;
  127183. /**
  127184. * Gets or set the current video mode for the video. It can be:
  127185. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  127186. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  127187. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  127188. */
  127189. get videoMode(): number;
  127190. set videoMode(value: number);
  127191. /**
  127192. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  127193. *
  127194. */
  127195. get halfDome(): boolean;
  127196. /**
  127197. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  127198. */
  127199. set halfDome(enabled: boolean);
  127200. /**
  127201. * Oberserver used in Stereoscopic VR Mode.
  127202. */
  127203. private _onBeforeCameraRenderObserver;
  127204. /**
  127205. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  127206. * @param name Element's name, child elements will append suffixes for their own names.
  127207. * @param urlsOrVideo defines the url(s) or the video element to use
  127208. * @param options An object containing optional or exposed sub element properties
  127209. */
  127210. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  127211. resolution?: number;
  127212. clickToPlay?: boolean;
  127213. autoPlay?: boolean;
  127214. loop?: boolean;
  127215. size?: number;
  127216. poster?: string;
  127217. faceForward?: boolean;
  127218. useDirectMapping?: boolean;
  127219. halfDomeMode?: boolean;
  127220. }, scene: Scene);
  127221. private _changeVideoMode;
  127222. /**
  127223. * Releases resources associated with this node.
  127224. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  127225. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  127226. */
  127227. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  127228. }
  127229. }
  127230. declare module BABYLON {
  127231. /**
  127232. * This class can be used to get instrumentation data from a Babylon engine
  127233. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  127234. */
  127235. export class EngineInstrumentation implements IDisposable {
  127236. /**
  127237. * Define the instrumented engine.
  127238. */
  127239. engine: Engine;
  127240. private _captureGPUFrameTime;
  127241. private _gpuFrameTimeToken;
  127242. private _gpuFrameTime;
  127243. private _captureShaderCompilationTime;
  127244. private _shaderCompilationTime;
  127245. private _onBeginFrameObserver;
  127246. private _onEndFrameObserver;
  127247. private _onBeforeShaderCompilationObserver;
  127248. private _onAfterShaderCompilationObserver;
  127249. /**
  127250. * Gets the perf counter used for GPU frame time
  127251. */
  127252. get gpuFrameTimeCounter(): PerfCounter;
  127253. /**
  127254. * Gets the GPU frame time capture status
  127255. */
  127256. get captureGPUFrameTime(): boolean;
  127257. /**
  127258. * Enable or disable the GPU frame time capture
  127259. */
  127260. set captureGPUFrameTime(value: boolean);
  127261. /**
  127262. * Gets the perf counter used for shader compilation time
  127263. */
  127264. get shaderCompilationTimeCounter(): PerfCounter;
  127265. /**
  127266. * Gets the shader compilation time capture status
  127267. */
  127268. get captureShaderCompilationTime(): boolean;
  127269. /**
  127270. * Enable or disable the shader compilation time capture
  127271. */
  127272. set captureShaderCompilationTime(value: boolean);
  127273. /**
  127274. * Instantiates a new engine instrumentation.
  127275. * This class can be used to get instrumentation data from a Babylon engine
  127276. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  127277. * @param engine Defines the engine to instrument
  127278. */
  127279. constructor(
  127280. /**
  127281. * Define the instrumented engine.
  127282. */
  127283. engine: Engine);
  127284. /**
  127285. * Dispose and release associated resources.
  127286. */
  127287. dispose(): void;
  127288. }
  127289. }
  127290. declare module BABYLON {
  127291. /**
  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#sceneinstrumentation
  127294. */
  127295. export class SceneInstrumentation implements IDisposable {
  127296. /**
  127297. * Defines the scene to instrument
  127298. */
  127299. scene: Scene;
  127300. private _captureActiveMeshesEvaluationTime;
  127301. private _activeMeshesEvaluationTime;
  127302. private _captureRenderTargetsRenderTime;
  127303. private _renderTargetsRenderTime;
  127304. private _captureFrameTime;
  127305. private _frameTime;
  127306. private _captureRenderTime;
  127307. private _renderTime;
  127308. private _captureInterFrameTime;
  127309. private _interFrameTime;
  127310. private _captureParticlesRenderTime;
  127311. private _particlesRenderTime;
  127312. private _captureSpritesRenderTime;
  127313. private _spritesRenderTime;
  127314. private _capturePhysicsTime;
  127315. private _physicsTime;
  127316. private _captureAnimationsTime;
  127317. private _animationsTime;
  127318. private _captureCameraRenderTime;
  127319. private _cameraRenderTime;
  127320. private _onBeforeActiveMeshesEvaluationObserver;
  127321. private _onAfterActiveMeshesEvaluationObserver;
  127322. private _onBeforeRenderTargetsRenderObserver;
  127323. private _onAfterRenderTargetsRenderObserver;
  127324. private _onAfterRenderObserver;
  127325. private _onBeforeDrawPhaseObserver;
  127326. private _onAfterDrawPhaseObserver;
  127327. private _onBeforeAnimationsObserver;
  127328. private _onBeforeParticlesRenderingObserver;
  127329. private _onAfterParticlesRenderingObserver;
  127330. private _onBeforeSpritesRenderingObserver;
  127331. private _onAfterSpritesRenderingObserver;
  127332. private _onBeforePhysicsObserver;
  127333. private _onAfterPhysicsObserver;
  127334. private _onAfterAnimationsObserver;
  127335. private _onBeforeCameraRenderObserver;
  127336. private _onAfterCameraRenderObserver;
  127337. /**
  127338. * Gets the perf counter used for active meshes evaluation time
  127339. */
  127340. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  127341. /**
  127342. * Gets the active meshes evaluation time capture status
  127343. */
  127344. get captureActiveMeshesEvaluationTime(): boolean;
  127345. /**
  127346. * Enable or disable the active meshes evaluation time capture
  127347. */
  127348. set captureActiveMeshesEvaluationTime(value: boolean);
  127349. /**
  127350. * Gets the perf counter used for render targets render time
  127351. */
  127352. get renderTargetsRenderTimeCounter(): PerfCounter;
  127353. /**
  127354. * Gets the render targets render time capture status
  127355. */
  127356. get captureRenderTargetsRenderTime(): boolean;
  127357. /**
  127358. * Enable or disable the render targets render time capture
  127359. */
  127360. set captureRenderTargetsRenderTime(value: boolean);
  127361. /**
  127362. * Gets the perf counter used for particles render time
  127363. */
  127364. get particlesRenderTimeCounter(): PerfCounter;
  127365. /**
  127366. * Gets the particles render time capture status
  127367. */
  127368. get captureParticlesRenderTime(): boolean;
  127369. /**
  127370. * Enable or disable the particles render time capture
  127371. */
  127372. set captureParticlesRenderTime(value: boolean);
  127373. /**
  127374. * Gets the perf counter used for sprites render time
  127375. */
  127376. get spritesRenderTimeCounter(): PerfCounter;
  127377. /**
  127378. * Gets the sprites render time capture status
  127379. */
  127380. get captureSpritesRenderTime(): boolean;
  127381. /**
  127382. * Enable or disable the sprites render time capture
  127383. */
  127384. set captureSpritesRenderTime(value: boolean);
  127385. /**
  127386. * Gets the perf counter used for physics time
  127387. */
  127388. get physicsTimeCounter(): PerfCounter;
  127389. /**
  127390. * Gets the physics time capture status
  127391. */
  127392. get capturePhysicsTime(): boolean;
  127393. /**
  127394. * Enable or disable the physics time capture
  127395. */
  127396. set capturePhysicsTime(value: boolean);
  127397. /**
  127398. * Gets the perf counter used for animations time
  127399. */
  127400. get animationsTimeCounter(): PerfCounter;
  127401. /**
  127402. * Gets the animations time capture status
  127403. */
  127404. get captureAnimationsTime(): boolean;
  127405. /**
  127406. * Enable or disable the animations time capture
  127407. */
  127408. set captureAnimationsTime(value: boolean);
  127409. /**
  127410. * Gets the perf counter used for frame time capture
  127411. */
  127412. get frameTimeCounter(): PerfCounter;
  127413. /**
  127414. * Gets the frame time capture status
  127415. */
  127416. get captureFrameTime(): boolean;
  127417. /**
  127418. * Enable or disable the frame time capture
  127419. */
  127420. set captureFrameTime(value: boolean);
  127421. /**
  127422. * Gets the perf counter used for inter-frames time capture
  127423. */
  127424. get interFrameTimeCounter(): PerfCounter;
  127425. /**
  127426. * Gets the inter-frames time capture status
  127427. */
  127428. get captureInterFrameTime(): boolean;
  127429. /**
  127430. * Enable or disable the inter-frames time capture
  127431. */
  127432. set captureInterFrameTime(value: boolean);
  127433. /**
  127434. * Gets the perf counter used for render time capture
  127435. */
  127436. get renderTimeCounter(): PerfCounter;
  127437. /**
  127438. * Gets the render time capture status
  127439. */
  127440. get captureRenderTime(): boolean;
  127441. /**
  127442. * Enable or disable the render time capture
  127443. */
  127444. set captureRenderTime(value: boolean);
  127445. /**
  127446. * Gets the perf counter used for camera render time capture
  127447. */
  127448. get cameraRenderTimeCounter(): PerfCounter;
  127449. /**
  127450. * Gets the camera render time capture status
  127451. */
  127452. get captureCameraRenderTime(): boolean;
  127453. /**
  127454. * Enable or disable the camera render time capture
  127455. */
  127456. set captureCameraRenderTime(value: boolean);
  127457. /**
  127458. * Gets the perf counter used for draw calls
  127459. */
  127460. get drawCallsCounter(): PerfCounter;
  127461. /**
  127462. * Instantiates a new scene instrumentation.
  127463. * This class can be used to get instrumentation data from a Babylon engine
  127464. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  127465. * @param scene Defines the scene to instrument
  127466. */
  127467. constructor(
  127468. /**
  127469. * Defines the scene to instrument
  127470. */
  127471. scene: Scene);
  127472. /**
  127473. * Dispose and release associated resources.
  127474. */
  127475. dispose(): void;
  127476. }
  127477. }
  127478. declare module BABYLON {
  127479. /** @hidden */
  127480. export var glowMapGenerationPixelShader: {
  127481. name: string;
  127482. shader: string;
  127483. };
  127484. }
  127485. declare module BABYLON {
  127486. /** @hidden */
  127487. export var glowMapGenerationVertexShader: {
  127488. name: string;
  127489. shader: string;
  127490. };
  127491. }
  127492. declare module BABYLON {
  127493. /**
  127494. * Effect layer options. This helps customizing the behaviour
  127495. * of the effect layer.
  127496. */
  127497. export interface IEffectLayerOptions {
  127498. /**
  127499. * Multiplication factor apply to the canvas size to compute the render target size
  127500. * used to generated the objects (the smaller the faster).
  127501. */
  127502. mainTextureRatio: number;
  127503. /**
  127504. * Enforces a fixed size texture to ensure effect stability across devices.
  127505. */
  127506. mainTextureFixedSize?: number;
  127507. /**
  127508. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  127509. */
  127510. alphaBlendingMode: number;
  127511. /**
  127512. * The camera attached to the layer.
  127513. */
  127514. camera: Nullable<Camera>;
  127515. /**
  127516. * The rendering group to draw the layer in.
  127517. */
  127518. renderingGroupId: number;
  127519. }
  127520. /**
  127521. * The effect layer Helps adding post process effect blended with the main pass.
  127522. *
  127523. * This can be for instance use to generate glow or higlight effects on the scene.
  127524. *
  127525. * The effect layer class can not be used directly and is intented to inherited from to be
  127526. * customized per effects.
  127527. */
  127528. export abstract class EffectLayer {
  127529. private _vertexBuffers;
  127530. private _indexBuffer;
  127531. private _cachedDefines;
  127532. private _effectLayerMapGenerationEffect;
  127533. private _effectLayerOptions;
  127534. private _mergeEffect;
  127535. protected _scene: Scene;
  127536. protected _engine: Engine;
  127537. protected _maxSize: number;
  127538. protected _mainTextureDesiredSize: ISize;
  127539. protected _mainTexture: RenderTargetTexture;
  127540. protected _shouldRender: boolean;
  127541. protected _postProcesses: PostProcess[];
  127542. protected _textures: BaseTexture[];
  127543. protected _emissiveTextureAndColor: {
  127544. texture: Nullable<BaseTexture>;
  127545. color: Color4;
  127546. };
  127547. /**
  127548. * The name of the layer
  127549. */
  127550. name: string;
  127551. /**
  127552. * The clear color of the texture used to generate the glow map.
  127553. */
  127554. neutralColor: Color4;
  127555. /**
  127556. * Specifies whether the highlight layer is enabled or not.
  127557. */
  127558. isEnabled: boolean;
  127559. /**
  127560. * Gets the camera attached to the layer.
  127561. */
  127562. get camera(): Nullable<Camera>;
  127563. /**
  127564. * Gets the rendering group id the layer should render in.
  127565. */
  127566. get renderingGroupId(): number;
  127567. set renderingGroupId(renderingGroupId: number);
  127568. /**
  127569. * An event triggered when the effect layer has been disposed.
  127570. */
  127571. onDisposeObservable: Observable<EffectLayer>;
  127572. /**
  127573. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  127574. */
  127575. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  127576. /**
  127577. * An event triggered when the generated texture is being merged in the scene.
  127578. */
  127579. onBeforeComposeObservable: Observable<EffectLayer>;
  127580. /**
  127581. * An event triggered when the mesh is rendered into the effect render target.
  127582. */
  127583. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  127584. /**
  127585. * An event triggered after the mesh has been rendered into the effect render target.
  127586. */
  127587. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  127588. /**
  127589. * An event triggered when the generated texture has been merged in the scene.
  127590. */
  127591. onAfterComposeObservable: Observable<EffectLayer>;
  127592. /**
  127593. * An event triggered when the efffect layer changes its size.
  127594. */
  127595. onSizeChangedObservable: Observable<EffectLayer>;
  127596. /** @hidden */
  127597. static _SceneComponentInitialization: (scene: Scene) => void;
  127598. /**
  127599. * Instantiates a new effect Layer and references it in the scene.
  127600. * @param name The name of the layer
  127601. * @param scene The scene to use the layer in
  127602. */
  127603. constructor(
  127604. /** The Friendly of the effect in the scene */
  127605. name: string, scene: Scene);
  127606. /**
  127607. * Get the effect name of the layer.
  127608. * @return The effect name
  127609. */
  127610. abstract getEffectName(): string;
  127611. /**
  127612. * Checks for the readiness of the element composing the layer.
  127613. * @param subMesh the mesh to check for
  127614. * @param useInstances specify whether or not to use instances to render the mesh
  127615. * @return true if ready otherwise, false
  127616. */
  127617. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  127618. /**
  127619. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  127620. * @returns true if the effect requires stencil during the main canvas render pass.
  127621. */
  127622. abstract needStencil(): boolean;
  127623. /**
  127624. * Create the merge effect. This is the shader use to blit the information back
  127625. * to the main canvas at the end of the scene rendering.
  127626. * @returns The effect containing the shader used to merge the effect on the main canvas
  127627. */
  127628. protected abstract _createMergeEffect(): Effect;
  127629. /**
  127630. * Creates the render target textures and post processes used in the effect layer.
  127631. */
  127632. protected abstract _createTextureAndPostProcesses(): void;
  127633. /**
  127634. * Implementation specific of rendering the generating effect on the main canvas.
  127635. * @param effect The effect used to render through
  127636. */
  127637. protected abstract _internalRender(effect: Effect): void;
  127638. /**
  127639. * Sets the required values for both the emissive texture and and the main color.
  127640. */
  127641. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  127642. /**
  127643. * Free any resources and references associated to a mesh.
  127644. * Internal use
  127645. * @param mesh The mesh to free.
  127646. */
  127647. abstract _disposeMesh(mesh: Mesh): void;
  127648. /**
  127649. * Serializes this layer (Glow or Highlight for example)
  127650. * @returns a serialized layer object
  127651. */
  127652. abstract serialize?(): any;
  127653. /**
  127654. * Initializes the effect layer with the required options.
  127655. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  127656. */
  127657. protected _init(options: Partial<IEffectLayerOptions>): void;
  127658. /**
  127659. * Generates the index buffer of the full screen quad blending to the main canvas.
  127660. */
  127661. private _generateIndexBuffer;
  127662. /**
  127663. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  127664. */
  127665. private _generateVertexBuffer;
  127666. /**
  127667. * Sets the main texture desired size which is the closest power of two
  127668. * of the engine canvas size.
  127669. */
  127670. private _setMainTextureSize;
  127671. /**
  127672. * Creates the main texture for the effect layer.
  127673. */
  127674. protected _createMainTexture(): void;
  127675. /**
  127676. * Adds specific effects defines.
  127677. * @param defines The defines to add specifics to.
  127678. */
  127679. protected _addCustomEffectDefines(defines: string[]): void;
  127680. /**
  127681. * Checks for the readiness of the element composing the layer.
  127682. * @param subMesh the mesh to check for
  127683. * @param useInstances specify whether or not to use instances to render the mesh
  127684. * @param emissiveTexture the associated emissive texture used to generate the glow
  127685. * @return true if ready otherwise, false
  127686. */
  127687. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  127688. /**
  127689. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  127690. */
  127691. render(): void;
  127692. /**
  127693. * Determine if a given mesh will be used in the current effect.
  127694. * @param mesh mesh to test
  127695. * @returns true if the mesh will be used
  127696. */
  127697. hasMesh(mesh: AbstractMesh): boolean;
  127698. /**
  127699. * Returns true if the layer contains information to display, otherwise false.
  127700. * @returns true if the glow layer should be rendered
  127701. */
  127702. shouldRender(): boolean;
  127703. /**
  127704. * Returns true if the mesh should render, otherwise false.
  127705. * @param mesh The mesh to render
  127706. * @returns true if it should render otherwise false
  127707. */
  127708. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  127709. /**
  127710. * Returns true if the mesh can be rendered, otherwise false.
  127711. * @param mesh The mesh to render
  127712. * @param material The material used on the mesh
  127713. * @returns true if it can be rendered otherwise false
  127714. */
  127715. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  127716. /**
  127717. * Returns true if the mesh should render, otherwise false.
  127718. * @param mesh The mesh to render
  127719. * @returns true if it should render otherwise false
  127720. */
  127721. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  127722. /**
  127723. * Renders the submesh passed in parameter to the generation map.
  127724. */
  127725. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  127726. /**
  127727. * Defines whether the current material of the mesh should be use to render the effect.
  127728. * @param mesh defines the current mesh to render
  127729. */
  127730. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  127731. /**
  127732. * Rebuild the required buffers.
  127733. * @hidden Internal use only.
  127734. */
  127735. _rebuild(): void;
  127736. /**
  127737. * Dispose only the render target textures and post process.
  127738. */
  127739. private _disposeTextureAndPostProcesses;
  127740. /**
  127741. * Dispose the highlight layer and free resources.
  127742. */
  127743. dispose(): void;
  127744. /**
  127745. * Gets the class name of the effect layer
  127746. * @returns the string with the class name of the effect layer
  127747. */
  127748. getClassName(): string;
  127749. /**
  127750. * Creates an effect layer from parsed effect layer data
  127751. * @param parsedEffectLayer defines effect layer data
  127752. * @param scene defines the current scene
  127753. * @param rootUrl defines the root URL containing the effect layer information
  127754. * @returns a parsed effect Layer
  127755. */
  127756. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  127757. }
  127758. }
  127759. declare module BABYLON {
  127760. interface AbstractScene {
  127761. /**
  127762. * The list of effect layers (highlights/glow) added to the scene
  127763. * @see http://doc.babylonjs.com/how_to/highlight_layer
  127764. * @see http://doc.babylonjs.com/how_to/glow_layer
  127765. */
  127766. effectLayers: Array<EffectLayer>;
  127767. /**
  127768. * Removes the given effect layer from this scene.
  127769. * @param toRemove defines the effect layer to remove
  127770. * @returns the index of the removed effect layer
  127771. */
  127772. removeEffectLayer(toRemove: EffectLayer): number;
  127773. /**
  127774. * Adds the given effect layer to this scene
  127775. * @param newEffectLayer defines the effect layer to add
  127776. */
  127777. addEffectLayer(newEffectLayer: EffectLayer): void;
  127778. }
  127779. /**
  127780. * Defines the layer scene component responsible to manage any effect layers
  127781. * in a given scene.
  127782. */
  127783. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  127784. /**
  127785. * The component name helpfull to identify the component in the list of scene components.
  127786. */
  127787. readonly name: string;
  127788. /**
  127789. * The scene the component belongs to.
  127790. */
  127791. scene: Scene;
  127792. private _engine;
  127793. private _renderEffects;
  127794. private _needStencil;
  127795. private _previousStencilState;
  127796. /**
  127797. * Creates a new instance of the component for the given scene
  127798. * @param scene Defines the scene to register the component in
  127799. */
  127800. constructor(scene: Scene);
  127801. /**
  127802. * Registers the component in a given scene
  127803. */
  127804. register(): void;
  127805. /**
  127806. * Rebuilds the elements related to this component in case of
  127807. * context lost for instance.
  127808. */
  127809. rebuild(): void;
  127810. /**
  127811. * Serializes the component data to the specified json object
  127812. * @param serializationObject The object to serialize to
  127813. */
  127814. serialize(serializationObject: any): void;
  127815. /**
  127816. * Adds all the elements from the container to the scene
  127817. * @param container the container holding the elements
  127818. */
  127819. addFromContainer(container: AbstractScene): void;
  127820. /**
  127821. * Removes all the elements in the container from the scene
  127822. * @param container contains the elements to remove
  127823. * @param dispose if the removed element should be disposed (default: false)
  127824. */
  127825. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  127826. /**
  127827. * Disposes the component and the associated ressources.
  127828. */
  127829. dispose(): void;
  127830. private _isReadyForMesh;
  127831. private _renderMainTexture;
  127832. private _setStencil;
  127833. private _setStencilBack;
  127834. private _draw;
  127835. private _drawCamera;
  127836. private _drawRenderingGroup;
  127837. }
  127838. }
  127839. declare module BABYLON {
  127840. /** @hidden */
  127841. export var glowMapMergePixelShader: {
  127842. name: string;
  127843. shader: string;
  127844. };
  127845. }
  127846. declare module BABYLON {
  127847. /** @hidden */
  127848. export var glowMapMergeVertexShader: {
  127849. name: string;
  127850. shader: string;
  127851. };
  127852. }
  127853. declare module BABYLON {
  127854. interface AbstractScene {
  127855. /**
  127856. * Return a the first highlight layer of the scene with a given name.
  127857. * @param name The name of the highlight layer to look for.
  127858. * @return The highlight layer if found otherwise null.
  127859. */
  127860. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  127861. }
  127862. /**
  127863. * Glow layer options. This helps customizing the behaviour
  127864. * of the glow layer.
  127865. */
  127866. export interface IGlowLayerOptions {
  127867. /**
  127868. * Multiplication factor apply to the canvas size to compute the render target size
  127869. * used to generated the glowing objects (the smaller the faster).
  127870. */
  127871. mainTextureRatio: number;
  127872. /**
  127873. * Enforces a fixed size texture to ensure resize independant blur.
  127874. */
  127875. mainTextureFixedSize?: number;
  127876. /**
  127877. * How big is the kernel of the blur texture.
  127878. */
  127879. blurKernelSize: number;
  127880. /**
  127881. * The camera attached to the layer.
  127882. */
  127883. camera: Nullable<Camera>;
  127884. /**
  127885. * Enable MSAA by chosing the number of samples.
  127886. */
  127887. mainTextureSamples?: number;
  127888. /**
  127889. * The rendering group to draw the layer in.
  127890. */
  127891. renderingGroupId: number;
  127892. }
  127893. /**
  127894. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  127895. *
  127896. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  127897. *
  127898. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  127899. */
  127900. export class GlowLayer extends EffectLayer {
  127901. /**
  127902. * Effect Name of the layer.
  127903. */
  127904. static readonly EffectName: string;
  127905. /**
  127906. * The default blur kernel size used for the glow.
  127907. */
  127908. static DefaultBlurKernelSize: number;
  127909. /**
  127910. * The default texture size ratio used for the glow.
  127911. */
  127912. static DefaultTextureRatio: number;
  127913. /**
  127914. * Sets the kernel size of the blur.
  127915. */
  127916. set blurKernelSize(value: number);
  127917. /**
  127918. * Gets the kernel size of the blur.
  127919. */
  127920. get blurKernelSize(): number;
  127921. /**
  127922. * Sets the glow intensity.
  127923. */
  127924. set intensity(value: number);
  127925. /**
  127926. * Gets the glow intensity.
  127927. */
  127928. get intensity(): number;
  127929. private _options;
  127930. private _intensity;
  127931. private _horizontalBlurPostprocess1;
  127932. private _verticalBlurPostprocess1;
  127933. private _horizontalBlurPostprocess2;
  127934. private _verticalBlurPostprocess2;
  127935. private _blurTexture1;
  127936. private _blurTexture2;
  127937. private _postProcesses1;
  127938. private _postProcesses2;
  127939. private _includedOnlyMeshes;
  127940. private _excludedMeshes;
  127941. private _meshesUsingTheirOwnMaterials;
  127942. /**
  127943. * Callback used to let the user override the color selection on a per mesh basis
  127944. */
  127945. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  127946. /**
  127947. * Callback used to let the user override the texture selection on a per mesh basis
  127948. */
  127949. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  127950. /**
  127951. * Instantiates a new glow Layer and references it to the scene.
  127952. * @param name The name of the layer
  127953. * @param scene The scene to use the layer in
  127954. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  127955. */
  127956. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  127957. /**
  127958. * Get the effect name of the layer.
  127959. * @return The effect name
  127960. */
  127961. getEffectName(): string;
  127962. /**
  127963. * Create the merge effect. This is the shader use to blit the information back
  127964. * to the main canvas at the end of the scene rendering.
  127965. */
  127966. protected _createMergeEffect(): Effect;
  127967. /**
  127968. * Creates the render target textures and post processes used in the glow layer.
  127969. */
  127970. protected _createTextureAndPostProcesses(): void;
  127971. /**
  127972. * Checks for the readiness of the element composing the layer.
  127973. * @param subMesh the mesh to check for
  127974. * @param useInstances specify wether or not to use instances to render the mesh
  127975. * @param emissiveTexture the associated emissive texture used to generate the glow
  127976. * @return true if ready otherwise, false
  127977. */
  127978. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  127979. /**
  127980. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  127981. */
  127982. needStencil(): boolean;
  127983. /**
  127984. * Returns true if the mesh can be rendered, otherwise false.
  127985. * @param mesh The mesh to render
  127986. * @param material The material used on the mesh
  127987. * @returns true if it can be rendered otherwise false
  127988. */
  127989. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  127990. /**
  127991. * Implementation specific of rendering the generating effect on the main canvas.
  127992. * @param effect The effect used to render through
  127993. */
  127994. protected _internalRender(effect: Effect): void;
  127995. /**
  127996. * Sets the required values for both the emissive texture and and the main color.
  127997. */
  127998. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  127999. /**
  128000. * Returns true if the mesh should render, otherwise false.
  128001. * @param mesh The mesh to render
  128002. * @returns true if it should render otherwise false
  128003. */
  128004. protected _shouldRenderMesh(mesh: Mesh): boolean;
  128005. /**
  128006. * Adds specific effects defines.
  128007. * @param defines The defines to add specifics to.
  128008. */
  128009. protected _addCustomEffectDefines(defines: string[]): void;
  128010. /**
  128011. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  128012. * @param mesh The mesh to exclude from the glow layer
  128013. */
  128014. addExcludedMesh(mesh: Mesh): void;
  128015. /**
  128016. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  128017. * @param mesh The mesh to remove
  128018. */
  128019. removeExcludedMesh(mesh: Mesh): void;
  128020. /**
  128021. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  128022. * @param mesh The mesh to include in the glow layer
  128023. */
  128024. addIncludedOnlyMesh(mesh: Mesh): void;
  128025. /**
  128026. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  128027. * @param mesh The mesh to remove
  128028. */
  128029. removeIncludedOnlyMesh(mesh: Mesh): void;
  128030. /**
  128031. * Determine if a given mesh will be used in the glow layer
  128032. * @param mesh The mesh to test
  128033. * @returns true if the mesh will be highlighted by the current glow layer
  128034. */
  128035. hasMesh(mesh: AbstractMesh): boolean;
  128036. /**
  128037. * Defines whether the current material of the mesh should be use to render the effect.
  128038. * @param mesh defines the current mesh to render
  128039. */
  128040. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  128041. /**
  128042. * Add a mesh to be rendered through its own material and not with emissive only.
  128043. * @param mesh The mesh for which we need to use its material
  128044. */
  128045. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  128046. /**
  128047. * Remove a mesh from being rendered through its own material and not with emissive only.
  128048. * @param mesh The mesh for which we need to not use its material
  128049. */
  128050. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  128051. /**
  128052. * Free any resources and references associated to a mesh.
  128053. * Internal use
  128054. * @param mesh The mesh to free.
  128055. * @hidden
  128056. */
  128057. _disposeMesh(mesh: Mesh): void;
  128058. /**
  128059. * Gets the class name of the effect layer
  128060. * @returns the string with the class name of the effect layer
  128061. */
  128062. getClassName(): string;
  128063. /**
  128064. * Serializes this glow layer
  128065. * @returns a serialized glow layer object
  128066. */
  128067. serialize(): any;
  128068. /**
  128069. * Creates a Glow Layer from parsed glow layer data
  128070. * @param parsedGlowLayer defines glow layer data
  128071. * @param scene defines the current scene
  128072. * @param rootUrl defines the root URL containing the glow layer information
  128073. * @returns a parsed Glow Layer
  128074. */
  128075. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  128076. }
  128077. }
  128078. declare module BABYLON {
  128079. /** @hidden */
  128080. export var glowBlurPostProcessPixelShader: {
  128081. name: string;
  128082. shader: string;
  128083. };
  128084. }
  128085. declare module BABYLON {
  128086. interface AbstractScene {
  128087. /**
  128088. * Return a the first highlight layer of the scene with a given name.
  128089. * @param name The name of the highlight layer to look for.
  128090. * @return The highlight layer if found otherwise null.
  128091. */
  128092. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  128093. }
  128094. /**
  128095. * Highlight layer options. This helps customizing the behaviour
  128096. * of the highlight layer.
  128097. */
  128098. export interface IHighlightLayerOptions {
  128099. /**
  128100. * Multiplication factor apply to the canvas size to compute the render target size
  128101. * used to generated the glowing objects (the smaller the faster).
  128102. */
  128103. mainTextureRatio: number;
  128104. /**
  128105. * Enforces a fixed size texture to ensure resize independant blur.
  128106. */
  128107. mainTextureFixedSize?: number;
  128108. /**
  128109. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  128110. * of the picture to blur (the smaller the faster).
  128111. */
  128112. blurTextureSizeRatio: number;
  128113. /**
  128114. * How big in texel of the blur texture is the vertical blur.
  128115. */
  128116. blurVerticalSize: number;
  128117. /**
  128118. * How big in texel of the blur texture is the horizontal blur.
  128119. */
  128120. blurHorizontalSize: number;
  128121. /**
  128122. * Alpha blending mode used to apply the blur. Default is combine.
  128123. */
  128124. alphaBlendingMode: number;
  128125. /**
  128126. * The camera attached to the layer.
  128127. */
  128128. camera: Nullable<Camera>;
  128129. /**
  128130. * Should we display highlight as a solid stroke?
  128131. */
  128132. isStroke?: boolean;
  128133. /**
  128134. * The rendering group to draw the layer in.
  128135. */
  128136. renderingGroupId: number;
  128137. }
  128138. /**
  128139. * The highlight layer Helps adding a glow effect around a mesh.
  128140. *
  128141. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  128142. * glowy meshes to your scene.
  128143. *
  128144. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  128145. */
  128146. export class HighlightLayer extends EffectLayer {
  128147. name: string;
  128148. /**
  128149. * Effect Name of the highlight layer.
  128150. */
  128151. static readonly EffectName: string;
  128152. /**
  128153. * The neutral color used during the preparation of the glow effect.
  128154. * This is black by default as the blend operation is a blend operation.
  128155. */
  128156. static NeutralColor: Color4;
  128157. /**
  128158. * Stencil value used for glowing meshes.
  128159. */
  128160. static GlowingMeshStencilReference: number;
  128161. /**
  128162. * Stencil value used for the other meshes in the scene.
  128163. */
  128164. static NormalMeshStencilReference: number;
  128165. /**
  128166. * Specifies whether or not the inner glow is ACTIVE in the layer.
  128167. */
  128168. innerGlow: boolean;
  128169. /**
  128170. * Specifies whether or not the outer glow is ACTIVE in the layer.
  128171. */
  128172. outerGlow: boolean;
  128173. /**
  128174. * Specifies the horizontal size of the blur.
  128175. */
  128176. set blurHorizontalSize(value: number);
  128177. /**
  128178. * Specifies the vertical size of the blur.
  128179. */
  128180. set blurVerticalSize(value: number);
  128181. /**
  128182. * Gets the horizontal size of the blur.
  128183. */
  128184. get blurHorizontalSize(): number;
  128185. /**
  128186. * Gets the vertical size of the blur.
  128187. */
  128188. get blurVerticalSize(): number;
  128189. /**
  128190. * An event triggered when the highlight layer is being blurred.
  128191. */
  128192. onBeforeBlurObservable: Observable<HighlightLayer>;
  128193. /**
  128194. * An event triggered when the highlight layer has been blurred.
  128195. */
  128196. onAfterBlurObservable: Observable<HighlightLayer>;
  128197. private _instanceGlowingMeshStencilReference;
  128198. private _options;
  128199. private _downSamplePostprocess;
  128200. private _horizontalBlurPostprocess;
  128201. private _verticalBlurPostprocess;
  128202. private _blurTexture;
  128203. private _meshes;
  128204. private _excludedMeshes;
  128205. /**
  128206. * Instantiates a new highlight Layer and references it to the scene..
  128207. * @param name The name of the layer
  128208. * @param scene The scene to use the layer in
  128209. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  128210. */
  128211. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  128212. /**
  128213. * Get the effect name of the layer.
  128214. * @return The effect name
  128215. */
  128216. getEffectName(): string;
  128217. /**
  128218. * Create the merge effect. This is the shader use to blit the information back
  128219. * to the main canvas at the end of the scene rendering.
  128220. */
  128221. protected _createMergeEffect(): Effect;
  128222. /**
  128223. * Creates the render target textures and post processes used in the highlight layer.
  128224. */
  128225. protected _createTextureAndPostProcesses(): void;
  128226. /**
  128227. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  128228. */
  128229. needStencil(): boolean;
  128230. /**
  128231. * Checks for the readiness of the element composing the layer.
  128232. * @param subMesh the mesh to check for
  128233. * @param useInstances specify wether or not to use instances to render the mesh
  128234. * @param emissiveTexture the associated emissive texture used to generate the glow
  128235. * @return true if ready otherwise, false
  128236. */
  128237. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  128238. /**
  128239. * Implementation specific of rendering the generating effect on the main canvas.
  128240. * @param effect The effect used to render through
  128241. */
  128242. protected _internalRender(effect: Effect): void;
  128243. /**
  128244. * Returns true if the layer contains information to display, otherwise false.
  128245. */
  128246. shouldRender(): boolean;
  128247. /**
  128248. * Returns true if the mesh should render, otherwise false.
  128249. * @param mesh The mesh to render
  128250. * @returns true if it should render otherwise false
  128251. */
  128252. protected _shouldRenderMesh(mesh: Mesh): boolean;
  128253. /**
  128254. * Adds specific effects defines.
  128255. * @param defines The defines to add specifics to.
  128256. */
  128257. protected _addCustomEffectDefines(defines: string[]): void;
  128258. /**
  128259. * Sets the required values for both the emissive texture and and the main color.
  128260. */
  128261. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  128262. /**
  128263. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  128264. * @param mesh The mesh to exclude from the highlight layer
  128265. */
  128266. addExcludedMesh(mesh: Mesh): void;
  128267. /**
  128268. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  128269. * @param mesh The mesh to highlight
  128270. */
  128271. removeExcludedMesh(mesh: Mesh): void;
  128272. /**
  128273. * Determine if a given mesh will be highlighted by the current HighlightLayer
  128274. * @param mesh mesh to test
  128275. * @returns true if the mesh will be highlighted by the current HighlightLayer
  128276. */
  128277. hasMesh(mesh: AbstractMesh): boolean;
  128278. /**
  128279. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  128280. * @param mesh The mesh to highlight
  128281. * @param color The color of the highlight
  128282. * @param glowEmissiveOnly Extract the glow from the emissive texture
  128283. */
  128284. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  128285. /**
  128286. * Remove a mesh from the highlight layer in order to make it stop glowing.
  128287. * @param mesh The mesh to highlight
  128288. */
  128289. removeMesh(mesh: Mesh): void;
  128290. /**
  128291. * Remove all the meshes currently referenced in the highlight layer
  128292. */
  128293. removeAllMeshes(): void;
  128294. /**
  128295. * Force the stencil to the normal expected value for none glowing parts
  128296. */
  128297. private _defaultStencilReference;
  128298. /**
  128299. * Free any resources and references associated to a mesh.
  128300. * Internal use
  128301. * @param mesh The mesh to free.
  128302. * @hidden
  128303. */
  128304. _disposeMesh(mesh: Mesh): void;
  128305. /**
  128306. * Dispose the highlight layer and free resources.
  128307. */
  128308. dispose(): void;
  128309. /**
  128310. * Gets the class name of the effect layer
  128311. * @returns the string with the class name of the effect layer
  128312. */
  128313. getClassName(): string;
  128314. /**
  128315. * Serializes this Highlight layer
  128316. * @returns a serialized Highlight layer object
  128317. */
  128318. serialize(): any;
  128319. /**
  128320. * Creates a Highlight layer from parsed Highlight layer data
  128321. * @param parsedHightlightLayer defines the Highlight layer data
  128322. * @param scene defines the current scene
  128323. * @param rootUrl defines the root URL containing the Highlight layer information
  128324. * @returns a parsed Highlight layer
  128325. */
  128326. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  128327. }
  128328. }
  128329. declare module BABYLON {
  128330. interface AbstractScene {
  128331. /**
  128332. * The list of layers (background and foreground) of the scene
  128333. */
  128334. layers: Array<Layer>;
  128335. }
  128336. /**
  128337. * Defines the layer scene component responsible to manage any layers
  128338. * in a given scene.
  128339. */
  128340. export class LayerSceneComponent implements ISceneComponent {
  128341. /**
  128342. * The component name helpfull to identify the component in the list of scene components.
  128343. */
  128344. readonly name: string;
  128345. /**
  128346. * The scene the component belongs to.
  128347. */
  128348. scene: Scene;
  128349. private _engine;
  128350. /**
  128351. * Creates a new instance of the component for the given scene
  128352. * @param scene Defines the scene to register the component in
  128353. */
  128354. constructor(scene: Scene);
  128355. /**
  128356. * Registers the component in a given scene
  128357. */
  128358. register(): void;
  128359. /**
  128360. * Rebuilds the elements related to this component in case of
  128361. * context lost for instance.
  128362. */
  128363. rebuild(): void;
  128364. /**
  128365. * Disposes the component and the associated ressources.
  128366. */
  128367. dispose(): void;
  128368. private _draw;
  128369. private _drawCameraPredicate;
  128370. private _drawCameraBackground;
  128371. private _drawCameraForeground;
  128372. private _drawRenderTargetPredicate;
  128373. private _drawRenderTargetBackground;
  128374. private _drawRenderTargetForeground;
  128375. /**
  128376. * Adds all the elements from the container to the scene
  128377. * @param container the container holding the elements
  128378. */
  128379. addFromContainer(container: AbstractScene): void;
  128380. /**
  128381. * Removes all the elements in the container from the scene
  128382. * @param container contains the elements to remove
  128383. * @param dispose if the removed element should be disposed (default: false)
  128384. */
  128385. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  128386. }
  128387. }
  128388. declare module BABYLON {
  128389. /** @hidden */
  128390. export var layerPixelShader: {
  128391. name: string;
  128392. shader: string;
  128393. };
  128394. }
  128395. declare module BABYLON {
  128396. /** @hidden */
  128397. export var layerVertexShader: {
  128398. name: string;
  128399. shader: string;
  128400. };
  128401. }
  128402. declare module BABYLON {
  128403. /**
  128404. * This represents a full screen 2d layer.
  128405. * This can be useful to display a picture in the background of your scene for instance.
  128406. * @see https://www.babylonjs-playground.com/#08A2BS#1
  128407. */
  128408. export class Layer {
  128409. /**
  128410. * Define the name of the layer.
  128411. */
  128412. name: string;
  128413. /**
  128414. * Define the texture the layer should display.
  128415. */
  128416. texture: Nullable<Texture>;
  128417. /**
  128418. * Is the layer in background or foreground.
  128419. */
  128420. isBackground: boolean;
  128421. /**
  128422. * Define the color of the layer (instead of texture).
  128423. */
  128424. color: Color4;
  128425. /**
  128426. * Define the scale of the layer in order to zoom in out of the texture.
  128427. */
  128428. scale: Vector2;
  128429. /**
  128430. * Define an offset for the layer in order to shift the texture.
  128431. */
  128432. offset: Vector2;
  128433. /**
  128434. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  128435. */
  128436. alphaBlendingMode: number;
  128437. /**
  128438. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  128439. * Alpha test will not mix with the background color in case of transparency.
  128440. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  128441. */
  128442. alphaTest: boolean;
  128443. /**
  128444. * Define a mask to restrict the layer to only some of the scene cameras.
  128445. */
  128446. layerMask: number;
  128447. /**
  128448. * Define the list of render target the layer is visible into.
  128449. */
  128450. renderTargetTextures: RenderTargetTexture[];
  128451. /**
  128452. * Define if the layer is only used in renderTarget or if it also
  128453. * renders in the main frame buffer of the canvas.
  128454. */
  128455. renderOnlyInRenderTargetTextures: boolean;
  128456. private _scene;
  128457. private _vertexBuffers;
  128458. private _indexBuffer;
  128459. private _effect;
  128460. private _previousDefines;
  128461. /**
  128462. * An event triggered when the layer is disposed.
  128463. */
  128464. onDisposeObservable: Observable<Layer>;
  128465. private _onDisposeObserver;
  128466. /**
  128467. * Back compatibility with callback before the onDisposeObservable existed.
  128468. * The set callback will be triggered when the layer has been disposed.
  128469. */
  128470. set onDispose(callback: () => void);
  128471. /**
  128472. * An event triggered before rendering the scene
  128473. */
  128474. onBeforeRenderObservable: Observable<Layer>;
  128475. private _onBeforeRenderObserver;
  128476. /**
  128477. * Back compatibility with callback before the onBeforeRenderObservable existed.
  128478. * The set callback will be triggered just before rendering the layer.
  128479. */
  128480. set onBeforeRender(callback: () => void);
  128481. /**
  128482. * An event triggered after rendering the scene
  128483. */
  128484. onAfterRenderObservable: Observable<Layer>;
  128485. private _onAfterRenderObserver;
  128486. /**
  128487. * Back compatibility with callback before the onAfterRenderObservable existed.
  128488. * The set callback will be triggered just after rendering the layer.
  128489. */
  128490. set onAfterRender(callback: () => void);
  128491. /**
  128492. * Instantiates a new layer.
  128493. * This represents a full screen 2d layer.
  128494. * This can be useful to display a picture in the background of your scene for instance.
  128495. * @see https://www.babylonjs-playground.com/#08A2BS#1
  128496. * @param name Define the name of the layer in the scene
  128497. * @param imgUrl Define the url of the texture to display in the layer
  128498. * @param scene Define the scene the layer belongs to
  128499. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  128500. * @param color Defines a color for the layer
  128501. */
  128502. constructor(
  128503. /**
  128504. * Define the name of the layer.
  128505. */
  128506. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  128507. private _createIndexBuffer;
  128508. /** @hidden */
  128509. _rebuild(): void;
  128510. /**
  128511. * Renders the layer in the scene.
  128512. */
  128513. render(): void;
  128514. /**
  128515. * Disposes and releases the associated ressources.
  128516. */
  128517. dispose(): void;
  128518. }
  128519. }
  128520. declare module BABYLON {
  128521. /** @hidden */
  128522. export var lensFlarePixelShader: {
  128523. name: string;
  128524. shader: string;
  128525. };
  128526. }
  128527. declare module BABYLON {
  128528. /** @hidden */
  128529. export var lensFlareVertexShader: {
  128530. name: string;
  128531. shader: string;
  128532. };
  128533. }
  128534. declare module BABYLON {
  128535. /**
  128536. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  128537. * It is usually composed of several `lensFlare`.
  128538. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  128539. */
  128540. export class LensFlareSystem {
  128541. /**
  128542. * Define the name of the lens flare system
  128543. */
  128544. name: string;
  128545. /**
  128546. * List of lens flares used in this system.
  128547. */
  128548. lensFlares: LensFlare[];
  128549. /**
  128550. * Define a limit from the border the lens flare can be visible.
  128551. */
  128552. borderLimit: number;
  128553. /**
  128554. * Define a viewport border we do not want to see the lens flare in.
  128555. */
  128556. viewportBorder: number;
  128557. /**
  128558. * Define a predicate which could limit the list of meshes able to occlude the effect.
  128559. */
  128560. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  128561. /**
  128562. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  128563. */
  128564. layerMask: number;
  128565. /**
  128566. * Define the id of the lens flare system in the scene.
  128567. * (equal to name by default)
  128568. */
  128569. id: string;
  128570. private _scene;
  128571. private _emitter;
  128572. private _vertexBuffers;
  128573. private _indexBuffer;
  128574. private _effect;
  128575. private _positionX;
  128576. private _positionY;
  128577. private _isEnabled;
  128578. /** @hidden */
  128579. static _SceneComponentInitialization: (scene: Scene) => void;
  128580. /**
  128581. * Instantiates a lens flare system.
  128582. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  128583. * It is usually composed of several `lensFlare`.
  128584. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  128585. * @param name Define the name of the lens flare system in the scene
  128586. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  128587. * @param scene Define the scene the lens flare system belongs to
  128588. */
  128589. constructor(
  128590. /**
  128591. * Define the name of the lens flare system
  128592. */
  128593. name: string, emitter: any, scene: Scene);
  128594. /**
  128595. * Define if the lens flare system is enabled.
  128596. */
  128597. get isEnabled(): boolean;
  128598. set isEnabled(value: boolean);
  128599. /**
  128600. * Get the scene the effects belongs to.
  128601. * @returns the scene holding the lens flare system
  128602. */
  128603. getScene(): Scene;
  128604. /**
  128605. * Get the emitter of the lens flare system.
  128606. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  128607. * @returns the emitter of the lens flare system
  128608. */
  128609. getEmitter(): any;
  128610. /**
  128611. * Set the emitter of the lens flare system.
  128612. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  128613. * @param newEmitter Define the new emitter of the system
  128614. */
  128615. setEmitter(newEmitter: any): void;
  128616. /**
  128617. * Get the lens flare system emitter position.
  128618. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  128619. * @returns the position
  128620. */
  128621. getEmitterPosition(): Vector3;
  128622. /**
  128623. * @hidden
  128624. */
  128625. computeEffectivePosition(globalViewport: Viewport): boolean;
  128626. /** @hidden */
  128627. _isVisible(): boolean;
  128628. /**
  128629. * @hidden
  128630. */
  128631. render(): boolean;
  128632. /**
  128633. * Dispose and release the lens flare with its associated resources.
  128634. */
  128635. dispose(): void;
  128636. /**
  128637. * Parse a lens flare system from a JSON repressentation
  128638. * @param parsedLensFlareSystem Define the JSON to parse
  128639. * @param scene Define the scene the parsed system should be instantiated in
  128640. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  128641. * @returns the parsed system
  128642. */
  128643. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  128644. /**
  128645. * Serialize the current Lens Flare System into a JSON representation.
  128646. * @returns the serialized JSON
  128647. */
  128648. serialize(): any;
  128649. }
  128650. }
  128651. declare module BABYLON {
  128652. /**
  128653. * This represents one of the lens effect in a `lensFlareSystem`.
  128654. * It controls one of the indiviual texture used in the effect.
  128655. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  128656. */
  128657. export class LensFlare {
  128658. /**
  128659. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  128660. */
  128661. size: number;
  128662. /**
  128663. * 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.
  128664. */
  128665. position: number;
  128666. /**
  128667. * Define the lens color.
  128668. */
  128669. color: Color3;
  128670. /**
  128671. * Define the lens texture.
  128672. */
  128673. texture: Nullable<Texture>;
  128674. /**
  128675. * Define the alpha mode to render this particular lens.
  128676. */
  128677. alphaMode: number;
  128678. private _system;
  128679. /**
  128680. * Creates a new Lens Flare.
  128681. * This represents one of the lens effect in a `lensFlareSystem`.
  128682. * It controls one of the indiviual texture used in the effect.
  128683. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  128684. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  128685. * @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.
  128686. * @param color Define the lens color
  128687. * @param imgUrl Define the lens texture url
  128688. * @param system Define the `lensFlareSystem` this flare is part of
  128689. * @returns The newly created Lens Flare
  128690. */
  128691. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  128692. /**
  128693. * Instantiates a new Lens Flare.
  128694. * This represents one of the lens effect in a `lensFlareSystem`.
  128695. * It controls one of the indiviual texture used in the effect.
  128696. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  128697. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  128698. * @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.
  128699. * @param color Define the lens color
  128700. * @param imgUrl Define the lens texture url
  128701. * @param system Define the `lensFlareSystem` this flare is part of
  128702. */
  128703. constructor(
  128704. /**
  128705. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  128706. */
  128707. size: number,
  128708. /**
  128709. * 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.
  128710. */
  128711. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  128712. /**
  128713. * Dispose and release the lens flare with its associated resources.
  128714. */
  128715. dispose(): void;
  128716. }
  128717. }
  128718. declare module BABYLON {
  128719. interface AbstractScene {
  128720. /**
  128721. * The list of lens flare system added to the scene
  128722. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  128723. */
  128724. lensFlareSystems: Array<LensFlareSystem>;
  128725. /**
  128726. * Removes the given lens flare system from this scene.
  128727. * @param toRemove The lens flare system to remove
  128728. * @returns The index of the removed lens flare system
  128729. */
  128730. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  128731. /**
  128732. * Adds the given lens flare system to this scene
  128733. * @param newLensFlareSystem The lens flare system to add
  128734. */
  128735. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  128736. /**
  128737. * Gets a lens flare system using its name
  128738. * @param name defines the name to look for
  128739. * @returns the lens flare system or null if not found
  128740. */
  128741. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  128742. /**
  128743. * Gets a lens flare system using its id
  128744. * @param id defines the id to look for
  128745. * @returns the lens flare system or null if not found
  128746. */
  128747. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  128748. }
  128749. /**
  128750. * Defines the lens flare scene component responsible to manage any lens flares
  128751. * in a given scene.
  128752. */
  128753. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  128754. /**
  128755. * The component name helpfull to identify the component in the list of scene components.
  128756. */
  128757. readonly name: string;
  128758. /**
  128759. * The scene the component belongs to.
  128760. */
  128761. scene: Scene;
  128762. /**
  128763. * Creates a new instance of the component for the given scene
  128764. * @param scene Defines the scene to register the component in
  128765. */
  128766. constructor(scene: Scene);
  128767. /**
  128768. * Registers the component in a given scene
  128769. */
  128770. register(): void;
  128771. /**
  128772. * Rebuilds the elements related to this component in case of
  128773. * context lost for instance.
  128774. */
  128775. rebuild(): void;
  128776. /**
  128777. * Adds all the elements from the container to the scene
  128778. * @param container the container holding the elements
  128779. */
  128780. addFromContainer(container: AbstractScene): void;
  128781. /**
  128782. * Removes all the elements in the container from the scene
  128783. * @param container contains the elements to remove
  128784. * @param dispose if the removed element should be disposed (default: false)
  128785. */
  128786. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  128787. /**
  128788. * Serializes the component data to the specified json object
  128789. * @param serializationObject The object to serialize to
  128790. */
  128791. serialize(serializationObject: any): void;
  128792. /**
  128793. * Disposes the component and the associated ressources.
  128794. */
  128795. dispose(): void;
  128796. private _draw;
  128797. }
  128798. }
  128799. declare module BABYLON {
  128800. /** @hidden */
  128801. export var depthPixelShader: {
  128802. name: string;
  128803. shader: string;
  128804. };
  128805. }
  128806. declare module BABYLON {
  128807. /** @hidden */
  128808. export var depthVertexShader: {
  128809. name: string;
  128810. shader: string;
  128811. };
  128812. }
  128813. declare module BABYLON {
  128814. /**
  128815. * This represents a depth renderer in Babylon.
  128816. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  128817. */
  128818. export class DepthRenderer {
  128819. private _scene;
  128820. private _depthMap;
  128821. private _effect;
  128822. private readonly _storeNonLinearDepth;
  128823. private readonly _clearColor;
  128824. /** Get if the depth renderer is using packed depth or not */
  128825. readonly isPacked: boolean;
  128826. private _cachedDefines;
  128827. private _camera;
  128828. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  128829. enabled: boolean;
  128830. /**
  128831. * Specifiess that the depth renderer will only be used within
  128832. * the camera it is created for.
  128833. * This can help forcing its rendering during the camera processing.
  128834. */
  128835. useOnlyInActiveCamera: boolean;
  128836. /** @hidden */
  128837. static _SceneComponentInitialization: (scene: Scene) => void;
  128838. /**
  128839. * Instantiates a depth renderer
  128840. * @param scene The scene the renderer belongs to
  128841. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  128842. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  128843. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  128844. */
  128845. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  128846. /**
  128847. * Creates the depth rendering effect and checks if the effect is ready.
  128848. * @param subMesh The submesh to be used to render the depth map of
  128849. * @param useInstances If multiple world instances should be used
  128850. * @returns if the depth renderer is ready to render the depth map
  128851. */
  128852. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  128853. /**
  128854. * Gets the texture which the depth map will be written to.
  128855. * @returns The depth map texture
  128856. */
  128857. getDepthMap(): RenderTargetTexture;
  128858. /**
  128859. * Disposes of the depth renderer.
  128860. */
  128861. dispose(): void;
  128862. }
  128863. }
  128864. declare module BABYLON {
  128865. /** @hidden */
  128866. export var minmaxReduxPixelShader: {
  128867. name: string;
  128868. shader: string;
  128869. };
  128870. }
  128871. declare module BABYLON {
  128872. /**
  128873. * This class computes a min/max reduction from a texture: it means it computes the minimum
  128874. * and maximum values from all values of the texture.
  128875. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  128876. * The source values are read from the red channel of the texture.
  128877. */
  128878. export class MinMaxReducer {
  128879. /**
  128880. * Observable triggered when the computation has been performed
  128881. */
  128882. onAfterReductionPerformed: Observable<{
  128883. min: number;
  128884. max: number;
  128885. }>;
  128886. protected _camera: Camera;
  128887. protected _sourceTexture: Nullable<RenderTargetTexture>;
  128888. protected _reductionSteps: Nullable<Array<PostProcess>>;
  128889. protected _postProcessManager: PostProcessManager;
  128890. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  128891. protected _forceFullscreenViewport: boolean;
  128892. /**
  128893. * Creates a min/max reducer
  128894. * @param camera The camera to use for the post processes
  128895. */
  128896. constructor(camera: Camera);
  128897. /**
  128898. * Gets the texture used to read the values from.
  128899. */
  128900. get sourceTexture(): Nullable<RenderTargetTexture>;
  128901. /**
  128902. * Sets the source texture to read the values from.
  128903. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  128904. * because in such textures '1' value must not be taken into account to compute the maximum
  128905. * as this value is used to clear the texture.
  128906. * Note that the computation is not activated by calling this function, you must call activate() for that!
  128907. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  128908. * @param depthRedux Indicates if the texture is a depth texture or not
  128909. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  128910. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  128911. */
  128912. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  128913. /**
  128914. * Defines the refresh rate of the computation.
  128915. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  128916. */
  128917. get refreshRate(): number;
  128918. set refreshRate(value: number);
  128919. protected _activated: boolean;
  128920. /**
  128921. * Gets the activation status of the reducer
  128922. */
  128923. get activated(): boolean;
  128924. /**
  128925. * Activates the reduction computation.
  128926. * When activated, the observers registered in onAfterReductionPerformed are
  128927. * called after the compuation is performed
  128928. */
  128929. activate(): void;
  128930. /**
  128931. * Deactivates the reduction computation.
  128932. */
  128933. deactivate(): void;
  128934. /**
  128935. * Disposes the min/max reducer
  128936. * @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.
  128937. */
  128938. dispose(disposeAll?: boolean): void;
  128939. }
  128940. }
  128941. declare module BABYLON {
  128942. /**
  128943. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  128944. */
  128945. export class DepthReducer extends MinMaxReducer {
  128946. private _depthRenderer;
  128947. private _depthRendererId;
  128948. /**
  128949. * Gets the depth renderer used for the computation.
  128950. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  128951. */
  128952. get depthRenderer(): Nullable<DepthRenderer>;
  128953. /**
  128954. * Creates a depth reducer
  128955. * @param camera The camera used to render the depth texture
  128956. */
  128957. constructor(camera: Camera);
  128958. /**
  128959. * Sets the depth renderer to use to generate the depth map
  128960. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  128961. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  128962. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  128963. */
  128964. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  128965. /** @hidden */
  128966. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  128967. /**
  128968. * Activates the reduction computation.
  128969. * When activated, the observers registered in onAfterReductionPerformed are
  128970. * called after the compuation is performed
  128971. */
  128972. activate(): void;
  128973. /**
  128974. * Deactivates the reduction computation.
  128975. */
  128976. deactivate(): void;
  128977. /**
  128978. * Disposes the depth reducer
  128979. * @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.
  128980. */
  128981. dispose(disposeAll?: boolean): void;
  128982. }
  128983. }
  128984. declare module BABYLON {
  128985. /**
  128986. * A CSM implementation allowing casting shadows on large scenes.
  128987. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  128988. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  128989. */
  128990. export class CascadedShadowGenerator extends ShadowGenerator {
  128991. private static readonly frustumCornersNDCSpace;
  128992. /**
  128993. * Name of the CSM class
  128994. */
  128995. static CLASSNAME: string;
  128996. /**
  128997. * Defines the default number of cascades used by the CSM.
  128998. */
  128999. static readonly DEFAULT_CASCADES_COUNT: number;
  129000. /**
  129001. * Defines the minimum number of cascades used by the CSM.
  129002. */
  129003. static readonly MIN_CASCADES_COUNT: number;
  129004. /**
  129005. * Defines the maximum number of cascades used by the CSM.
  129006. */
  129007. static readonly MAX_CASCADES_COUNT: number;
  129008. protected _validateFilter(filter: number): number;
  129009. /**
  129010. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  129011. */
  129012. penumbraDarkness: number;
  129013. private _numCascades;
  129014. /**
  129015. * Gets or set the number of cascades used by the CSM.
  129016. */
  129017. get numCascades(): number;
  129018. set numCascades(value: number);
  129019. /**
  129020. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  129021. * The trade off is that you loose some precision in the shadow rendering when enabling this setting.
  129022. */
  129023. stabilizeCascades: boolean;
  129024. private _freezeShadowCastersBoundingInfo;
  129025. private _freezeShadowCastersBoundingInfoObservable;
  129026. /**
  129027. * Enables or disables the shadow casters bounding info computation.
  129028. * If your shadow casters don't move, you can disable this feature.
  129029. * If it is enabled, the bounding box computation is done every frame.
  129030. */
  129031. get freezeShadowCastersBoundingInfo(): boolean;
  129032. set freezeShadowCastersBoundingInfo(freeze: boolean);
  129033. private _scbiMin;
  129034. private _scbiMax;
  129035. protected _computeShadowCastersBoundingInfo(): void;
  129036. protected _shadowCastersBoundingInfo: BoundingInfo;
  129037. /**
  129038. * Gets or sets the shadow casters bounding info.
  129039. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  129040. * so that the system won't overwrite the bounds you provide
  129041. */
  129042. get shadowCastersBoundingInfo(): BoundingInfo;
  129043. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  129044. protected _breaksAreDirty: boolean;
  129045. protected _minDistance: number;
  129046. protected _maxDistance: number;
  129047. /**
  129048. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  129049. *
  129050. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  129051. * If you don't know these values, simply leave them to their defaults and don't call this function.
  129052. * @param min minimal distance for the breaks (default to 0.)
  129053. * @param max maximal distance for the breaks (default to 1.)
  129054. */
  129055. setMinMaxDistance(min: number, max: number): void;
  129056. /** Gets the minimal distance used in the cascade break computation */
  129057. get minDistance(): number;
  129058. /** Gets the maximal distance used in the cascade break computation */
  129059. get maxDistance(): number;
  129060. /**
  129061. * Gets the class name of that object
  129062. * @returns "CascadedShadowGenerator"
  129063. */
  129064. getClassName(): string;
  129065. private _cascadeMinExtents;
  129066. private _cascadeMaxExtents;
  129067. /**
  129068. * Gets a cascade minimum extents
  129069. * @param cascadeIndex index of the cascade
  129070. * @returns the minimum cascade extents
  129071. */
  129072. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  129073. /**
  129074. * Gets a cascade maximum extents
  129075. * @param cascadeIndex index of the cascade
  129076. * @returns the maximum cascade extents
  129077. */
  129078. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  129079. private _cascades;
  129080. private _currentLayer;
  129081. private _viewSpaceFrustumsZ;
  129082. private _viewMatrices;
  129083. private _projectionMatrices;
  129084. private _transformMatrices;
  129085. private _transformMatricesAsArray;
  129086. private _frustumLengths;
  129087. private _lightSizeUVCorrection;
  129088. private _depthCorrection;
  129089. private _frustumCornersWorldSpace;
  129090. private _frustumCenter;
  129091. private _shadowCameraPos;
  129092. private _shadowMaxZ;
  129093. /**
  129094. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  129095. * It defaults to camera.maxZ
  129096. */
  129097. get shadowMaxZ(): number;
  129098. /**
  129099. * Sets the shadow max z distance.
  129100. */
  129101. set shadowMaxZ(value: number);
  129102. protected _debug: boolean;
  129103. /**
  129104. * Gets or sets the debug flag.
  129105. * When enabled, the cascades are materialized by different colors on the screen.
  129106. */
  129107. get debug(): boolean;
  129108. set debug(dbg: boolean);
  129109. private _depthClamp;
  129110. /**
  129111. * Gets or sets the depth clamping value.
  129112. *
  129113. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  129114. * to account for the shadow casters far away.
  129115. *
  129116. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  129117. */
  129118. get depthClamp(): boolean;
  129119. set depthClamp(value: boolean);
  129120. private _cascadeBlendPercentage;
  129121. /**
  129122. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  129123. * It defaults to 0.1 (10% blending).
  129124. */
  129125. get cascadeBlendPercentage(): number;
  129126. set cascadeBlendPercentage(value: number);
  129127. private _lambda;
  129128. /**
  129129. * Gets or set the lambda parameter.
  129130. * This parameter is used to split the camera frustum and create the cascades.
  129131. * 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.
  129132. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  129133. */
  129134. get lambda(): number;
  129135. set lambda(value: number);
  129136. /**
  129137. * Gets the view matrix corresponding to a given cascade
  129138. * @param cascadeNum cascade to retrieve the view matrix from
  129139. * @returns the cascade view matrix
  129140. */
  129141. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  129142. /**
  129143. * Gets the projection matrix corresponding to a given cascade
  129144. * @param cascadeNum cascade to retrieve the projection matrix from
  129145. * @returns the cascade projection matrix
  129146. */
  129147. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  129148. /**
  129149. * Gets the transformation matrix corresponding to a given cascade
  129150. * @param cascadeNum cascade to retrieve the transformation matrix from
  129151. * @returns the cascade transformation matrix
  129152. */
  129153. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  129154. private _depthRenderer;
  129155. /**
  129156. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  129157. *
  129158. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  129159. *
  129160. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  129161. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  129162. * @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
  129163. */
  129164. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  129165. private _depthReducer;
  129166. private _autoCalcDepthBounds;
  129167. /**
  129168. * Gets or sets the autoCalcDepthBounds property.
  129169. *
  129170. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  129171. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  129172. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  129173. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  129174. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  129175. */
  129176. get autoCalcDepthBounds(): boolean;
  129177. set autoCalcDepthBounds(value: boolean);
  129178. /**
  129179. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  129180. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  129181. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  129182. * for setting the refresh rate on the renderer yourself!
  129183. */
  129184. get autoCalcDepthBoundsRefreshRate(): number;
  129185. set autoCalcDepthBoundsRefreshRate(value: number);
  129186. /**
  129187. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  129188. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  129189. * you change the camera near/far planes!
  129190. */
  129191. splitFrustum(): void;
  129192. private _splitFrustum;
  129193. private _computeMatrices;
  129194. private _computeFrustumInWorldSpace;
  129195. private _computeCascadeFrustum;
  129196. /**
  129197. * Support test.
  129198. */
  129199. static get IsSupported(): boolean;
  129200. /** @hidden */
  129201. static _SceneComponentInitialization: (scene: Scene) => void;
  129202. /**
  129203. * Creates a Cascaded Shadow Generator object.
  129204. * A ShadowGenerator is the required tool to use the shadows.
  129205. * Each directional light casting shadows needs to use its own ShadowGenerator.
  129206. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  129207. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  129208. * @param light The directional light object generating the shadows.
  129209. * @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.
  129210. */
  129211. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  129212. protected _initializeGenerator(): void;
  129213. protected _createTargetRenderTexture(): void;
  129214. protected _initializeShadowMap(): void;
  129215. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect): void;
  129216. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  129217. /**
  129218. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  129219. * @param defines Defines of the material we want to update
  129220. * @param lightIndex Index of the light in the enabled light list of the material
  129221. */
  129222. prepareDefines(defines: any, lightIndex: number): void;
  129223. /**
  129224. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  129225. * defined in the generator but impacting the effect).
  129226. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  129227. * @param effect The effect we are binfing the information for
  129228. */
  129229. bindShadowLight(lightIndex: string, effect: Effect): void;
  129230. /**
  129231. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  129232. * (eq to view projection * shadow projection matrices)
  129233. * @returns The transform matrix used to create the shadow map
  129234. */
  129235. getTransformMatrix(): Matrix;
  129236. /**
  129237. * Disposes the ShadowGenerator.
  129238. * Returns nothing.
  129239. */
  129240. dispose(): void;
  129241. /**
  129242. * Serializes the shadow generator setup to a json object.
  129243. * @returns The serialized JSON object
  129244. */
  129245. serialize(): any;
  129246. /**
  129247. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  129248. * @param parsedShadowGenerator The JSON object to parse
  129249. * @param scene The scene to create the shadow map for
  129250. * @returns The parsed shadow generator
  129251. */
  129252. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  129253. }
  129254. }
  129255. declare module BABYLON {
  129256. /**
  129257. * Defines the shadow generator component responsible to manage any shadow generators
  129258. * in a given scene.
  129259. */
  129260. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  129261. /**
  129262. * The component name helpfull to identify the component in the list of scene components.
  129263. */
  129264. readonly name: string;
  129265. /**
  129266. * The scene the component belongs to.
  129267. */
  129268. scene: Scene;
  129269. /**
  129270. * Creates a new instance of the component for the given scene
  129271. * @param scene Defines the scene to register the component in
  129272. */
  129273. constructor(scene: Scene);
  129274. /**
  129275. * Registers the component in a given scene
  129276. */
  129277. register(): void;
  129278. /**
  129279. * Rebuilds the elements related to this component in case of
  129280. * context lost for instance.
  129281. */
  129282. rebuild(): void;
  129283. /**
  129284. * Serializes the component data to the specified json object
  129285. * @param serializationObject The object to serialize to
  129286. */
  129287. serialize(serializationObject: any): void;
  129288. /**
  129289. * Adds all the elements from the container to the scene
  129290. * @param container the container holding the elements
  129291. */
  129292. addFromContainer(container: AbstractScene): void;
  129293. /**
  129294. * Removes all the elements in the container from the scene
  129295. * @param container contains the elements to remove
  129296. * @param dispose if the removed element should be disposed (default: false)
  129297. */
  129298. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  129299. /**
  129300. * Rebuilds the elements related to this component in case of
  129301. * context lost for instance.
  129302. */
  129303. dispose(): void;
  129304. private _gatherRenderTargets;
  129305. }
  129306. }
  129307. declare module BABYLON {
  129308. /**
  129309. * A point light is a light defined by an unique point in world space.
  129310. * The light is emitted in every direction from this point.
  129311. * A good example of a point light is a standard light bulb.
  129312. * Documentation: https://doc.babylonjs.com/babylon101/lights
  129313. */
  129314. export class PointLight extends ShadowLight {
  129315. private _shadowAngle;
  129316. /**
  129317. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  129318. * This specifies what angle the shadow will use to be created.
  129319. *
  129320. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  129321. */
  129322. get shadowAngle(): number;
  129323. /**
  129324. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  129325. * This specifies what angle the shadow will use to be created.
  129326. *
  129327. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  129328. */
  129329. set shadowAngle(value: number);
  129330. /**
  129331. * Gets the direction if it has been set.
  129332. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  129333. */
  129334. get direction(): Vector3;
  129335. /**
  129336. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  129337. */
  129338. set direction(value: Vector3);
  129339. /**
  129340. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  129341. * A PointLight emits the light in every direction.
  129342. * It can cast shadows.
  129343. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  129344. * ```javascript
  129345. * var pointLight = new PointLight("pl", camera.position, scene);
  129346. * ```
  129347. * Documentation : https://doc.babylonjs.com/babylon101/lights
  129348. * @param name The light friendly name
  129349. * @param position The position of the point light in the scene
  129350. * @param scene The scene the lights belongs to
  129351. */
  129352. constructor(name: string, position: Vector3, scene: Scene);
  129353. /**
  129354. * Returns the string "PointLight"
  129355. * @returns the class name
  129356. */
  129357. getClassName(): string;
  129358. /**
  129359. * Returns the integer 0.
  129360. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  129361. */
  129362. getTypeID(): number;
  129363. /**
  129364. * Specifies wether or not the shadowmap should be a cube texture.
  129365. * @returns true if the shadowmap needs to be a cube texture.
  129366. */
  129367. needCube(): boolean;
  129368. /**
  129369. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  129370. * @param faceIndex The index of the face we are computed the direction to generate shadow
  129371. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  129372. */
  129373. getShadowDirection(faceIndex?: number): Vector3;
  129374. /**
  129375. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  129376. * - fov = PI / 2
  129377. * - aspect ratio : 1.0
  129378. * - z-near and far equal to the active camera minZ and maxZ.
  129379. * Returns the PointLight.
  129380. */
  129381. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  129382. protected _buildUniformLayout(): void;
  129383. /**
  129384. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  129385. * @param effect The effect to update
  129386. * @param lightIndex The index of the light in the effect to update
  129387. * @returns The point light
  129388. */
  129389. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  129390. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  129391. /**
  129392. * Prepares the list of defines specific to the light type.
  129393. * @param defines the list of defines
  129394. * @param lightIndex defines the index of the light for the effect
  129395. */
  129396. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  129397. }
  129398. }
  129399. declare module BABYLON {
  129400. /**
  129401. * Header information of HDR texture files.
  129402. */
  129403. export interface HDRInfo {
  129404. /**
  129405. * The height of the texture in pixels.
  129406. */
  129407. height: number;
  129408. /**
  129409. * The width of the texture in pixels.
  129410. */
  129411. width: number;
  129412. /**
  129413. * The index of the beginning of the data in the binary file.
  129414. */
  129415. dataPosition: number;
  129416. }
  129417. /**
  129418. * This groups tools to convert HDR texture to native colors array.
  129419. */
  129420. export class HDRTools {
  129421. private static Ldexp;
  129422. private static Rgbe2float;
  129423. private static readStringLine;
  129424. /**
  129425. * Reads header information from an RGBE texture stored in a native array.
  129426. * More information on this format are available here:
  129427. * https://en.wikipedia.org/wiki/RGBE_image_format
  129428. *
  129429. * @param uint8array The binary file stored in native array.
  129430. * @return The header information.
  129431. */
  129432. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  129433. /**
  129434. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  129435. * This RGBE texture needs to store the information as a panorama.
  129436. *
  129437. * More information on this format are available here:
  129438. * https://en.wikipedia.org/wiki/RGBE_image_format
  129439. *
  129440. * @param buffer The binary file stored in an array buffer.
  129441. * @param size The expected size of the extracted cubemap.
  129442. * @return The Cube Map information.
  129443. */
  129444. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  129445. /**
  129446. * Returns the pixels data extracted from an RGBE texture.
  129447. * This pixels will be stored left to right up to down in the R G B order in one array.
  129448. *
  129449. * More information on this format are available here:
  129450. * https://en.wikipedia.org/wiki/RGBE_image_format
  129451. *
  129452. * @param uint8array The binary file stored in an array buffer.
  129453. * @param hdrInfo The header information of the file.
  129454. * @return The pixels data in RGB right to left up to down order.
  129455. */
  129456. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  129457. private static RGBE_ReadPixels_RLE;
  129458. }
  129459. }
  129460. declare module BABYLON {
  129461. /**
  129462. * This represents a texture coming from an HDR input.
  129463. *
  129464. * The only supported format is currently panorama picture stored in RGBE format.
  129465. * Example of such files can be found on HDRLib: http://hdrlib.com/
  129466. */
  129467. export class HDRCubeTexture extends BaseTexture {
  129468. private static _facesMapping;
  129469. private _generateHarmonics;
  129470. private _noMipmap;
  129471. private _textureMatrix;
  129472. private _size;
  129473. private _onLoad;
  129474. private _onError;
  129475. /**
  129476. * The texture URL.
  129477. */
  129478. url: string;
  129479. /**
  129480. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  129481. */
  129482. coordinatesMode: number;
  129483. protected _isBlocking: boolean;
  129484. /**
  129485. * Sets wether or not the texture is blocking during loading.
  129486. */
  129487. set isBlocking(value: boolean);
  129488. /**
  129489. * Gets wether or not the texture is blocking during loading.
  129490. */
  129491. get isBlocking(): boolean;
  129492. protected _rotationY: number;
  129493. /**
  129494. * Sets texture matrix rotation angle around Y axis in radians.
  129495. */
  129496. set rotationY(value: number);
  129497. /**
  129498. * Gets texture matrix rotation angle around Y axis radians.
  129499. */
  129500. get rotationY(): number;
  129501. /**
  129502. * Gets or sets the center of the bounding box associated with the cube texture
  129503. * It must define where the camera used to render the texture was set
  129504. */
  129505. boundingBoxPosition: Vector3;
  129506. private _boundingBoxSize;
  129507. /**
  129508. * Gets or sets the size of the bounding box associated with the cube texture
  129509. * When defined, the cubemap will switch to local mode
  129510. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  129511. * @example https://www.babylonjs-playground.com/#RNASML
  129512. */
  129513. set boundingBoxSize(value: Vector3);
  129514. get boundingBoxSize(): Vector3;
  129515. /**
  129516. * Instantiates an HDRTexture from the following parameters.
  129517. *
  129518. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  129519. * @param scene The scene the texture will be used in
  129520. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  129521. * @param noMipmap Forces to not generate the mipmap if true
  129522. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  129523. * @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)
  129524. * @param reserved Reserved flag for internal use.
  129525. */
  129526. 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>);
  129527. /**
  129528. * Get the current class name of the texture useful for serialization or dynamic coding.
  129529. * @returns "HDRCubeTexture"
  129530. */
  129531. getClassName(): string;
  129532. /**
  129533. * Occurs when the file is raw .hdr file.
  129534. */
  129535. private loadTexture;
  129536. clone(): HDRCubeTexture;
  129537. delayLoad(): void;
  129538. /**
  129539. * Get the texture reflection matrix used to rotate/transform the reflection.
  129540. * @returns the reflection matrix
  129541. */
  129542. getReflectionTextureMatrix(): Matrix;
  129543. /**
  129544. * Set the texture reflection matrix used to rotate/transform the reflection.
  129545. * @param value Define the reflection matrix to set
  129546. */
  129547. setReflectionTextureMatrix(value: Matrix): void;
  129548. /**
  129549. * Parses a JSON representation of an HDR Texture in order to create the texture
  129550. * @param parsedTexture Define the JSON representation
  129551. * @param scene Define the scene the texture should be created in
  129552. * @param rootUrl Define the root url in case we need to load relative dependencies
  129553. * @returns the newly created texture after parsing
  129554. */
  129555. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  129556. serialize(): any;
  129557. }
  129558. }
  129559. declare module BABYLON {
  129560. /**
  129561. * Class used to control physics engine
  129562. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  129563. */
  129564. export class PhysicsEngine implements IPhysicsEngine {
  129565. private _physicsPlugin;
  129566. /**
  129567. * Global value used to control the smallest number supported by the simulation
  129568. */
  129569. static Epsilon: number;
  129570. private _impostors;
  129571. private _joints;
  129572. private _subTimeStep;
  129573. /**
  129574. * Gets the gravity vector used by the simulation
  129575. */
  129576. gravity: Vector3;
  129577. /**
  129578. * Factory used to create the default physics plugin.
  129579. * @returns The default physics plugin
  129580. */
  129581. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  129582. /**
  129583. * Creates a new Physics Engine
  129584. * @param gravity defines the gravity vector used by the simulation
  129585. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  129586. */
  129587. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  129588. /**
  129589. * Sets the gravity vector used by the simulation
  129590. * @param gravity defines the gravity vector to use
  129591. */
  129592. setGravity(gravity: Vector3): void;
  129593. /**
  129594. * Set the time step of the physics engine.
  129595. * Default is 1/60.
  129596. * To slow it down, enter 1/600 for example.
  129597. * To speed it up, 1/30
  129598. * @param newTimeStep defines the new timestep to apply to this world.
  129599. */
  129600. setTimeStep(newTimeStep?: number): void;
  129601. /**
  129602. * Get the time step of the physics engine.
  129603. * @returns the current time step
  129604. */
  129605. getTimeStep(): number;
  129606. /**
  129607. * Set the sub time step of the physics engine.
  129608. * Default is 0 meaning there is no sub steps
  129609. * To increase physics resolution precision, set a small value (like 1 ms)
  129610. * @param subTimeStep defines the new sub timestep used for physics resolution.
  129611. */
  129612. setSubTimeStep(subTimeStep?: number): void;
  129613. /**
  129614. * Get the sub time step of the physics engine.
  129615. * @returns the current sub time step
  129616. */
  129617. getSubTimeStep(): number;
  129618. /**
  129619. * Release all resources
  129620. */
  129621. dispose(): void;
  129622. /**
  129623. * Gets the name of the current physics plugin
  129624. * @returns the name of the plugin
  129625. */
  129626. getPhysicsPluginName(): string;
  129627. /**
  129628. * Adding a new impostor for the impostor tracking.
  129629. * This will be done by the impostor itself.
  129630. * @param impostor the impostor to add
  129631. */
  129632. addImpostor(impostor: PhysicsImpostor): void;
  129633. /**
  129634. * Remove an impostor from the engine.
  129635. * This impostor and its mesh will not longer be updated by the physics engine.
  129636. * @param impostor the impostor to remove
  129637. */
  129638. removeImpostor(impostor: PhysicsImpostor): void;
  129639. /**
  129640. * Add a joint to the physics engine
  129641. * @param mainImpostor defines the main impostor to which the joint is added.
  129642. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  129643. * @param joint defines the joint that will connect both impostors.
  129644. */
  129645. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  129646. /**
  129647. * Removes a joint from the simulation
  129648. * @param mainImpostor defines the impostor used with the joint
  129649. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  129650. * @param joint defines the joint to remove
  129651. */
  129652. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  129653. /**
  129654. * Called by the scene. No need to call it.
  129655. * @param delta defines the timespam between frames
  129656. */
  129657. _step(delta: number): void;
  129658. /**
  129659. * Gets the current plugin used to run the simulation
  129660. * @returns current plugin
  129661. */
  129662. getPhysicsPlugin(): IPhysicsEnginePlugin;
  129663. /**
  129664. * Gets the list of physic impostors
  129665. * @returns an array of PhysicsImpostor
  129666. */
  129667. getImpostors(): Array<PhysicsImpostor>;
  129668. /**
  129669. * Gets the impostor for a physics enabled object
  129670. * @param object defines the object impersonated by the impostor
  129671. * @returns the PhysicsImpostor or null if not found
  129672. */
  129673. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  129674. /**
  129675. * Gets the impostor for a physics body object
  129676. * @param body defines physics body used by the impostor
  129677. * @returns the PhysicsImpostor or null if not found
  129678. */
  129679. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  129680. /**
  129681. * Does a raycast in the physics world
  129682. * @param from when should the ray start?
  129683. * @param to when should the ray end?
  129684. * @returns PhysicsRaycastResult
  129685. */
  129686. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  129687. }
  129688. }
  129689. declare module BABYLON {
  129690. /** @hidden */
  129691. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  129692. private _useDeltaForWorldStep;
  129693. world: any;
  129694. name: string;
  129695. private _physicsMaterials;
  129696. private _fixedTimeStep;
  129697. private _cannonRaycastResult;
  129698. private _raycastResult;
  129699. private _physicsBodysToRemoveAfterStep;
  129700. BJSCANNON: any;
  129701. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  129702. setGravity(gravity: Vector3): void;
  129703. setTimeStep(timeStep: number): void;
  129704. getTimeStep(): number;
  129705. executeStep(delta: number): void;
  129706. private _removeMarkedPhysicsBodiesFromWorld;
  129707. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  129708. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  129709. generatePhysicsBody(impostor: PhysicsImpostor): void;
  129710. private _processChildMeshes;
  129711. removePhysicsBody(impostor: PhysicsImpostor): void;
  129712. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  129713. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  129714. private _addMaterial;
  129715. private _checkWithEpsilon;
  129716. private _createShape;
  129717. private _createHeightmap;
  129718. private _minus90X;
  129719. private _plus90X;
  129720. private _tmpPosition;
  129721. private _tmpDeltaPosition;
  129722. private _tmpUnityRotation;
  129723. private _updatePhysicsBodyTransformation;
  129724. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  129725. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  129726. isSupported(): boolean;
  129727. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  129728. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  129729. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  129730. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  129731. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  129732. getBodyMass(impostor: PhysicsImpostor): number;
  129733. getBodyFriction(impostor: PhysicsImpostor): number;
  129734. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  129735. getBodyRestitution(impostor: PhysicsImpostor): number;
  129736. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  129737. sleepBody(impostor: PhysicsImpostor): void;
  129738. wakeUpBody(impostor: PhysicsImpostor): void;
  129739. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  129740. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  129741. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  129742. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  129743. getRadius(impostor: PhysicsImpostor): number;
  129744. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  129745. dispose(): void;
  129746. private _extendNamespace;
  129747. /**
  129748. * Does a raycast in the physics world
  129749. * @param from when should the ray start?
  129750. * @param to when should the ray end?
  129751. * @returns PhysicsRaycastResult
  129752. */
  129753. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  129754. }
  129755. }
  129756. declare module BABYLON {
  129757. /** @hidden */
  129758. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  129759. world: any;
  129760. name: string;
  129761. BJSOIMO: any;
  129762. private _raycastResult;
  129763. constructor(iterations?: number, oimoInjection?: any);
  129764. setGravity(gravity: Vector3): void;
  129765. setTimeStep(timeStep: number): void;
  129766. getTimeStep(): number;
  129767. private _tmpImpostorsArray;
  129768. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  129769. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  129770. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  129771. generatePhysicsBody(impostor: PhysicsImpostor): void;
  129772. private _tmpPositionVector;
  129773. removePhysicsBody(impostor: PhysicsImpostor): void;
  129774. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  129775. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  129776. isSupported(): boolean;
  129777. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  129778. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  129779. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  129780. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  129781. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  129782. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  129783. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  129784. getBodyMass(impostor: PhysicsImpostor): number;
  129785. getBodyFriction(impostor: PhysicsImpostor): number;
  129786. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  129787. getBodyRestitution(impostor: PhysicsImpostor): number;
  129788. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  129789. sleepBody(impostor: PhysicsImpostor): void;
  129790. wakeUpBody(impostor: PhysicsImpostor): void;
  129791. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  129792. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  129793. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  129794. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  129795. getRadius(impostor: PhysicsImpostor): number;
  129796. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  129797. dispose(): void;
  129798. /**
  129799. * Does a raycast in the physics world
  129800. * @param from when should the ray start?
  129801. * @param to when should the ray end?
  129802. * @returns PhysicsRaycastResult
  129803. */
  129804. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  129805. }
  129806. }
  129807. declare module BABYLON {
  129808. /**
  129809. * Class containing static functions to help procedurally build meshes
  129810. */
  129811. export class RibbonBuilder {
  129812. /**
  129813. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  129814. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  129815. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  129816. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  129817. * * 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
  129818. * * 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
  129819. * * 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
  129820. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  129821. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  129822. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  129823. * * 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
  129824. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  129825. * * 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
  129826. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  129827. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  129828. * @param name defines the name of the mesh
  129829. * @param options defines the options used to create the mesh
  129830. * @param scene defines the hosting scene
  129831. * @returns the ribbon mesh
  129832. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  129833. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  129834. */
  129835. static CreateRibbon(name: string, options: {
  129836. pathArray: Vector3[][];
  129837. closeArray?: boolean;
  129838. closePath?: boolean;
  129839. offset?: number;
  129840. updatable?: boolean;
  129841. sideOrientation?: number;
  129842. frontUVs?: Vector4;
  129843. backUVs?: Vector4;
  129844. instance?: Mesh;
  129845. invertUV?: boolean;
  129846. uvs?: Vector2[];
  129847. colors?: Color4[];
  129848. }, scene?: Nullable<Scene>): Mesh;
  129849. }
  129850. }
  129851. declare module BABYLON {
  129852. /**
  129853. * Class containing static functions to help procedurally build meshes
  129854. */
  129855. export class ShapeBuilder {
  129856. /**
  129857. * 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.
  129858. * * 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.
  129859. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  129860. * * 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.
  129861. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  129862. * * 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
  129863. * * 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
  129864. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  129865. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  129866. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  129867. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  129868. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  129869. * @param name defines the name of the mesh
  129870. * @param options defines the options used to create the mesh
  129871. * @param scene defines the hosting scene
  129872. * @returns the extruded shape mesh
  129873. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  129874. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  129875. */
  129876. static ExtrudeShape(name: string, options: {
  129877. shape: Vector3[];
  129878. path: Vector3[];
  129879. scale?: number;
  129880. rotation?: number;
  129881. cap?: number;
  129882. updatable?: boolean;
  129883. sideOrientation?: number;
  129884. frontUVs?: Vector4;
  129885. backUVs?: Vector4;
  129886. instance?: Mesh;
  129887. invertUV?: boolean;
  129888. }, scene?: Nullable<Scene>): Mesh;
  129889. /**
  129890. * Creates an custom extruded shape mesh.
  129891. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  129892. * * 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.
  129893. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  129894. * * 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
  129895. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  129896. * * 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
  129897. * * It must returns a float value that will be the scale value applied to the shape on each path point
  129898. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  129899. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  129900. * * 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
  129901. * * 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
  129902. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  129903. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  129904. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  129905. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  129906. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  129907. * @param name defines the name of the mesh
  129908. * @param options defines the options used to create the mesh
  129909. * @param scene defines the hosting scene
  129910. * @returns the custom extruded shape mesh
  129911. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  129912. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  129913. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  129914. */
  129915. static ExtrudeShapeCustom(name: string, options: {
  129916. shape: Vector3[];
  129917. path: Vector3[];
  129918. scaleFunction?: any;
  129919. rotationFunction?: any;
  129920. ribbonCloseArray?: boolean;
  129921. ribbonClosePath?: boolean;
  129922. cap?: number;
  129923. updatable?: boolean;
  129924. sideOrientation?: number;
  129925. frontUVs?: Vector4;
  129926. backUVs?: Vector4;
  129927. instance?: Mesh;
  129928. invertUV?: boolean;
  129929. }, scene?: Nullable<Scene>): Mesh;
  129930. private static _ExtrudeShapeGeneric;
  129931. }
  129932. }
  129933. declare module BABYLON {
  129934. /**
  129935. * AmmoJS Physics plugin
  129936. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  129937. * @see https://github.com/kripken/ammo.js/
  129938. */
  129939. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  129940. private _useDeltaForWorldStep;
  129941. /**
  129942. * Reference to the Ammo library
  129943. */
  129944. bjsAMMO: any;
  129945. /**
  129946. * Created ammoJS world which physics bodies are added to
  129947. */
  129948. world: any;
  129949. /**
  129950. * Name of the plugin
  129951. */
  129952. name: string;
  129953. private _timeStep;
  129954. private _fixedTimeStep;
  129955. private _maxSteps;
  129956. private _tmpQuaternion;
  129957. private _tmpAmmoTransform;
  129958. private _tmpAmmoQuaternion;
  129959. private _tmpAmmoConcreteContactResultCallback;
  129960. private _collisionConfiguration;
  129961. private _dispatcher;
  129962. private _overlappingPairCache;
  129963. private _solver;
  129964. private _softBodySolver;
  129965. private _tmpAmmoVectorA;
  129966. private _tmpAmmoVectorB;
  129967. private _tmpAmmoVectorC;
  129968. private _tmpAmmoVectorD;
  129969. private _tmpContactCallbackResult;
  129970. private _tmpAmmoVectorRCA;
  129971. private _tmpAmmoVectorRCB;
  129972. private _raycastResult;
  129973. private static readonly DISABLE_COLLISION_FLAG;
  129974. private static readonly KINEMATIC_FLAG;
  129975. private static readonly DISABLE_DEACTIVATION_FLAG;
  129976. /**
  129977. * Initializes the ammoJS plugin
  129978. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  129979. * @param ammoInjection can be used to inject your own ammo reference
  129980. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  129981. */
  129982. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  129983. /**
  129984. * Sets the gravity of the physics world (m/(s^2))
  129985. * @param gravity Gravity to set
  129986. */
  129987. setGravity(gravity: Vector3): void;
  129988. /**
  129989. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  129990. * @param timeStep timestep to use in seconds
  129991. */
  129992. setTimeStep(timeStep: number): void;
  129993. /**
  129994. * 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)
  129995. * @param fixedTimeStep fixedTimeStep to use in seconds
  129996. */
  129997. setFixedTimeStep(fixedTimeStep: number): void;
  129998. /**
  129999. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  130000. * @param maxSteps the maximum number of steps by the physics engine per frame
  130001. */
  130002. setMaxSteps(maxSteps: number): void;
  130003. /**
  130004. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  130005. * @returns the current timestep in seconds
  130006. */
  130007. getTimeStep(): number;
  130008. /**
  130009. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  130010. */
  130011. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  130012. private _isImpostorInContact;
  130013. private _isImpostorPairInContact;
  130014. private _stepSimulation;
  130015. /**
  130016. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  130017. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  130018. * After the step the babylon meshes are set to the position of the physics imposters
  130019. * @param delta amount of time to step forward
  130020. * @param impostors array of imposters to update before/after the step
  130021. */
  130022. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  130023. /**
  130024. * Update babylon mesh to match physics world object
  130025. * @param impostor imposter to match
  130026. */
  130027. private _afterSoftStep;
  130028. /**
  130029. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  130030. * @param impostor imposter to match
  130031. */
  130032. private _ropeStep;
  130033. /**
  130034. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  130035. * @param impostor imposter to match
  130036. */
  130037. private _softbodyOrClothStep;
  130038. private _tmpMatrix;
  130039. /**
  130040. * Applies an impulse on the imposter
  130041. * @param impostor imposter to apply impulse to
  130042. * @param force amount of force to be applied to the imposter
  130043. * @param contactPoint the location to apply the impulse on the imposter
  130044. */
  130045. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  130046. /**
  130047. * Applies a force on the imposter
  130048. * @param impostor imposter to apply force
  130049. * @param force amount of force to be applied to the imposter
  130050. * @param contactPoint the location to apply the force on the imposter
  130051. */
  130052. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  130053. /**
  130054. * Creates a physics body using the plugin
  130055. * @param impostor the imposter to create the physics body on
  130056. */
  130057. generatePhysicsBody(impostor: PhysicsImpostor): void;
  130058. /**
  130059. * Removes the physics body from the imposter and disposes of the body's memory
  130060. * @param impostor imposter to remove the physics body from
  130061. */
  130062. removePhysicsBody(impostor: PhysicsImpostor): void;
  130063. /**
  130064. * Generates a joint
  130065. * @param impostorJoint the imposter joint to create the joint with
  130066. */
  130067. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  130068. /**
  130069. * Removes a joint
  130070. * @param impostorJoint the imposter joint to remove the joint from
  130071. */
  130072. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  130073. private _addMeshVerts;
  130074. /**
  130075. * Initialise the soft body vertices to match its object's (mesh) vertices
  130076. * Softbody vertices (nodes) are in world space and to match this
  130077. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  130078. * @param impostor to create the softbody for
  130079. */
  130080. private _softVertexData;
  130081. /**
  130082. * Create an impostor's soft body
  130083. * @param impostor to create the softbody for
  130084. */
  130085. private _createSoftbody;
  130086. /**
  130087. * Create cloth for an impostor
  130088. * @param impostor to create the softbody for
  130089. */
  130090. private _createCloth;
  130091. /**
  130092. * Create rope for an impostor
  130093. * @param impostor to create the softbody for
  130094. */
  130095. private _createRope;
  130096. /**
  130097. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  130098. * @param impostor to create the custom physics shape for
  130099. */
  130100. private _createCustom;
  130101. private _addHullVerts;
  130102. private _createShape;
  130103. /**
  130104. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  130105. * @param impostor imposter containing the physics body and babylon object
  130106. */
  130107. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  130108. /**
  130109. * Sets the babylon object's position/rotation from the physics body's position/rotation
  130110. * @param impostor imposter containing the physics body and babylon object
  130111. * @param newPosition new position
  130112. * @param newRotation new rotation
  130113. */
  130114. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  130115. /**
  130116. * If this plugin is supported
  130117. * @returns true if its supported
  130118. */
  130119. isSupported(): boolean;
  130120. /**
  130121. * Sets the linear velocity of the physics body
  130122. * @param impostor imposter to set the velocity on
  130123. * @param velocity velocity to set
  130124. */
  130125. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  130126. /**
  130127. * Sets the angular velocity of the physics body
  130128. * @param impostor imposter to set the velocity on
  130129. * @param velocity velocity to set
  130130. */
  130131. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  130132. /**
  130133. * gets the linear velocity
  130134. * @param impostor imposter to get linear velocity from
  130135. * @returns linear velocity
  130136. */
  130137. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  130138. /**
  130139. * gets the angular velocity
  130140. * @param impostor imposter to get angular velocity from
  130141. * @returns angular velocity
  130142. */
  130143. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  130144. /**
  130145. * Sets the mass of physics body
  130146. * @param impostor imposter to set the mass on
  130147. * @param mass mass to set
  130148. */
  130149. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  130150. /**
  130151. * Gets the mass of the physics body
  130152. * @param impostor imposter to get the mass from
  130153. * @returns mass
  130154. */
  130155. getBodyMass(impostor: PhysicsImpostor): number;
  130156. /**
  130157. * Gets friction of the impostor
  130158. * @param impostor impostor to get friction from
  130159. * @returns friction value
  130160. */
  130161. getBodyFriction(impostor: PhysicsImpostor): number;
  130162. /**
  130163. * Sets friction of the impostor
  130164. * @param impostor impostor to set friction on
  130165. * @param friction friction value
  130166. */
  130167. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  130168. /**
  130169. * Gets restitution of the impostor
  130170. * @param impostor impostor to get restitution from
  130171. * @returns restitution value
  130172. */
  130173. getBodyRestitution(impostor: PhysicsImpostor): number;
  130174. /**
  130175. * Sets resitution of the impostor
  130176. * @param impostor impostor to set resitution on
  130177. * @param restitution resitution value
  130178. */
  130179. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  130180. /**
  130181. * Gets pressure inside the impostor
  130182. * @param impostor impostor to get pressure from
  130183. * @returns pressure value
  130184. */
  130185. getBodyPressure(impostor: PhysicsImpostor): number;
  130186. /**
  130187. * Sets pressure inside a soft body impostor
  130188. * Cloth and rope must remain 0 pressure
  130189. * @param impostor impostor to set pressure on
  130190. * @param pressure pressure value
  130191. */
  130192. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  130193. /**
  130194. * Gets stiffness of the impostor
  130195. * @param impostor impostor to get stiffness from
  130196. * @returns pressure value
  130197. */
  130198. getBodyStiffness(impostor: PhysicsImpostor): number;
  130199. /**
  130200. * Sets stiffness of the impostor
  130201. * @param impostor impostor to set stiffness on
  130202. * @param stiffness stiffness value from 0 to 1
  130203. */
  130204. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  130205. /**
  130206. * Gets velocityIterations of the impostor
  130207. * @param impostor impostor to get velocity iterations from
  130208. * @returns velocityIterations value
  130209. */
  130210. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  130211. /**
  130212. * Sets velocityIterations of the impostor
  130213. * @param impostor impostor to set velocity iterations on
  130214. * @param velocityIterations velocityIterations value
  130215. */
  130216. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  130217. /**
  130218. * Gets positionIterations of the impostor
  130219. * @param impostor impostor to get position iterations from
  130220. * @returns positionIterations value
  130221. */
  130222. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  130223. /**
  130224. * Sets positionIterations of the impostor
  130225. * @param impostor impostor to set position on
  130226. * @param positionIterations positionIterations value
  130227. */
  130228. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  130229. /**
  130230. * Append an anchor to a cloth object
  130231. * @param impostor is the cloth impostor to add anchor to
  130232. * @param otherImpostor is the rigid impostor to anchor to
  130233. * @param width ratio across width from 0 to 1
  130234. * @param height ratio up height from 0 to 1
  130235. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  130236. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  130237. */
  130238. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  130239. /**
  130240. * Append an hook to a rope object
  130241. * @param impostor is the rope impostor to add hook to
  130242. * @param otherImpostor is the rigid impostor to hook to
  130243. * @param length ratio along the rope from 0 to 1
  130244. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  130245. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  130246. */
  130247. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  130248. /**
  130249. * Sleeps the physics body and stops it from being active
  130250. * @param impostor impostor to sleep
  130251. */
  130252. sleepBody(impostor: PhysicsImpostor): void;
  130253. /**
  130254. * Activates the physics body
  130255. * @param impostor impostor to activate
  130256. */
  130257. wakeUpBody(impostor: PhysicsImpostor): void;
  130258. /**
  130259. * Updates the distance parameters of the joint
  130260. * @param joint joint to update
  130261. * @param maxDistance maximum distance of the joint
  130262. * @param minDistance minimum distance of the joint
  130263. */
  130264. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  130265. /**
  130266. * Sets a motor on the joint
  130267. * @param joint joint to set motor on
  130268. * @param speed speed of the motor
  130269. * @param maxForce maximum force of the motor
  130270. * @param motorIndex index of the motor
  130271. */
  130272. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  130273. /**
  130274. * Sets the motors limit
  130275. * @param joint joint to set limit on
  130276. * @param upperLimit upper limit
  130277. * @param lowerLimit lower limit
  130278. */
  130279. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  130280. /**
  130281. * Syncs the position and rotation of a mesh with the impostor
  130282. * @param mesh mesh to sync
  130283. * @param impostor impostor to update the mesh with
  130284. */
  130285. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  130286. /**
  130287. * Gets the radius of the impostor
  130288. * @param impostor impostor to get radius from
  130289. * @returns the radius
  130290. */
  130291. getRadius(impostor: PhysicsImpostor): number;
  130292. /**
  130293. * Gets the box size of the impostor
  130294. * @param impostor impostor to get box size from
  130295. * @param result the resulting box size
  130296. */
  130297. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  130298. /**
  130299. * Disposes of the impostor
  130300. */
  130301. dispose(): void;
  130302. /**
  130303. * Does a raycast in the physics world
  130304. * @param from when should the ray start?
  130305. * @param to when should the ray end?
  130306. * @returns PhysicsRaycastResult
  130307. */
  130308. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  130309. }
  130310. }
  130311. declare module BABYLON {
  130312. interface AbstractScene {
  130313. /**
  130314. * The list of reflection probes added to the scene
  130315. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  130316. */
  130317. reflectionProbes: Array<ReflectionProbe>;
  130318. /**
  130319. * Removes the given reflection probe from this scene.
  130320. * @param toRemove The reflection probe to remove
  130321. * @returns The index of the removed reflection probe
  130322. */
  130323. removeReflectionProbe(toRemove: ReflectionProbe): number;
  130324. /**
  130325. * Adds the given reflection probe to this scene.
  130326. * @param newReflectionProbe The reflection probe to add
  130327. */
  130328. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  130329. }
  130330. /**
  130331. * Class used to generate realtime reflection / refraction cube textures
  130332. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  130333. */
  130334. export class ReflectionProbe {
  130335. /** defines the name of the probe */
  130336. name: string;
  130337. private _scene;
  130338. private _renderTargetTexture;
  130339. private _projectionMatrix;
  130340. private _viewMatrix;
  130341. private _target;
  130342. private _add;
  130343. private _attachedMesh;
  130344. private _invertYAxis;
  130345. /** Gets or sets probe position (center of the cube map) */
  130346. position: Vector3;
  130347. /**
  130348. * Creates a new reflection probe
  130349. * @param name defines the name of the probe
  130350. * @param size defines the texture resolution (for each face)
  130351. * @param scene defines the hosting scene
  130352. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  130353. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  130354. */
  130355. constructor(
  130356. /** defines the name of the probe */
  130357. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  130358. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  130359. get samples(): number;
  130360. set samples(value: number);
  130361. /** Gets or sets the refresh rate to use (on every frame by default) */
  130362. get refreshRate(): number;
  130363. set refreshRate(value: number);
  130364. /**
  130365. * Gets the hosting scene
  130366. * @returns a Scene
  130367. */
  130368. getScene(): Scene;
  130369. /** Gets the internal CubeTexture used to render to */
  130370. get cubeTexture(): RenderTargetTexture;
  130371. /** Gets the list of meshes to render */
  130372. get renderList(): Nullable<AbstractMesh[]>;
  130373. /**
  130374. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  130375. * @param mesh defines the mesh to attach to
  130376. */
  130377. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  130378. /**
  130379. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  130380. * @param renderingGroupId The rendering group id corresponding to its index
  130381. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  130382. */
  130383. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  130384. /**
  130385. * Clean all associated resources
  130386. */
  130387. dispose(): void;
  130388. /**
  130389. * Converts the reflection probe information to a readable string for debug purpose.
  130390. * @param fullDetails Supports for multiple levels of logging within scene loading
  130391. * @returns the human readable reflection probe info
  130392. */
  130393. toString(fullDetails?: boolean): string;
  130394. /**
  130395. * Get the class name of the relfection probe.
  130396. * @returns "ReflectionProbe"
  130397. */
  130398. getClassName(): string;
  130399. /**
  130400. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  130401. * @returns The JSON representation of the texture
  130402. */
  130403. serialize(): any;
  130404. /**
  130405. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  130406. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  130407. * @param scene Define the scene the parsed reflection probe should be instantiated in
  130408. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  130409. * @returns The parsed reflection probe if successful
  130410. */
  130411. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  130412. }
  130413. }
  130414. declare module BABYLON {
  130415. /** @hidden */
  130416. export var _BabylonLoaderRegistered: boolean;
  130417. /**
  130418. * Helps setting up some configuration for the babylon file loader.
  130419. */
  130420. export class BabylonFileLoaderConfiguration {
  130421. /**
  130422. * The loader does not allow injecting custom physix engine into the plugins.
  130423. * Unfortunately in ES6, we need to manually inject them into the plugin.
  130424. * So you could set this variable to your engine import to make it work.
  130425. */
  130426. static LoaderInjectedPhysicsEngine: any;
  130427. }
  130428. }
  130429. declare module BABYLON {
  130430. /**
  130431. * The Physically based simple base material of BJS.
  130432. *
  130433. * This enables better naming and convention enforcements on top of the pbrMaterial.
  130434. * It is used as the base class for both the specGloss and metalRough conventions.
  130435. */
  130436. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  130437. /**
  130438. * Number of Simultaneous lights allowed on the material.
  130439. */
  130440. maxSimultaneousLights: number;
  130441. /**
  130442. * If sets to true, disables all the lights affecting the material.
  130443. */
  130444. disableLighting: boolean;
  130445. /**
  130446. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  130447. */
  130448. environmentTexture: BaseTexture;
  130449. /**
  130450. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  130451. */
  130452. invertNormalMapX: boolean;
  130453. /**
  130454. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  130455. */
  130456. invertNormalMapY: boolean;
  130457. /**
  130458. * Normal map used in the model.
  130459. */
  130460. normalTexture: BaseTexture;
  130461. /**
  130462. * Emissivie color used to self-illuminate the model.
  130463. */
  130464. emissiveColor: Color3;
  130465. /**
  130466. * Emissivie texture used to self-illuminate the model.
  130467. */
  130468. emissiveTexture: BaseTexture;
  130469. /**
  130470. * Occlusion Channel Strenght.
  130471. */
  130472. occlusionStrength: number;
  130473. /**
  130474. * Occlusion Texture of the material (adding extra occlusion effects).
  130475. */
  130476. occlusionTexture: BaseTexture;
  130477. /**
  130478. * Defines the alpha limits in alpha test mode.
  130479. */
  130480. alphaCutOff: number;
  130481. /**
  130482. * Gets the current double sided mode.
  130483. */
  130484. get doubleSided(): boolean;
  130485. /**
  130486. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  130487. */
  130488. set doubleSided(value: boolean);
  130489. /**
  130490. * Stores the pre-calculated light information of a mesh in a texture.
  130491. */
  130492. lightmapTexture: BaseTexture;
  130493. /**
  130494. * If true, the light map contains occlusion information instead of lighting info.
  130495. */
  130496. useLightmapAsShadowmap: boolean;
  130497. /**
  130498. * Instantiates a new PBRMaterial instance.
  130499. *
  130500. * @param name The material name
  130501. * @param scene The scene the material will be use in.
  130502. */
  130503. constructor(name: string, scene: Scene);
  130504. getClassName(): string;
  130505. }
  130506. }
  130507. declare module BABYLON {
  130508. /**
  130509. * The PBR material of BJS following the metal roughness convention.
  130510. *
  130511. * This fits to the PBR convention in the GLTF definition:
  130512. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  130513. */
  130514. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  130515. /**
  130516. * The base color has two different interpretations depending on the value of metalness.
  130517. * When the material is a metal, the base color is the specific measured reflectance value
  130518. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  130519. * of the material.
  130520. */
  130521. baseColor: Color3;
  130522. /**
  130523. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  130524. * well as opacity information in the alpha channel.
  130525. */
  130526. baseTexture: BaseTexture;
  130527. /**
  130528. * Specifies the metallic scalar value of the material.
  130529. * Can also be used to scale the metalness values of the metallic texture.
  130530. */
  130531. metallic: number;
  130532. /**
  130533. * Specifies the roughness scalar value of the material.
  130534. * Can also be used to scale the roughness values of the metallic texture.
  130535. */
  130536. roughness: number;
  130537. /**
  130538. * Texture containing both the metallic value in the B channel and the
  130539. * roughness value in the G channel to keep better precision.
  130540. */
  130541. metallicRoughnessTexture: BaseTexture;
  130542. /**
  130543. * Instantiates a new PBRMetalRoughnessMaterial instance.
  130544. *
  130545. * @param name The material name
  130546. * @param scene The scene the material will be use in.
  130547. */
  130548. constructor(name: string, scene: Scene);
  130549. /**
  130550. * Return the currrent class name of the material.
  130551. */
  130552. getClassName(): string;
  130553. /**
  130554. * Makes a duplicate of the current material.
  130555. * @param name - name to use for the new material.
  130556. */
  130557. clone(name: string): PBRMetallicRoughnessMaterial;
  130558. /**
  130559. * Serialize the material to a parsable JSON object.
  130560. */
  130561. serialize(): any;
  130562. /**
  130563. * Parses a JSON object correponding to the serialize function.
  130564. */
  130565. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  130566. }
  130567. }
  130568. declare module BABYLON {
  130569. /**
  130570. * The PBR material of BJS following the specular glossiness convention.
  130571. *
  130572. * This fits to the PBR convention in the GLTF definition:
  130573. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  130574. */
  130575. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  130576. /**
  130577. * Specifies the diffuse color of the material.
  130578. */
  130579. diffuseColor: Color3;
  130580. /**
  130581. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  130582. * channel.
  130583. */
  130584. diffuseTexture: BaseTexture;
  130585. /**
  130586. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  130587. */
  130588. specularColor: Color3;
  130589. /**
  130590. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  130591. */
  130592. glossiness: number;
  130593. /**
  130594. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  130595. */
  130596. specularGlossinessTexture: BaseTexture;
  130597. /**
  130598. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  130599. *
  130600. * @param name The material name
  130601. * @param scene The scene the material will be use in.
  130602. */
  130603. constructor(name: string, scene: Scene);
  130604. /**
  130605. * Return the currrent class name of the material.
  130606. */
  130607. getClassName(): string;
  130608. /**
  130609. * Makes a duplicate of the current material.
  130610. * @param name - name to use for the new material.
  130611. */
  130612. clone(name: string): PBRSpecularGlossinessMaterial;
  130613. /**
  130614. * Serialize the material to a parsable JSON object.
  130615. */
  130616. serialize(): any;
  130617. /**
  130618. * Parses a JSON object correponding to the serialize function.
  130619. */
  130620. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  130621. }
  130622. }
  130623. declare module BABYLON {
  130624. /**
  130625. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  130626. * It can help converting any input color in a desired output one. This can then be used to create effects
  130627. * from sepia, black and white to sixties or futuristic rendering...
  130628. *
  130629. * The only supported format is currently 3dl.
  130630. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  130631. */
  130632. export class ColorGradingTexture extends BaseTexture {
  130633. /**
  130634. * The current texture matrix. (will always be identity in color grading texture)
  130635. */
  130636. private _textureMatrix;
  130637. /**
  130638. * The texture URL.
  130639. */
  130640. url: string;
  130641. /**
  130642. * Empty line regex stored for GC.
  130643. */
  130644. private static _noneEmptyLineRegex;
  130645. private _engine;
  130646. /**
  130647. * Instantiates a ColorGradingTexture from the following parameters.
  130648. *
  130649. * @param url The location of the color gradind data (currently only supporting 3dl)
  130650. * @param scene The scene the texture will be used in
  130651. */
  130652. constructor(url: string, scene: Scene);
  130653. /**
  130654. * Returns the texture matrix used in most of the material.
  130655. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  130656. */
  130657. getTextureMatrix(): Matrix;
  130658. /**
  130659. * Occurs when the file being loaded is a .3dl LUT file.
  130660. */
  130661. private load3dlTexture;
  130662. /**
  130663. * Starts the loading process of the texture.
  130664. */
  130665. private loadTexture;
  130666. /**
  130667. * Clones the color gradind texture.
  130668. */
  130669. clone(): ColorGradingTexture;
  130670. /**
  130671. * Called during delayed load for textures.
  130672. */
  130673. delayLoad(): void;
  130674. /**
  130675. * Parses a color grading texture serialized by Babylon.
  130676. * @param parsedTexture The texture information being parsedTexture
  130677. * @param scene The scene to load the texture in
  130678. * @param rootUrl The root url of the data assets to load
  130679. * @return A color gradind texture
  130680. */
  130681. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  130682. /**
  130683. * Serializes the LUT texture to json format.
  130684. */
  130685. serialize(): any;
  130686. }
  130687. }
  130688. declare module BABYLON {
  130689. /**
  130690. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  130691. */
  130692. export class EquiRectangularCubeTexture extends BaseTexture {
  130693. /** The six faces of the cube. */
  130694. private static _FacesMapping;
  130695. private _noMipmap;
  130696. private _onLoad;
  130697. private _onError;
  130698. /** The size of the cubemap. */
  130699. private _size;
  130700. /** The buffer of the image. */
  130701. private _buffer;
  130702. /** The width of the input image. */
  130703. private _width;
  130704. /** The height of the input image. */
  130705. private _height;
  130706. /** The URL to the image. */
  130707. url: string;
  130708. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  130709. coordinatesMode: number;
  130710. /**
  130711. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  130712. * @param url The location of the image
  130713. * @param scene The scene the texture will be used in
  130714. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  130715. * @param noMipmap Forces to not generate the mipmap if true
  130716. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  130717. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  130718. * @param onLoad — defines a callback called when texture is loaded
  130719. * @param onError — defines a callback called if there is an error
  130720. */
  130721. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  130722. /**
  130723. * Load the image data, by putting the image on a canvas and extracting its buffer.
  130724. */
  130725. private loadImage;
  130726. /**
  130727. * Convert the image buffer into a cubemap and create a CubeTexture.
  130728. */
  130729. private loadTexture;
  130730. /**
  130731. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  130732. * @param buffer The ArrayBuffer that should be converted.
  130733. * @returns The buffer as Float32Array.
  130734. */
  130735. private getFloat32ArrayFromArrayBuffer;
  130736. /**
  130737. * Get the current class name of the texture useful for serialization or dynamic coding.
  130738. * @returns "EquiRectangularCubeTexture"
  130739. */
  130740. getClassName(): string;
  130741. /**
  130742. * Create a clone of the current EquiRectangularCubeTexture and return it.
  130743. * @returns A clone of the current EquiRectangularCubeTexture.
  130744. */
  130745. clone(): EquiRectangularCubeTexture;
  130746. }
  130747. }
  130748. declare module BABYLON {
  130749. /**
  130750. * Based on jsTGALoader - Javascript loader for TGA file
  130751. * By Vincent Thibault
  130752. * @see http://blog.robrowser.com/javascript-tga-loader.html
  130753. */
  130754. export class TGATools {
  130755. private static _TYPE_INDEXED;
  130756. private static _TYPE_RGB;
  130757. private static _TYPE_GREY;
  130758. private static _TYPE_RLE_INDEXED;
  130759. private static _TYPE_RLE_RGB;
  130760. private static _TYPE_RLE_GREY;
  130761. private static _ORIGIN_MASK;
  130762. private static _ORIGIN_SHIFT;
  130763. private static _ORIGIN_BL;
  130764. private static _ORIGIN_BR;
  130765. private static _ORIGIN_UL;
  130766. private static _ORIGIN_UR;
  130767. /**
  130768. * Gets the header of a TGA file
  130769. * @param data defines the TGA data
  130770. * @returns the header
  130771. */
  130772. static GetTGAHeader(data: Uint8Array): any;
  130773. /**
  130774. * Uploads TGA content to a Babylon Texture
  130775. * @hidden
  130776. */
  130777. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  130778. /** @hidden */
  130779. 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;
  130780. /** @hidden */
  130781. 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;
  130782. /** @hidden */
  130783. 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;
  130784. /** @hidden */
  130785. 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;
  130786. /** @hidden */
  130787. 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;
  130788. /** @hidden */
  130789. 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;
  130790. }
  130791. }
  130792. declare module BABYLON {
  130793. /**
  130794. * Implementation of the TGA Texture Loader.
  130795. * @hidden
  130796. */
  130797. export class _TGATextureLoader implements IInternalTextureLoader {
  130798. /**
  130799. * Defines wether the loader supports cascade loading the different faces.
  130800. */
  130801. readonly supportCascades: boolean;
  130802. /**
  130803. * This returns if the loader support the current file information.
  130804. * @param extension defines the file extension of the file being loaded
  130805. * @returns true if the loader can load the specified file
  130806. */
  130807. canLoad(extension: string): boolean;
  130808. /**
  130809. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  130810. * @param data contains the texture data
  130811. * @param texture defines the BabylonJS internal texture
  130812. * @param createPolynomials will be true if polynomials have been requested
  130813. * @param onLoad defines the callback to trigger once the texture is ready
  130814. * @param onError defines the callback to trigger in case of error
  130815. */
  130816. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  130817. /**
  130818. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  130819. * @param data contains the texture data
  130820. * @param texture defines the BabylonJS internal texture
  130821. * @param callback defines the method to call once ready to upload
  130822. */
  130823. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  130824. }
  130825. }
  130826. declare module BABYLON {
  130827. /**
  130828. * Info about the .basis files
  130829. */
  130830. class BasisFileInfo {
  130831. /**
  130832. * If the file has alpha
  130833. */
  130834. hasAlpha: boolean;
  130835. /**
  130836. * Info about each image of the basis file
  130837. */
  130838. images: Array<{
  130839. levels: Array<{
  130840. width: number;
  130841. height: number;
  130842. transcodedPixels: ArrayBufferView;
  130843. }>;
  130844. }>;
  130845. }
  130846. /**
  130847. * Result of transcoding a basis file
  130848. */
  130849. class TranscodeResult {
  130850. /**
  130851. * Info about the .basis file
  130852. */
  130853. fileInfo: BasisFileInfo;
  130854. /**
  130855. * Format to use when loading the file
  130856. */
  130857. format: number;
  130858. }
  130859. /**
  130860. * Configuration options for the Basis transcoder
  130861. */
  130862. export class BasisTranscodeConfiguration {
  130863. /**
  130864. * Supported compression formats used to determine the supported output format of the transcoder
  130865. */
  130866. supportedCompressionFormats?: {
  130867. /**
  130868. * etc1 compression format
  130869. */
  130870. etc1?: boolean;
  130871. /**
  130872. * s3tc compression format
  130873. */
  130874. s3tc?: boolean;
  130875. /**
  130876. * pvrtc compression format
  130877. */
  130878. pvrtc?: boolean;
  130879. /**
  130880. * etc2 compression format
  130881. */
  130882. etc2?: boolean;
  130883. };
  130884. /**
  130885. * If mipmap levels should be loaded for transcoded images (Default: true)
  130886. */
  130887. loadMipmapLevels?: boolean;
  130888. /**
  130889. * Index of a single image to load (Default: all images)
  130890. */
  130891. loadSingleImage?: number;
  130892. }
  130893. /**
  130894. * Used to load .Basis files
  130895. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  130896. */
  130897. export class BasisTools {
  130898. private static _IgnoreSupportedFormats;
  130899. /**
  130900. * URL to use when loading the basis transcoder
  130901. */
  130902. static JSModuleURL: string;
  130903. /**
  130904. * URL to use when loading the wasm module for the transcoder
  130905. */
  130906. static WasmModuleURL: string;
  130907. /**
  130908. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  130909. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  130910. * @returns internal format corresponding to the Basis format
  130911. */
  130912. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  130913. private static _WorkerPromise;
  130914. private static _Worker;
  130915. private static _actionId;
  130916. private static _CreateWorkerAsync;
  130917. /**
  130918. * Transcodes a loaded image file to compressed pixel data
  130919. * @param data image data to transcode
  130920. * @param config configuration options for the transcoding
  130921. * @returns a promise resulting in the transcoded image
  130922. */
  130923. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  130924. /**
  130925. * Loads a texture from the transcode result
  130926. * @param texture texture load to
  130927. * @param transcodeResult the result of transcoding the basis file to load from
  130928. */
  130929. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  130930. }
  130931. }
  130932. declare module BABYLON {
  130933. /**
  130934. * Loader for .basis file format
  130935. */
  130936. export class _BasisTextureLoader implements IInternalTextureLoader {
  130937. /**
  130938. * Defines whether the loader supports cascade loading the different faces.
  130939. */
  130940. readonly supportCascades: boolean;
  130941. /**
  130942. * This returns if the loader support the current file information.
  130943. * @param extension defines the file extension of the file being loaded
  130944. * @returns true if the loader can load the specified file
  130945. */
  130946. canLoad(extension: string): boolean;
  130947. /**
  130948. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  130949. * @param data contains the texture data
  130950. * @param texture defines the BabylonJS internal texture
  130951. * @param createPolynomials will be true if polynomials have been requested
  130952. * @param onLoad defines the callback to trigger once the texture is ready
  130953. * @param onError defines the callback to trigger in case of error
  130954. */
  130955. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  130956. /**
  130957. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  130958. * @param data contains the texture data
  130959. * @param texture defines the BabylonJS internal texture
  130960. * @param callback defines the method to call once ready to upload
  130961. */
  130962. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  130963. }
  130964. }
  130965. declare module BABYLON {
  130966. /**
  130967. * 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.
  130968. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  130969. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  130970. */
  130971. export class CustomProceduralTexture extends ProceduralTexture {
  130972. private _animate;
  130973. private _time;
  130974. private _config;
  130975. private _texturePath;
  130976. /**
  130977. * Instantiates a new Custom Procedural Texture.
  130978. * 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.
  130979. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  130980. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  130981. * @param name Define the name of the texture
  130982. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  130983. * @param size Define the size of the texture to create
  130984. * @param scene Define the scene the texture belongs to
  130985. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  130986. * @param generateMipMaps Define if the texture should creates mip maps or not
  130987. */
  130988. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  130989. private _loadJson;
  130990. /**
  130991. * Is the texture ready to be used ? (rendered at least once)
  130992. * @returns true if ready, otherwise, false.
  130993. */
  130994. isReady(): boolean;
  130995. /**
  130996. * Render the texture to its associated render target.
  130997. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  130998. */
  130999. render(useCameraPostProcess?: boolean): void;
  131000. /**
  131001. * Update the list of dependant textures samplers in the shader.
  131002. */
  131003. updateTextures(): void;
  131004. /**
  131005. * Update the uniform values of the procedural texture in the shader.
  131006. */
  131007. updateShaderUniforms(): void;
  131008. /**
  131009. * Define if the texture animates or not.
  131010. */
  131011. get animate(): boolean;
  131012. set animate(value: boolean);
  131013. }
  131014. }
  131015. declare module BABYLON {
  131016. /** @hidden */
  131017. export var noisePixelShader: {
  131018. name: string;
  131019. shader: string;
  131020. };
  131021. }
  131022. declare module BABYLON {
  131023. /**
  131024. * Class used to generate noise procedural textures
  131025. */
  131026. export class NoiseProceduralTexture extends ProceduralTexture {
  131027. private _time;
  131028. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  131029. brightness: number;
  131030. /** Defines the number of octaves to process */
  131031. octaves: number;
  131032. /** Defines the level of persistence (0.8 by default) */
  131033. persistence: number;
  131034. /** Gets or sets animation speed factor (default is 1) */
  131035. animationSpeedFactor: number;
  131036. /**
  131037. * Creates a new NoiseProceduralTexture
  131038. * @param name defines the name fo the texture
  131039. * @param size defines the size of the texture (default is 256)
  131040. * @param scene defines the hosting scene
  131041. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  131042. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  131043. */
  131044. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  131045. private _updateShaderUniforms;
  131046. protected _getDefines(): string;
  131047. /** Generate the current state of the procedural texture */
  131048. render(useCameraPostProcess?: boolean): void;
  131049. /**
  131050. * Serializes this noise procedural texture
  131051. * @returns a serialized noise procedural texture object
  131052. */
  131053. serialize(): any;
  131054. /**
  131055. * Clone the texture.
  131056. * @returns the cloned texture
  131057. */
  131058. clone(): NoiseProceduralTexture;
  131059. /**
  131060. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  131061. * @param parsedTexture defines parsed texture data
  131062. * @param scene defines the current scene
  131063. * @param rootUrl defines the root URL containing noise procedural texture information
  131064. * @returns a parsed NoiseProceduralTexture
  131065. */
  131066. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  131067. }
  131068. }
  131069. declare module BABYLON {
  131070. /**
  131071. * Raw cube texture where the raw buffers are passed in
  131072. */
  131073. export class RawCubeTexture extends CubeTexture {
  131074. /**
  131075. * Creates a cube texture where the raw buffers are passed in.
  131076. * @param scene defines the scene the texture is attached to
  131077. * @param data defines the array of data to use to create each face
  131078. * @param size defines the size of the textures
  131079. * @param format defines the format of the data
  131080. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  131081. * @param generateMipMaps defines if the engine should generate the mip levels
  131082. * @param invertY defines if data must be stored with Y axis inverted
  131083. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  131084. * @param compression defines the compression used (null by default)
  131085. */
  131086. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  131087. /**
  131088. * Updates the raw cube texture.
  131089. * @param data defines the data to store
  131090. * @param format defines the data format
  131091. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  131092. * @param invertY defines if data must be stored with Y axis inverted
  131093. * @param compression defines the compression used (null by default)
  131094. * @param level defines which level of the texture to update
  131095. */
  131096. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  131097. /**
  131098. * Updates a raw cube texture with RGBD encoded data.
  131099. * @param data defines the array of data [mipmap][face] to use to create each face
  131100. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  131101. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  131102. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  131103. * @returns a promsie that resolves when the operation is complete
  131104. */
  131105. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  131106. /**
  131107. * Clones the raw cube texture.
  131108. * @return a new cube texture
  131109. */
  131110. clone(): CubeTexture;
  131111. /** @hidden */
  131112. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  131113. }
  131114. }
  131115. declare module BABYLON {
  131116. /**
  131117. * Class used to store 3D textures containing user data
  131118. */
  131119. export class RawTexture3D extends Texture {
  131120. /** Gets or sets the texture format to use */
  131121. format: number;
  131122. private _engine;
  131123. /**
  131124. * Create a new RawTexture3D
  131125. * @param data defines the data of the texture
  131126. * @param width defines the width of the texture
  131127. * @param height defines the height of the texture
  131128. * @param depth defines the depth of the texture
  131129. * @param format defines the texture format to use
  131130. * @param scene defines the hosting scene
  131131. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  131132. * @param invertY defines if texture must be stored with Y axis inverted
  131133. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  131134. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  131135. */
  131136. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  131137. /** Gets or sets the texture format to use */
  131138. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  131139. /**
  131140. * Update the texture with new data
  131141. * @param data defines the data to store in the texture
  131142. */
  131143. update(data: ArrayBufferView): void;
  131144. }
  131145. }
  131146. declare module BABYLON {
  131147. /**
  131148. * Class used to store 2D array textures containing user data
  131149. */
  131150. export class RawTexture2DArray extends Texture {
  131151. /** Gets or sets the texture format to use */
  131152. format: number;
  131153. private _engine;
  131154. /**
  131155. * Create a new RawTexture2DArray
  131156. * @param data defines the data of the texture
  131157. * @param width defines the width of the texture
  131158. * @param height defines the height of the texture
  131159. * @param depth defines the number of layers of the texture
  131160. * @param format defines the texture format to use
  131161. * @param scene defines the hosting scene
  131162. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  131163. * @param invertY defines if texture must be stored with Y axis inverted
  131164. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  131165. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  131166. */
  131167. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  131168. /** Gets or sets the texture format to use */
  131169. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  131170. /**
  131171. * Update the texture with new data
  131172. * @param data defines the data to store in the texture
  131173. */
  131174. update(data: ArrayBufferView): void;
  131175. }
  131176. }
  131177. declare module BABYLON {
  131178. /**
  131179. * Creates a refraction texture used by refraction channel of the standard material.
  131180. * It is like a mirror but to see through a material.
  131181. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  131182. */
  131183. export class RefractionTexture extends RenderTargetTexture {
  131184. /**
  131185. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  131186. * 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.
  131187. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  131188. */
  131189. refractionPlane: Plane;
  131190. /**
  131191. * Define how deep under the surface we should see.
  131192. */
  131193. depth: number;
  131194. /**
  131195. * Creates a refraction texture used by refraction channel of the standard material.
  131196. * It is like a mirror but to see through a material.
  131197. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  131198. * @param name Define the texture name
  131199. * @param size Define the size of the underlying texture
  131200. * @param scene Define the scene the refraction belongs to
  131201. * @param generateMipMaps Define if we need to generate mips level for the refraction
  131202. */
  131203. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  131204. /**
  131205. * Clone the refraction texture.
  131206. * @returns the cloned texture
  131207. */
  131208. clone(): RefractionTexture;
  131209. /**
  131210. * Serialize the texture to a JSON representation you could use in Parse later on
  131211. * @returns the serialized JSON representation
  131212. */
  131213. serialize(): any;
  131214. }
  131215. }
  131216. declare module BABYLON {
  131217. /**
  131218. * Defines the options related to the creation of an HtmlElementTexture
  131219. */
  131220. export interface IHtmlElementTextureOptions {
  131221. /**
  131222. * Defines wether mip maps should be created or not.
  131223. */
  131224. generateMipMaps?: boolean;
  131225. /**
  131226. * Defines the sampling mode of the texture.
  131227. */
  131228. samplingMode?: number;
  131229. /**
  131230. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  131231. */
  131232. engine: Nullable<ThinEngine>;
  131233. /**
  131234. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  131235. */
  131236. scene: Nullable<Scene>;
  131237. }
  131238. /**
  131239. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  131240. * To be as efficient as possible depending on your constraints nothing aside the first upload
  131241. * is automatically managed.
  131242. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  131243. * in your application.
  131244. *
  131245. * As the update is not automatic, you need to call them manually.
  131246. */
  131247. export class HtmlElementTexture extends BaseTexture {
  131248. /**
  131249. * The texture URL.
  131250. */
  131251. element: HTMLVideoElement | HTMLCanvasElement;
  131252. private static readonly DefaultOptions;
  131253. private _textureMatrix;
  131254. private _engine;
  131255. private _isVideo;
  131256. private _generateMipMaps;
  131257. private _samplingMode;
  131258. /**
  131259. * Instantiates a HtmlElementTexture from the following parameters.
  131260. *
  131261. * @param name Defines the name of the texture
  131262. * @param element Defines the video or canvas the texture is filled with
  131263. * @param options Defines the other none mandatory texture creation options
  131264. */
  131265. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  131266. private _createInternalTexture;
  131267. /**
  131268. * Returns the texture matrix used in most of the material.
  131269. */
  131270. getTextureMatrix(): Matrix;
  131271. /**
  131272. * Updates the content of the texture.
  131273. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  131274. */
  131275. update(invertY?: Nullable<boolean>): void;
  131276. }
  131277. }
  131278. declare module BABYLON {
  131279. /**
  131280. * Defines the basic options interface of a TexturePacker Frame
  131281. */
  131282. export interface ITexturePackerFrame {
  131283. /**
  131284. * The frame ID
  131285. */
  131286. id: number;
  131287. /**
  131288. * The frames Scale
  131289. */
  131290. scale: Vector2;
  131291. /**
  131292. * The Frames offset
  131293. */
  131294. offset: Vector2;
  131295. }
  131296. /**
  131297. * This is a support class for frame Data on texture packer sets.
  131298. */
  131299. export class TexturePackerFrame implements 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. * Initializes a texture package frame.
  131314. * @param id The numerical frame identifier
  131315. * @param scale Scalar Vector2 for UV frame
  131316. * @param offset Vector2 for the frame position in UV units.
  131317. * @returns TexturePackerFrame
  131318. */
  131319. constructor(id: number, scale: Vector2, offset: Vector2);
  131320. }
  131321. }
  131322. declare module BABYLON {
  131323. /**
  131324. * Defines the basic options interface of a TexturePacker
  131325. */
  131326. export interface ITexturePackerOptions {
  131327. /**
  131328. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  131329. */
  131330. map?: string[];
  131331. /**
  131332. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  131333. */
  131334. uvsIn?: string;
  131335. /**
  131336. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  131337. */
  131338. uvsOut?: string;
  131339. /**
  131340. * number representing the layout style. Defaults to LAYOUT_STRIP
  131341. */
  131342. layout?: number;
  131343. /**
  131344. * number of columns if using custom column count layout(2). This defaults to 4.
  131345. */
  131346. colnum?: number;
  131347. /**
  131348. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  131349. */
  131350. updateInputMeshes?: boolean;
  131351. /**
  131352. * boolean flag to dispose all the source textures. Defaults to true.
  131353. */
  131354. disposeSources?: boolean;
  131355. /**
  131356. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  131357. */
  131358. fillBlanks?: boolean;
  131359. /**
  131360. * string value representing the context fill style color. Defaults to 'black'.
  131361. */
  131362. customFillColor?: string;
  131363. /**
  131364. * Width and Height Value of each Frame in the TexturePacker Sets
  131365. */
  131366. frameSize?: number;
  131367. /**
  131368. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  131369. */
  131370. paddingRatio?: number;
  131371. /**
  131372. * Number that declares the fill method for the padding gutter.
  131373. */
  131374. paddingMode?: number;
  131375. /**
  131376. * If in SUBUV_COLOR padding mode what color to use.
  131377. */
  131378. paddingColor?: Color3 | Color4;
  131379. }
  131380. /**
  131381. * Defines the basic interface of a TexturePacker JSON File
  131382. */
  131383. export interface ITexturePackerJSON {
  131384. /**
  131385. * The frame ID
  131386. */
  131387. name: string;
  131388. /**
  131389. * The base64 channel data
  131390. */
  131391. sets: any;
  131392. /**
  131393. * The options of the Packer
  131394. */
  131395. options: ITexturePackerOptions;
  131396. /**
  131397. * The frame data of the Packer
  131398. */
  131399. frames: Array<number>;
  131400. }
  131401. /**
  131402. * This is a support class that generates a series of packed texture sets.
  131403. * @see https://doc.babylonjs.com/babylon101/materials
  131404. */
  131405. export class TexturePacker {
  131406. /** Packer Layout Constant 0 */
  131407. static readonly LAYOUT_STRIP: number;
  131408. /** Packer Layout Constant 1 */
  131409. static readonly LAYOUT_POWER2: number;
  131410. /** Packer Layout Constant 2 */
  131411. static readonly LAYOUT_COLNUM: number;
  131412. /** Packer Layout Constant 0 */
  131413. static readonly SUBUV_WRAP: number;
  131414. /** Packer Layout Constant 1 */
  131415. static readonly SUBUV_EXTEND: number;
  131416. /** Packer Layout Constant 2 */
  131417. static readonly SUBUV_COLOR: number;
  131418. /** The Name of the Texture Package */
  131419. name: string;
  131420. /** The scene scope of the TexturePacker */
  131421. scene: Scene;
  131422. /** The Meshes to target */
  131423. meshes: AbstractMesh[];
  131424. /** Arguments passed with the Constructor */
  131425. options: ITexturePackerOptions;
  131426. /** The promise that is started upon initialization */
  131427. promise: Nullable<Promise<TexturePacker | string>>;
  131428. /** The Container object for the channel sets that are generated */
  131429. sets: object;
  131430. /** The Container array for the frames that are generated */
  131431. frames: TexturePackerFrame[];
  131432. /** The expected number of textures the system is parsing. */
  131433. private _expecting;
  131434. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  131435. private _paddingValue;
  131436. /**
  131437. * Initializes a texture package series from an array of meshes or a single mesh.
  131438. * @param name The name of the package
  131439. * @param meshes The target meshes to compose the package from
  131440. * @param options The arguments that texture packer should follow while building.
  131441. * @param scene The scene which the textures are scoped to.
  131442. * @returns TexturePacker
  131443. */
  131444. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  131445. /**
  131446. * Starts the package process
  131447. * @param resolve The promises resolution function
  131448. * @returns TexturePacker
  131449. */
  131450. private _createFrames;
  131451. /**
  131452. * Calculates the Size of the Channel Sets
  131453. * @returns Vector2
  131454. */
  131455. private _calculateSize;
  131456. /**
  131457. * Calculates the UV data for the frames.
  131458. * @param baseSize the base frameSize
  131459. * @param padding the base frame padding
  131460. * @param dtSize size of the Dynamic Texture for that channel
  131461. * @param dtUnits is 1/dtSize
  131462. * @param update flag to update the input meshes
  131463. */
  131464. private _calculateMeshUVFrames;
  131465. /**
  131466. * Calculates the frames Offset.
  131467. * @param index of the frame
  131468. * @returns Vector2
  131469. */
  131470. private _getFrameOffset;
  131471. /**
  131472. * Updates a Mesh to the frame data
  131473. * @param mesh that is the target
  131474. * @param frameID or the frame index
  131475. */
  131476. private _updateMeshUV;
  131477. /**
  131478. * Updates a Meshes materials to use the texture packer channels
  131479. * @param m is the mesh to target
  131480. * @param force all channels on the packer to be set.
  131481. */
  131482. private _updateTextureReferences;
  131483. /**
  131484. * Public method to set a Mesh to a frame
  131485. * @param m that is the target
  131486. * @param frameID or the frame index
  131487. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  131488. */
  131489. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  131490. /**
  131491. * Starts the async promise to compile the texture packer.
  131492. * @returns Promise<void>
  131493. */
  131494. processAsync(): Promise<void>;
  131495. /**
  131496. * Disposes all textures associated with this packer
  131497. */
  131498. dispose(): void;
  131499. /**
  131500. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  131501. * @param imageType is the image type to use.
  131502. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  131503. */
  131504. download(imageType?: string, quality?: number): void;
  131505. /**
  131506. * Public method to load a texturePacker JSON file.
  131507. * @param data of the JSON file in string format.
  131508. */
  131509. updateFromJSON(data: string): void;
  131510. }
  131511. }
  131512. declare module BABYLON {
  131513. /**
  131514. * Enum used to define the target of a block
  131515. */
  131516. export enum NodeMaterialBlockTargets {
  131517. /** Vertex shader */
  131518. Vertex = 1,
  131519. /** Fragment shader */
  131520. Fragment = 2,
  131521. /** Neutral */
  131522. Neutral = 4,
  131523. /** Vertex and Fragment */
  131524. VertexAndFragment = 3
  131525. }
  131526. }
  131527. declare module BABYLON {
  131528. /**
  131529. * Defines the kind of connection point for node based material
  131530. */
  131531. export enum NodeMaterialBlockConnectionPointTypes {
  131532. /** Float */
  131533. Float = 1,
  131534. /** Int */
  131535. Int = 2,
  131536. /** Vector2 */
  131537. Vector2 = 4,
  131538. /** Vector3 */
  131539. Vector3 = 8,
  131540. /** Vector4 */
  131541. Vector4 = 16,
  131542. /** Color3 */
  131543. Color3 = 32,
  131544. /** Color4 */
  131545. Color4 = 64,
  131546. /** Matrix */
  131547. Matrix = 128,
  131548. /** Detect type based on connection */
  131549. AutoDetect = 1024,
  131550. /** Output type that will be defined by input type */
  131551. BasedOnInput = 2048
  131552. }
  131553. }
  131554. declare module BABYLON {
  131555. /**
  131556. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  131557. */
  131558. export enum NodeMaterialBlockConnectionPointMode {
  131559. /** Value is an uniform */
  131560. Uniform = 0,
  131561. /** Value is a mesh attribute */
  131562. Attribute = 1,
  131563. /** Value is a varying between vertex and fragment shaders */
  131564. Varying = 2,
  131565. /** Mode is undefined */
  131566. Undefined = 3
  131567. }
  131568. }
  131569. declare module BABYLON {
  131570. /**
  131571. * Enum used to define system values e.g. values automatically provided by the system
  131572. */
  131573. export enum NodeMaterialSystemValues {
  131574. /** World */
  131575. World = 1,
  131576. /** View */
  131577. View = 2,
  131578. /** Projection */
  131579. Projection = 3,
  131580. /** ViewProjection */
  131581. ViewProjection = 4,
  131582. /** WorldView */
  131583. WorldView = 5,
  131584. /** WorldViewProjection */
  131585. WorldViewProjection = 6,
  131586. /** CameraPosition */
  131587. CameraPosition = 7,
  131588. /** Fog Color */
  131589. FogColor = 8,
  131590. /** Delta time */
  131591. DeltaTime = 9
  131592. }
  131593. }
  131594. declare module BABYLON {
  131595. /**
  131596. * Root class for all node material optimizers
  131597. */
  131598. export class NodeMaterialOptimizer {
  131599. /**
  131600. * Function used to optimize a NodeMaterial graph
  131601. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  131602. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  131603. */
  131604. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  131605. }
  131606. }
  131607. declare module BABYLON {
  131608. /**
  131609. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  131610. */
  131611. export class TransformBlock extends NodeMaterialBlock {
  131612. /**
  131613. * Defines the value to use to complement W value to transform it to a Vector4
  131614. */
  131615. complementW: number;
  131616. /**
  131617. * Defines the value to use to complement z value to transform it to a Vector4
  131618. */
  131619. complementZ: number;
  131620. /**
  131621. * Creates a new TransformBlock
  131622. * @param name defines the block name
  131623. */
  131624. constructor(name: string);
  131625. /**
  131626. * Gets the current class name
  131627. * @returns the class name
  131628. */
  131629. getClassName(): string;
  131630. /**
  131631. * Gets the vector input
  131632. */
  131633. get vector(): NodeMaterialConnectionPoint;
  131634. /**
  131635. * Gets the output component
  131636. */
  131637. get output(): NodeMaterialConnectionPoint;
  131638. /**
  131639. * Gets the xyz output component
  131640. */
  131641. get xyz(): NodeMaterialConnectionPoint;
  131642. /**
  131643. * Gets the matrix transform input
  131644. */
  131645. get transform(): NodeMaterialConnectionPoint;
  131646. protected _buildBlock(state: NodeMaterialBuildState): this;
  131647. serialize(): any;
  131648. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  131649. protected _dumpPropertiesCode(): string;
  131650. }
  131651. }
  131652. declare module BABYLON {
  131653. /**
  131654. * Block used to output the vertex position
  131655. */
  131656. export class VertexOutputBlock extends NodeMaterialBlock {
  131657. /**
  131658. * Creates a new VertexOutputBlock
  131659. * @param name defines the block name
  131660. */
  131661. constructor(name: string);
  131662. /**
  131663. * Gets the current class name
  131664. * @returns the class name
  131665. */
  131666. getClassName(): string;
  131667. /**
  131668. * Gets the vector input component
  131669. */
  131670. get vector(): NodeMaterialConnectionPoint;
  131671. protected _buildBlock(state: NodeMaterialBuildState): this;
  131672. }
  131673. }
  131674. declare module BABYLON {
  131675. /**
  131676. * Block used to output the final color
  131677. */
  131678. export class FragmentOutputBlock extends NodeMaterialBlock {
  131679. /**
  131680. * Create a new FragmentOutputBlock
  131681. * @param name defines the block name
  131682. */
  131683. constructor(name: string);
  131684. /**
  131685. * Gets the current class name
  131686. * @returns the class name
  131687. */
  131688. getClassName(): string;
  131689. /**
  131690. * Gets the rgba input component
  131691. */
  131692. get rgba(): NodeMaterialConnectionPoint;
  131693. /**
  131694. * Gets the rgb input component
  131695. */
  131696. get rgb(): NodeMaterialConnectionPoint;
  131697. /**
  131698. * Gets the a input component
  131699. */
  131700. get a(): NodeMaterialConnectionPoint;
  131701. protected _buildBlock(state: NodeMaterialBuildState): this;
  131702. }
  131703. }
  131704. declare module BABYLON {
  131705. /**
  131706. * Block used to read a reflection texture from a sampler
  131707. */
  131708. export class ReflectionTextureBlock extends NodeMaterialBlock {
  131709. private _define3DName;
  131710. private _defineCubicName;
  131711. private _defineExplicitName;
  131712. private _defineProjectionName;
  131713. private _defineLocalCubicName;
  131714. private _defineSphericalName;
  131715. private _definePlanarName;
  131716. private _defineEquirectangularName;
  131717. private _defineMirroredEquirectangularFixedName;
  131718. private _defineEquirectangularFixedName;
  131719. private _defineSkyboxName;
  131720. private _cubeSamplerName;
  131721. private _2DSamplerName;
  131722. private _positionUVWName;
  131723. private _directionWName;
  131724. private _reflectionCoordsName;
  131725. private _reflection2DCoordsName;
  131726. private _reflectionColorName;
  131727. private _reflectionMatrixName;
  131728. /**
  131729. * Gets or sets the texture associated with the node
  131730. */
  131731. texture: Nullable<BaseTexture>;
  131732. /**
  131733. * Create a new TextureBlock
  131734. * @param name defines the block name
  131735. */
  131736. constructor(name: string);
  131737. /**
  131738. * Gets the current class name
  131739. * @returns the class name
  131740. */
  131741. getClassName(): string;
  131742. /**
  131743. * Gets the world position input component
  131744. */
  131745. get position(): NodeMaterialConnectionPoint;
  131746. /**
  131747. * Gets the world position input component
  131748. */
  131749. get worldPosition(): NodeMaterialConnectionPoint;
  131750. /**
  131751. * Gets the world normal input component
  131752. */
  131753. get worldNormal(): NodeMaterialConnectionPoint;
  131754. /**
  131755. * Gets the world input component
  131756. */
  131757. get world(): NodeMaterialConnectionPoint;
  131758. /**
  131759. * Gets the camera (or eye) position component
  131760. */
  131761. get cameraPosition(): NodeMaterialConnectionPoint;
  131762. /**
  131763. * Gets the view input component
  131764. */
  131765. get view(): NodeMaterialConnectionPoint;
  131766. /**
  131767. * Gets the rgb output component
  131768. */
  131769. get rgb(): NodeMaterialConnectionPoint;
  131770. /**
  131771. * Gets the r output component
  131772. */
  131773. get r(): NodeMaterialConnectionPoint;
  131774. /**
  131775. * Gets the g output component
  131776. */
  131777. get g(): NodeMaterialConnectionPoint;
  131778. /**
  131779. * Gets the b output component
  131780. */
  131781. get b(): NodeMaterialConnectionPoint;
  131782. autoConfigure(material: NodeMaterial): void;
  131783. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  131784. isReady(): boolean;
  131785. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  131786. private _injectVertexCode;
  131787. private _writeOutput;
  131788. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  131789. protected _dumpPropertiesCode(): string;
  131790. serialize(): any;
  131791. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  131792. }
  131793. }
  131794. declare module BABYLON {
  131795. /**
  131796. * Interface used to configure the node material editor
  131797. */
  131798. export interface INodeMaterialEditorOptions {
  131799. /** Define the URl to load node editor script */
  131800. editorURL?: string;
  131801. }
  131802. /** @hidden */
  131803. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  131804. NORMAL: boolean;
  131805. TANGENT: boolean;
  131806. UV1: boolean;
  131807. /** BONES */
  131808. NUM_BONE_INFLUENCERS: number;
  131809. BonesPerMesh: number;
  131810. BONETEXTURE: boolean;
  131811. /** MORPH TARGETS */
  131812. MORPHTARGETS: boolean;
  131813. MORPHTARGETS_NORMAL: boolean;
  131814. MORPHTARGETS_TANGENT: boolean;
  131815. MORPHTARGETS_UV: boolean;
  131816. NUM_MORPH_INFLUENCERS: number;
  131817. /** IMAGE PROCESSING */
  131818. IMAGEPROCESSING: boolean;
  131819. VIGNETTE: boolean;
  131820. VIGNETTEBLENDMODEMULTIPLY: boolean;
  131821. VIGNETTEBLENDMODEOPAQUE: boolean;
  131822. TONEMAPPING: boolean;
  131823. TONEMAPPING_ACES: boolean;
  131824. CONTRAST: boolean;
  131825. EXPOSURE: boolean;
  131826. COLORCURVES: boolean;
  131827. COLORGRADING: boolean;
  131828. COLORGRADING3D: boolean;
  131829. SAMPLER3DGREENDEPTH: boolean;
  131830. SAMPLER3DBGRMAP: boolean;
  131831. IMAGEPROCESSINGPOSTPROCESS: boolean;
  131832. /** MISC. */
  131833. BUMPDIRECTUV: number;
  131834. constructor();
  131835. setValue(name: string, value: boolean): void;
  131836. }
  131837. /**
  131838. * Class used to configure NodeMaterial
  131839. */
  131840. export interface INodeMaterialOptions {
  131841. /**
  131842. * Defines if blocks should emit comments
  131843. */
  131844. emitComments: boolean;
  131845. }
  131846. /**
  131847. * Class used to create a node based material built by assembling shader blocks
  131848. */
  131849. export class NodeMaterial extends PushMaterial {
  131850. private static _BuildIdGenerator;
  131851. private _options;
  131852. private _vertexCompilationState;
  131853. private _fragmentCompilationState;
  131854. private _sharedData;
  131855. private _buildId;
  131856. private _buildWasSuccessful;
  131857. private _cachedWorldViewMatrix;
  131858. private _cachedWorldViewProjectionMatrix;
  131859. private _optimizers;
  131860. private _animationFrame;
  131861. /** Define the Url to load node editor script */
  131862. static EditorURL: string;
  131863. /** Define the Url to load snippets */
  131864. static SnippetUrl: string;
  131865. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  131866. static IgnoreTexturesAtLoadTime: boolean;
  131867. private BJSNODEMATERIALEDITOR;
  131868. /** Get the inspector from bundle or global */
  131869. private _getGlobalNodeMaterialEditor;
  131870. /**
  131871. * Snippet ID if the material was created from the snippet server
  131872. */
  131873. snippetId: string;
  131874. /**
  131875. * Gets or sets data used by visual editor
  131876. * @see https://nme.babylonjs.com
  131877. */
  131878. editorData: any;
  131879. /**
  131880. * 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)
  131881. */
  131882. ignoreAlpha: boolean;
  131883. /**
  131884. * Defines the maximum number of lights that can be used in the material
  131885. */
  131886. maxSimultaneousLights: number;
  131887. /**
  131888. * Observable raised when the material is built
  131889. */
  131890. onBuildObservable: Observable<NodeMaterial>;
  131891. /**
  131892. * Gets or sets the root nodes of the material vertex shader
  131893. */
  131894. _vertexOutputNodes: NodeMaterialBlock[];
  131895. /**
  131896. * Gets or sets the root nodes of the material fragment (pixel) shader
  131897. */
  131898. _fragmentOutputNodes: NodeMaterialBlock[];
  131899. /** Gets or sets options to control the node material overall behavior */
  131900. get options(): INodeMaterialOptions;
  131901. set options(options: INodeMaterialOptions);
  131902. /**
  131903. * Default configuration related to image processing available in the standard Material.
  131904. */
  131905. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  131906. /**
  131907. * Gets the image processing configuration used either in this material.
  131908. */
  131909. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  131910. /**
  131911. * Sets the Default image processing configuration used either in the this material.
  131912. *
  131913. * If sets to null, the scene one is in use.
  131914. */
  131915. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  131916. /**
  131917. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  131918. */
  131919. attachedBlocks: NodeMaterialBlock[];
  131920. /**
  131921. * Create a new node based material
  131922. * @param name defines the material name
  131923. * @param scene defines the hosting scene
  131924. * @param options defines creation option
  131925. */
  131926. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  131927. /**
  131928. * Gets the current class name of the material e.g. "NodeMaterial"
  131929. * @returns the class name
  131930. */
  131931. getClassName(): string;
  131932. /**
  131933. * Keep track of the image processing observer to allow dispose and replace.
  131934. */
  131935. private _imageProcessingObserver;
  131936. /**
  131937. * Attaches a new image processing configuration to the Standard Material.
  131938. * @param configuration
  131939. */
  131940. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  131941. /**
  131942. * Get a block by its name
  131943. * @param name defines the name of the block to retrieve
  131944. * @returns the required block or null if not found
  131945. */
  131946. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  131947. /**
  131948. * Get a block by its name
  131949. * @param predicate defines the predicate used to find the good candidate
  131950. * @returns the required block or null if not found
  131951. */
  131952. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  131953. /**
  131954. * Get an input block by its name
  131955. * @param predicate defines the predicate used to find the good candidate
  131956. * @returns the required input block or null if not found
  131957. */
  131958. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  131959. /**
  131960. * Gets the list of input blocks attached to this material
  131961. * @returns an array of InputBlocks
  131962. */
  131963. getInputBlocks(): InputBlock[];
  131964. /**
  131965. * Adds a new optimizer to the list of optimizers
  131966. * @param optimizer defines the optimizers to add
  131967. * @returns the current material
  131968. */
  131969. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  131970. /**
  131971. * Remove an optimizer from the list of optimizers
  131972. * @param optimizer defines the optimizers to remove
  131973. * @returns the current material
  131974. */
  131975. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  131976. /**
  131977. * Add a new block to the list of output nodes
  131978. * @param node defines the node to add
  131979. * @returns the current material
  131980. */
  131981. addOutputNode(node: NodeMaterialBlock): this;
  131982. /**
  131983. * Remove a block from the list of root nodes
  131984. * @param node defines the node to remove
  131985. * @returns the current material
  131986. */
  131987. removeOutputNode(node: NodeMaterialBlock): this;
  131988. private _addVertexOutputNode;
  131989. private _removeVertexOutputNode;
  131990. private _addFragmentOutputNode;
  131991. private _removeFragmentOutputNode;
  131992. /**
  131993. * Specifies if the material will require alpha blending
  131994. * @returns a boolean specifying if alpha blending is needed
  131995. */
  131996. needAlphaBlending(): boolean;
  131997. /**
  131998. * Specifies if this material should be rendered in alpha test mode
  131999. * @returns a boolean specifying if an alpha test is needed.
  132000. */
  132001. needAlphaTesting(): boolean;
  132002. private _initializeBlock;
  132003. private _resetDualBlocks;
  132004. /**
  132005. * Remove a block from the current node material
  132006. * @param block defines the block to remove
  132007. */
  132008. removeBlock(block: NodeMaterialBlock): void;
  132009. /**
  132010. * Build the material and generates the inner effect
  132011. * @param verbose defines if the build should log activity
  132012. */
  132013. build(verbose?: boolean): void;
  132014. /**
  132015. * Runs an otpimization phase to try to improve the shader code
  132016. */
  132017. optimize(): void;
  132018. private _prepareDefinesForAttributes;
  132019. /**
  132020. * Get if the submesh is ready to be used and all its information available.
  132021. * Child classes can use it to update shaders
  132022. * @param mesh defines the mesh to check
  132023. * @param subMesh defines which submesh to check
  132024. * @param useInstances specifies that instances should be used
  132025. * @returns a boolean indicating that the submesh is ready or not
  132026. */
  132027. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  132028. /**
  132029. * Get a string representing the shaders built by the current node graph
  132030. */
  132031. get compiledShaders(): string;
  132032. /**
  132033. * Binds the world matrix to the material
  132034. * @param world defines the world transformation matrix
  132035. */
  132036. bindOnlyWorldMatrix(world: Matrix): void;
  132037. /**
  132038. * Binds the submesh to this material by preparing the effect and shader to draw
  132039. * @param world defines the world transformation matrix
  132040. * @param mesh defines the mesh containing the submesh
  132041. * @param subMesh defines the submesh to bind the material to
  132042. */
  132043. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  132044. /**
  132045. * Gets the active textures from the material
  132046. * @returns an array of textures
  132047. */
  132048. getActiveTextures(): BaseTexture[];
  132049. /**
  132050. * Gets the list of texture blocks
  132051. * @returns an array of texture blocks
  132052. */
  132053. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  132054. /**
  132055. * Specifies if the material uses a texture
  132056. * @param texture defines the texture to check against the material
  132057. * @returns a boolean specifying if the material uses the texture
  132058. */
  132059. hasTexture(texture: BaseTexture): boolean;
  132060. /**
  132061. * Disposes the material
  132062. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  132063. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  132064. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  132065. */
  132066. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  132067. /** Creates the node editor window. */
  132068. private _createNodeEditor;
  132069. /**
  132070. * Launch the node material editor
  132071. * @param config Define the configuration of the editor
  132072. * @return a promise fulfilled when the node editor is visible
  132073. */
  132074. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  132075. /**
  132076. * Clear the current material
  132077. */
  132078. clear(): void;
  132079. /**
  132080. * Clear the current material and set it to a default state
  132081. */
  132082. setToDefault(): void;
  132083. /**
  132084. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  132085. * @param url defines the url to load from
  132086. * @returns a promise that will fullfil when the material is fully loaded
  132087. */
  132088. loadAsync(url: string): Promise<void>;
  132089. private _gatherBlocks;
  132090. /**
  132091. * Generate a string containing the code declaration required to create an equivalent of this material
  132092. * @returns a string
  132093. */
  132094. generateCode(): string;
  132095. /**
  132096. * Serializes this material in a JSON representation
  132097. * @returns the serialized material object
  132098. */
  132099. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  132100. private _restoreConnections;
  132101. /**
  132102. * Clear the current graph and load a new one from a serialization object
  132103. * @param source defines the JSON representation of the material
  132104. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  132105. */
  132106. loadFromSerialization(source: any, rootUrl?: string): void;
  132107. /**
  132108. * Makes a duplicate of the current material.
  132109. * @param name - name to use for the new material.
  132110. */
  132111. clone(name: string): NodeMaterial;
  132112. /**
  132113. * Creates a node material from parsed material data
  132114. * @param source defines the JSON representation of the material
  132115. * @param scene defines the hosting scene
  132116. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  132117. * @returns a new node material
  132118. */
  132119. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  132120. /**
  132121. * Creates a node material from a snippet saved in a remote file
  132122. * @param name defines the name of the material to create
  132123. * @param url defines the url to load from
  132124. * @param scene defines the hosting scene
  132125. * @returns a promise that will resolve to the new node material
  132126. */
  132127. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  132128. /**
  132129. * Creates a node material from a snippet saved by the node material editor
  132130. * @param snippetId defines the snippet to load
  132131. * @param scene defines the hosting scene
  132132. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  132133. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  132134. * @returns a promise that will resolve to the new node material
  132135. */
  132136. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  132137. /**
  132138. * Creates a new node material set to default basic configuration
  132139. * @param name defines the name of the material
  132140. * @param scene defines the hosting scene
  132141. * @returns a new NodeMaterial
  132142. */
  132143. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  132144. }
  132145. }
  132146. declare module BABYLON {
  132147. /**
  132148. * Block used to read a texture from a sampler
  132149. */
  132150. export class TextureBlock extends NodeMaterialBlock {
  132151. private _defineName;
  132152. private _linearDefineName;
  132153. private _tempTextureRead;
  132154. private _samplerName;
  132155. private _transformedUVName;
  132156. private _textureTransformName;
  132157. private _textureInfoName;
  132158. private _mainUVName;
  132159. private _mainUVDefineName;
  132160. /**
  132161. * Gets or sets the texture associated with the node
  132162. */
  132163. texture: Nullable<Texture>;
  132164. /**
  132165. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  132166. */
  132167. convertToGammaSpace: boolean;
  132168. /**
  132169. * Create a new TextureBlock
  132170. * @param name defines the block name
  132171. */
  132172. constructor(name: string);
  132173. /**
  132174. * Gets the current class name
  132175. * @returns the class name
  132176. */
  132177. getClassName(): string;
  132178. /**
  132179. * Gets the uv input component
  132180. */
  132181. get uv(): NodeMaterialConnectionPoint;
  132182. /**
  132183. * Gets the rgba output component
  132184. */
  132185. get rgba(): NodeMaterialConnectionPoint;
  132186. /**
  132187. * Gets the rgb output component
  132188. */
  132189. get rgb(): NodeMaterialConnectionPoint;
  132190. /**
  132191. * Gets the r output component
  132192. */
  132193. get r(): NodeMaterialConnectionPoint;
  132194. /**
  132195. * Gets the g output component
  132196. */
  132197. get g(): NodeMaterialConnectionPoint;
  132198. /**
  132199. * Gets the b output component
  132200. */
  132201. get b(): NodeMaterialConnectionPoint;
  132202. /**
  132203. * Gets the a output component
  132204. */
  132205. get a(): NodeMaterialConnectionPoint;
  132206. get target(): NodeMaterialBlockTargets;
  132207. autoConfigure(material: NodeMaterial): void;
  132208. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  132209. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  132210. isReady(): boolean;
  132211. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  132212. private get _isMixed();
  132213. private _injectVertexCode;
  132214. private _writeTextureRead;
  132215. private _writeOutput;
  132216. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  132217. protected _dumpPropertiesCode(): string;
  132218. serialize(): any;
  132219. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  132220. }
  132221. }
  132222. declare module BABYLON {
  132223. /**
  132224. * Class used to store shared data between 2 NodeMaterialBuildState
  132225. */
  132226. export class NodeMaterialBuildStateSharedData {
  132227. /**
  132228. * Gets the list of emitted varyings
  132229. */
  132230. temps: string[];
  132231. /**
  132232. * Gets the list of emitted varyings
  132233. */
  132234. varyings: string[];
  132235. /**
  132236. * Gets the varying declaration string
  132237. */
  132238. varyingDeclaration: string;
  132239. /**
  132240. * Input blocks
  132241. */
  132242. inputBlocks: InputBlock[];
  132243. /**
  132244. * Input blocks
  132245. */
  132246. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  132247. /**
  132248. * Bindable blocks (Blocks that need to set data to the effect)
  132249. */
  132250. bindableBlocks: NodeMaterialBlock[];
  132251. /**
  132252. * List of blocks that can provide a compilation fallback
  132253. */
  132254. blocksWithFallbacks: NodeMaterialBlock[];
  132255. /**
  132256. * List of blocks that can provide a define update
  132257. */
  132258. blocksWithDefines: NodeMaterialBlock[];
  132259. /**
  132260. * List of blocks that can provide a repeatable content
  132261. */
  132262. repeatableContentBlocks: NodeMaterialBlock[];
  132263. /**
  132264. * List of blocks that can provide a dynamic list of uniforms
  132265. */
  132266. dynamicUniformBlocks: NodeMaterialBlock[];
  132267. /**
  132268. * List of blocks that can block the isReady function for the material
  132269. */
  132270. blockingBlocks: NodeMaterialBlock[];
  132271. /**
  132272. * Gets the list of animated inputs
  132273. */
  132274. animatedInputs: InputBlock[];
  132275. /**
  132276. * Build Id used to avoid multiple recompilations
  132277. */
  132278. buildId: number;
  132279. /** List of emitted variables */
  132280. variableNames: {
  132281. [key: string]: number;
  132282. };
  132283. /** List of emitted defines */
  132284. defineNames: {
  132285. [key: string]: number;
  132286. };
  132287. /** Should emit comments? */
  132288. emitComments: boolean;
  132289. /** Emit build activity */
  132290. verbose: boolean;
  132291. /** Gets or sets the hosting scene */
  132292. scene: Scene;
  132293. /**
  132294. * Gets the compilation hints emitted at compilation time
  132295. */
  132296. hints: {
  132297. needWorldViewMatrix: boolean;
  132298. needWorldViewProjectionMatrix: boolean;
  132299. needAlphaBlending: boolean;
  132300. needAlphaTesting: boolean;
  132301. };
  132302. /**
  132303. * List of compilation checks
  132304. */
  132305. checks: {
  132306. emitVertex: boolean;
  132307. emitFragment: boolean;
  132308. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  132309. };
  132310. /** Creates a new shared data */
  132311. constructor();
  132312. /**
  132313. * Emits console errors and exceptions if there is a failing check
  132314. */
  132315. emitErrors(): void;
  132316. }
  132317. }
  132318. declare module BABYLON {
  132319. /**
  132320. * Class used to store node based material build state
  132321. */
  132322. export class NodeMaterialBuildState {
  132323. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  132324. supportUniformBuffers: boolean;
  132325. /**
  132326. * Gets the list of emitted attributes
  132327. */
  132328. attributes: string[];
  132329. /**
  132330. * Gets the list of emitted uniforms
  132331. */
  132332. uniforms: string[];
  132333. /**
  132334. * Gets the list of emitted constants
  132335. */
  132336. constants: string[];
  132337. /**
  132338. * Gets the list of emitted samplers
  132339. */
  132340. samplers: string[];
  132341. /**
  132342. * Gets the list of emitted functions
  132343. */
  132344. functions: {
  132345. [key: string]: string;
  132346. };
  132347. /**
  132348. * Gets the list of emitted extensions
  132349. */
  132350. extensions: {
  132351. [key: string]: string;
  132352. };
  132353. /**
  132354. * Gets the target of the compilation state
  132355. */
  132356. target: NodeMaterialBlockTargets;
  132357. /**
  132358. * Gets the list of emitted counters
  132359. */
  132360. counters: {
  132361. [key: string]: number;
  132362. };
  132363. /**
  132364. * Shared data between multiple NodeMaterialBuildState instances
  132365. */
  132366. sharedData: NodeMaterialBuildStateSharedData;
  132367. /** @hidden */
  132368. _vertexState: NodeMaterialBuildState;
  132369. /** @hidden */
  132370. _attributeDeclaration: string;
  132371. /** @hidden */
  132372. _uniformDeclaration: string;
  132373. /** @hidden */
  132374. _constantDeclaration: string;
  132375. /** @hidden */
  132376. _samplerDeclaration: string;
  132377. /** @hidden */
  132378. _varyingTransfer: string;
  132379. private _repeatableContentAnchorIndex;
  132380. /** @hidden */
  132381. _builtCompilationString: string;
  132382. /**
  132383. * Gets the emitted compilation strings
  132384. */
  132385. compilationString: string;
  132386. /**
  132387. * Finalize the compilation strings
  132388. * @param state defines the current compilation state
  132389. */
  132390. finalize(state: NodeMaterialBuildState): void;
  132391. /** @hidden */
  132392. get _repeatableContentAnchor(): string;
  132393. /** @hidden */
  132394. _getFreeVariableName(prefix: string): string;
  132395. /** @hidden */
  132396. _getFreeDefineName(prefix: string): string;
  132397. /** @hidden */
  132398. _excludeVariableName(name: string): void;
  132399. /** @hidden */
  132400. _emit2DSampler(name: string): void;
  132401. /** @hidden */
  132402. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  132403. /** @hidden */
  132404. _emitExtension(name: string, extension: string): void;
  132405. /** @hidden */
  132406. _emitFunction(name: string, code: string, comments: string): void;
  132407. /** @hidden */
  132408. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  132409. replaceStrings?: {
  132410. search: RegExp;
  132411. replace: string;
  132412. }[];
  132413. repeatKey?: string;
  132414. }): string;
  132415. /** @hidden */
  132416. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  132417. repeatKey?: string;
  132418. removeAttributes?: boolean;
  132419. removeUniforms?: boolean;
  132420. removeVaryings?: boolean;
  132421. removeIfDef?: boolean;
  132422. replaceStrings?: {
  132423. search: RegExp;
  132424. replace: string;
  132425. }[];
  132426. }, storeKey?: string): void;
  132427. /** @hidden */
  132428. _registerTempVariable(name: string): boolean;
  132429. /** @hidden */
  132430. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  132431. /** @hidden */
  132432. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  132433. /** @hidden */
  132434. _emitFloat(value: number): string;
  132435. }
  132436. }
  132437. declare module BABYLON {
  132438. /**
  132439. * Defines a block that can be used inside a node based material
  132440. */
  132441. export class NodeMaterialBlock {
  132442. private _buildId;
  132443. private _buildTarget;
  132444. private _target;
  132445. private _isFinalMerger;
  132446. private _isInput;
  132447. protected _isUnique: boolean;
  132448. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  132449. inputsAreExclusive: boolean;
  132450. /** @hidden */
  132451. _codeVariableName: string;
  132452. /** @hidden */
  132453. _inputs: NodeMaterialConnectionPoint[];
  132454. /** @hidden */
  132455. _outputs: NodeMaterialConnectionPoint[];
  132456. /** @hidden */
  132457. _preparationId: number;
  132458. /**
  132459. * Gets or sets the name of the block
  132460. */
  132461. name: string;
  132462. /**
  132463. * Gets or sets the unique id of the node
  132464. */
  132465. uniqueId: number;
  132466. /**
  132467. * Gets or sets the comments associated with this block
  132468. */
  132469. comments: string;
  132470. /**
  132471. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  132472. */
  132473. get isUnique(): boolean;
  132474. /**
  132475. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  132476. */
  132477. get isFinalMerger(): boolean;
  132478. /**
  132479. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  132480. */
  132481. get isInput(): boolean;
  132482. /**
  132483. * Gets or sets the build Id
  132484. */
  132485. get buildId(): number;
  132486. set buildId(value: number);
  132487. /**
  132488. * Gets or sets the target of the block
  132489. */
  132490. get target(): NodeMaterialBlockTargets;
  132491. set target(value: NodeMaterialBlockTargets);
  132492. /**
  132493. * Gets the list of input points
  132494. */
  132495. get inputs(): NodeMaterialConnectionPoint[];
  132496. /** Gets the list of output points */
  132497. get outputs(): NodeMaterialConnectionPoint[];
  132498. /**
  132499. * Find an input by its name
  132500. * @param name defines the name of the input to look for
  132501. * @returns the input or null if not found
  132502. */
  132503. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  132504. /**
  132505. * Find an output by its name
  132506. * @param name defines the name of the outputto look for
  132507. * @returns the output or null if not found
  132508. */
  132509. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  132510. /**
  132511. * Creates a new NodeMaterialBlock
  132512. * @param name defines the block name
  132513. * @param target defines the target of that block (Vertex by default)
  132514. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  132515. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  132516. */
  132517. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  132518. /**
  132519. * Initialize the block and prepare the context for build
  132520. * @param state defines the state that will be used for the build
  132521. */
  132522. initialize(state: NodeMaterialBuildState): void;
  132523. /**
  132524. * Bind data to effect. Will only be called for blocks with isBindable === true
  132525. * @param effect defines the effect to bind data to
  132526. * @param nodeMaterial defines the hosting NodeMaterial
  132527. * @param mesh defines the mesh that will be rendered
  132528. */
  132529. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  132530. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  132531. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  132532. protected _writeFloat(value: number): string;
  132533. /**
  132534. * Gets the current class name e.g. "NodeMaterialBlock"
  132535. * @returns the class name
  132536. */
  132537. getClassName(): string;
  132538. /**
  132539. * Register a new input. Must be called inside a block constructor
  132540. * @param name defines the connection point name
  132541. * @param type defines the connection point type
  132542. * @param isOptional defines a boolean indicating that this input can be omitted
  132543. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  132544. * @returns the current block
  132545. */
  132546. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  132547. /**
  132548. * Register a new output. Must be called inside a block constructor
  132549. * @param name defines the connection point name
  132550. * @param type defines the connection point type
  132551. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  132552. * @returns the current block
  132553. */
  132554. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  132555. /**
  132556. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  132557. * @param forOutput defines an optional connection point to check compatibility with
  132558. * @returns the first available input or null
  132559. */
  132560. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  132561. /**
  132562. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  132563. * @param forBlock defines an optional block to check compatibility with
  132564. * @returns the first available input or null
  132565. */
  132566. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  132567. /**
  132568. * Gets the sibling of the given output
  132569. * @param current defines the current output
  132570. * @returns the next output in the list or null
  132571. */
  132572. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  132573. /**
  132574. * Connect current block with another block
  132575. * @param other defines the block to connect with
  132576. * @param options define the various options to help pick the right connections
  132577. * @returns the current block
  132578. */
  132579. connectTo(other: NodeMaterialBlock, options?: {
  132580. input?: string;
  132581. output?: string;
  132582. outputSwizzle?: string;
  132583. }): this | undefined;
  132584. protected _buildBlock(state: NodeMaterialBuildState): void;
  132585. /**
  132586. * Add uniforms, samplers and uniform buffers at compilation time
  132587. * @param state defines the state to update
  132588. * @param nodeMaterial defines the node material requesting the update
  132589. * @param defines defines the material defines to update
  132590. * @param uniformBuffers defines the list of uniform buffer names
  132591. */
  132592. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  132593. /**
  132594. * Add potential fallbacks if shader compilation fails
  132595. * @param mesh defines the mesh to be rendered
  132596. * @param fallbacks defines the current prioritized list of fallbacks
  132597. */
  132598. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  132599. /**
  132600. * Initialize defines for shader compilation
  132601. * @param mesh defines the mesh to be rendered
  132602. * @param nodeMaterial defines the node material requesting the update
  132603. * @param defines defines the material defines to update
  132604. * @param useInstances specifies that instances should be used
  132605. */
  132606. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  132607. /**
  132608. * Update defines for shader compilation
  132609. * @param mesh defines the mesh to be rendered
  132610. * @param nodeMaterial defines the node material requesting the update
  132611. * @param defines defines the material defines to update
  132612. * @param useInstances specifies that instances should be used
  132613. */
  132614. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  132615. /**
  132616. * Lets the block try to connect some inputs automatically
  132617. * @param material defines the hosting NodeMaterial
  132618. */
  132619. autoConfigure(material: NodeMaterial): void;
  132620. /**
  132621. * Function called when a block is declared as repeatable content generator
  132622. * @param vertexShaderState defines the current compilation state for the vertex shader
  132623. * @param fragmentShaderState defines the current compilation state for the fragment shader
  132624. * @param mesh defines the mesh to be rendered
  132625. * @param defines defines the material defines to update
  132626. */
  132627. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  132628. /**
  132629. * Checks if the block is ready
  132630. * @param mesh defines the mesh to be rendered
  132631. * @param nodeMaterial defines the node material requesting the update
  132632. * @param defines defines the material defines to update
  132633. * @param useInstances specifies that instances should be used
  132634. * @returns true if the block is ready
  132635. */
  132636. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  132637. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  132638. private _processBuild;
  132639. /**
  132640. * Compile the current node and generate the shader code
  132641. * @param state defines the current compilation state (uniforms, samplers, current string)
  132642. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  132643. * @returns true if already built
  132644. */
  132645. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  132646. protected _inputRename(name: string): string;
  132647. protected _outputRename(name: string): string;
  132648. protected _dumpPropertiesCode(): string;
  132649. /** @hidden */
  132650. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  132651. /** @hidden */
  132652. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  132653. /**
  132654. * Clone the current block to a new identical block
  132655. * @param scene defines the hosting scene
  132656. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  132657. * @returns a copy of the current block
  132658. */
  132659. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  132660. /**
  132661. * Serializes this block in a JSON representation
  132662. * @returns the serialized block object
  132663. */
  132664. serialize(): any;
  132665. /** @hidden */
  132666. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  132667. /**
  132668. * Release resources
  132669. */
  132670. dispose(): void;
  132671. }
  132672. }
  132673. declare module BABYLON {
  132674. /**
  132675. * Enum defining the type of animations supported by InputBlock
  132676. */
  132677. export enum AnimatedInputBlockTypes {
  132678. /** No animation */
  132679. None = 0,
  132680. /** Time based animation. Will only work for floats */
  132681. Time = 1
  132682. }
  132683. }
  132684. declare module BABYLON {
  132685. /**
  132686. * Block used to expose an input value
  132687. */
  132688. export class InputBlock extends NodeMaterialBlock {
  132689. private _mode;
  132690. private _associatedVariableName;
  132691. private _storedValue;
  132692. private _valueCallback;
  132693. private _type;
  132694. private _animationType;
  132695. /** Gets or set a value used to limit the range of float values */
  132696. min: number;
  132697. /** Gets or set a value used to limit the range of float values */
  132698. max: number;
  132699. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  132700. isBoolean: boolean;
  132701. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  132702. matrixMode: number;
  132703. /** @hidden */
  132704. _systemValue: Nullable<NodeMaterialSystemValues>;
  132705. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  132706. visibleInInspector: boolean;
  132707. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  132708. isConstant: boolean;
  132709. /** Gets or sets the group to use to display this block in the Inspector */
  132710. groupInInspector: string;
  132711. /** Gets an observable raised when the value is changed */
  132712. onValueChangedObservable: Observable<InputBlock>;
  132713. /**
  132714. * Gets or sets the connection point type (default is float)
  132715. */
  132716. get type(): NodeMaterialBlockConnectionPointTypes;
  132717. /**
  132718. * Creates a new InputBlock
  132719. * @param name defines the block name
  132720. * @param target defines the target of that block (Vertex by default)
  132721. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  132722. */
  132723. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  132724. /**
  132725. * Gets the output component
  132726. */
  132727. get output(): NodeMaterialConnectionPoint;
  132728. /**
  132729. * Set the source of this connection point to a vertex attribute
  132730. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  132731. * @returns the current connection point
  132732. */
  132733. setAsAttribute(attributeName?: string): InputBlock;
  132734. /**
  132735. * Set the source of this connection point to a system value
  132736. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  132737. * @returns the current connection point
  132738. */
  132739. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  132740. /**
  132741. * Gets or sets the value of that point.
  132742. * Please note that this value will be ignored if valueCallback is defined
  132743. */
  132744. get value(): any;
  132745. set value(value: any);
  132746. /**
  132747. * Gets or sets a callback used to get the value of that point.
  132748. * Please note that setting this value will force the connection point to ignore the value property
  132749. */
  132750. get valueCallback(): () => any;
  132751. set valueCallback(value: () => any);
  132752. /**
  132753. * Gets or sets the associated variable name in the shader
  132754. */
  132755. get associatedVariableName(): string;
  132756. set associatedVariableName(value: string);
  132757. /** Gets or sets the type of animation applied to the input */
  132758. get animationType(): AnimatedInputBlockTypes;
  132759. set animationType(value: AnimatedInputBlockTypes);
  132760. /**
  132761. * Gets a boolean indicating that this connection point not defined yet
  132762. */
  132763. get isUndefined(): boolean;
  132764. /**
  132765. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  132766. * In this case the connection point name must be the name of the uniform to use.
  132767. * Can only be set on inputs
  132768. */
  132769. get isUniform(): boolean;
  132770. set isUniform(value: boolean);
  132771. /**
  132772. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  132773. * In this case the connection point name must be the name of the attribute to use
  132774. * Can only be set on inputs
  132775. */
  132776. get isAttribute(): boolean;
  132777. set isAttribute(value: boolean);
  132778. /**
  132779. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  132780. * Can only be set on exit points
  132781. */
  132782. get isVarying(): boolean;
  132783. set isVarying(value: boolean);
  132784. /**
  132785. * Gets a boolean indicating that the current connection point is a system value
  132786. */
  132787. get isSystemValue(): boolean;
  132788. /**
  132789. * Gets or sets the current well known value or null if not defined as a system value
  132790. */
  132791. get systemValue(): Nullable<NodeMaterialSystemValues>;
  132792. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  132793. /**
  132794. * Gets the current class name
  132795. * @returns the class name
  132796. */
  132797. getClassName(): string;
  132798. /**
  132799. * Animate the input if animationType !== None
  132800. * @param scene defines the rendering scene
  132801. */
  132802. animate(scene: Scene): void;
  132803. private _emitDefine;
  132804. initialize(state: NodeMaterialBuildState): void;
  132805. /**
  132806. * Set the input block to its default value (based on its type)
  132807. */
  132808. setDefaultValue(): void;
  132809. private _emitConstant;
  132810. private _emit;
  132811. /** @hidden */
  132812. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  132813. /** @hidden */
  132814. _transmit(effect: Effect, scene: Scene): void;
  132815. protected _buildBlock(state: NodeMaterialBuildState): void;
  132816. protected _dumpPropertiesCode(): string;
  132817. dispose(): void;
  132818. serialize(): any;
  132819. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  132820. }
  132821. }
  132822. declare module BABYLON {
  132823. /**
  132824. * Enum used to define the compatibility state between two connection points
  132825. */
  132826. export enum NodeMaterialConnectionPointCompatibilityStates {
  132827. /** Points are compatibles */
  132828. Compatible = 0,
  132829. /** Points are incompatible because of their types */
  132830. TypeIncompatible = 1,
  132831. /** Points are incompatible because of their targets (vertex vs fragment) */
  132832. TargetIncompatible = 2
  132833. }
  132834. /**
  132835. * Defines the direction of a connection point
  132836. */
  132837. export enum NodeMaterialConnectionPointDirection {
  132838. /** Input */
  132839. Input = 0,
  132840. /** Output */
  132841. Output = 1
  132842. }
  132843. /**
  132844. * Defines a connection point for a block
  132845. */
  132846. export class NodeMaterialConnectionPoint {
  132847. /** @hidden */
  132848. _ownerBlock: NodeMaterialBlock;
  132849. /** @hidden */
  132850. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  132851. private _endpoints;
  132852. private _associatedVariableName;
  132853. private _direction;
  132854. /** @hidden */
  132855. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  132856. /** @hidden */
  132857. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  132858. private _type;
  132859. /** @hidden */
  132860. _enforceAssociatedVariableName: boolean;
  132861. /** Gets the direction of the point */
  132862. get direction(): NodeMaterialConnectionPointDirection;
  132863. /**
  132864. * Gets or sets the additional types supported by this connection point
  132865. */
  132866. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  132867. /**
  132868. * Gets or sets the additional types excluded by this connection point
  132869. */
  132870. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  132871. /**
  132872. * Observable triggered when this point is connected
  132873. */
  132874. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  132875. /**
  132876. * Gets or sets the associated variable name in the shader
  132877. */
  132878. get associatedVariableName(): string;
  132879. set associatedVariableName(value: string);
  132880. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  132881. get innerType(): NodeMaterialBlockConnectionPointTypes;
  132882. /**
  132883. * Gets or sets the connection point type (default is float)
  132884. */
  132885. get type(): NodeMaterialBlockConnectionPointTypes;
  132886. set type(value: NodeMaterialBlockConnectionPointTypes);
  132887. /**
  132888. * Gets or sets the connection point name
  132889. */
  132890. name: string;
  132891. /**
  132892. * Gets or sets a boolean indicating that this connection point can be omitted
  132893. */
  132894. isOptional: boolean;
  132895. /**
  132896. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  132897. */
  132898. define: string;
  132899. /** @hidden */
  132900. _prioritizeVertex: boolean;
  132901. private _target;
  132902. /** Gets or sets the target of that connection point */
  132903. get target(): NodeMaterialBlockTargets;
  132904. set target(value: NodeMaterialBlockTargets);
  132905. /**
  132906. * Gets a boolean indicating that the current point is connected
  132907. */
  132908. get isConnected(): boolean;
  132909. /**
  132910. * Gets a boolean indicating that the current point is connected to an input block
  132911. */
  132912. get isConnectedToInputBlock(): boolean;
  132913. /**
  132914. * Gets a the connected input block (if any)
  132915. */
  132916. get connectInputBlock(): Nullable<InputBlock>;
  132917. /** Get the other side of the connection (if any) */
  132918. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  132919. /** Get the block that owns this connection point */
  132920. get ownerBlock(): NodeMaterialBlock;
  132921. /** Get the block connected on the other side of this connection (if any) */
  132922. get sourceBlock(): Nullable<NodeMaterialBlock>;
  132923. /** Get the block connected on the endpoints of this connection (if any) */
  132924. get connectedBlocks(): Array<NodeMaterialBlock>;
  132925. /** Gets the list of connected endpoints */
  132926. get endpoints(): NodeMaterialConnectionPoint[];
  132927. /** Gets a boolean indicating if that output point is connected to at least one input */
  132928. get hasEndpoints(): boolean;
  132929. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  132930. get isConnectedInVertexShader(): boolean;
  132931. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  132932. get isConnectedInFragmentShader(): boolean;
  132933. /**
  132934. * Creates a new connection point
  132935. * @param name defines the connection point name
  132936. * @param ownerBlock defines the block hosting this connection point
  132937. * @param direction defines the direction of the connection point
  132938. */
  132939. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  132940. /**
  132941. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  132942. * @returns the class name
  132943. */
  132944. getClassName(): string;
  132945. /**
  132946. * Gets a boolean indicating if the current point can be connected to another point
  132947. * @param connectionPoint defines the other connection point
  132948. * @returns a boolean
  132949. */
  132950. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  132951. /**
  132952. * Gets a number indicating if the current point can be connected to another point
  132953. * @param connectionPoint defines the other connection point
  132954. * @returns a number defining the compatibility state
  132955. */
  132956. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  132957. /**
  132958. * Connect this point to another connection point
  132959. * @param connectionPoint defines the other connection point
  132960. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  132961. * @returns the current connection point
  132962. */
  132963. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  132964. /**
  132965. * Disconnect this point from one of his endpoint
  132966. * @param endpoint defines the other connection point
  132967. * @returns the current connection point
  132968. */
  132969. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  132970. /**
  132971. * Serializes this point in a JSON representation
  132972. * @returns the serialized point object
  132973. */
  132974. serialize(): any;
  132975. /**
  132976. * Release resources
  132977. */
  132978. dispose(): void;
  132979. }
  132980. }
  132981. declare module BABYLON {
  132982. /**
  132983. * Block used to add support for vertex skinning (bones)
  132984. */
  132985. export class BonesBlock extends NodeMaterialBlock {
  132986. /**
  132987. * Creates a new BonesBlock
  132988. * @param name defines the block name
  132989. */
  132990. constructor(name: string);
  132991. /**
  132992. * Initialize the block and prepare the context for build
  132993. * @param state defines the state that will be used for the build
  132994. */
  132995. initialize(state: NodeMaterialBuildState): void;
  132996. /**
  132997. * Gets the current class name
  132998. * @returns the class name
  132999. */
  133000. getClassName(): string;
  133001. /**
  133002. * Gets the matrix indices input component
  133003. */
  133004. get matricesIndices(): NodeMaterialConnectionPoint;
  133005. /**
  133006. * Gets the matrix weights input component
  133007. */
  133008. get matricesWeights(): NodeMaterialConnectionPoint;
  133009. /**
  133010. * Gets the extra matrix indices input component
  133011. */
  133012. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  133013. /**
  133014. * Gets the extra matrix weights input component
  133015. */
  133016. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  133017. /**
  133018. * Gets the world input component
  133019. */
  133020. get world(): NodeMaterialConnectionPoint;
  133021. /**
  133022. * Gets the output component
  133023. */
  133024. get output(): NodeMaterialConnectionPoint;
  133025. autoConfigure(material: NodeMaterial): void;
  133026. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  133027. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  133028. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  133029. protected _buildBlock(state: NodeMaterialBuildState): this;
  133030. }
  133031. }
  133032. declare module BABYLON {
  133033. /**
  133034. * Block used to add support for instances
  133035. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  133036. */
  133037. export class InstancesBlock extends NodeMaterialBlock {
  133038. /**
  133039. * Creates a new InstancesBlock
  133040. * @param name defines the block name
  133041. */
  133042. constructor(name: string);
  133043. /**
  133044. * Gets the current class name
  133045. * @returns the class name
  133046. */
  133047. getClassName(): string;
  133048. /**
  133049. * Gets the first world row input component
  133050. */
  133051. get world0(): NodeMaterialConnectionPoint;
  133052. /**
  133053. * Gets the second world row input component
  133054. */
  133055. get world1(): NodeMaterialConnectionPoint;
  133056. /**
  133057. * Gets the third world row input component
  133058. */
  133059. get world2(): NodeMaterialConnectionPoint;
  133060. /**
  133061. * Gets the forth world row input component
  133062. */
  133063. get world3(): NodeMaterialConnectionPoint;
  133064. /**
  133065. * Gets the world input component
  133066. */
  133067. get world(): NodeMaterialConnectionPoint;
  133068. /**
  133069. * Gets the output component
  133070. */
  133071. get output(): NodeMaterialConnectionPoint;
  133072. /**
  133073. * Gets the isntanceID component
  133074. */
  133075. get instanceID(): NodeMaterialConnectionPoint;
  133076. autoConfigure(material: NodeMaterial): void;
  133077. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  133078. protected _buildBlock(state: NodeMaterialBuildState): this;
  133079. }
  133080. }
  133081. declare module BABYLON {
  133082. /**
  133083. * Block used to add morph targets support to vertex shader
  133084. */
  133085. export class MorphTargetsBlock extends NodeMaterialBlock {
  133086. private _repeatableContentAnchor;
  133087. /**
  133088. * Create a new MorphTargetsBlock
  133089. * @param name defines the block name
  133090. */
  133091. constructor(name: string);
  133092. /**
  133093. * Gets the current class name
  133094. * @returns the class name
  133095. */
  133096. getClassName(): string;
  133097. /**
  133098. * Gets the position input component
  133099. */
  133100. get position(): NodeMaterialConnectionPoint;
  133101. /**
  133102. * Gets the normal input component
  133103. */
  133104. get normal(): NodeMaterialConnectionPoint;
  133105. /**
  133106. * Gets the tangent input component
  133107. */
  133108. get tangent(): NodeMaterialConnectionPoint;
  133109. /**
  133110. * Gets the tangent input component
  133111. */
  133112. get uv(): NodeMaterialConnectionPoint;
  133113. /**
  133114. * Gets the position output component
  133115. */
  133116. get positionOutput(): NodeMaterialConnectionPoint;
  133117. /**
  133118. * Gets the normal output component
  133119. */
  133120. get normalOutput(): NodeMaterialConnectionPoint;
  133121. /**
  133122. * Gets the tangent output component
  133123. */
  133124. get tangentOutput(): NodeMaterialConnectionPoint;
  133125. /**
  133126. * Gets the tangent output component
  133127. */
  133128. get uvOutput(): NodeMaterialConnectionPoint;
  133129. initialize(state: NodeMaterialBuildState): void;
  133130. autoConfigure(material: NodeMaterial): void;
  133131. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  133132. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  133133. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  133134. protected _buildBlock(state: NodeMaterialBuildState): this;
  133135. }
  133136. }
  133137. declare module BABYLON {
  133138. /**
  133139. * Block used to get data information from a light
  133140. */
  133141. export class LightInformationBlock extends NodeMaterialBlock {
  133142. private _lightDataUniformName;
  133143. private _lightColorUniformName;
  133144. private _lightTypeDefineName;
  133145. /**
  133146. * Gets or sets the light associated with this block
  133147. */
  133148. light: Nullable<Light>;
  133149. /**
  133150. * Creates a new LightInformationBlock
  133151. * @param name defines the block name
  133152. */
  133153. constructor(name: string);
  133154. /**
  133155. * Gets the current class name
  133156. * @returns the class name
  133157. */
  133158. getClassName(): string;
  133159. /**
  133160. * Gets the world position input component
  133161. */
  133162. get worldPosition(): NodeMaterialConnectionPoint;
  133163. /**
  133164. * Gets the direction output component
  133165. */
  133166. get direction(): NodeMaterialConnectionPoint;
  133167. /**
  133168. * Gets the direction output component
  133169. */
  133170. get color(): NodeMaterialConnectionPoint;
  133171. /**
  133172. * Gets the direction output component
  133173. */
  133174. get intensity(): NodeMaterialConnectionPoint;
  133175. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  133176. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  133177. protected _buildBlock(state: NodeMaterialBuildState): this;
  133178. serialize(): any;
  133179. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  133180. }
  133181. }
  133182. declare module BABYLON {
  133183. /**
  133184. * Block used to add image processing support to fragment shader
  133185. */
  133186. export class ImageProcessingBlock extends NodeMaterialBlock {
  133187. /**
  133188. * Create a new ImageProcessingBlock
  133189. * @param name defines the block name
  133190. */
  133191. constructor(name: string);
  133192. /**
  133193. * Gets the current class name
  133194. * @returns the class name
  133195. */
  133196. getClassName(): string;
  133197. /**
  133198. * Gets the color input component
  133199. */
  133200. get color(): NodeMaterialConnectionPoint;
  133201. /**
  133202. * Gets the output component
  133203. */
  133204. get output(): NodeMaterialConnectionPoint;
  133205. /**
  133206. * Initialize the block and prepare the context for build
  133207. * @param state defines the state that will be used for the build
  133208. */
  133209. initialize(state: NodeMaterialBuildState): void;
  133210. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  133211. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  133212. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  133213. protected _buildBlock(state: NodeMaterialBuildState): this;
  133214. }
  133215. }
  133216. declare module BABYLON {
  133217. /**
  133218. * Block used to pertub normals based on a normal map
  133219. */
  133220. export class PerturbNormalBlock extends NodeMaterialBlock {
  133221. private _tangentSpaceParameterName;
  133222. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  133223. invertX: boolean;
  133224. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  133225. invertY: boolean;
  133226. /**
  133227. * Create a new PerturbNormalBlock
  133228. * @param name defines the block name
  133229. */
  133230. constructor(name: string);
  133231. /**
  133232. * Gets the current class name
  133233. * @returns the class name
  133234. */
  133235. getClassName(): string;
  133236. /**
  133237. * Gets the world position input component
  133238. */
  133239. get worldPosition(): NodeMaterialConnectionPoint;
  133240. /**
  133241. * Gets the world normal input component
  133242. */
  133243. get worldNormal(): NodeMaterialConnectionPoint;
  133244. /**
  133245. * Gets the world tangent input component
  133246. */
  133247. get worldTangent(): NodeMaterialConnectionPoint;
  133248. /**
  133249. * Gets the uv input component
  133250. */
  133251. get uv(): NodeMaterialConnectionPoint;
  133252. /**
  133253. * Gets the normal map color input component
  133254. */
  133255. get normalMapColor(): NodeMaterialConnectionPoint;
  133256. /**
  133257. * Gets the strength input component
  133258. */
  133259. get strength(): NodeMaterialConnectionPoint;
  133260. /**
  133261. * Gets the output component
  133262. */
  133263. get output(): NodeMaterialConnectionPoint;
  133264. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  133265. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  133266. autoConfigure(material: NodeMaterial): void;
  133267. protected _buildBlock(state: NodeMaterialBuildState): this;
  133268. protected _dumpPropertiesCode(): string;
  133269. serialize(): any;
  133270. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  133271. }
  133272. }
  133273. declare module BABYLON {
  133274. /**
  133275. * Block used to discard a pixel if a value is smaller than a cutoff
  133276. */
  133277. export class DiscardBlock extends NodeMaterialBlock {
  133278. /**
  133279. * Create a new DiscardBlock
  133280. * @param name defines the block name
  133281. */
  133282. constructor(name: string);
  133283. /**
  133284. * Gets the current class name
  133285. * @returns the class name
  133286. */
  133287. getClassName(): string;
  133288. /**
  133289. * Gets the color input component
  133290. */
  133291. get value(): NodeMaterialConnectionPoint;
  133292. /**
  133293. * Gets the cutoff input component
  133294. */
  133295. get cutoff(): NodeMaterialConnectionPoint;
  133296. protected _buildBlock(state: NodeMaterialBuildState): this;
  133297. }
  133298. }
  133299. declare module BABYLON {
  133300. /**
  133301. * Block used to test if the fragment shader is front facing
  133302. */
  133303. export class FrontFacingBlock extends NodeMaterialBlock {
  133304. /**
  133305. * Creates a new FrontFacingBlock
  133306. * @param name defines the block name
  133307. */
  133308. constructor(name: string);
  133309. /**
  133310. * Gets the current class name
  133311. * @returns the class name
  133312. */
  133313. getClassName(): string;
  133314. /**
  133315. * Gets the output component
  133316. */
  133317. get output(): NodeMaterialConnectionPoint;
  133318. protected _buildBlock(state: NodeMaterialBuildState): this;
  133319. }
  133320. }
  133321. declare module BABYLON {
  133322. /**
  133323. * Block used to get the derivative value on x and y of a given input
  133324. */
  133325. export class DerivativeBlock extends NodeMaterialBlock {
  133326. /**
  133327. * Create a new DerivativeBlock
  133328. * @param name defines the block name
  133329. */
  133330. constructor(name: string);
  133331. /**
  133332. * Gets the current class name
  133333. * @returns the class name
  133334. */
  133335. getClassName(): string;
  133336. /**
  133337. * Gets the input component
  133338. */
  133339. get input(): NodeMaterialConnectionPoint;
  133340. /**
  133341. * Gets the derivative output on x
  133342. */
  133343. get dx(): NodeMaterialConnectionPoint;
  133344. /**
  133345. * Gets the derivative output on y
  133346. */
  133347. get dy(): NodeMaterialConnectionPoint;
  133348. protected _buildBlock(state: NodeMaterialBuildState): this;
  133349. }
  133350. }
  133351. declare module BABYLON {
  133352. /**
  133353. * Block used to add support for scene fog
  133354. */
  133355. export class FogBlock extends NodeMaterialBlock {
  133356. private _fogDistanceName;
  133357. private _fogParameters;
  133358. /**
  133359. * Create a new FogBlock
  133360. * @param name defines the block name
  133361. */
  133362. constructor(name: string);
  133363. /**
  133364. * Gets the current class name
  133365. * @returns the class name
  133366. */
  133367. getClassName(): string;
  133368. /**
  133369. * Gets the world position input component
  133370. */
  133371. get worldPosition(): NodeMaterialConnectionPoint;
  133372. /**
  133373. * Gets the view input component
  133374. */
  133375. get view(): NodeMaterialConnectionPoint;
  133376. /**
  133377. * Gets the color input component
  133378. */
  133379. get input(): NodeMaterialConnectionPoint;
  133380. /**
  133381. * Gets the fog color input component
  133382. */
  133383. get fogColor(): NodeMaterialConnectionPoint;
  133384. /**
  133385. * Gets the output component
  133386. */
  133387. get output(): NodeMaterialConnectionPoint;
  133388. autoConfigure(material: NodeMaterial): void;
  133389. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  133390. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  133391. protected _buildBlock(state: NodeMaterialBuildState): this;
  133392. }
  133393. }
  133394. declare module BABYLON {
  133395. /**
  133396. * Block used to add light in the fragment shader
  133397. */
  133398. export class LightBlock extends NodeMaterialBlock {
  133399. private _lightId;
  133400. /**
  133401. * Gets or sets the light associated with this block
  133402. */
  133403. light: Nullable<Light>;
  133404. /**
  133405. * Create a new LightBlock
  133406. * @param name defines the block name
  133407. */
  133408. constructor(name: string);
  133409. /**
  133410. * Gets the current class name
  133411. * @returns the class name
  133412. */
  133413. getClassName(): string;
  133414. /**
  133415. * Gets the world position input component
  133416. */
  133417. get worldPosition(): NodeMaterialConnectionPoint;
  133418. /**
  133419. * Gets the world normal input component
  133420. */
  133421. get worldNormal(): NodeMaterialConnectionPoint;
  133422. /**
  133423. * Gets the camera (or eye) position component
  133424. */
  133425. get cameraPosition(): NodeMaterialConnectionPoint;
  133426. /**
  133427. * Gets the glossiness component
  133428. */
  133429. get glossiness(): NodeMaterialConnectionPoint;
  133430. /**
  133431. * Gets the glossinness power component
  133432. */
  133433. get glossPower(): NodeMaterialConnectionPoint;
  133434. /**
  133435. * Gets the diffuse color component
  133436. */
  133437. get diffuseColor(): NodeMaterialConnectionPoint;
  133438. /**
  133439. * Gets the specular color component
  133440. */
  133441. get specularColor(): NodeMaterialConnectionPoint;
  133442. /**
  133443. * Gets the diffuse output component
  133444. */
  133445. get diffuseOutput(): NodeMaterialConnectionPoint;
  133446. /**
  133447. * Gets the specular output component
  133448. */
  133449. get specularOutput(): NodeMaterialConnectionPoint;
  133450. /**
  133451. * Gets the shadow output component
  133452. */
  133453. get shadow(): NodeMaterialConnectionPoint;
  133454. autoConfigure(material: NodeMaterial): void;
  133455. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  133456. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  133457. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  133458. private _injectVertexCode;
  133459. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  133460. serialize(): any;
  133461. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  133462. }
  133463. }
  133464. declare module BABYLON {
  133465. /**
  133466. * Block used to multiply 2 values
  133467. */
  133468. export class MultiplyBlock extends NodeMaterialBlock {
  133469. /**
  133470. * Creates a new MultiplyBlock
  133471. * @param name defines the block name
  133472. */
  133473. constructor(name: string);
  133474. /**
  133475. * Gets the current class name
  133476. * @returns the class name
  133477. */
  133478. getClassName(): string;
  133479. /**
  133480. * Gets the left operand input component
  133481. */
  133482. get left(): NodeMaterialConnectionPoint;
  133483. /**
  133484. * Gets the right operand input component
  133485. */
  133486. get right(): NodeMaterialConnectionPoint;
  133487. /**
  133488. * Gets the output component
  133489. */
  133490. get output(): NodeMaterialConnectionPoint;
  133491. protected _buildBlock(state: NodeMaterialBuildState): this;
  133492. }
  133493. }
  133494. declare module BABYLON {
  133495. /**
  133496. * Block used to add 2 vectors
  133497. */
  133498. export class AddBlock extends NodeMaterialBlock {
  133499. /**
  133500. * Creates a new AddBlock
  133501. * @param name defines the block name
  133502. */
  133503. constructor(name: string);
  133504. /**
  133505. * Gets the current class name
  133506. * @returns the class name
  133507. */
  133508. getClassName(): string;
  133509. /**
  133510. * Gets the left operand input component
  133511. */
  133512. get left(): NodeMaterialConnectionPoint;
  133513. /**
  133514. * Gets the right operand input component
  133515. */
  133516. get right(): NodeMaterialConnectionPoint;
  133517. /**
  133518. * Gets the output component
  133519. */
  133520. get output(): NodeMaterialConnectionPoint;
  133521. protected _buildBlock(state: NodeMaterialBuildState): this;
  133522. }
  133523. }
  133524. declare module BABYLON {
  133525. /**
  133526. * Block used to scale a vector by a float
  133527. */
  133528. export class ScaleBlock extends NodeMaterialBlock {
  133529. /**
  133530. * Creates a new ScaleBlock
  133531. * @param name defines the block name
  133532. */
  133533. constructor(name: string);
  133534. /**
  133535. * Gets the current class name
  133536. * @returns the class name
  133537. */
  133538. getClassName(): string;
  133539. /**
  133540. * Gets the input component
  133541. */
  133542. get input(): NodeMaterialConnectionPoint;
  133543. /**
  133544. * Gets the factor input component
  133545. */
  133546. get factor(): NodeMaterialConnectionPoint;
  133547. /**
  133548. * Gets the output component
  133549. */
  133550. get output(): NodeMaterialConnectionPoint;
  133551. protected _buildBlock(state: NodeMaterialBuildState): this;
  133552. }
  133553. }
  133554. declare module BABYLON {
  133555. /**
  133556. * Block used to clamp a float
  133557. */
  133558. export class ClampBlock extends NodeMaterialBlock {
  133559. /** Gets or sets the minimum range */
  133560. minimum: number;
  133561. /** Gets or sets the maximum range */
  133562. maximum: number;
  133563. /**
  133564. * Creates a new ClampBlock
  133565. * @param name defines the block name
  133566. */
  133567. constructor(name: string);
  133568. /**
  133569. * Gets the current class name
  133570. * @returns the class name
  133571. */
  133572. getClassName(): string;
  133573. /**
  133574. * Gets the value input component
  133575. */
  133576. get value(): NodeMaterialConnectionPoint;
  133577. /**
  133578. * Gets the output component
  133579. */
  133580. get output(): NodeMaterialConnectionPoint;
  133581. protected _buildBlock(state: NodeMaterialBuildState): this;
  133582. protected _dumpPropertiesCode(): string;
  133583. serialize(): any;
  133584. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  133585. }
  133586. }
  133587. declare module BABYLON {
  133588. /**
  133589. * Block used to apply a cross product between 2 vectors
  133590. */
  133591. export class CrossBlock extends NodeMaterialBlock {
  133592. /**
  133593. * Creates a new CrossBlock
  133594. * @param name defines the block name
  133595. */
  133596. constructor(name: string);
  133597. /**
  133598. * Gets the current class name
  133599. * @returns the class name
  133600. */
  133601. getClassName(): string;
  133602. /**
  133603. * Gets the left operand input component
  133604. */
  133605. get left(): NodeMaterialConnectionPoint;
  133606. /**
  133607. * Gets the right operand input component
  133608. */
  133609. get right(): NodeMaterialConnectionPoint;
  133610. /**
  133611. * Gets the output component
  133612. */
  133613. get output(): NodeMaterialConnectionPoint;
  133614. protected _buildBlock(state: NodeMaterialBuildState): this;
  133615. }
  133616. }
  133617. declare module BABYLON {
  133618. /**
  133619. * Block used to apply a dot product between 2 vectors
  133620. */
  133621. export class DotBlock extends NodeMaterialBlock {
  133622. /**
  133623. * Creates a new DotBlock
  133624. * @param name defines the block name
  133625. */
  133626. constructor(name: string);
  133627. /**
  133628. * Gets the current class name
  133629. * @returns the class name
  133630. */
  133631. getClassName(): string;
  133632. /**
  133633. * Gets the left operand input component
  133634. */
  133635. get left(): NodeMaterialConnectionPoint;
  133636. /**
  133637. * Gets the right operand input component
  133638. */
  133639. get right(): NodeMaterialConnectionPoint;
  133640. /**
  133641. * Gets the output component
  133642. */
  133643. get output(): NodeMaterialConnectionPoint;
  133644. protected _buildBlock(state: NodeMaterialBuildState): this;
  133645. }
  133646. }
  133647. declare module BABYLON {
  133648. /**
  133649. * Block used to remap a float from a range to a new one
  133650. */
  133651. export class RemapBlock extends NodeMaterialBlock {
  133652. /**
  133653. * Gets or sets the source range
  133654. */
  133655. sourceRange: Vector2;
  133656. /**
  133657. * Gets or sets the target range
  133658. */
  133659. targetRange: Vector2;
  133660. /**
  133661. * Creates a new RemapBlock
  133662. * @param name defines the block name
  133663. */
  133664. constructor(name: string);
  133665. /**
  133666. * Gets the current class name
  133667. * @returns the class name
  133668. */
  133669. getClassName(): string;
  133670. /**
  133671. * Gets the input component
  133672. */
  133673. get input(): NodeMaterialConnectionPoint;
  133674. /**
  133675. * Gets the source min input component
  133676. */
  133677. get sourceMin(): NodeMaterialConnectionPoint;
  133678. /**
  133679. * Gets the source max input component
  133680. */
  133681. get sourceMax(): NodeMaterialConnectionPoint;
  133682. /**
  133683. * Gets the target min input component
  133684. */
  133685. get targetMin(): NodeMaterialConnectionPoint;
  133686. /**
  133687. * Gets the target max input component
  133688. */
  133689. get targetMax(): NodeMaterialConnectionPoint;
  133690. /**
  133691. * Gets the output component
  133692. */
  133693. get output(): NodeMaterialConnectionPoint;
  133694. protected _buildBlock(state: NodeMaterialBuildState): this;
  133695. protected _dumpPropertiesCode(): string;
  133696. serialize(): any;
  133697. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  133698. }
  133699. }
  133700. declare module BABYLON {
  133701. /**
  133702. * Block used to normalize a vector
  133703. */
  133704. export class NormalizeBlock extends NodeMaterialBlock {
  133705. /**
  133706. * Creates a new NormalizeBlock
  133707. * @param name defines the block name
  133708. */
  133709. constructor(name: string);
  133710. /**
  133711. * Gets the current class name
  133712. * @returns the class name
  133713. */
  133714. getClassName(): string;
  133715. /**
  133716. * Gets the input component
  133717. */
  133718. get input(): NodeMaterialConnectionPoint;
  133719. /**
  133720. * Gets the output component
  133721. */
  133722. get output(): NodeMaterialConnectionPoint;
  133723. protected _buildBlock(state: NodeMaterialBuildState): this;
  133724. }
  133725. }
  133726. declare module BABYLON {
  133727. /**
  133728. * Operations supported by the Trigonometry block
  133729. */
  133730. export enum TrigonometryBlockOperations {
  133731. /** Cos */
  133732. Cos = 0,
  133733. /** Sin */
  133734. Sin = 1,
  133735. /** Abs */
  133736. Abs = 2,
  133737. /** Exp */
  133738. Exp = 3,
  133739. /** Exp2 */
  133740. Exp2 = 4,
  133741. /** Round */
  133742. Round = 5,
  133743. /** Floor */
  133744. Floor = 6,
  133745. /** Ceiling */
  133746. Ceiling = 7,
  133747. /** Square root */
  133748. Sqrt = 8,
  133749. /** Log */
  133750. Log = 9,
  133751. /** Tangent */
  133752. Tan = 10,
  133753. /** Arc tangent */
  133754. ArcTan = 11,
  133755. /** Arc cosinus */
  133756. ArcCos = 12,
  133757. /** Arc sinus */
  133758. ArcSin = 13,
  133759. /** Fraction */
  133760. Fract = 14,
  133761. /** Sign */
  133762. Sign = 15,
  133763. /** To radians (from degrees) */
  133764. Radians = 16,
  133765. /** To degrees (from radians) */
  133766. Degrees = 17
  133767. }
  133768. /**
  133769. * Block used to apply trigonometry operation to floats
  133770. */
  133771. export class TrigonometryBlock extends NodeMaterialBlock {
  133772. /**
  133773. * Gets or sets the operation applied by the block
  133774. */
  133775. operation: TrigonometryBlockOperations;
  133776. /**
  133777. * Creates a new TrigonometryBlock
  133778. * @param name defines the block name
  133779. */
  133780. constructor(name: string);
  133781. /**
  133782. * Gets the current class name
  133783. * @returns the class name
  133784. */
  133785. getClassName(): string;
  133786. /**
  133787. * Gets the input component
  133788. */
  133789. get input(): NodeMaterialConnectionPoint;
  133790. /**
  133791. * Gets the output component
  133792. */
  133793. get output(): NodeMaterialConnectionPoint;
  133794. protected _buildBlock(state: NodeMaterialBuildState): this;
  133795. serialize(): any;
  133796. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  133797. protected _dumpPropertiesCode(): string;
  133798. }
  133799. }
  133800. declare module BABYLON {
  133801. /**
  133802. * Block used to create a Color3/4 out of individual inputs (one for each component)
  133803. */
  133804. export class ColorMergerBlock extends NodeMaterialBlock {
  133805. /**
  133806. * Create a new ColorMergerBlock
  133807. * @param name defines the block name
  133808. */
  133809. constructor(name: string);
  133810. /**
  133811. * Gets the current class name
  133812. * @returns the class name
  133813. */
  133814. getClassName(): string;
  133815. /**
  133816. * Gets the rgb component (input)
  133817. */
  133818. get rgbIn(): NodeMaterialConnectionPoint;
  133819. /**
  133820. * Gets the r component (input)
  133821. */
  133822. get r(): NodeMaterialConnectionPoint;
  133823. /**
  133824. * Gets the g component (input)
  133825. */
  133826. get g(): NodeMaterialConnectionPoint;
  133827. /**
  133828. * Gets the b component (input)
  133829. */
  133830. get b(): NodeMaterialConnectionPoint;
  133831. /**
  133832. * Gets the a component (input)
  133833. */
  133834. get a(): NodeMaterialConnectionPoint;
  133835. /**
  133836. * Gets the rgba component (output)
  133837. */
  133838. get rgba(): NodeMaterialConnectionPoint;
  133839. /**
  133840. * Gets the rgb component (output)
  133841. */
  133842. get rgbOut(): NodeMaterialConnectionPoint;
  133843. /**
  133844. * Gets the rgb component (output)
  133845. * @deprecated Please use rgbOut instead.
  133846. */
  133847. get rgb(): NodeMaterialConnectionPoint;
  133848. protected _buildBlock(state: NodeMaterialBuildState): this;
  133849. }
  133850. }
  133851. declare module BABYLON {
  133852. /**
  133853. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  133854. */
  133855. export class VectorMergerBlock extends NodeMaterialBlock {
  133856. /**
  133857. * Create a new VectorMergerBlock
  133858. * @param name defines the block name
  133859. */
  133860. constructor(name: string);
  133861. /**
  133862. * Gets the current class name
  133863. * @returns the class name
  133864. */
  133865. getClassName(): string;
  133866. /**
  133867. * Gets the xyz component (input)
  133868. */
  133869. get xyzIn(): NodeMaterialConnectionPoint;
  133870. /**
  133871. * Gets the xy component (input)
  133872. */
  133873. get xyIn(): NodeMaterialConnectionPoint;
  133874. /**
  133875. * Gets the x component (input)
  133876. */
  133877. get x(): NodeMaterialConnectionPoint;
  133878. /**
  133879. * Gets the y component (input)
  133880. */
  133881. get y(): NodeMaterialConnectionPoint;
  133882. /**
  133883. * Gets the z component (input)
  133884. */
  133885. get z(): NodeMaterialConnectionPoint;
  133886. /**
  133887. * Gets the w component (input)
  133888. */
  133889. get w(): NodeMaterialConnectionPoint;
  133890. /**
  133891. * Gets the xyzw component (output)
  133892. */
  133893. get xyzw(): NodeMaterialConnectionPoint;
  133894. /**
  133895. * Gets the xyz component (output)
  133896. */
  133897. get xyzOut(): NodeMaterialConnectionPoint;
  133898. /**
  133899. * Gets the xy component (output)
  133900. */
  133901. get xyOut(): NodeMaterialConnectionPoint;
  133902. /**
  133903. * Gets the xy component (output)
  133904. * @deprecated Please use xyOut instead.
  133905. */
  133906. get xy(): NodeMaterialConnectionPoint;
  133907. /**
  133908. * Gets the xyz component (output)
  133909. * @deprecated Please use xyzOut instead.
  133910. */
  133911. get xyz(): NodeMaterialConnectionPoint;
  133912. protected _buildBlock(state: NodeMaterialBuildState): this;
  133913. }
  133914. }
  133915. declare module BABYLON {
  133916. /**
  133917. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  133918. */
  133919. export class ColorSplitterBlock extends NodeMaterialBlock {
  133920. /**
  133921. * Create a new ColorSplitterBlock
  133922. * @param name defines the block name
  133923. */
  133924. constructor(name: string);
  133925. /**
  133926. * Gets the current class name
  133927. * @returns the class name
  133928. */
  133929. getClassName(): string;
  133930. /**
  133931. * Gets the rgba component (input)
  133932. */
  133933. get rgba(): NodeMaterialConnectionPoint;
  133934. /**
  133935. * Gets the rgb component (input)
  133936. */
  133937. get rgbIn(): NodeMaterialConnectionPoint;
  133938. /**
  133939. * Gets the rgb component (output)
  133940. */
  133941. get rgbOut(): NodeMaterialConnectionPoint;
  133942. /**
  133943. * Gets the r component (output)
  133944. */
  133945. get r(): NodeMaterialConnectionPoint;
  133946. /**
  133947. * Gets the g component (output)
  133948. */
  133949. get g(): NodeMaterialConnectionPoint;
  133950. /**
  133951. * Gets the b component (output)
  133952. */
  133953. get b(): NodeMaterialConnectionPoint;
  133954. /**
  133955. * Gets the a component (output)
  133956. */
  133957. get a(): NodeMaterialConnectionPoint;
  133958. protected _inputRename(name: string): string;
  133959. protected _outputRename(name: string): string;
  133960. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  133961. }
  133962. }
  133963. declare module BABYLON {
  133964. /**
  133965. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  133966. */
  133967. export class VectorSplitterBlock extends NodeMaterialBlock {
  133968. /**
  133969. * Create a new VectorSplitterBlock
  133970. * @param name defines the block name
  133971. */
  133972. constructor(name: string);
  133973. /**
  133974. * Gets the current class name
  133975. * @returns the class name
  133976. */
  133977. getClassName(): string;
  133978. /**
  133979. * Gets the xyzw component (input)
  133980. */
  133981. get xyzw(): NodeMaterialConnectionPoint;
  133982. /**
  133983. * Gets the xyz component (input)
  133984. */
  133985. get xyzIn(): NodeMaterialConnectionPoint;
  133986. /**
  133987. * Gets the xy component (input)
  133988. */
  133989. get xyIn(): NodeMaterialConnectionPoint;
  133990. /**
  133991. * Gets the xyz component (output)
  133992. */
  133993. get xyzOut(): NodeMaterialConnectionPoint;
  133994. /**
  133995. * Gets the xy component (output)
  133996. */
  133997. get xyOut(): NodeMaterialConnectionPoint;
  133998. /**
  133999. * Gets the x component (output)
  134000. */
  134001. get x(): NodeMaterialConnectionPoint;
  134002. /**
  134003. * Gets the y component (output)
  134004. */
  134005. get y(): NodeMaterialConnectionPoint;
  134006. /**
  134007. * Gets the z component (output)
  134008. */
  134009. get z(): NodeMaterialConnectionPoint;
  134010. /**
  134011. * Gets the w component (output)
  134012. */
  134013. get w(): NodeMaterialConnectionPoint;
  134014. protected _inputRename(name: string): string;
  134015. protected _outputRename(name: string): string;
  134016. protected _buildBlock(state: NodeMaterialBuildState): this;
  134017. }
  134018. }
  134019. declare module BABYLON {
  134020. /**
  134021. * Block used to lerp between 2 values
  134022. */
  134023. export class LerpBlock extends NodeMaterialBlock {
  134024. /**
  134025. * Creates a new LerpBlock
  134026. * @param name defines the block name
  134027. */
  134028. constructor(name: string);
  134029. /**
  134030. * Gets the current class name
  134031. * @returns the class name
  134032. */
  134033. getClassName(): string;
  134034. /**
  134035. * Gets the left operand input component
  134036. */
  134037. get left(): NodeMaterialConnectionPoint;
  134038. /**
  134039. * Gets the right operand input component
  134040. */
  134041. get right(): NodeMaterialConnectionPoint;
  134042. /**
  134043. * Gets the gradient operand input component
  134044. */
  134045. get gradient(): NodeMaterialConnectionPoint;
  134046. /**
  134047. * Gets the output component
  134048. */
  134049. get output(): NodeMaterialConnectionPoint;
  134050. protected _buildBlock(state: NodeMaterialBuildState): this;
  134051. }
  134052. }
  134053. declare module BABYLON {
  134054. /**
  134055. * Block used to divide 2 vectors
  134056. */
  134057. export class DivideBlock extends NodeMaterialBlock {
  134058. /**
  134059. * Creates a new DivideBlock
  134060. * @param name defines the block name
  134061. */
  134062. constructor(name: string);
  134063. /**
  134064. * Gets the current class name
  134065. * @returns the class name
  134066. */
  134067. getClassName(): string;
  134068. /**
  134069. * Gets the left operand input component
  134070. */
  134071. get left(): NodeMaterialConnectionPoint;
  134072. /**
  134073. * Gets the right operand input component
  134074. */
  134075. get right(): NodeMaterialConnectionPoint;
  134076. /**
  134077. * Gets the output component
  134078. */
  134079. get output(): NodeMaterialConnectionPoint;
  134080. protected _buildBlock(state: NodeMaterialBuildState): this;
  134081. }
  134082. }
  134083. declare module BABYLON {
  134084. /**
  134085. * Block used to subtract 2 vectors
  134086. */
  134087. export class SubtractBlock extends NodeMaterialBlock {
  134088. /**
  134089. * Creates a new SubtractBlock
  134090. * @param name defines the block name
  134091. */
  134092. constructor(name: string);
  134093. /**
  134094. * Gets the current class name
  134095. * @returns the class name
  134096. */
  134097. getClassName(): string;
  134098. /**
  134099. * Gets the left operand input component
  134100. */
  134101. get left(): NodeMaterialConnectionPoint;
  134102. /**
  134103. * Gets the right operand input component
  134104. */
  134105. get right(): NodeMaterialConnectionPoint;
  134106. /**
  134107. * Gets the output component
  134108. */
  134109. get output(): NodeMaterialConnectionPoint;
  134110. protected _buildBlock(state: NodeMaterialBuildState): this;
  134111. }
  134112. }
  134113. declare module BABYLON {
  134114. /**
  134115. * Block used to step a value
  134116. */
  134117. export class StepBlock extends NodeMaterialBlock {
  134118. /**
  134119. * Creates a new StepBlock
  134120. * @param name defines the block name
  134121. */
  134122. constructor(name: string);
  134123. /**
  134124. * Gets the current class name
  134125. * @returns the class name
  134126. */
  134127. getClassName(): string;
  134128. /**
  134129. * Gets the value operand input component
  134130. */
  134131. get value(): NodeMaterialConnectionPoint;
  134132. /**
  134133. * Gets the edge operand input component
  134134. */
  134135. get edge(): NodeMaterialConnectionPoint;
  134136. /**
  134137. * Gets the output component
  134138. */
  134139. get output(): NodeMaterialConnectionPoint;
  134140. protected _buildBlock(state: NodeMaterialBuildState): this;
  134141. }
  134142. }
  134143. declare module BABYLON {
  134144. /**
  134145. * Block used to get the opposite (1 - x) of a value
  134146. */
  134147. export class OneMinusBlock extends NodeMaterialBlock {
  134148. /**
  134149. * Creates a new OneMinusBlock
  134150. * @param name defines the block name
  134151. */
  134152. constructor(name: string);
  134153. /**
  134154. * Gets the current class name
  134155. * @returns the class name
  134156. */
  134157. getClassName(): string;
  134158. /**
  134159. * Gets the input component
  134160. */
  134161. get input(): NodeMaterialConnectionPoint;
  134162. /**
  134163. * Gets the output component
  134164. */
  134165. get output(): NodeMaterialConnectionPoint;
  134166. protected _buildBlock(state: NodeMaterialBuildState): this;
  134167. }
  134168. }
  134169. declare module BABYLON {
  134170. /**
  134171. * Block used to get the view direction
  134172. */
  134173. export class ViewDirectionBlock extends NodeMaterialBlock {
  134174. /**
  134175. * Creates a new ViewDirectionBlock
  134176. * @param name defines the block name
  134177. */
  134178. constructor(name: string);
  134179. /**
  134180. * Gets the current class name
  134181. * @returns the class name
  134182. */
  134183. getClassName(): string;
  134184. /**
  134185. * Gets the world position component
  134186. */
  134187. get worldPosition(): NodeMaterialConnectionPoint;
  134188. /**
  134189. * Gets the camera position component
  134190. */
  134191. get cameraPosition(): NodeMaterialConnectionPoint;
  134192. /**
  134193. * Gets the output component
  134194. */
  134195. get output(): NodeMaterialConnectionPoint;
  134196. autoConfigure(material: NodeMaterial): void;
  134197. protected _buildBlock(state: NodeMaterialBuildState): this;
  134198. }
  134199. }
  134200. declare module BABYLON {
  134201. /**
  134202. * Block used to compute fresnel value
  134203. */
  134204. export class FresnelBlock extends NodeMaterialBlock {
  134205. /**
  134206. * Create a new FresnelBlock
  134207. * @param name defines the block name
  134208. */
  134209. constructor(name: string);
  134210. /**
  134211. * Gets the current class name
  134212. * @returns the class name
  134213. */
  134214. getClassName(): string;
  134215. /**
  134216. * Gets the world normal input component
  134217. */
  134218. get worldNormal(): NodeMaterialConnectionPoint;
  134219. /**
  134220. * Gets the view direction input component
  134221. */
  134222. get viewDirection(): NodeMaterialConnectionPoint;
  134223. /**
  134224. * Gets the bias input component
  134225. */
  134226. get bias(): NodeMaterialConnectionPoint;
  134227. /**
  134228. * Gets the camera (or eye) position component
  134229. */
  134230. get power(): NodeMaterialConnectionPoint;
  134231. /**
  134232. * Gets the fresnel output component
  134233. */
  134234. get fresnel(): NodeMaterialConnectionPoint;
  134235. autoConfigure(material: NodeMaterial): void;
  134236. protected _buildBlock(state: NodeMaterialBuildState): this;
  134237. }
  134238. }
  134239. declare module BABYLON {
  134240. /**
  134241. * Block used to get the max of 2 values
  134242. */
  134243. export class MaxBlock extends NodeMaterialBlock {
  134244. /**
  134245. * Creates a new MaxBlock
  134246. * @param name defines the block name
  134247. */
  134248. constructor(name: string);
  134249. /**
  134250. * Gets the current class name
  134251. * @returns the class name
  134252. */
  134253. getClassName(): string;
  134254. /**
  134255. * Gets the left operand input component
  134256. */
  134257. get left(): NodeMaterialConnectionPoint;
  134258. /**
  134259. * Gets the right operand input component
  134260. */
  134261. get right(): NodeMaterialConnectionPoint;
  134262. /**
  134263. * Gets the output component
  134264. */
  134265. get output(): NodeMaterialConnectionPoint;
  134266. protected _buildBlock(state: NodeMaterialBuildState): this;
  134267. }
  134268. }
  134269. declare module BABYLON {
  134270. /**
  134271. * Block used to get the min of 2 values
  134272. */
  134273. export class MinBlock extends NodeMaterialBlock {
  134274. /**
  134275. * Creates a new MinBlock
  134276. * @param name defines the block name
  134277. */
  134278. constructor(name: string);
  134279. /**
  134280. * Gets the current class name
  134281. * @returns the class name
  134282. */
  134283. getClassName(): string;
  134284. /**
  134285. * Gets the left operand input component
  134286. */
  134287. get left(): NodeMaterialConnectionPoint;
  134288. /**
  134289. * Gets the right operand input component
  134290. */
  134291. get right(): NodeMaterialConnectionPoint;
  134292. /**
  134293. * Gets the output component
  134294. */
  134295. get output(): NodeMaterialConnectionPoint;
  134296. protected _buildBlock(state: NodeMaterialBuildState): this;
  134297. }
  134298. }
  134299. declare module BABYLON {
  134300. /**
  134301. * Block used to get the distance between 2 values
  134302. */
  134303. export class DistanceBlock extends NodeMaterialBlock {
  134304. /**
  134305. * Creates a new DistanceBlock
  134306. * @param name defines the block name
  134307. */
  134308. constructor(name: string);
  134309. /**
  134310. * Gets the current class name
  134311. * @returns the class name
  134312. */
  134313. getClassName(): string;
  134314. /**
  134315. * Gets the left operand input component
  134316. */
  134317. get left(): NodeMaterialConnectionPoint;
  134318. /**
  134319. * Gets the right operand input component
  134320. */
  134321. get right(): NodeMaterialConnectionPoint;
  134322. /**
  134323. * Gets the output component
  134324. */
  134325. get output(): NodeMaterialConnectionPoint;
  134326. protected _buildBlock(state: NodeMaterialBuildState): this;
  134327. }
  134328. }
  134329. declare module BABYLON {
  134330. /**
  134331. * Block used to get the length of a vector
  134332. */
  134333. export class LengthBlock extends NodeMaterialBlock {
  134334. /**
  134335. * Creates a new LengthBlock
  134336. * @param name defines the block name
  134337. */
  134338. constructor(name: string);
  134339. /**
  134340. * Gets the current class name
  134341. * @returns the class name
  134342. */
  134343. getClassName(): string;
  134344. /**
  134345. * Gets the value input component
  134346. */
  134347. get value(): NodeMaterialConnectionPoint;
  134348. /**
  134349. * Gets the output component
  134350. */
  134351. get output(): NodeMaterialConnectionPoint;
  134352. protected _buildBlock(state: NodeMaterialBuildState): this;
  134353. }
  134354. }
  134355. declare module BABYLON {
  134356. /**
  134357. * Block used to get negative version of a value (i.e. x * -1)
  134358. */
  134359. export class NegateBlock extends NodeMaterialBlock {
  134360. /**
  134361. * Creates a new NegateBlock
  134362. * @param name defines the block name
  134363. */
  134364. constructor(name: string);
  134365. /**
  134366. * Gets the current class name
  134367. * @returns the class name
  134368. */
  134369. getClassName(): string;
  134370. /**
  134371. * Gets the value input component
  134372. */
  134373. get value(): NodeMaterialConnectionPoint;
  134374. /**
  134375. * Gets the output component
  134376. */
  134377. get output(): NodeMaterialConnectionPoint;
  134378. protected _buildBlock(state: NodeMaterialBuildState): this;
  134379. }
  134380. }
  134381. declare module BABYLON {
  134382. /**
  134383. * Block used to get the value of the first parameter raised to the power of the second
  134384. */
  134385. export class PowBlock extends NodeMaterialBlock {
  134386. /**
  134387. * Creates a new PowBlock
  134388. * @param name defines the block name
  134389. */
  134390. constructor(name: string);
  134391. /**
  134392. * Gets the current class name
  134393. * @returns the class name
  134394. */
  134395. getClassName(): string;
  134396. /**
  134397. * Gets the value operand input component
  134398. */
  134399. get value(): NodeMaterialConnectionPoint;
  134400. /**
  134401. * Gets the power operand input component
  134402. */
  134403. get power(): NodeMaterialConnectionPoint;
  134404. /**
  134405. * Gets the output component
  134406. */
  134407. get output(): NodeMaterialConnectionPoint;
  134408. protected _buildBlock(state: NodeMaterialBuildState): this;
  134409. }
  134410. }
  134411. declare module BABYLON {
  134412. /**
  134413. * Block used to get a random number
  134414. */
  134415. export class RandomNumberBlock extends NodeMaterialBlock {
  134416. /**
  134417. * Creates a new RandomNumberBlock
  134418. * @param name defines the block name
  134419. */
  134420. constructor(name: string);
  134421. /**
  134422. * Gets the current class name
  134423. * @returns the class name
  134424. */
  134425. getClassName(): string;
  134426. /**
  134427. * Gets the seed input component
  134428. */
  134429. get seed(): NodeMaterialConnectionPoint;
  134430. /**
  134431. * Gets the output component
  134432. */
  134433. get output(): NodeMaterialConnectionPoint;
  134434. protected _buildBlock(state: NodeMaterialBuildState): this;
  134435. }
  134436. }
  134437. declare module BABYLON {
  134438. /**
  134439. * Block used to compute arc tangent of 2 values
  134440. */
  134441. export class ArcTan2Block extends NodeMaterialBlock {
  134442. /**
  134443. * Creates a new ArcTan2Block
  134444. * @param name defines the block name
  134445. */
  134446. constructor(name: string);
  134447. /**
  134448. * Gets the current class name
  134449. * @returns the class name
  134450. */
  134451. getClassName(): string;
  134452. /**
  134453. * Gets the x operand input component
  134454. */
  134455. get x(): NodeMaterialConnectionPoint;
  134456. /**
  134457. * Gets the y operand input component
  134458. */
  134459. get y(): NodeMaterialConnectionPoint;
  134460. /**
  134461. * Gets the output component
  134462. */
  134463. get output(): NodeMaterialConnectionPoint;
  134464. protected _buildBlock(state: NodeMaterialBuildState): this;
  134465. }
  134466. }
  134467. declare module BABYLON {
  134468. /**
  134469. * Block used to smooth step a value
  134470. */
  134471. export class SmoothStepBlock extends NodeMaterialBlock {
  134472. /**
  134473. * Creates a new SmoothStepBlock
  134474. * @param name defines the block name
  134475. */
  134476. constructor(name: string);
  134477. /**
  134478. * Gets the current class name
  134479. * @returns the class name
  134480. */
  134481. getClassName(): string;
  134482. /**
  134483. * Gets the value operand input component
  134484. */
  134485. get value(): NodeMaterialConnectionPoint;
  134486. /**
  134487. * Gets the first edge operand input component
  134488. */
  134489. get edge0(): NodeMaterialConnectionPoint;
  134490. /**
  134491. * Gets the second edge operand input component
  134492. */
  134493. get edge1(): NodeMaterialConnectionPoint;
  134494. /**
  134495. * Gets the output component
  134496. */
  134497. get output(): NodeMaterialConnectionPoint;
  134498. protected _buildBlock(state: NodeMaterialBuildState): this;
  134499. }
  134500. }
  134501. declare module BABYLON {
  134502. /**
  134503. * Block used to get the reciprocal (1 / x) of a value
  134504. */
  134505. export class ReciprocalBlock extends NodeMaterialBlock {
  134506. /**
  134507. * Creates a new ReciprocalBlock
  134508. * @param name defines the block name
  134509. */
  134510. constructor(name: string);
  134511. /**
  134512. * Gets the current class name
  134513. * @returns the class name
  134514. */
  134515. getClassName(): string;
  134516. /**
  134517. * Gets the input component
  134518. */
  134519. get input(): NodeMaterialConnectionPoint;
  134520. /**
  134521. * Gets the output component
  134522. */
  134523. get output(): NodeMaterialConnectionPoint;
  134524. protected _buildBlock(state: NodeMaterialBuildState): this;
  134525. }
  134526. }
  134527. declare module BABYLON {
  134528. /**
  134529. * Block used to replace a color by another one
  134530. */
  134531. export class ReplaceColorBlock extends NodeMaterialBlock {
  134532. /**
  134533. * Creates a new ReplaceColorBlock
  134534. * @param name defines the block name
  134535. */
  134536. constructor(name: string);
  134537. /**
  134538. * Gets the current class name
  134539. * @returns the class name
  134540. */
  134541. getClassName(): string;
  134542. /**
  134543. * Gets the value input component
  134544. */
  134545. get value(): NodeMaterialConnectionPoint;
  134546. /**
  134547. * Gets the reference input component
  134548. */
  134549. get reference(): NodeMaterialConnectionPoint;
  134550. /**
  134551. * Gets the distance input component
  134552. */
  134553. get distance(): NodeMaterialConnectionPoint;
  134554. /**
  134555. * Gets the replacement input component
  134556. */
  134557. get replacement(): NodeMaterialConnectionPoint;
  134558. /**
  134559. * Gets the output component
  134560. */
  134561. get output(): NodeMaterialConnectionPoint;
  134562. protected _buildBlock(state: NodeMaterialBuildState): this;
  134563. }
  134564. }
  134565. declare module BABYLON {
  134566. /**
  134567. * Block used to posterize a value
  134568. * @see https://en.wikipedia.org/wiki/Posterization
  134569. */
  134570. export class PosterizeBlock extends NodeMaterialBlock {
  134571. /**
  134572. * Creates a new PosterizeBlock
  134573. * @param name defines the block name
  134574. */
  134575. constructor(name: string);
  134576. /**
  134577. * Gets the current class name
  134578. * @returns the class name
  134579. */
  134580. getClassName(): string;
  134581. /**
  134582. * Gets the value input component
  134583. */
  134584. get value(): NodeMaterialConnectionPoint;
  134585. /**
  134586. * Gets the steps input component
  134587. */
  134588. get steps(): NodeMaterialConnectionPoint;
  134589. /**
  134590. * Gets the output component
  134591. */
  134592. get output(): NodeMaterialConnectionPoint;
  134593. protected _buildBlock(state: NodeMaterialBuildState): this;
  134594. }
  134595. }
  134596. declare module BABYLON {
  134597. /**
  134598. * Operations supported by the Wave block
  134599. */
  134600. export enum WaveBlockKind {
  134601. /** SawTooth */
  134602. SawTooth = 0,
  134603. /** Square */
  134604. Square = 1,
  134605. /** Triangle */
  134606. Triangle = 2
  134607. }
  134608. /**
  134609. * Block used to apply wave operation to floats
  134610. */
  134611. export class WaveBlock extends NodeMaterialBlock {
  134612. /**
  134613. * Gets or sets the kibnd of wave to be applied by the block
  134614. */
  134615. kind: WaveBlockKind;
  134616. /**
  134617. * Creates a new WaveBlock
  134618. * @param name defines the block name
  134619. */
  134620. constructor(name: string);
  134621. /**
  134622. * Gets the current class name
  134623. * @returns the class name
  134624. */
  134625. getClassName(): string;
  134626. /**
  134627. * Gets the input component
  134628. */
  134629. get input(): NodeMaterialConnectionPoint;
  134630. /**
  134631. * Gets the output component
  134632. */
  134633. get output(): NodeMaterialConnectionPoint;
  134634. protected _buildBlock(state: NodeMaterialBuildState): this;
  134635. serialize(): any;
  134636. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  134637. }
  134638. }
  134639. declare module BABYLON {
  134640. /**
  134641. * Class used to store a color step for the GradientBlock
  134642. */
  134643. export class GradientBlockColorStep {
  134644. /**
  134645. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  134646. */
  134647. step: number;
  134648. /**
  134649. * Gets or sets the color associated with this step
  134650. */
  134651. color: Color3;
  134652. /**
  134653. * Creates a new GradientBlockColorStep
  134654. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  134655. * @param color defines the color associated with this step
  134656. */
  134657. constructor(
  134658. /**
  134659. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  134660. */
  134661. step: number,
  134662. /**
  134663. * Gets or sets the color associated with this step
  134664. */
  134665. color: Color3);
  134666. }
  134667. /**
  134668. * Block used to return a color from a gradient based on an input value between 0 and 1
  134669. */
  134670. export class GradientBlock extends NodeMaterialBlock {
  134671. /**
  134672. * Gets or sets the list of color steps
  134673. */
  134674. colorSteps: GradientBlockColorStep[];
  134675. /**
  134676. * Creates a new GradientBlock
  134677. * @param name defines the block name
  134678. */
  134679. constructor(name: string);
  134680. /**
  134681. * Gets the current class name
  134682. * @returns the class name
  134683. */
  134684. getClassName(): string;
  134685. /**
  134686. * Gets the gradient input component
  134687. */
  134688. get gradient(): NodeMaterialConnectionPoint;
  134689. /**
  134690. * Gets the output component
  134691. */
  134692. get output(): NodeMaterialConnectionPoint;
  134693. private _writeColorConstant;
  134694. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  134695. serialize(): any;
  134696. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  134697. protected _dumpPropertiesCode(): string;
  134698. }
  134699. }
  134700. declare module BABYLON {
  134701. /**
  134702. * Block used to normalize lerp between 2 values
  134703. */
  134704. export class NLerpBlock extends NodeMaterialBlock {
  134705. /**
  134706. * Creates a new NLerpBlock
  134707. * @param name defines the block name
  134708. */
  134709. constructor(name: string);
  134710. /**
  134711. * Gets the current class name
  134712. * @returns the class name
  134713. */
  134714. getClassName(): string;
  134715. /**
  134716. * Gets the left operand input component
  134717. */
  134718. get left(): NodeMaterialConnectionPoint;
  134719. /**
  134720. * Gets the right operand input component
  134721. */
  134722. get right(): NodeMaterialConnectionPoint;
  134723. /**
  134724. * Gets the gradient operand input component
  134725. */
  134726. get gradient(): NodeMaterialConnectionPoint;
  134727. /**
  134728. * Gets the output component
  134729. */
  134730. get output(): NodeMaterialConnectionPoint;
  134731. protected _buildBlock(state: NodeMaterialBuildState): this;
  134732. }
  134733. }
  134734. declare module BABYLON {
  134735. /**
  134736. * block used to Generate a Worley Noise 3D Noise Pattern
  134737. */
  134738. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  134739. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  134740. manhattanDistance: boolean;
  134741. /**
  134742. * Creates a new WorleyNoise3DBlock
  134743. * @param name defines the block name
  134744. */
  134745. constructor(name: string);
  134746. /**
  134747. * Gets the current class name
  134748. * @returns the class name
  134749. */
  134750. getClassName(): string;
  134751. /**
  134752. * Gets the seed input component
  134753. */
  134754. get seed(): NodeMaterialConnectionPoint;
  134755. /**
  134756. * Gets the jitter input component
  134757. */
  134758. get jitter(): NodeMaterialConnectionPoint;
  134759. /**
  134760. * Gets the output component
  134761. */
  134762. get output(): NodeMaterialConnectionPoint;
  134763. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  134764. /**
  134765. * Exposes the properties to the UI?
  134766. */
  134767. protected _dumpPropertiesCode(): string;
  134768. /**
  134769. * Exposes the properties to the Seralize?
  134770. */
  134771. serialize(): any;
  134772. /**
  134773. * Exposes the properties to the deseralize?
  134774. */
  134775. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  134776. }
  134777. }
  134778. declare module BABYLON {
  134779. /**
  134780. * block used to Generate a Simplex Perlin 3d Noise Pattern
  134781. */
  134782. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  134783. /**
  134784. * Creates a new SimplexPerlin3DBlock
  134785. * @param name defines the block name
  134786. */
  134787. constructor(name: string);
  134788. /**
  134789. * Gets the current class name
  134790. * @returns the class name
  134791. */
  134792. getClassName(): string;
  134793. /**
  134794. * Gets the seed operand input component
  134795. */
  134796. get seed(): NodeMaterialConnectionPoint;
  134797. /**
  134798. * Gets the output component
  134799. */
  134800. get output(): NodeMaterialConnectionPoint;
  134801. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  134802. }
  134803. }
  134804. declare module BABYLON {
  134805. /**
  134806. * Block used to blend normals
  134807. */
  134808. export class NormalBlendBlock extends NodeMaterialBlock {
  134809. /**
  134810. * Creates a new NormalBlendBlock
  134811. * @param name defines the block name
  134812. */
  134813. constructor(name: string);
  134814. /**
  134815. * Gets the current class name
  134816. * @returns the class name
  134817. */
  134818. getClassName(): string;
  134819. /**
  134820. * Gets the first input component
  134821. */
  134822. get normalMap0(): NodeMaterialConnectionPoint;
  134823. /**
  134824. * Gets the second input component
  134825. */
  134826. get normalMap1(): NodeMaterialConnectionPoint;
  134827. /**
  134828. * Gets the output component
  134829. */
  134830. get output(): NodeMaterialConnectionPoint;
  134831. protected _buildBlock(state: NodeMaterialBuildState): this;
  134832. }
  134833. }
  134834. declare module BABYLON {
  134835. /**
  134836. * Block used to rotate a 2d vector by a given angle
  134837. */
  134838. export class Rotate2dBlock extends NodeMaterialBlock {
  134839. /**
  134840. * Creates a new Rotate2dBlock
  134841. * @param name defines the block name
  134842. */
  134843. constructor(name: string);
  134844. /**
  134845. * Gets the current class name
  134846. * @returns the class name
  134847. */
  134848. getClassName(): string;
  134849. /**
  134850. * Gets the input vector
  134851. */
  134852. get input(): NodeMaterialConnectionPoint;
  134853. /**
  134854. * Gets the input angle
  134855. */
  134856. get angle(): NodeMaterialConnectionPoint;
  134857. /**
  134858. * Gets the output component
  134859. */
  134860. get output(): NodeMaterialConnectionPoint;
  134861. autoConfigure(material: NodeMaterial): void;
  134862. protected _buildBlock(state: NodeMaterialBuildState): this;
  134863. }
  134864. }
  134865. declare module BABYLON {
  134866. /**
  134867. * Block used to get the reflected vector from a direction and a normal
  134868. */
  134869. export class ReflectBlock extends NodeMaterialBlock {
  134870. /**
  134871. * Creates a new ReflectBlock
  134872. * @param name defines the block name
  134873. */
  134874. constructor(name: string);
  134875. /**
  134876. * Gets the current class name
  134877. * @returns the class name
  134878. */
  134879. getClassName(): string;
  134880. /**
  134881. * Gets the incident component
  134882. */
  134883. get incident(): NodeMaterialConnectionPoint;
  134884. /**
  134885. * Gets the normal component
  134886. */
  134887. get normal(): NodeMaterialConnectionPoint;
  134888. /**
  134889. * Gets the output component
  134890. */
  134891. get output(): NodeMaterialConnectionPoint;
  134892. protected _buildBlock(state: NodeMaterialBuildState): this;
  134893. }
  134894. }
  134895. declare module BABYLON {
  134896. /**
  134897. * Block used to get the refracted vector from a direction and a normal
  134898. */
  134899. export class RefractBlock extends NodeMaterialBlock {
  134900. /**
  134901. * Creates a new RefractBlock
  134902. * @param name defines the block name
  134903. */
  134904. constructor(name: string);
  134905. /**
  134906. * Gets the current class name
  134907. * @returns the class name
  134908. */
  134909. getClassName(): string;
  134910. /**
  134911. * Gets the incident component
  134912. */
  134913. get incident(): NodeMaterialConnectionPoint;
  134914. /**
  134915. * Gets the normal component
  134916. */
  134917. get normal(): NodeMaterialConnectionPoint;
  134918. /**
  134919. * Gets the index of refraction component
  134920. */
  134921. get ior(): NodeMaterialConnectionPoint;
  134922. /**
  134923. * Gets the output component
  134924. */
  134925. get output(): NodeMaterialConnectionPoint;
  134926. protected _buildBlock(state: NodeMaterialBuildState): this;
  134927. }
  134928. }
  134929. declare module BABYLON {
  134930. /**
  134931. * Block used to desaturate a color
  134932. */
  134933. export class DesaturateBlock extends NodeMaterialBlock {
  134934. /**
  134935. * Creates a new DesaturateBlock
  134936. * @param name defines the block name
  134937. */
  134938. constructor(name: string);
  134939. /**
  134940. * Gets the current class name
  134941. * @returns the class name
  134942. */
  134943. getClassName(): string;
  134944. /**
  134945. * Gets the color operand input component
  134946. */
  134947. get color(): NodeMaterialConnectionPoint;
  134948. /**
  134949. * Gets the level operand input component
  134950. */
  134951. get level(): NodeMaterialConnectionPoint;
  134952. /**
  134953. * Gets the output component
  134954. */
  134955. get output(): NodeMaterialConnectionPoint;
  134956. protected _buildBlock(state: NodeMaterialBuildState): this;
  134957. }
  134958. }
  134959. declare module BABYLON {
  134960. /**
  134961. * Effect Render Options
  134962. */
  134963. export interface IEffectRendererOptions {
  134964. /**
  134965. * Defines the vertices positions.
  134966. */
  134967. positions?: number[];
  134968. /**
  134969. * Defines the indices.
  134970. */
  134971. indices?: number[];
  134972. }
  134973. /**
  134974. * Helper class to render one or more effects.
  134975. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  134976. */
  134977. export class EffectRenderer {
  134978. private engine;
  134979. private static _DefaultOptions;
  134980. private _vertexBuffers;
  134981. private _indexBuffer;
  134982. private _fullscreenViewport;
  134983. /**
  134984. * Creates an effect renderer
  134985. * @param engine the engine to use for rendering
  134986. * @param options defines the options of the effect renderer
  134987. */
  134988. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  134989. /**
  134990. * Sets the current viewport in normalized coordinates 0-1
  134991. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  134992. */
  134993. setViewport(viewport?: Viewport): void;
  134994. /**
  134995. * Binds the embedded attributes buffer to the effect.
  134996. * @param effect Defines the effect to bind the attributes for
  134997. */
  134998. bindBuffers(effect: Effect): void;
  134999. /**
  135000. * Sets the current effect wrapper to use during draw.
  135001. * The effect needs to be ready before calling this api.
  135002. * This also sets the default full screen position attribute.
  135003. * @param effectWrapper Defines the effect to draw with
  135004. */
  135005. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  135006. /**
  135007. * Draws a full screen quad.
  135008. */
  135009. draw(): void;
  135010. private isRenderTargetTexture;
  135011. /**
  135012. * renders one or more effects to a specified texture
  135013. * @param effectWrapper the effect to renderer
  135014. * @param outputTexture texture to draw to, if null it will render to the screen.
  135015. */
  135016. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  135017. /**
  135018. * Disposes of the effect renderer
  135019. */
  135020. dispose(): void;
  135021. }
  135022. /**
  135023. * Options to create an EffectWrapper
  135024. */
  135025. interface EffectWrapperCreationOptions {
  135026. /**
  135027. * Engine to use to create the effect
  135028. */
  135029. engine: ThinEngine;
  135030. /**
  135031. * Fragment shader for the effect
  135032. */
  135033. fragmentShader: string;
  135034. /**
  135035. * Vertex shader for the effect
  135036. */
  135037. vertexShader?: string;
  135038. /**
  135039. * Attributes to use in the shader
  135040. */
  135041. attributeNames?: Array<string>;
  135042. /**
  135043. * Uniforms to use in the shader
  135044. */
  135045. uniformNames?: Array<string>;
  135046. /**
  135047. * Texture sampler names to use in the shader
  135048. */
  135049. samplerNames?: Array<string>;
  135050. /**
  135051. * The friendly name of the effect displayed in Spector.
  135052. */
  135053. name?: string;
  135054. }
  135055. /**
  135056. * Wraps an effect to be used for rendering
  135057. */
  135058. export class EffectWrapper {
  135059. /**
  135060. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  135061. */
  135062. onApplyObservable: Observable<{}>;
  135063. /**
  135064. * The underlying effect
  135065. */
  135066. effect: Effect;
  135067. /**
  135068. * Creates an effect to be renderer
  135069. * @param creationOptions options to create the effect
  135070. */
  135071. constructor(creationOptions: EffectWrapperCreationOptions);
  135072. /**
  135073. * Disposes of the effect wrapper
  135074. */
  135075. dispose(): void;
  135076. }
  135077. }
  135078. declare module BABYLON {
  135079. /**
  135080. * Helper class to push actions to a pool of workers.
  135081. */
  135082. export class WorkerPool implements IDisposable {
  135083. private _workerInfos;
  135084. private _pendingActions;
  135085. /**
  135086. * Constructor
  135087. * @param workers Array of workers to use for actions
  135088. */
  135089. constructor(workers: Array<Worker>);
  135090. /**
  135091. * Terminates all workers and clears any pending actions.
  135092. */
  135093. dispose(): void;
  135094. /**
  135095. * Pushes an action to the worker pool. If all the workers are active, the action will be
  135096. * pended until a worker has completed its action.
  135097. * @param action The action to perform. Call onComplete when the action is complete.
  135098. */
  135099. push(action: (worker: Worker, onComplete: () => void) => void): void;
  135100. private _execute;
  135101. }
  135102. }
  135103. declare module BABYLON {
  135104. /**
  135105. * Configuration for Draco compression
  135106. */
  135107. export interface IDracoCompressionConfiguration {
  135108. /**
  135109. * Configuration for the decoder.
  135110. */
  135111. decoder: {
  135112. /**
  135113. * The url to the WebAssembly module.
  135114. */
  135115. wasmUrl?: string;
  135116. /**
  135117. * The url to the WebAssembly binary.
  135118. */
  135119. wasmBinaryUrl?: string;
  135120. /**
  135121. * The url to the fallback JavaScript module.
  135122. */
  135123. fallbackUrl?: string;
  135124. };
  135125. }
  135126. /**
  135127. * Draco compression (https://google.github.io/draco/)
  135128. *
  135129. * This class wraps the Draco module.
  135130. *
  135131. * **Encoder**
  135132. *
  135133. * The encoder is not currently implemented.
  135134. *
  135135. * **Decoder**
  135136. *
  135137. * 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.
  135138. *
  135139. * To update the configuration, use the following code:
  135140. * ```javascript
  135141. * DracoCompression.Configuration = {
  135142. * decoder: {
  135143. * wasmUrl: "<url to the WebAssembly library>",
  135144. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  135145. * fallbackUrl: "<url to the fallback JavaScript library>",
  135146. * }
  135147. * };
  135148. * ```
  135149. *
  135150. * 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.
  135151. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  135152. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  135153. *
  135154. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  135155. * ```javascript
  135156. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  135157. * ```
  135158. *
  135159. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  135160. */
  135161. export class DracoCompression implements IDisposable {
  135162. private _workerPoolPromise?;
  135163. private _decoderModulePromise?;
  135164. /**
  135165. * The configuration. Defaults to the following urls:
  135166. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  135167. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  135168. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  135169. */
  135170. static Configuration: IDracoCompressionConfiguration;
  135171. /**
  135172. * Returns true if the decoder configuration is available.
  135173. */
  135174. static get DecoderAvailable(): boolean;
  135175. /**
  135176. * Default number of workers to create when creating the draco compression object.
  135177. */
  135178. static DefaultNumWorkers: number;
  135179. private static GetDefaultNumWorkers;
  135180. private static _Default;
  135181. /**
  135182. * Default instance for the draco compression object.
  135183. */
  135184. static get Default(): DracoCompression;
  135185. /**
  135186. * Constructor
  135187. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  135188. */
  135189. constructor(numWorkers?: number);
  135190. /**
  135191. * Stop all async operations and release resources.
  135192. */
  135193. dispose(): void;
  135194. /**
  135195. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  135196. * @returns a promise that resolves when ready
  135197. */
  135198. whenReadyAsync(): Promise<void>;
  135199. /**
  135200. * Decode Draco compressed mesh data to vertex data.
  135201. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  135202. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  135203. * @returns A promise that resolves with the decoded vertex data
  135204. */
  135205. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  135206. [kind: string]: number;
  135207. }): Promise<VertexData>;
  135208. }
  135209. }
  135210. declare module BABYLON {
  135211. /**
  135212. * Class for building Constructive Solid Geometry
  135213. */
  135214. export class CSG {
  135215. private polygons;
  135216. /**
  135217. * The world matrix
  135218. */
  135219. matrix: Matrix;
  135220. /**
  135221. * Stores the position
  135222. */
  135223. position: Vector3;
  135224. /**
  135225. * Stores the rotation
  135226. */
  135227. rotation: Vector3;
  135228. /**
  135229. * Stores the rotation quaternion
  135230. */
  135231. rotationQuaternion: Nullable<Quaternion>;
  135232. /**
  135233. * Stores the scaling vector
  135234. */
  135235. scaling: Vector3;
  135236. /**
  135237. * Convert the Mesh to CSG
  135238. * @param mesh The Mesh to convert to CSG
  135239. * @returns A new CSG from the Mesh
  135240. */
  135241. static FromMesh(mesh: Mesh): CSG;
  135242. /**
  135243. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  135244. * @param polygons Polygons used to construct a CSG solid
  135245. */
  135246. private static FromPolygons;
  135247. /**
  135248. * Clones, or makes a deep copy, of the CSG
  135249. * @returns A new CSG
  135250. */
  135251. clone(): CSG;
  135252. /**
  135253. * Unions this CSG with another CSG
  135254. * @param csg The CSG to union against this CSG
  135255. * @returns The unioned CSG
  135256. */
  135257. union(csg: CSG): CSG;
  135258. /**
  135259. * Unions this CSG with another CSG in place
  135260. * @param csg The CSG to union against this CSG
  135261. */
  135262. unionInPlace(csg: CSG): void;
  135263. /**
  135264. * Subtracts this CSG with another CSG
  135265. * @param csg The CSG to subtract against this CSG
  135266. * @returns A new CSG
  135267. */
  135268. subtract(csg: CSG): CSG;
  135269. /**
  135270. * Subtracts this CSG with another CSG in place
  135271. * @param csg The CSG to subtact against this CSG
  135272. */
  135273. subtractInPlace(csg: CSG): void;
  135274. /**
  135275. * Intersect this CSG with another CSG
  135276. * @param csg The CSG to intersect against this CSG
  135277. * @returns A new CSG
  135278. */
  135279. intersect(csg: CSG): CSG;
  135280. /**
  135281. * Intersects this CSG with another CSG in place
  135282. * @param csg The CSG to intersect against this CSG
  135283. */
  135284. intersectInPlace(csg: CSG): void;
  135285. /**
  135286. * Return a new CSG solid with solid and empty space switched. This solid is
  135287. * not modified.
  135288. * @returns A new CSG solid with solid and empty space switched
  135289. */
  135290. inverse(): CSG;
  135291. /**
  135292. * Inverses the CSG in place
  135293. */
  135294. inverseInPlace(): void;
  135295. /**
  135296. * This is used to keep meshes transformations so they can be restored
  135297. * when we build back a Babylon Mesh
  135298. * NB : All CSG operations are performed in world coordinates
  135299. * @param csg The CSG to copy the transform attributes from
  135300. * @returns This CSG
  135301. */
  135302. copyTransformAttributes(csg: CSG): CSG;
  135303. /**
  135304. * Build Raw mesh from CSG
  135305. * Coordinates here are in world space
  135306. * @param name The name of the mesh geometry
  135307. * @param scene The Scene
  135308. * @param keepSubMeshes Specifies if the submeshes should be kept
  135309. * @returns A new Mesh
  135310. */
  135311. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  135312. /**
  135313. * Build Mesh from CSG taking material and transforms into account
  135314. * @param name The name of the Mesh
  135315. * @param material The material of the Mesh
  135316. * @param scene The Scene
  135317. * @param keepSubMeshes Specifies if submeshes should be kept
  135318. * @returns The new Mesh
  135319. */
  135320. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  135321. }
  135322. }
  135323. declare module BABYLON {
  135324. /**
  135325. * Class used to create a trail following a mesh
  135326. */
  135327. export class TrailMesh extends Mesh {
  135328. private _generator;
  135329. private _autoStart;
  135330. private _running;
  135331. private _diameter;
  135332. private _length;
  135333. private _sectionPolygonPointsCount;
  135334. private _sectionVectors;
  135335. private _sectionNormalVectors;
  135336. private _beforeRenderObserver;
  135337. /**
  135338. * @constructor
  135339. * @param name The value used by scene.getMeshByName() to do a lookup.
  135340. * @param generator The mesh or transform node to generate a trail.
  135341. * @param scene The scene to add this mesh to.
  135342. * @param diameter Diameter of trailing mesh. Default is 1.
  135343. * @param length Length of trailing mesh. Default is 60.
  135344. * @param autoStart Automatically start trailing mesh. Default true.
  135345. */
  135346. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  135347. /**
  135348. * "TrailMesh"
  135349. * @returns "TrailMesh"
  135350. */
  135351. getClassName(): string;
  135352. private _createMesh;
  135353. /**
  135354. * Start trailing mesh.
  135355. */
  135356. start(): void;
  135357. /**
  135358. * Stop trailing mesh.
  135359. */
  135360. stop(): void;
  135361. /**
  135362. * Update trailing mesh geometry.
  135363. */
  135364. update(): void;
  135365. /**
  135366. * Returns a new TrailMesh object.
  135367. * @param name is a string, the name given to the new mesh
  135368. * @param newGenerator use new generator object for cloned trail mesh
  135369. * @returns a new mesh
  135370. */
  135371. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  135372. /**
  135373. * Serializes this trail mesh
  135374. * @param serializationObject object to write serialization to
  135375. */
  135376. serialize(serializationObject: any): void;
  135377. /**
  135378. * Parses a serialized trail mesh
  135379. * @param parsedMesh the serialized mesh
  135380. * @param scene the scene to create the trail mesh in
  135381. * @returns the created trail mesh
  135382. */
  135383. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  135384. }
  135385. }
  135386. declare module BABYLON {
  135387. /**
  135388. * Class containing static functions to help procedurally build meshes
  135389. */
  135390. export class TiledBoxBuilder {
  135391. /**
  135392. * Creates a box mesh
  135393. * 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)
  135394. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  135395. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  135396. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  135397. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  135398. * @param name defines the name of the mesh
  135399. * @param options defines the options used to create the mesh
  135400. * @param scene defines the hosting scene
  135401. * @returns the box mesh
  135402. */
  135403. static CreateTiledBox(name: string, options: {
  135404. pattern?: number;
  135405. width?: number;
  135406. height?: number;
  135407. depth?: number;
  135408. tileSize?: number;
  135409. tileWidth?: number;
  135410. tileHeight?: number;
  135411. alignHorizontal?: number;
  135412. alignVertical?: number;
  135413. faceUV?: Vector4[];
  135414. faceColors?: Color4[];
  135415. sideOrientation?: number;
  135416. updatable?: boolean;
  135417. }, scene?: Nullable<Scene>): Mesh;
  135418. }
  135419. }
  135420. declare module BABYLON {
  135421. /**
  135422. * Class containing static functions to help procedurally build meshes
  135423. */
  135424. export class TorusKnotBuilder {
  135425. /**
  135426. * Creates a torus knot mesh
  135427. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  135428. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  135429. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  135430. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  135431. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  135432. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  135433. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  135434. * @param name defines the name of the mesh
  135435. * @param options defines the options used to create the mesh
  135436. * @param scene defines the hosting scene
  135437. * @returns the torus knot mesh
  135438. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  135439. */
  135440. static CreateTorusKnot(name: string, options: {
  135441. radius?: number;
  135442. tube?: number;
  135443. radialSegments?: number;
  135444. tubularSegments?: number;
  135445. p?: number;
  135446. q?: number;
  135447. updatable?: boolean;
  135448. sideOrientation?: number;
  135449. frontUVs?: Vector4;
  135450. backUVs?: Vector4;
  135451. }, scene: any): Mesh;
  135452. }
  135453. }
  135454. declare module BABYLON {
  135455. /**
  135456. * Polygon
  135457. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  135458. */
  135459. export class Polygon {
  135460. /**
  135461. * Creates a rectangle
  135462. * @param xmin bottom X coord
  135463. * @param ymin bottom Y coord
  135464. * @param xmax top X coord
  135465. * @param ymax top Y coord
  135466. * @returns points that make the resulting rectation
  135467. */
  135468. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  135469. /**
  135470. * Creates a circle
  135471. * @param radius radius of circle
  135472. * @param cx scale in x
  135473. * @param cy scale in y
  135474. * @param numberOfSides number of sides that make up the circle
  135475. * @returns points that make the resulting circle
  135476. */
  135477. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  135478. /**
  135479. * Creates a polygon from input string
  135480. * @param input Input polygon data
  135481. * @returns the parsed points
  135482. */
  135483. static Parse(input: string): Vector2[];
  135484. /**
  135485. * Starts building a polygon from x and y coordinates
  135486. * @param x x coordinate
  135487. * @param y y coordinate
  135488. * @returns the started path2
  135489. */
  135490. static StartingAt(x: number, y: number): Path2;
  135491. }
  135492. /**
  135493. * Builds a polygon
  135494. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  135495. */
  135496. export class PolygonMeshBuilder {
  135497. private _points;
  135498. private _outlinepoints;
  135499. private _holes;
  135500. private _name;
  135501. private _scene;
  135502. private _epoints;
  135503. private _eholes;
  135504. private _addToepoint;
  135505. /**
  135506. * Babylon reference to the earcut plugin.
  135507. */
  135508. bjsEarcut: any;
  135509. /**
  135510. * Creates a PolygonMeshBuilder
  135511. * @param name name of the builder
  135512. * @param contours Path of the polygon
  135513. * @param scene scene to add to when creating the mesh
  135514. * @param earcutInjection can be used to inject your own earcut reference
  135515. */
  135516. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  135517. /**
  135518. * Adds a whole within the polygon
  135519. * @param hole Array of points defining the hole
  135520. * @returns this
  135521. */
  135522. addHole(hole: Vector2[]): PolygonMeshBuilder;
  135523. /**
  135524. * Creates the polygon
  135525. * @param updatable If the mesh should be updatable
  135526. * @param depth The depth of the mesh created
  135527. * @returns the created mesh
  135528. */
  135529. build(updatable?: boolean, depth?: number): Mesh;
  135530. /**
  135531. * Creates the polygon
  135532. * @param depth The depth of the mesh created
  135533. * @returns the created VertexData
  135534. */
  135535. buildVertexData(depth?: number): VertexData;
  135536. /**
  135537. * Adds a side to the polygon
  135538. * @param positions points that make the polygon
  135539. * @param normals normals of the polygon
  135540. * @param uvs uvs of the polygon
  135541. * @param indices indices of the polygon
  135542. * @param bounds bounds of the polygon
  135543. * @param points points of the polygon
  135544. * @param depth depth of the polygon
  135545. * @param flip flip of the polygon
  135546. */
  135547. private addSide;
  135548. }
  135549. }
  135550. declare module BABYLON {
  135551. /**
  135552. * Class containing static functions to help procedurally build meshes
  135553. */
  135554. export class PolygonBuilder {
  135555. /**
  135556. * Creates a polygon mesh
  135557. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  135558. * * 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
  135559. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  135560. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  135561. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  135562. * * Remember you can only change the shape positions, not their number when updating a polygon
  135563. * @param name defines the name of the mesh
  135564. * @param options defines the options used to create the mesh
  135565. * @param scene defines the hosting scene
  135566. * @param earcutInjection can be used to inject your own earcut reference
  135567. * @returns the polygon mesh
  135568. */
  135569. static CreatePolygon(name: string, options: {
  135570. shape: Vector3[];
  135571. holes?: Vector3[][];
  135572. depth?: number;
  135573. faceUV?: Vector4[];
  135574. faceColors?: Color4[];
  135575. updatable?: boolean;
  135576. sideOrientation?: number;
  135577. frontUVs?: Vector4;
  135578. backUVs?: Vector4;
  135579. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  135580. /**
  135581. * Creates an extruded polygon mesh, with depth in the Y direction.
  135582. * * 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)
  135583. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  135584. * @param name defines the name of the mesh
  135585. * @param options defines the options used to create the mesh
  135586. * @param scene defines the hosting scene
  135587. * @param earcutInjection can be used to inject your own earcut reference
  135588. * @returns the polygon mesh
  135589. */
  135590. static ExtrudePolygon(name: string, options: {
  135591. shape: Vector3[];
  135592. holes?: Vector3[][];
  135593. depth?: number;
  135594. faceUV?: Vector4[];
  135595. faceColors?: Color4[];
  135596. updatable?: boolean;
  135597. sideOrientation?: number;
  135598. frontUVs?: Vector4;
  135599. backUVs?: Vector4;
  135600. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  135601. }
  135602. }
  135603. declare module BABYLON {
  135604. /**
  135605. * Class containing static functions to help procedurally build meshes
  135606. */
  135607. export class LatheBuilder {
  135608. /**
  135609. * Creates lathe mesh.
  135610. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  135611. * * 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
  135612. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  135613. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  135614. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  135615. * * 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
  135616. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  135617. * * 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
  135618. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  135619. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  135620. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  135621. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  135622. * @param name defines the name of the mesh
  135623. * @param options defines the options used to create the mesh
  135624. * @param scene defines the hosting scene
  135625. * @returns the lathe mesh
  135626. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  135627. */
  135628. static CreateLathe(name: string, options: {
  135629. shape: Vector3[];
  135630. radius?: number;
  135631. tessellation?: number;
  135632. clip?: number;
  135633. arc?: number;
  135634. closed?: boolean;
  135635. updatable?: boolean;
  135636. sideOrientation?: number;
  135637. frontUVs?: Vector4;
  135638. backUVs?: Vector4;
  135639. cap?: number;
  135640. invertUV?: boolean;
  135641. }, scene?: Nullable<Scene>): Mesh;
  135642. }
  135643. }
  135644. declare module BABYLON {
  135645. /**
  135646. * Class containing static functions to help procedurally build meshes
  135647. */
  135648. export class TiledPlaneBuilder {
  135649. /**
  135650. * Creates a tiled plane mesh
  135651. * * The parameter `pattern` will, depending on value, do nothing or
  135652. * * * flip (reflect about central vertical) alternate tiles across and up
  135653. * * * flip every tile on alternate rows
  135654. * * * rotate (180 degs) alternate tiles across and up
  135655. * * * rotate every tile on alternate rows
  135656. * * * flip and rotate alternate tiles across and up
  135657. * * * flip and rotate every tile on alternate rows
  135658. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  135659. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  135660. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  135661. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  135662. * * 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)
  135663. * * 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)
  135664. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  135665. * @param name defines the name of the mesh
  135666. * @param options defines the options used to create the mesh
  135667. * @param scene defines the hosting scene
  135668. * @returns the box mesh
  135669. */
  135670. static CreateTiledPlane(name: string, options: {
  135671. pattern?: number;
  135672. tileSize?: number;
  135673. tileWidth?: number;
  135674. tileHeight?: number;
  135675. size?: number;
  135676. width?: number;
  135677. height?: number;
  135678. alignHorizontal?: number;
  135679. alignVertical?: number;
  135680. sideOrientation?: number;
  135681. frontUVs?: Vector4;
  135682. backUVs?: Vector4;
  135683. updatable?: boolean;
  135684. }, scene?: Nullable<Scene>): Mesh;
  135685. }
  135686. }
  135687. declare module BABYLON {
  135688. /**
  135689. * Class containing static functions to help procedurally build meshes
  135690. */
  135691. export class TubeBuilder {
  135692. /**
  135693. * Creates a tube mesh.
  135694. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  135695. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  135696. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  135697. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  135698. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  135699. * * 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)
  135700. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  135701. * * 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
  135702. * * 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
  135703. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  135704. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  135705. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  135706. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  135707. * @param name defines the name of the mesh
  135708. * @param options defines the options used to create the mesh
  135709. * @param scene defines the hosting scene
  135710. * @returns the tube mesh
  135711. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  135712. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  135713. */
  135714. static CreateTube(name: string, options: {
  135715. path: Vector3[];
  135716. radius?: number;
  135717. tessellation?: number;
  135718. radiusFunction?: {
  135719. (i: number, distance: number): number;
  135720. };
  135721. cap?: number;
  135722. arc?: number;
  135723. updatable?: boolean;
  135724. sideOrientation?: number;
  135725. frontUVs?: Vector4;
  135726. backUVs?: Vector4;
  135727. instance?: Mesh;
  135728. invertUV?: boolean;
  135729. }, scene?: Nullable<Scene>): Mesh;
  135730. }
  135731. }
  135732. declare module BABYLON {
  135733. /**
  135734. * Class containing static functions to help procedurally build meshes
  135735. */
  135736. export class IcoSphereBuilder {
  135737. /**
  135738. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  135739. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  135740. * * 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`)
  135741. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  135742. * * 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
  135743. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  135744. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  135745. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  135746. * @param name defines the name of the mesh
  135747. * @param options defines the options used to create the mesh
  135748. * @param scene defines the hosting scene
  135749. * @returns the icosahedron mesh
  135750. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  135751. */
  135752. static CreateIcoSphere(name: string, options: {
  135753. radius?: number;
  135754. radiusX?: number;
  135755. radiusY?: number;
  135756. radiusZ?: number;
  135757. flat?: boolean;
  135758. subdivisions?: number;
  135759. sideOrientation?: number;
  135760. frontUVs?: Vector4;
  135761. backUVs?: Vector4;
  135762. updatable?: boolean;
  135763. }, scene?: Nullable<Scene>): Mesh;
  135764. }
  135765. }
  135766. declare module BABYLON {
  135767. /**
  135768. * Class containing static functions to help procedurally build meshes
  135769. */
  135770. export class DecalBuilder {
  135771. /**
  135772. * Creates a decal mesh.
  135773. * 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
  135774. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  135775. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  135776. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  135777. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  135778. * @param name defines the name of the mesh
  135779. * @param sourceMesh defines the mesh where the decal must be applied
  135780. * @param options defines the options used to create the mesh
  135781. * @param scene defines the hosting scene
  135782. * @returns the decal mesh
  135783. * @see https://doc.babylonjs.com/how_to/decals
  135784. */
  135785. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  135786. position?: Vector3;
  135787. normal?: Vector3;
  135788. size?: Vector3;
  135789. angle?: number;
  135790. }): Mesh;
  135791. }
  135792. }
  135793. declare module BABYLON {
  135794. /**
  135795. * Class containing static functions to help procedurally build meshes
  135796. */
  135797. export class MeshBuilder {
  135798. /**
  135799. * Creates a box mesh
  135800. * * The parameter `size` sets the size (float) of each box side (default 1)
  135801. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  135802. * * 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)
  135803. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  135804. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  135805. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  135806. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  135807. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  135808. * @param name defines the name of the mesh
  135809. * @param options defines the options used to create the mesh
  135810. * @param scene defines the hosting scene
  135811. * @returns the box mesh
  135812. */
  135813. static CreateBox(name: string, options: {
  135814. size?: number;
  135815. width?: number;
  135816. height?: number;
  135817. depth?: number;
  135818. faceUV?: Vector4[];
  135819. faceColors?: Color4[];
  135820. sideOrientation?: number;
  135821. frontUVs?: Vector4;
  135822. backUVs?: Vector4;
  135823. wrap?: boolean;
  135824. topBaseAt?: number;
  135825. bottomBaseAt?: number;
  135826. updatable?: boolean;
  135827. }, scene?: Nullable<Scene>): Mesh;
  135828. /**
  135829. * Creates a tiled box mesh
  135830. * * faceTiles sets the pattern, tile size and number of tiles for a face
  135831. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  135832. * @param name defines the name of the mesh
  135833. * @param options defines the options used to create the mesh
  135834. * @param scene defines the hosting scene
  135835. * @returns the tiled box mesh
  135836. */
  135837. static CreateTiledBox(name: string, options: {
  135838. pattern?: number;
  135839. size?: number;
  135840. width?: number;
  135841. height?: number;
  135842. depth: number;
  135843. tileSize?: number;
  135844. tileWidth?: number;
  135845. tileHeight?: number;
  135846. faceUV?: Vector4[];
  135847. faceColors?: Color4[];
  135848. alignHorizontal?: number;
  135849. alignVertical?: number;
  135850. sideOrientation?: number;
  135851. updatable?: boolean;
  135852. }, scene?: Nullable<Scene>): Mesh;
  135853. /**
  135854. * Creates a sphere mesh
  135855. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  135856. * * 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`)
  135857. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  135858. * * 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
  135859. * * 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)
  135860. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  135861. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  135862. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  135863. * @param name defines the name of the mesh
  135864. * @param options defines the options used to create the mesh
  135865. * @param scene defines the hosting scene
  135866. * @returns the sphere mesh
  135867. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  135868. */
  135869. static CreateSphere(name: string, options: {
  135870. segments?: number;
  135871. diameter?: number;
  135872. diameterX?: number;
  135873. diameterY?: number;
  135874. diameterZ?: number;
  135875. arc?: number;
  135876. slice?: number;
  135877. sideOrientation?: number;
  135878. frontUVs?: Vector4;
  135879. backUVs?: Vector4;
  135880. updatable?: boolean;
  135881. }, scene?: Nullable<Scene>): Mesh;
  135882. /**
  135883. * Creates a plane polygonal mesh. By default, this is a disc
  135884. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  135885. * * 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
  135886. * * 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
  135887. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  135888. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  135889. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  135890. * @param name defines the name of the mesh
  135891. * @param options defines the options used to create the mesh
  135892. * @param scene defines the hosting scene
  135893. * @returns the plane polygonal mesh
  135894. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  135895. */
  135896. static CreateDisc(name: string, options: {
  135897. radius?: number;
  135898. tessellation?: number;
  135899. arc?: number;
  135900. updatable?: boolean;
  135901. sideOrientation?: number;
  135902. frontUVs?: Vector4;
  135903. backUVs?: Vector4;
  135904. }, scene?: Nullable<Scene>): Mesh;
  135905. /**
  135906. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  135907. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  135908. * * 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`)
  135909. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  135910. * * 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
  135911. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  135912. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  135913. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  135914. * @param name defines the name of the mesh
  135915. * @param options defines the options used to create the mesh
  135916. * @param scene defines the hosting scene
  135917. * @returns the icosahedron mesh
  135918. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  135919. */
  135920. static CreateIcoSphere(name: string, options: {
  135921. radius?: number;
  135922. radiusX?: number;
  135923. radiusY?: number;
  135924. radiusZ?: number;
  135925. flat?: boolean;
  135926. subdivisions?: number;
  135927. sideOrientation?: number;
  135928. frontUVs?: Vector4;
  135929. backUVs?: Vector4;
  135930. updatable?: boolean;
  135931. }, scene?: Nullable<Scene>): Mesh;
  135932. /**
  135933. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  135934. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  135935. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  135936. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  135937. * * 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
  135938. * * 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
  135939. * * 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
  135940. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  135941. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  135942. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  135943. * * 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
  135944. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  135945. * * 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
  135946. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  135947. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  135948. * @param name defines the name of the mesh
  135949. * @param options defines the options used to create the mesh
  135950. * @param scene defines the hosting scene
  135951. * @returns the ribbon mesh
  135952. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  135953. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  135954. */
  135955. static CreateRibbon(name: string, options: {
  135956. pathArray: Vector3[][];
  135957. closeArray?: boolean;
  135958. closePath?: boolean;
  135959. offset?: number;
  135960. updatable?: boolean;
  135961. sideOrientation?: number;
  135962. frontUVs?: Vector4;
  135963. backUVs?: Vector4;
  135964. instance?: Mesh;
  135965. invertUV?: boolean;
  135966. uvs?: Vector2[];
  135967. colors?: Color4[];
  135968. }, scene?: Nullable<Scene>): Mesh;
  135969. /**
  135970. * Creates a cylinder or a cone mesh
  135971. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  135972. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  135973. * * 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.
  135974. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  135975. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  135976. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  135977. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  135978. * * 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).
  135979. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  135980. * * 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).
  135981. * * 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
  135982. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  135983. * * 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
  135984. * * 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.
  135985. * * If `enclose` is false, a ring surface is one element.
  135986. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  135987. * * 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
  135988. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  135989. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  135990. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  135991. * @param name defines the name of the mesh
  135992. * @param options defines the options used to create the mesh
  135993. * @param scene defines the hosting scene
  135994. * @returns the cylinder mesh
  135995. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  135996. */
  135997. static CreateCylinder(name: string, options: {
  135998. height?: number;
  135999. diameterTop?: number;
  136000. diameterBottom?: number;
  136001. diameter?: number;
  136002. tessellation?: number;
  136003. subdivisions?: number;
  136004. arc?: number;
  136005. faceColors?: Color4[];
  136006. faceUV?: Vector4[];
  136007. updatable?: boolean;
  136008. hasRings?: boolean;
  136009. enclose?: boolean;
  136010. cap?: number;
  136011. sideOrientation?: number;
  136012. frontUVs?: Vector4;
  136013. backUVs?: Vector4;
  136014. }, scene?: Nullable<Scene>): Mesh;
  136015. /**
  136016. * Creates a torus mesh
  136017. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  136018. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  136019. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  136020. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  136021. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  136022. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  136023. * @param name defines the name of the mesh
  136024. * @param options defines the options used to create the mesh
  136025. * @param scene defines the hosting scene
  136026. * @returns the torus mesh
  136027. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  136028. */
  136029. static CreateTorus(name: string, options: {
  136030. diameter?: number;
  136031. thickness?: number;
  136032. tessellation?: number;
  136033. updatable?: boolean;
  136034. sideOrientation?: number;
  136035. frontUVs?: Vector4;
  136036. backUVs?: Vector4;
  136037. }, scene?: Nullable<Scene>): Mesh;
  136038. /**
  136039. * Creates a torus knot mesh
  136040. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  136041. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  136042. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  136043. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  136044. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  136045. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  136046. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  136047. * @param name defines the name of the mesh
  136048. * @param options defines the options used to create the mesh
  136049. * @param scene defines the hosting scene
  136050. * @returns the torus knot mesh
  136051. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  136052. */
  136053. static CreateTorusKnot(name: string, options: {
  136054. radius?: number;
  136055. tube?: number;
  136056. radialSegments?: number;
  136057. tubularSegments?: number;
  136058. p?: number;
  136059. q?: number;
  136060. updatable?: boolean;
  136061. sideOrientation?: number;
  136062. frontUVs?: Vector4;
  136063. backUVs?: Vector4;
  136064. }, scene?: Nullable<Scene>): Mesh;
  136065. /**
  136066. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  136067. * * 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
  136068. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  136069. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  136070. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  136071. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  136072. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  136073. * * 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
  136074. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  136075. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  136076. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  136077. * @param name defines the name of the new line system
  136078. * @param options defines the options used to create the line system
  136079. * @param scene defines the hosting scene
  136080. * @returns a new line system mesh
  136081. */
  136082. static CreateLineSystem(name: string, options: {
  136083. lines: Vector3[][];
  136084. updatable?: boolean;
  136085. instance?: Nullable<LinesMesh>;
  136086. colors?: Nullable<Color4[][]>;
  136087. useVertexAlpha?: boolean;
  136088. }, scene: Nullable<Scene>): LinesMesh;
  136089. /**
  136090. * Creates a line mesh
  136091. * 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
  136092. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  136093. * * The parameter `points` is an array successive Vector3
  136094. * * 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
  136095. * * The optional parameter `colors` is an array of successive Color4, one per line point
  136096. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  136097. * * When updating an instance, remember that only point positions can change, not the number of points
  136098. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  136099. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  136100. * @param name defines the name of the new line system
  136101. * @param options defines the options used to create the line system
  136102. * @param scene defines the hosting scene
  136103. * @returns a new line mesh
  136104. */
  136105. static CreateLines(name: string, options: {
  136106. points: Vector3[];
  136107. updatable?: boolean;
  136108. instance?: Nullable<LinesMesh>;
  136109. colors?: Color4[];
  136110. useVertexAlpha?: boolean;
  136111. }, scene?: Nullable<Scene>): LinesMesh;
  136112. /**
  136113. * Creates a dashed line mesh
  136114. * * 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
  136115. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  136116. * * The parameter `points` is an array successive Vector3
  136117. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  136118. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  136119. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  136120. * * 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
  136121. * * When updating an instance, remember that only point positions can change, not the number of points
  136122. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  136123. * @param name defines the name of the mesh
  136124. * @param options defines the options used to create the mesh
  136125. * @param scene defines the hosting scene
  136126. * @returns the dashed line mesh
  136127. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  136128. */
  136129. static CreateDashedLines(name: string, options: {
  136130. points: Vector3[];
  136131. dashSize?: number;
  136132. gapSize?: number;
  136133. dashNb?: number;
  136134. updatable?: boolean;
  136135. instance?: LinesMesh;
  136136. }, scene?: Nullable<Scene>): LinesMesh;
  136137. /**
  136138. * 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.
  136139. * * 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.
  136140. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  136141. * * 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.
  136142. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  136143. * * 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
  136144. * * 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
  136145. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  136146. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  136147. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  136148. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  136149. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  136150. * @param name defines the name of the mesh
  136151. * @param options defines the options used to create the mesh
  136152. * @param scene defines the hosting scene
  136153. * @returns the extruded shape mesh
  136154. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  136155. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  136156. */
  136157. static ExtrudeShape(name: string, options: {
  136158. shape: Vector3[];
  136159. path: Vector3[];
  136160. scale?: number;
  136161. rotation?: number;
  136162. cap?: number;
  136163. updatable?: boolean;
  136164. sideOrientation?: number;
  136165. frontUVs?: Vector4;
  136166. backUVs?: Vector4;
  136167. instance?: Mesh;
  136168. invertUV?: boolean;
  136169. }, scene?: Nullable<Scene>): Mesh;
  136170. /**
  136171. * Creates an custom extruded shape mesh.
  136172. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  136173. * * 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.
  136174. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  136175. * * 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
  136176. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  136177. * * 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
  136178. * * It must returns a float value that will be the scale value applied to the shape on each path point
  136179. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  136180. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  136181. * * 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
  136182. * * 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
  136183. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  136184. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  136185. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  136186. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  136187. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  136188. * @param name defines the name of the mesh
  136189. * @param options defines the options used to create the mesh
  136190. * @param scene defines the hosting scene
  136191. * @returns the custom extruded shape mesh
  136192. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  136193. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  136194. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  136195. */
  136196. static ExtrudeShapeCustom(name: string, options: {
  136197. shape: Vector3[];
  136198. path: Vector3[];
  136199. scaleFunction?: any;
  136200. rotationFunction?: any;
  136201. ribbonCloseArray?: boolean;
  136202. ribbonClosePath?: boolean;
  136203. cap?: number;
  136204. updatable?: boolean;
  136205. sideOrientation?: number;
  136206. frontUVs?: Vector4;
  136207. backUVs?: Vector4;
  136208. instance?: Mesh;
  136209. invertUV?: boolean;
  136210. }, scene?: Nullable<Scene>): Mesh;
  136211. /**
  136212. * Creates lathe mesh.
  136213. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  136214. * * 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
  136215. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  136216. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  136217. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  136218. * * 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
  136219. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  136220. * * 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
  136221. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  136222. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  136223. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  136224. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  136225. * @param name defines the name of the mesh
  136226. * @param options defines the options used to create the mesh
  136227. * @param scene defines the hosting scene
  136228. * @returns the lathe mesh
  136229. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  136230. */
  136231. static CreateLathe(name: string, options: {
  136232. shape: Vector3[];
  136233. radius?: number;
  136234. tessellation?: number;
  136235. clip?: number;
  136236. arc?: number;
  136237. closed?: boolean;
  136238. updatable?: boolean;
  136239. sideOrientation?: number;
  136240. frontUVs?: Vector4;
  136241. backUVs?: Vector4;
  136242. cap?: number;
  136243. invertUV?: boolean;
  136244. }, scene?: Nullable<Scene>): Mesh;
  136245. /**
  136246. * Creates a tiled plane mesh
  136247. * * You can set a limited pattern arrangement with the tiles
  136248. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  136249. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  136250. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  136251. * @param name defines the name of the mesh
  136252. * @param options defines the options used to create the mesh
  136253. * @param scene defines the hosting scene
  136254. * @returns the plane mesh
  136255. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  136256. */
  136257. static CreateTiledPlane(name: string, options: {
  136258. pattern?: number;
  136259. tileSize?: number;
  136260. tileWidth?: number;
  136261. tileHeight?: number;
  136262. size?: number;
  136263. width?: number;
  136264. height?: number;
  136265. alignHorizontal?: number;
  136266. alignVertical?: number;
  136267. sideOrientation?: number;
  136268. frontUVs?: Vector4;
  136269. backUVs?: Vector4;
  136270. updatable?: boolean;
  136271. }, scene?: Nullable<Scene>): Mesh;
  136272. /**
  136273. * Creates a plane mesh
  136274. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  136275. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  136276. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  136277. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  136278. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  136279. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  136280. * @param name defines the name of the mesh
  136281. * @param options defines the options used to create the mesh
  136282. * @param scene defines the hosting scene
  136283. * @returns the plane mesh
  136284. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  136285. */
  136286. static CreatePlane(name: string, options: {
  136287. size?: number;
  136288. width?: number;
  136289. height?: number;
  136290. sideOrientation?: number;
  136291. frontUVs?: Vector4;
  136292. backUVs?: Vector4;
  136293. updatable?: boolean;
  136294. sourcePlane?: Plane;
  136295. }, scene?: Nullable<Scene>): Mesh;
  136296. /**
  136297. * Creates a ground mesh
  136298. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  136299. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  136300. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  136301. * @param name defines the name of the mesh
  136302. * @param options defines the options used to create the mesh
  136303. * @param scene defines the hosting scene
  136304. * @returns the ground mesh
  136305. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  136306. */
  136307. static CreateGround(name: string, options: {
  136308. width?: number;
  136309. height?: number;
  136310. subdivisions?: number;
  136311. subdivisionsX?: number;
  136312. subdivisionsY?: number;
  136313. updatable?: boolean;
  136314. }, scene?: Nullable<Scene>): Mesh;
  136315. /**
  136316. * Creates a tiled ground mesh
  136317. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  136318. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  136319. * * 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
  136320. * * 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
  136321. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  136322. * @param name defines the name of the mesh
  136323. * @param options defines the options used to create the mesh
  136324. * @param scene defines the hosting scene
  136325. * @returns the tiled ground mesh
  136326. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  136327. */
  136328. static CreateTiledGround(name: string, options: {
  136329. xmin: number;
  136330. zmin: number;
  136331. xmax: number;
  136332. zmax: number;
  136333. subdivisions?: {
  136334. w: number;
  136335. h: number;
  136336. };
  136337. precision?: {
  136338. w: number;
  136339. h: number;
  136340. };
  136341. updatable?: boolean;
  136342. }, scene?: Nullable<Scene>): Mesh;
  136343. /**
  136344. * Creates a ground mesh from a height map
  136345. * * The parameter `url` sets the URL of the height map image resource.
  136346. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  136347. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  136348. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  136349. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  136350. * * 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.
  136351. * * 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).
  136352. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  136353. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  136354. * @param name defines the name of the mesh
  136355. * @param url defines the url to the height map
  136356. * @param options defines the options used to create the mesh
  136357. * @param scene defines the hosting scene
  136358. * @returns the ground mesh
  136359. * @see https://doc.babylonjs.com/babylon101/height_map
  136360. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  136361. */
  136362. static CreateGroundFromHeightMap(name: string, url: string, options: {
  136363. width?: number;
  136364. height?: number;
  136365. subdivisions?: number;
  136366. minHeight?: number;
  136367. maxHeight?: number;
  136368. colorFilter?: Color3;
  136369. alphaFilter?: number;
  136370. updatable?: boolean;
  136371. onReady?: (mesh: GroundMesh) => void;
  136372. }, scene?: Nullable<Scene>): GroundMesh;
  136373. /**
  136374. * Creates a polygon mesh
  136375. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  136376. * * 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
  136377. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  136378. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  136379. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  136380. * * Remember you can only change the shape positions, not their number when updating a polygon
  136381. * @param name defines the name of the mesh
  136382. * @param options defines the options used to create the mesh
  136383. * @param scene defines the hosting scene
  136384. * @param earcutInjection can be used to inject your own earcut reference
  136385. * @returns the polygon mesh
  136386. */
  136387. static CreatePolygon(name: string, options: {
  136388. shape: Vector3[];
  136389. holes?: Vector3[][];
  136390. depth?: number;
  136391. faceUV?: Vector4[];
  136392. faceColors?: Color4[];
  136393. updatable?: boolean;
  136394. sideOrientation?: number;
  136395. frontUVs?: Vector4;
  136396. backUVs?: Vector4;
  136397. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  136398. /**
  136399. * Creates an extruded polygon mesh, with depth in the Y direction.
  136400. * * 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)
  136401. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  136402. * @param name defines the name of the mesh
  136403. * @param options defines the options used to create the mesh
  136404. * @param scene defines the hosting scene
  136405. * @param earcutInjection can be used to inject your own earcut reference
  136406. * @returns the polygon mesh
  136407. */
  136408. static ExtrudePolygon(name: string, options: {
  136409. shape: Vector3[];
  136410. holes?: Vector3[][];
  136411. depth?: number;
  136412. faceUV?: Vector4[];
  136413. faceColors?: Color4[];
  136414. updatable?: boolean;
  136415. sideOrientation?: number;
  136416. frontUVs?: Vector4;
  136417. backUVs?: Vector4;
  136418. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  136419. /**
  136420. * Creates a tube mesh.
  136421. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  136422. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  136423. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  136424. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  136425. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  136426. * * 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)
  136427. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  136428. * * 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
  136429. * * 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
  136430. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  136431. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  136432. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  136433. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  136434. * @param name defines the name of the mesh
  136435. * @param options defines the options used to create the mesh
  136436. * @param scene defines the hosting scene
  136437. * @returns the tube mesh
  136438. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  136439. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  136440. */
  136441. static CreateTube(name: string, options: {
  136442. path: Vector3[];
  136443. radius?: number;
  136444. tessellation?: number;
  136445. radiusFunction?: {
  136446. (i: number, distance: number): number;
  136447. };
  136448. cap?: number;
  136449. arc?: number;
  136450. updatable?: boolean;
  136451. sideOrientation?: number;
  136452. frontUVs?: Vector4;
  136453. backUVs?: Vector4;
  136454. instance?: Mesh;
  136455. invertUV?: boolean;
  136456. }, scene?: Nullable<Scene>): Mesh;
  136457. /**
  136458. * Creates a polyhedron mesh
  136459. * * 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
  136460. * * The parameter `size` (positive float, default 1) sets the polygon size
  136461. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  136462. * * 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`
  136463. * * 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
  136464. * * 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)`)
  136465. * * 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
  136466. * * 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
  136467. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  136468. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  136469. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  136470. * @param name defines the name of the mesh
  136471. * @param options defines the options used to create the mesh
  136472. * @param scene defines the hosting scene
  136473. * @returns the polyhedron mesh
  136474. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  136475. */
  136476. static CreatePolyhedron(name: string, options: {
  136477. type?: number;
  136478. size?: number;
  136479. sizeX?: number;
  136480. sizeY?: number;
  136481. sizeZ?: number;
  136482. custom?: any;
  136483. faceUV?: Vector4[];
  136484. faceColors?: Color4[];
  136485. flat?: boolean;
  136486. updatable?: boolean;
  136487. sideOrientation?: number;
  136488. frontUVs?: Vector4;
  136489. backUVs?: Vector4;
  136490. }, scene?: Nullable<Scene>): Mesh;
  136491. /**
  136492. * Creates a decal mesh.
  136493. * 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
  136494. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  136495. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  136496. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  136497. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  136498. * @param name defines the name of the mesh
  136499. * @param sourceMesh defines the mesh where the decal must be applied
  136500. * @param options defines the options used to create the mesh
  136501. * @param scene defines the hosting scene
  136502. * @returns the decal mesh
  136503. * @see https://doc.babylonjs.com/how_to/decals
  136504. */
  136505. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  136506. position?: Vector3;
  136507. normal?: Vector3;
  136508. size?: Vector3;
  136509. angle?: number;
  136510. }): Mesh;
  136511. }
  136512. }
  136513. declare module BABYLON {
  136514. /**
  136515. * A simplifier interface for future simplification implementations
  136516. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  136517. */
  136518. export interface ISimplifier {
  136519. /**
  136520. * Simplification of a given mesh according to the given settings.
  136521. * Since this requires computation, it is assumed that the function runs async.
  136522. * @param settings The settings of the simplification, including quality and distance
  136523. * @param successCallback A callback that will be called after the mesh was simplified.
  136524. * @param errorCallback in case of an error, this callback will be called. optional.
  136525. */
  136526. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  136527. }
  136528. /**
  136529. * Expected simplification settings.
  136530. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  136531. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  136532. */
  136533. export interface ISimplificationSettings {
  136534. /**
  136535. * Gets or sets the expected quality
  136536. */
  136537. quality: number;
  136538. /**
  136539. * Gets or sets the distance when this optimized version should be used
  136540. */
  136541. distance: number;
  136542. /**
  136543. * Gets an already optimized mesh
  136544. */
  136545. optimizeMesh?: boolean;
  136546. }
  136547. /**
  136548. * Class used to specify simplification options
  136549. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  136550. */
  136551. export class SimplificationSettings implements ISimplificationSettings {
  136552. /** expected quality */
  136553. quality: number;
  136554. /** distance when this optimized version should be used */
  136555. distance: number;
  136556. /** already optimized mesh */
  136557. optimizeMesh?: boolean | undefined;
  136558. /**
  136559. * Creates a SimplificationSettings
  136560. * @param quality expected quality
  136561. * @param distance distance when this optimized version should be used
  136562. * @param optimizeMesh already optimized mesh
  136563. */
  136564. constructor(
  136565. /** expected quality */
  136566. quality: number,
  136567. /** distance when this optimized version should be used */
  136568. distance: number,
  136569. /** already optimized mesh */
  136570. optimizeMesh?: boolean | undefined);
  136571. }
  136572. /**
  136573. * Interface used to define a simplification task
  136574. */
  136575. export interface ISimplificationTask {
  136576. /**
  136577. * Array of settings
  136578. */
  136579. settings: Array<ISimplificationSettings>;
  136580. /**
  136581. * Simplification type
  136582. */
  136583. simplificationType: SimplificationType;
  136584. /**
  136585. * Mesh to simplify
  136586. */
  136587. mesh: Mesh;
  136588. /**
  136589. * Callback called on success
  136590. */
  136591. successCallback?: () => void;
  136592. /**
  136593. * Defines if parallel processing can be used
  136594. */
  136595. parallelProcessing: boolean;
  136596. }
  136597. /**
  136598. * Queue used to order the simplification tasks
  136599. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  136600. */
  136601. export class SimplificationQueue {
  136602. private _simplificationArray;
  136603. /**
  136604. * Gets a boolean indicating that the process is still running
  136605. */
  136606. running: boolean;
  136607. /**
  136608. * Creates a new queue
  136609. */
  136610. constructor();
  136611. /**
  136612. * Adds a new simplification task
  136613. * @param task defines a task to add
  136614. */
  136615. addTask(task: ISimplificationTask): void;
  136616. /**
  136617. * Execute next task
  136618. */
  136619. executeNext(): void;
  136620. /**
  136621. * Execute a simplification task
  136622. * @param task defines the task to run
  136623. */
  136624. runSimplification(task: ISimplificationTask): void;
  136625. private getSimplifier;
  136626. }
  136627. /**
  136628. * The implemented types of simplification
  136629. * At the moment only Quadratic Error Decimation is implemented
  136630. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  136631. */
  136632. export enum SimplificationType {
  136633. /** Quadratic error decimation */
  136634. QUADRATIC = 0
  136635. }
  136636. /**
  136637. * An implementation of the Quadratic Error simplification algorithm.
  136638. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  136639. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  136640. * @author RaananW
  136641. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  136642. */
  136643. export class QuadraticErrorSimplification implements ISimplifier {
  136644. private _mesh;
  136645. private triangles;
  136646. private vertices;
  136647. private references;
  136648. private _reconstructedMesh;
  136649. /** Gets or sets the number pf sync interations */
  136650. syncIterations: number;
  136651. /** Gets or sets the aggressiveness of the simplifier */
  136652. aggressiveness: number;
  136653. /** Gets or sets the number of allowed iterations for decimation */
  136654. decimationIterations: number;
  136655. /** Gets or sets the espilon to use for bounding box computation */
  136656. boundingBoxEpsilon: number;
  136657. /**
  136658. * Creates a new QuadraticErrorSimplification
  136659. * @param _mesh defines the target mesh
  136660. */
  136661. constructor(_mesh: Mesh);
  136662. /**
  136663. * Simplification of a given mesh according to the given settings.
  136664. * Since this requires computation, it is assumed that the function runs async.
  136665. * @param settings The settings of the simplification, including quality and distance
  136666. * @param successCallback A callback that will be called after the mesh was simplified.
  136667. */
  136668. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  136669. private runDecimation;
  136670. private initWithMesh;
  136671. private init;
  136672. private reconstructMesh;
  136673. private initDecimatedMesh;
  136674. private isFlipped;
  136675. private updateTriangles;
  136676. private identifyBorder;
  136677. private updateMesh;
  136678. private vertexError;
  136679. private calculateError;
  136680. }
  136681. }
  136682. declare module BABYLON {
  136683. interface Scene {
  136684. /** @hidden (Backing field) */
  136685. _simplificationQueue: SimplificationQueue;
  136686. /**
  136687. * Gets or sets the simplification queue attached to the scene
  136688. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  136689. */
  136690. simplificationQueue: SimplificationQueue;
  136691. }
  136692. interface Mesh {
  136693. /**
  136694. * Simplify the mesh according to the given array of settings.
  136695. * Function will return immediately and will simplify async
  136696. * @param settings a collection of simplification settings
  136697. * @param parallelProcessing should all levels calculate parallel or one after the other
  136698. * @param simplificationType the type of simplification to run
  136699. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  136700. * @returns the current mesh
  136701. */
  136702. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  136703. }
  136704. /**
  136705. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  136706. * created in a scene
  136707. */
  136708. export class SimplicationQueueSceneComponent implements ISceneComponent {
  136709. /**
  136710. * The component name helpfull to identify the component in the list of scene components.
  136711. */
  136712. readonly name: string;
  136713. /**
  136714. * The scene the component belongs to.
  136715. */
  136716. scene: Scene;
  136717. /**
  136718. * Creates a new instance of the component for the given scene
  136719. * @param scene Defines the scene to register the component in
  136720. */
  136721. constructor(scene: Scene);
  136722. /**
  136723. * Registers the component in a given scene
  136724. */
  136725. register(): void;
  136726. /**
  136727. * Rebuilds the elements related to this component in case of
  136728. * context lost for instance.
  136729. */
  136730. rebuild(): void;
  136731. /**
  136732. * Disposes the component and the associated ressources
  136733. */
  136734. dispose(): void;
  136735. private _beforeCameraUpdate;
  136736. }
  136737. }
  136738. declare module BABYLON {
  136739. /**
  136740. * Navigation plugin interface to add navigation constrained by a navigation mesh
  136741. */
  136742. export interface INavigationEnginePlugin {
  136743. /**
  136744. * plugin name
  136745. */
  136746. name: string;
  136747. /**
  136748. * Creates a navigation mesh
  136749. * @param meshes array of all the geometry used to compute the navigatio mesh
  136750. * @param parameters bunch of parameters used to filter geometry
  136751. */
  136752. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  136753. /**
  136754. * Create a navigation mesh debug mesh
  136755. * @param scene is where the mesh will be added
  136756. * @returns debug display mesh
  136757. */
  136758. createDebugNavMesh(scene: Scene): Mesh;
  136759. /**
  136760. * Get a navigation mesh constrained position, closest to the parameter position
  136761. * @param position world position
  136762. * @returns the closest point to position constrained by the navigation mesh
  136763. */
  136764. getClosestPoint(position: Vector3): Vector3;
  136765. /**
  136766. * Get a navigation mesh constrained position, closest to the parameter position
  136767. * @param position world position
  136768. * @param result output the closest point to position constrained by the navigation mesh
  136769. */
  136770. getClosestPointToRef(position: Vector3, result: Vector3): void;
  136771. /**
  136772. * Get a navigation mesh constrained position, within a particular radius
  136773. * @param position world position
  136774. * @param maxRadius the maximum distance to the constrained world position
  136775. * @returns the closest point to position constrained by the navigation mesh
  136776. */
  136777. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  136778. /**
  136779. * Get a navigation mesh constrained position, within a particular radius
  136780. * @param position world position
  136781. * @param maxRadius the maximum distance to the constrained world position
  136782. * @param result output the closest point to position constrained by the navigation mesh
  136783. */
  136784. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  136785. /**
  136786. * Compute the final position from a segment made of destination-position
  136787. * @param position world position
  136788. * @param destination world position
  136789. * @returns the resulting point along the navmesh
  136790. */
  136791. moveAlong(position: Vector3, destination: Vector3): Vector3;
  136792. /**
  136793. * Compute the final position from a segment made of destination-position
  136794. * @param position world position
  136795. * @param destination world position
  136796. * @param result output the resulting point along the navmesh
  136797. */
  136798. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  136799. /**
  136800. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  136801. * @param start world position
  136802. * @param end world position
  136803. * @returns array containing world position composing the path
  136804. */
  136805. computePath(start: Vector3, end: Vector3): Vector3[];
  136806. /**
  136807. * If this plugin is supported
  136808. * @returns true if plugin is supported
  136809. */
  136810. isSupported(): boolean;
  136811. /**
  136812. * Create a new Crowd so you can add agents
  136813. * @param maxAgents the maximum agent count in the crowd
  136814. * @param maxAgentRadius the maximum radius an agent can have
  136815. * @param scene to attach the crowd to
  136816. * @returns the crowd you can add agents to
  136817. */
  136818. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  136819. /**
  136820. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  136821. * The queries will try to find a solution within those bounds
  136822. * default is (1,1,1)
  136823. * @param extent x,y,z value that define the extent around the queries point of reference
  136824. */
  136825. setDefaultQueryExtent(extent: Vector3): void;
  136826. /**
  136827. * Get the Bounding box extent specified by setDefaultQueryExtent
  136828. * @returns the box extent values
  136829. */
  136830. getDefaultQueryExtent(): Vector3;
  136831. /**
  136832. * build the navmesh from a previously saved state using getNavmeshData
  136833. * @param data the Uint8Array returned by getNavmeshData
  136834. */
  136835. buildFromNavmeshData(data: Uint8Array): void;
  136836. /**
  136837. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  136838. * @returns data the Uint8Array that can be saved and reused
  136839. */
  136840. getNavmeshData(): Uint8Array;
  136841. /**
  136842. * Get the Bounding box extent result specified by setDefaultQueryExtent
  136843. * @param result output the box extent values
  136844. */
  136845. getDefaultQueryExtentToRef(result: Vector3): void;
  136846. /**
  136847. * Release all resources
  136848. */
  136849. dispose(): void;
  136850. }
  136851. /**
  136852. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  136853. */
  136854. export interface ICrowd {
  136855. /**
  136856. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  136857. * You can attach anything to that node. The node position is updated in the scene update tick.
  136858. * @param pos world position that will be constrained by the navigation mesh
  136859. * @param parameters agent parameters
  136860. * @param transform hooked to the agent that will be update by the scene
  136861. * @returns agent index
  136862. */
  136863. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  136864. /**
  136865. * Returns the agent position in world space
  136866. * @param index agent index returned by addAgent
  136867. * @returns world space position
  136868. */
  136869. getAgentPosition(index: number): Vector3;
  136870. /**
  136871. * Gets the agent position result in world space
  136872. * @param index agent index returned by addAgent
  136873. * @param result output world space position
  136874. */
  136875. getAgentPositionToRef(index: number, result: Vector3): void;
  136876. /**
  136877. * Gets the agent velocity in world space
  136878. * @param index agent index returned by addAgent
  136879. * @returns world space velocity
  136880. */
  136881. getAgentVelocity(index: number): Vector3;
  136882. /**
  136883. * Gets the agent velocity result in world space
  136884. * @param index agent index returned by addAgent
  136885. * @param result output world space velocity
  136886. */
  136887. getAgentVelocityToRef(index: number, result: Vector3): void;
  136888. /**
  136889. * remove a particular agent previously created
  136890. * @param index agent index returned by addAgent
  136891. */
  136892. removeAgent(index: number): void;
  136893. /**
  136894. * get the list of all agents attached to this crowd
  136895. * @returns list of agent indices
  136896. */
  136897. getAgents(): number[];
  136898. /**
  136899. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  136900. * @param deltaTime in seconds
  136901. */
  136902. update(deltaTime: number): void;
  136903. /**
  136904. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  136905. * @param index agent index returned by addAgent
  136906. * @param destination targeted world position
  136907. */
  136908. agentGoto(index: number, destination: Vector3): void;
  136909. /**
  136910. * Teleport the agent to a new position
  136911. * @param index agent index returned by addAgent
  136912. * @param destination targeted world position
  136913. */
  136914. agentTeleport(index: number, destination: Vector3): void;
  136915. /**
  136916. * Update agent parameters
  136917. * @param index agent index returned by addAgent
  136918. * @param parameters agent parameters
  136919. */
  136920. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  136921. /**
  136922. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  136923. * The queries will try to find a solution within those bounds
  136924. * default is (1,1,1)
  136925. * @param extent x,y,z value that define the extent around the queries point of reference
  136926. */
  136927. setDefaultQueryExtent(extent: Vector3): void;
  136928. /**
  136929. * Get the Bounding box extent specified by setDefaultQueryExtent
  136930. * @returns the box extent values
  136931. */
  136932. getDefaultQueryExtent(): Vector3;
  136933. /**
  136934. * Get the Bounding box extent result specified by setDefaultQueryExtent
  136935. * @param result output the box extent values
  136936. */
  136937. getDefaultQueryExtentToRef(result: Vector3): void;
  136938. /**
  136939. * Release all resources
  136940. */
  136941. dispose(): void;
  136942. }
  136943. /**
  136944. * Configures an agent
  136945. */
  136946. export interface IAgentParameters {
  136947. /**
  136948. * Agent radius. [Limit: >= 0]
  136949. */
  136950. radius: number;
  136951. /**
  136952. * Agent height. [Limit: > 0]
  136953. */
  136954. height: number;
  136955. /**
  136956. * Maximum allowed acceleration. [Limit: >= 0]
  136957. */
  136958. maxAcceleration: number;
  136959. /**
  136960. * Maximum allowed speed. [Limit: >= 0]
  136961. */
  136962. maxSpeed: number;
  136963. /**
  136964. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  136965. */
  136966. collisionQueryRange: number;
  136967. /**
  136968. * The path visibility optimization range. [Limit: > 0]
  136969. */
  136970. pathOptimizationRange: number;
  136971. /**
  136972. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  136973. */
  136974. separationWeight: number;
  136975. }
  136976. /**
  136977. * Configures the navigation mesh creation
  136978. */
  136979. export interface INavMeshParameters {
  136980. /**
  136981. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  136982. */
  136983. cs: number;
  136984. /**
  136985. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  136986. */
  136987. ch: number;
  136988. /**
  136989. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  136990. */
  136991. walkableSlopeAngle: number;
  136992. /**
  136993. * Minimum floor to 'ceiling' height that will still allow the floor area to
  136994. * be considered walkable. [Limit: >= 3] [Units: vx]
  136995. */
  136996. walkableHeight: number;
  136997. /**
  136998. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  136999. */
  137000. walkableClimb: number;
  137001. /**
  137002. * The distance to erode/shrink the walkable area of the heightfield away from
  137003. * obstructions. [Limit: >=0] [Units: vx]
  137004. */
  137005. walkableRadius: number;
  137006. /**
  137007. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  137008. */
  137009. maxEdgeLen: number;
  137010. /**
  137011. * The maximum distance a simplfied contour's border edges should deviate
  137012. * the original raw contour. [Limit: >=0] [Units: vx]
  137013. */
  137014. maxSimplificationError: number;
  137015. /**
  137016. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  137017. */
  137018. minRegionArea: number;
  137019. /**
  137020. * Any regions with a span count smaller than this value will, if possible,
  137021. * be merged with larger regions. [Limit: >=0] [Units: vx]
  137022. */
  137023. mergeRegionArea: number;
  137024. /**
  137025. * The maximum number of vertices allowed for polygons generated during the
  137026. * contour to polygon conversion process. [Limit: >= 3]
  137027. */
  137028. maxVertsPerPoly: number;
  137029. /**
  137030. * Sets the sampling distance to use when generating the detail mesh.
  137031. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  137032. */
  137033. detailSampleDist: number;
  137034. /**
  137035. * The maximum distance the detail mesh surface should deviate from heightfield
  137036. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  137037. */
  137038. detailSampleMaxError: number;
  137039. }
  137040. }
  137041. declare module BABYLON {
  137042. /**
  137043. * RecastJS navigation plugin
  137044. */
  137045. export class RecastJSPlugin implements INavigationEnginePlugin {
  137046. /**
  137047. * Reference to the Recast library
  137048. */
  137049. bjsRECAST: any;
  137050. /**
  137051. * plugin name
  137052. */
  137053. name: string;
  137054. /**
  137055. * the first navmesh created. We might extend this to support multiple navmeshes
  137056. */
  137057. navMesh: any;
  137058. /**
  137059. * Initializes the recastJS plugin
  137060. * @param recastInjection can be used to inject your own recast reference
  137061. */
  137062. constructor(recastInjection?: any);
  137063. /**
  137064. * Creates a navigation mesh
  137065. * @param meshes array of all the geometry used to compute the navigatio mesh
  137066. * @param parameters bunch of parameters used to filter geometry
  137067. */
  137068. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  137069. /**
  137070. * Create a navigation mesh debug mesh
  137071. * @param scene is where the mesh will be added
  137072. * @returns debug display mesh
  137073. */
  137074. createDebugNavMesh(scene: Scene): Mesh;
  137075. /**
  137076. * Get a navigation mesh constrained position, closest to the parameter position
  137077. * @param position world position
  137078. * @returns the closest point to position constrained by the navigation mesh
  137079. */
  137080. getClosestPoint(position: Vector3): Vector3;
  137081. /**
  137082. * Get a navigation mesh constrained position, closest to the parameter position
  137083. * @param position world position
  137084. * @param result output the closest point to position constrained by the navigation mesh
  137085. */
  137086. getClosestPointToRef(position: Vector3, result: Vector3): void;
  137087. /**
  137088. * Get a navigation mesh constrained position, within a particular radius
  137089. * @param position world position
  137090. * @param maxRadius the maximum distance to the constrained world position
  137091. * @returns the closest point to position constrained by the navigation mesh
  137092. */
  137093. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  137094. /**
  137095. * Get a navigation mesh constrained position, within a particular radius
  137096. * @param position world position
  137097. * @param maxRadius the maximum distance to the constrained world position
  137098. * @param result output the closest point to position constrained by the navigation mesh
  137099. */
  137100. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  137101. /**
  137102. * Compute the final position from a segment made of destination-position
  137103. * @param position world position
  137104. * @param destination world position
  137105. * @returns the resulting point along the navmesh
  137106. */
  137107. moveAlong(position: Vector3, destination: Vector3): Vector3;
  137108. /**
  137109. * Compute the final position from a segment made of destination-position
  137110. * @param position world position
  137111. * @param destination world position
  137112. * @param result output the resulting point along the navmesh
  137113. */
  137114. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  137115. /**
  137116. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  137117. * @param start world position
  137118. * @param end world position
  137119. * @returns array containing world position composing the path
  137120. */
  137121. computePath(start: Vector3, end: Vector3): Vector3[];
  137122. /**
  137123. * Create a new Crowd so you can add agents
  137124. * @param maxAgents the maximum agent count in the crowd
  137125. * @param maxAgentRadius the maximum radius an agent can have
  137126. * @param scene to attach the crowd to
  137127. * @returns the crowd you can add agents to
  137128. */
  137129. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  137130. /**
  137131. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  137132. * The queries will try to find a solution within those bounds
  137133. * default is (1,1,1)
  137134. * @param extent x,y,z value that define the extent around the queries point of reference
  137135. */
  137136. setDefaultQueryExtent(extent: Vector3): void;
  137137. /**
  137138. * Get the Bounding box extent specified by setDefaultQueryExtent
  137139. * @returns the box extent values
  137140. */
  137141. getDefaultQueryExtent(): Vector3;
  137142. /**
  137143. * build the navmesh from a previously saved state using getNavmeshData
  137144. * @param data the Uint8Array returned by getNavmeshData
  137145. */
  137146. buildFromNavmeshData(data: Uint8Array): void;
  137147. /**
  137148. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  137149. * @returns data the Uint8Array that can be saved and reused
  137150. */
  137151. getNavmeshData(): Uint8Array;
  137152. /**
  137153. * Get the Bounding box extent result specified by setDefaultQueryExtent
  137154. * @param result output the box extent values
  137155. */
  137156. getDefaultQueryExtentToRef(result: Vector3): void;
  137157. /**
  137158. * Disposes
  137159. */
  137160. dispose(): void;
  137161. /**
  137162. * If this plugin is supported
  137163. * @returns true if plugin is supported
  137164. */
  137165. isSupported(): boolean;
  137166. }
  137167. /**
  137168. * Recast detour crowd implementation
  137169. */
  137170. export class RecastJSCrowd implements ICrowd {
  137171. /**
  137172. * Recast/detour plugin
  137173. */
  137174. bjsRECASTPlugin: RecastJSPlugin;
  137175. /**
  137176. * Link to the detour crowd
  137177. */
  137178. recastCrowd: any;
  137179. /**
  137180. * One transform per agent
  137181. */
  137182. transforms: TransformNode[];
  137183. /**
  137184. * All agents created
  137185. */
  137186. agents: number[];
  137187. /**
  137188. * Link to the scene is kept to unregister the crowd from the scene
  137189. */
  137190. private _scene;
  137191. /**
  137192. * Observer for crowd updates
  137193. */
  137194. private _onBeforeAnimationsObserver;
  137195. /**
  137196. * Constructor
  137197. * @param plugin recastJS plugin
  137198. * @param maxAgents the maximum agent count in the crowd
  137199. * @param maxAgentRadius the maximum radius an agent can have
  137200. * @param scene to attach the crowd to
  137201. * @returns the crowd you can add agents to
  137202. */
  137203. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  137204. /**
  137205. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  137206. * You can attach anything to that node. The node position is updated in the scene update tick.
  137207. * @param pos world position that will be constrained by the navigation mesh
  137208. * @param parameters agent parameters
  137209. * @param transform hooked to the agent that will be update by the scene
  137210. * @returns agent index
  137211. */
  137212. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  137213. /**
  137214. * Returns the agent position in world space
  137215. * @param index agent index returned by addAgent
  137216. * @returns world space position
  137217. */
  137218. getAgentPosition(index: number): Vector3;
  137219. /**
  137220. * Returns the agent position result in world space
  137221. * @param index agent index returned by addAgent
  137222. * @param result output world space position
  137223. */
  137224. getAgentPositionToRef(index: number, result: Vector3): void;
  137225. /**
  137226. * Returns the agent velocity in world space
  137227. * @param index agent index returned by addAgent
  137228. * @returns world space velocity
  137229. */
  137230. getAgentVelocity(index: number): Vector3;
  137231. /**
  137232. * Returns the agent velocity result in world space
  137233. * @param index agent index returned by addAgent
  137234. * @param result output world space velocity
  137235. */
  137236. getAgentVelocityToRef(index: number, result: Vector3): void;
  137237. /**
  137238. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  137239. * @param index agent index returned by addAgent
  137240. * @param destination targeted world position
  137241. */
  137242. agentGoto(index: number, destination: Vector3): void;
  137243. /**
  137244. * Teleport the agent to a new position
  137245. * @param index agent index returned by addAgent
  137246. * @param destination targeted world position
  137247. */
  137248. agentTeleport(index: number, destination: Vector3): void;
  137249. /**
  137250. * Update agent parameters
  137251. * @param index agent index returned by addAgent
  137252. * @param parameters agent parameters
  137253. */
  137254. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  137255. /**
  137256. * remove a particular agent previously created
  137257. * @param index agent index returned by addAgent
  137258. */
  137259. removeAgent(index: number): void;
  137260. /**
  137261. * get the list of all agents attached to this crowd
  137262. * @returns list of agent indices
  137263. */
  137264. getAgents(): number[];
  137265. /**
  137266. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  137267. * @param deltaTime in seconds
  137268. */
  137269. update(deltaTime: number): void;
  137270. /**
  137271. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  137272. * The queries will try to find a solution within those bounds
  137273. * default is (1,1,1)
  137274. * @param extent x,y,z value that define the extent around the queries point of reference
  137275. */
  137276. setDefaultQueryExtent(extent: Vector3): void;
  137277. /**
  137278. * Get the Bounding box extent specified by setDefaultQueryExtent
  137279. * @returns the box extent values
  137280. */
  137281. getDefaultQueryExtent(): Vector3;
  137282. /**
  137283. * Get the Bounding box extent result specified by setDefaultQueryExtent
  137284. * @param result output the box extent values
  137285. */
  137286. getDefaultQueryExtentToRef(result: Vector3): void;
  137287. /**
  137288. * Release all resources
  137289. */
  137290. dispose(): void;
  137291. }
  137292. }
  137293. declare module BABYLON {
  137294. /**
  137295. * Class used to enable access to IndexedDB
  137296. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  137297. */
  137298. export class Database implements IOfflineProvider {
  137299. private _callbackManifestChecked;
  137300. private _currentSceneUrl;
  137301. private _db;
  137302. private _enableSceneOffline;
  137303. private _enableTexturesOffline;
  137304. private _manifestVersionFound;
  137305. private _mustUpdateRessources;
  137306. private _hasReachedQuota;
  137307. private _isSupported;
  137308. private _idbFactory;
  137309. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  137310. private static IsUASupportingBlobStorage;
  137311. /**
  137312. * Gets a boolean indicating if Database storate is enabled (off by default)
  137313. */
  137314. static IDBStorageEnabled: boolean;
  137315. /**
  137316. * Gets a boolean indicating if scene must be saved in the database
  137317. */
  137318. get enableSceneOffline(): boolean;
  137319. /**
  137320. * Gets a boolean indicating if textures must be saved in the database
  137321. */
  137322. get enableTexturesOffline(): boolean;
  137323. /**
  137324. * Creates a new Database
  137325. * @param urlToScene defines the url to load the scene
  137326. * @param callbackManifestChecked defines the callback to use when manifest is checked
  137327. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  137328. */
  137329. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  137330. private static _ParseURL;
  137331. private static _ReturnFullUrlLocation;
  137332. private _checkManifestFile;
  137333. /**
  137334. * Open the database and make it available
  137335. * @param successCallback defines the callback to call on success
  137336. * @param errorCallback defines the callback to call on error
  137337. */
  137338. open(successCallback: () => void, errorCallback: () => void): void;
  137339. /**
  137340. * Loads an image from the database
  137341. * @param url defines the url to load from
  137342. * @param image defines the target DOM image
  137343. */
  137344. loadImage(url: string, image: HTMLImageElement): void;
  137345. private _loadImageFromDBAsync;
  137346. private _saveImageIntoDBAsync;
  137347. private _checkVersionFromDB;
  137348. private _loadVersionFromDBAsync;
  137349. private _saveVersionIntoDBAsync;
  137350. /**
  137351. * Loads a file from database
  137352. * @param url defines the URL to load from
  137353. * @param sceneLoaded defines a callback to call on success
  137354. * @param progressCallBack defines a callback to call when progress changed
  137355. * @param errorCallback defines a callback to call on error
  137356. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  137357. */
  137358. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  137359. private _loadFileAsync;
  137360. private _saveFileAsync;
  137361. /**
  137362. * Validates if xhr data is correct
  137363. * @param xhr defines the request to validate
  137364. * @param dataType defines the expected data type
  137365. * @returns true if data is correct
  137366. */
  137367. private static _ValidateXHRData;
  137368. }
  137369. }
  137370. declare module BABYLON {
  137371. /** @hidden */
  137372. export var gpuUpdateParticlesPixelShader: {
  137373. name: string;
  137374. shader: string;
  137375. };
  137376. }
  137377. declare module BABYLON {
  137378. /** @hidden */
  137379. export var gpuUpdateParticlesVertexShader: {
  137380. name: string;
  137381. shader: string;
  137382. };
  137383. }
  137384. declare module BABYLON {
  137385. /** @hidden */
  137386. export var clipPlaneFragmentDeclaration2: {
  137387. name: string;
  137388. shader: string;
  137389. };
  137390. }
  137391. declare module BABYLON {
  137392. /** @hidden */
  137393. export var gpuRenderParticlesPixelShader: {
  137394. name: string;
  137395. shader: string;
  137396. };
  137397. }
  137398. declare module BABYLON {
  137399. /** @hidden */
  137400. export var clipPlaneVertexDeclaration2: {
  137401. name: string;
  137402. shader: string;
  137403. };
  137404. }
  137405. declare module BABYLON {
  137406. /** @hidden */
  137407. export var gpuRenderParticlesVertexShader: {
  137408. name: string;
  137409. shader: string;
  137410. };
  137411. }
  137412. declare module BABYLON {
  137413. /**
  137414. * This represents a GPU particle system in Babylon
  137415. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  137416. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  137417. */
  137418. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  137419. /**
  137420. * The layer mask we are rendering the particles through.
  137421. */
  137422. layerMask: number;
  137423. private _capacity;
  137424. private _activeCount;
  137425. private _currentActiveCount;
  137426. private _accumulatedCount;
  137427. private _renderEffect;
  137428. private _updateEffect;
  137429. private _buffer0;
  137430. private _buffer1;
  137431. private _spriteBuffer;
  137432. private _updateVAO;
  137433. private _renderVAO;
  137434. private _targetIndex;
  137435. private _sourceBuffer;
  137436. private _targetBuffer;
  137437. private _engine;
  137438. private _currentRenderId;
  137439. private _started;
  137440. private _stopped;
  137441. private _timeDelta;
  137442. private _randomTexture;
  137443. private _randomTexture2;
  137444. private _attributesStrideSize;
  137445. private _updateEffectOptions;
  137446. private _randomTextureSize;
  137447. private _actualFrame;
  137448. private readonly _rawTextureWidth;
  137449. /**
  137450. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  137451. */
  137452. static get IsSupported(): boolean;
  137453. /**
  137454. * An event triggered when the system is disposed.
  137455. */
  137456. onDisposeObservable: Observable<GPUParticleSystem>;
  137457. /**
  137458. * Gets the maximum number of particles active at the same time.
  137459. * @returns The max number of active particles.
  137460. */
  137461. getCapacity(): number;
  137462. /**
  137463. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  137464. * to override the particles.
  137465. */
  137466. forceDepthWrite: boolean;
  137467. /**
  137468. * Gets or set the number of active particles
  137469. */
  137470. get activeParticleCount(): number;
  137471. set activeParticleCount(value: number);
  137472. private _preWarmDone;
  137473. /**
  137474. * Specifies if the particles are updated in emitter local space or world space.
  137475. * This is always false for GPU particles
  137476. */
  137477. get isLocal(): boolean;
  137478. set isLocal(value: boolean);
  137479. /**
  137480. * Is this system ready to be used/rendered
  137481. * @return true if the system is ready
  137482. */
  137483. isReady(): boolean;
  137484. /**
  137485. * Gets if the system has been started. (Note: this will still be true after stop is called)
  137486. * @returns True if it has been started, otherwise false.
  137487. */
  137488. isStarted(): boolean;
  137489. /**
  137490. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  137491. * @returns True if it has been stopped, otherwise false.
  137492. */
  137493. isStopped(): boolean;
  137494. /**
  137495. * Gets a boolean indicating that the system is stopping
  137496. * @returns true if the system is currently stopping
  137497. */
  137498. isStopping(): boolean;
  137499. /**
  137500. * Gets the number of particles active at the same time.
  137501. * @returns The number of active particles.
  137502. */
  137503. getActiveCount(): number;
  137504. /**
  137505. * Starts the particle system and begins to emit
  137506. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  137507. */
  137508. start(delay?: number): void;
  137509. /**
  137510. * Stops the particle system.
  137511. */
  137512. stop(): void;
  137513. /**
  137514. * Remove all active particles
  137515. */
  137516. reset(): void;
  137517. /**
  137518. * Returns the string "GPUParticleSystem"
  137519. * @returns a string containing the class name
  137520. */
  137521. getClassName(): string;
  137522. private _colorGradientsTexture;
  137523. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  137524. /**
  137525. * Adds a new color gradient
  137526. * @param gradient defines the gradient to use (between 0 and 1)
  137527. * @param color1 defines the color to affect to the specified gradient
  137528. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  137529. * @returns the current particle system
  137530. */
  137531. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  137532. private _refreshColorGradient;
  137533. /** Force the system to rebuild all gradients that need to be resync */
  137534. forceRefreshGradients(): void;
  137535. /**
  137536. * Remove a specific color gradient
  137537. * @param gradient defines the gradient to remove
  137538. * @returns the current particle system
  137539. */
  137540. removeColorGradient(gradient: number): GPUParticleSystem;
  137541. private _angularSpeedGradientsTexture;
  137542. private _sizeGradientsTexture;
  137543. private _velocityGradientsTexture;
  137544. private _limitVelocityGradientsTexture;
  137545. private _dragGradientsTexture;
  137546. private _addFactorGradient;
  137547. /**
  137548. * Adds a new size gradient
  137549. * @param gradient defines the gradient to use (between 0 and 1)
  137550. * @param factor defines the size factor to affect to the specified gradient
  137551. * @returns the current particle system
  137552. */
  137553. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  137554. /**
  137555. * Remove a specific size gradient
  137556. * @param gradient defines the gradient to remove
  137557. * @returns the current particle system
  137558. */
  137559. removeSizeGradient(gradient: number): GPUParticleSystem;
  137560. private _refreshFactorGradient;
  137561. /**
  137562. * Adds a new angular speed gradient
  137563. * @param gradient defines the gradient to use (between 0 and 1)
  137564. * @param factor defines the angular speed to affect to the specified gradient
  137565. * @returns the current particle system
  137566. */
  137567. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  137568. /**
  137569. * Remove a specific angular speed gradient
  137570. * @param gradient defines the gradient to remove
  137571. * @returns the current particle system
  137572. */
  137573. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  137574. /**
  137575. * Adds a new velocity gradient
  137576. * @param gradient defines the gradient to use (between 0 and 1)
  137577. * @param factor defines the velocity to affect to the specified gradient
  137578. * @returns the current particle system
  137579. */
  137580. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  137581. /**
  137582. * Remove a specific velocity gradient
  137583. * @param gradient defines the gradient to remove
  137584. * @returns the current particle system
  137585. */
  137586. removeVelocityGradient(gradient: number): GPUParticleSystem;
  137587. /**
  137588. * Adds a new limit velocity gradient
  137589. * @param gradient defines the gradient to use (between 0 and 1)
  137590. * @param factor defines the limit velocity value to affect to the specified gradient
  137591. * @returns the current particle system
  137592. */
  137593. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  137594. /**
  137595. * Remove a specific limit velocity gradient
  137596. * @param gradient defines the gradient to remove
  137597. * @returns the current particle system
  137598. */
  137599. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  137600. /**
  137601. * Adds a new drag gradient
  137602. * @param gradient defines the gradient to use (between 0 and 1)
  137603. * @param factor defines the drag value to affect to the specified gradient
  137604. * @returns the current particle system
  137605. */
  137606. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  137607. /**
  137608. * Remove a specific drag gradient
  137609. * @param gradient defines the gradient to remove
  137610. * @returns the current particle system
  137611. */
  137612. removeDragGradient(gradient: number): GPUParticleSystem;
  137613. /**
  137614. * Not supported by GPUParticleSystem
  137615. * @param gradient defines the gradient to use (between 0 and 1)
  137616. * @param factor defines the emit rate value to affect to the specified gradient
  137617. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  137618. * @returns the current particle system
  137619. */
  137620. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  137621. /**
  137622. * Not supported by GPUParticleSystem
  137623. * @param gradient defines the gradient to remove
  137624. * @returns the current particle system
  137625. */
  137626. removeEmitRateGradient(gradient: number): IParticleSystem;
  137627. /**
  137628. * Not supported by GPUParticleSystem
  137629. * @param gradient defines the gradient to use (between 0 and 1)
  137630. * @param factor defines the start size value to affect to the specified gradient
  137631. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  137632. * @returns the current particle system
  137633. */
  137634. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  137635. /**
  137636. * Not supported by GPUParticleSystem
  137637. * @param gradient defines the gradient to remove
  137638. * @returns the current particle system
  137639. */
  137640. removeStartSizeGradient(gradient: number): IParticleSystem;
  137641. /**
  137642. * Not supported by GPUParticleSystem
  137643. * @param gradient defines the gradient to use (between 0 and 1)
  137644. * @param min defines the color remap minimal range
  137645. * @param max defines the color remap maximal range
  137646. * @returns the current particle system
  137647. */
  137648. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  137649. /**
  137650. * Not supported by GPUParticleSystem
  137651. * @param gradient defines the gradient to remove
  137652. * @returns the current particle system
  137653. */
  137654. removeColorRemapGradient(): IParticleSystem;
  137655. /**
  137656. * Not supported by GPUParticleSystem
  137657. * @param gradient defines the gradient to use (between 0 and 1)
  137658. * @param min defines the alpha remap minimal range
  137659. * @param max defines the alpha remap maximal range
  137660. * @returns the current particle system
  137661. */
  137662. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  137663. /**
  137664. * Not supported by GPUParticleSystem
  137665. * @param gradient defines the gradient to remove
  137666. * @returns the current particle system
  137667. */
  137668. removeAlphaRemapGradient(): IParticleSystem;
  137669. /**
  137670. * Not supported by GPUParticleSystem
  137671. * @param gradient defines the gradient to use (between 0 and 1)
  137672. * @param color defines the color to affect to the specified gradient
  137673. * @returns the current particle system
  137674. */
  137675. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  137676. /**
  137677. * Not supported by GPUParticleSystem
  137678. * @param gradient defines the gradient to remove
  137679. * @returns the current particle system
  137680. */
  137681. removeRampGradient(): IParticleSystem;
  137682. /**
  137683. * Not supported by GPUParticleSystem
  137684. * @returns the list of ramp gradients
  137685. */
  137686. getRampGradients(): Nullable<Array<Color3Gradient>>;
  137687. /**
  137688. * Not supported by GPUParticleSystem
  137689. * Gets or sets a boolean indicating that ramp gradients must be used
  137690. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  137691. */
  137692. get useRampGradients(): boolean;
  137693. set useRampGradients(value: boolean);
  137694. /**
  137695. * Not supported by GPUParticleSystem
  137696. * @param gradient defines the gradient to use (between 0 and 1)
  137697. * @param factor defines the life time factor to affect to the specified gradient
  137698. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  137699. * @returns the current particle system
  137700. */
  137701. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  137702. /**
  137703. * Not supported by GPUParticleSystem
  137704. * @param gradient defines the gradient to remove
  137705. * @returns the current particle system
  137706. */
  137707. removeLifeTimeGradient(gradient: number): IParticleSystem;
  137708. /**
  137709. * Instantiates a GPU particle system.
  137710. * 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.
  137711. * @param name The name of the particle system
  137712. * @param options The options used to create the system
  137713. * @param scene The scene the particle system belongs to
  137714. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  137715. */
  137716. constructor(name: string, options: Partial<{
  137717. capacity: number;
  137718. randomTextureSize: number;
  137719. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  137720. protected _reset(): void;
  137721. private _createUpdateVAO;
  137722. private _createRenderVAO;
  137723. private _initialize;
  137724. /** @hidden */
  137725. _recreateUpdateEffect(): void;
  137726. /** @hidden */
  137727. _recreateRenderEffect(): void;
  137728. /**
  137729. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  137730. * @param preWarm defines if we are in the pre-warmimg phase
  137731. */
  137732. animate(preWarm?: boolean): void;
  137733. private _createFactorGradientTexture;
  137734. private _createSizeGradientTexture;
  137735. private _createAngularSpeedGradientTexture;
  137736. private _createVelocityGradientTexture;
  137737. private _createLimitVelocityGradientTexture;
  137738. private _createDragGradientTexture;
  137739. private _createColorGradientTexture;
  137740. /**
  137741. * Renders the particle system in its current state
  137742. * @param preWarm defines if the system should only update the particles but not render them
  137743. * @returns the current number of particles
  137744. */
  137745. render(preWarm?: boolean): number;
  137746. /**
  137747. * Rebuilds the particle system
  137748. */
  137749. rebuild(): void;
  137750. private _releaseBuffers;
  137751. private _releaseVAOs;
  137752. /**
  137753. * Disposes the particle system and free the associated resources
  137754. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  137755. */
  137756. dispose(disposeTexture?: boolean): void;
  137757. /**
  137758. * Clones the particle system.
  137759. * @param name The name of the cloned object
  137760. * @param newEmitter The new emitter to use
  137761. * @returns the cloned particle system
  137762. */
  137763. clone(name: string, newEmitter: any): GPUParticleSystem;
  137764. /**
  137765. * Serializes the particle system to a JSON object
  137766. * @param serializeTexture defines if the texture must be serialized as well
  137767. * @returns the JSON object
  137768. */
  137769. serialize(serializeTexture?: boolean): any;
  137770. /**
  137771. * Parses a JSON object to create a GPU particle system.
  137772. * @param parsedParticleSystem The JSON object to parse
  137773. * @param scene The scene to create the particle system in
  137774. * @param rootUrl The root url to use to load external dependencies like texture
  137775. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  137776. * @returns the parsed GPU particle system
  137777. */
  137778. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  137779. }
  137780. }
  137781. declare module BABYLON {
  137782. /**
  137783. * Represents a set of particle systems working together to create a specific effect
  137784. */
  137785. export class ParticleSystemSet implements IDisposable {
  137786. /**
  137787. * Gets or sets base Assets URL
  137788. */
  137789. static BaseAssetsUrl: string;
  137790. private _emitterCreationOptions;
  137791. private _emitterNode;
  137792. /**
  137793. * Gets the particle system list
  137794. */
  137795. systems: IParticleSystem[];
  137796. /**
  137797. * Gets the emitter node used with this set
  137798. */
  137799. get emitterNode(): Nullable<TransformNode>;
  137800. /**
  137801. * Creates a new emitter mesh as a sphere
  137802. * @param options defines the options used to create the sphere
  137803. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  137804. * @param scene defines the hosting scene
  137805. */
  137806. setEmitterAsSphere(options: {
  137807. diameter: number;
  137808. segments: number;
  137809. color: Color3;
  137810. }, renderingGroupId: number, scene: Scene): void;
  137811. /**
  137812. * Starts all particle systems of the set
  137813. * @param emitter defines an optional mesh to use as emitter for the particle systems
  137814. */
  137815. start(emitter?: AbstractMesh): void;
  137816. /**
  137817. * Release all associated resources
  137818. */
  137819. dispose(): void;
  137820. /**
  137821. * Serialize the set into a JSON compatible object
  137822. * @param serializeTexture defines if the texture must be serialized as well
  137823. * @returns a JSON compatible representation of the set
  137824. */
  137825. serialize(serializeTexture?: boolean): any;
  137826. /**
  137827. * Parse a new ParticleSystemSet from a serialized source
  137828. * @param data defines a JSON compatible representation of the set
  137829. * @param scene defines the hosting scene
  137830. * @param gpu defines if we want GPU particles or CPU particles
  137831. * @returns a new ParticleSystemSet
  137832. */
  137833. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  137834. }
  137835. }
  137836. declare module BABYLON {
  137837. /**
  137838. * This class is made for on one-liner static method to help creating particle system set.
  137839. */
  137840. export class ParticleHelper {
  137841. /**
  137842. * Gets or sets base Assets URL
  137843. */
  137844. static BaseAssetsUrl: string;
  137845. /** Define the Url to load snippets */
  137846. static SnippetUrl: string;
  137847. /**
  137848. * Create a default particle system that you can tweak
  137849. * @param emitter defines the emitter to use
  137850. * @param capacity defines the system capacity (default is 500 particles)
  137851. * @param scene defines the hosting scene
  137852. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  137853. * @returns the new Particle system
  137854. */
  137855. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  137856. /**
  137857. * This is the main static method (one-liner) of this helper to create different particle systems
  137858. * @param type This string represents the type to the particle system to create
  137859. * @param scene The scene where the particle system should live
  137860. * @param gpu If the system will use gpu
  137861. * @returns the ParticleSystemSet created
  137862. */
  137863. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  137864. /**
  137865. * Static function used to export a particle system to a ParticleSystemSet variable.
  137866. * Please note that the emitter shape is not exported
  137867. * @param systems defines the particle systems to export
  137868. * @returns the created particle system set
  137869. */
  137870. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  137871. /**
  137872. * Creates a particle system from a snippet saved in a remote file
  137873. * @param name defines the name of the particle system to create
  137874. * @param url defines the url to load from
  137875. * @param scene defines the hosting scene
  137876. * @param gpu If the system will use gpu
  137877. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  137878. * @returns a promise that will resolve to the new particle system
  137879. */
  137880. static ParseFromFileAsync(name: string, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  137881. /**
  137882. * Creates a particle system from a snippet saved by the particle system editor
  137883. * @param snippetId defines the snippet to load
  137884. * @param scene defines the hosting scene
  137885. * @param gpu If the system will use gpu
  137886. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  137887. * @returns a promise that will resolve to the new particle system
  137888. */
  137889. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  137890. }
  137891. }
  137892. declare module BABYLON {
  137893. interface Engine {
  137894. /**
  137895. * Create an effect to use with particle systems.
  137896. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  137897. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  137898. * @param uniformsNames defines a list of attribute names
  137899. * @param samplers defines an array of string used to represent textures
  137900. * @param defines defines the string containing the defines to use to compile the shaders
  137901. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  137902. * @param onCompiled defines a function to call when the effect creation is successful
  137903. * @param onError defines a function to call when the effect creation has failed
  137904. * @returns the new Effect
  137905. */
  137906. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  137907. }
  137908. interface Mesh {
  137909. /**
  137910. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  137911. * @returns an array of IParticleSystem
  137912. */
  137913. getEmittedParticleSystems(): IParticleSystem[];
  137914. /**
  137915. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  137916. * @returns an array of IParticleSystem
  137917. */
  137918. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  137919. }
  137920. /**
  137921. * @hidden
  137922. */
  137923. export var _IDoNeedToBeInTheBuild: number;
  137924. }
  137925. declare module BABYLON {
  137926. /** Defines the 4 color options */
  137927. export enum PointColor {
  137928. /** color value */
  137929. Color = 2,
  137930. /** uv value */
  137931. UV = 1,
  137932. /** random value */
  137933. Random = 0,
  137934. /** stated value */
  137935. Stated = 3
  137936. }
  137937. /**
  137938. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  137939. * 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.
  137940. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  137941. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  137942. *
  137943. * Full documentation here : TO BE ENTERED
  137944. */
  137945. export class PointsCloudSystem implements IDisposable {
  137946. /**
  137947. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  137948. * Example : var p = SPS.particles[i];
  137949. */
  137950. particles: CloudPoint[];
  137951. /**
  137952. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  137953. */
  137954. nbParticles: number;
  137955. /**
  137956. * This a counter for your own usage. It's not set by any SPS functions.
  137957. */
  137958. counter: number;
  137959. /**
  137960. * The PCS name. This name is also given to the underlying mesh.
  137961. */
  137962. name: string;
  137963. /**
  137964. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  137965. */
  137966. mesh: Mesh;
  137967. /**
  137968. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  137969. * Please read :
  137970. */
  137971. vars: any;
  137972. /**
  137973. * @hidden
  137974. */
  137975. _size: number;
  137976. private _scene;
  137977. private _promises;
  137978. private _positions;
  137979. private _indices;
  137980. private _normals;
  137981. private _colors;
  137982. private _uvs;
  137983. private _indices32;
  137984. private _positions32;
  137985. private _colors32;
  137986. private _uvs32;
  137987. private _updatable;
  137988. private _isVisibilityBoxLocked;
  137989. private _alwaysVisible;
  137990. private _groups;
  137991. private _groupCounter;
  137992. private _computeParticleColor;
  137993. private _computeParticleTexture;
  137994. private _computeParticleRotation;
  137995. private _computeBoundingBox;
  137996. private _isReady;
  137997. /**
  137998. * Creates a PCS (Points Cloud System) object
  137999. * @param name (String) is the PCS name, this will be the underlying mesh name
  138000. * @param pointSize (number) is the size for each point
  138001. * @param scene (Scene) is the scene in which the PCS is added
  138002. * @param options defines the options of the PCS e.g.
  138003. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  138004. */
  138005. constructor(name: string, pointSize: number, scene: Scene, options?: {
  138006. updatable?: boolean;
  138007. });
  138008. /**
  138009. * Builds the PCS underlying mesh. Returns a standard Mesh.
  138010. * If no points were added to the PCS, the returned mesh is just a single point.
  138011. * @returns a promise for the created mesh
  138012. */
  138013. buildMeshAsync(): Promise<Mesh>;
  138014. /**
  138015. * @hidden
  138016. */
  138017. private _buildMesh;
  138018. private _addParticle;
  138019. private _randomUnitVector;
  138020. private _getColorIndicesForCoord;
  138021. private _setPointsColorOrUV;
  138022. private _colorFromTexture;
  138023. private _calculateDensity;
  138024. /**
  138025. * Adds points to the PCS in random positions within a unit sphere
  138026. * @param nb (positive integer) the number of particles to be created from this model
  138027. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  138028. * @returns the number of groups in the system
  138029. */
  138030. addPoints(nb: number, pointFunction?: any): number;
  138031. /**
  138032. * Adds points to the PCS from the surface of the model shape
  138033. * @param mesh is any Mesh object that will be used as a surface model for the points
  138034. * @param nb (positive integer) the number of particles to be created from this model
  138035. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  138036. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  138037. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  138038. * @returns the number of groups in the system
  138039. */
  138040. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  138041. /**
  138042. * Adds points to the PCS inside the model shape
  138043. * @param mesh is any Mesh object that will be used as a surface model for the points
  138044. * @param nb (positive integer) the number of particles to be created from this model
  138045. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  138046. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  138047. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  138048. * @returns the number of groups in the system
  138049. */
  138050. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  138051. /**
  138052. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  138053. * This method calls `updateParticle()` for each particle of the SPS.
  138054. * For an animated SPS, it is usually called within the render loop.
  138055. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  138056. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  138057. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  138058. * @returns the PCS.
  138059. */
  138060. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  138061. /**
  138062. * Disposes the PCS.
  138063. */
  138064. dispose(): void;
  138065. /**
  138066. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  138067. * doc :
  138068. * @returns the PCS.
  138069. */
  138070. refreshVisibleSize(): PointsCloudSystem;
  138071. /**
  138072. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  138073. * @param size the size (float) of the visibility box
  138074. * note : this doesn't lock the PCS mesh bounding box.
  138075. * doc :
  138076. */
  138077. setVisibilityBox(size: number): void;
  138078. /**
  138079. * Gets whether the PCS is always visible or not
  138080. * doc :
  138081. */
  138082. get isAlwaysVisible(): boolean;
  138083. /**
  138084. * Sets the PCS as always visible or not
  138085. * doc :
  138086. */
  138087. set isAlwaysVisible(val: boolean);
  138088. /**
  138089. * Tells to `setParticles()` to compute the particle rotations or not
  138090. * Default value : false. The PCS is faster when it's set to false
  138091. * Note : particle rotations are only applied to parent particles
  138092. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  138093. */
  138094. set computeParticleRotation(val: boolean);
  138095. /**
  138096. * Tells to `setParticles()` to compute the particle colors or not.
  138097. * Default value : true. The PCS is faster when it's set to false.
  138098. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  138099. */
  138100. set computeParticleColor(val: boolean);
  138101. set computeParticleTexture(val: boolean);
  138102. /**
  138103. * Gets if `setParticles()` computes the particle colors or not.
  138104. * Default value : false. The PCS is faster when it's set to false.
  138105. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  138106. */
  138107. get computeParticleColor(): boolean;
  138108. /**
  138109. * Gets if `setParticles()` computes the particle textures or not.
  138110. * Default value : false. The PCS is faster when it's set to false.
  138111. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  138112. */
  138113. get computeParticleTexture(): boolean;
  138114. /**
  138115. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  138116. */
  138117. set computeBoundingBox(val: boolean);
  138118. /**
  138119. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  138120. */
  138121. get computeBoundingBox(): boolean;
  138122. /**
  138123. * This function does nothing. It may be overwritten to set all the particle first values.
  138124. * The PCS doesn't call this function, you may have to call it by your own.
  138125. * doc :
  138126. */
  138127. initParticles(): void;
  138128. /**
  138129. * This function does nothing. It may be overwritten to recycle a particle
  138130. * The PCS doesn't call this function, you can to call it
  138131. * doc :
  138132. * @param particle The particle to recycle
  138133. * @returns the recycled particle
  138134. */
  138135. recycleParticle(particle: CloudPoint): CloudPoint;
  138136. /**
  138137. * Updates a particle : this function should be overwritten by the user.
  138138. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  138139. * doc :
  138140. * @example : just set a particle position or velocity and recycle conditions
  138141. * @param particle The particle to update
  138142. * @returns the updated particle
  138143. */
  138144. updateParticle(particle: CloudPoint): CloudPoint;
  138145. /**
  138146. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  138147. * This does nothing and may be overwritten by the user.
  138148. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  138149. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  138150. * @param update the boolean update value actually passed to setParticles()
  138151. */
  138152. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  138153. /**
  138154. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  138155. * This will be passed three parameters.
  138156. * This does nothing and may be overwritten by the user.
  138157. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  138158. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  138159. * @param update the boolean update value actually passed to setParticles()
  138160. */
  138161. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  138162. }
  138163. }
  138164. declare module BABYLON {
  138165. /**
  138166. * Represents one particle of a points cloud system.
  138167. */
  138168. export class CloudPoint {
  138169. /**
  138170. * particle global index
  138171. */
  138172. idx: number;
  138173. /**
  138174. * The color of the particle
  138175. */
  138176. color: Nullable<Color4>;
  138177. /**
  138178. * The world space position of the particle.
  138179. */
  138180. position: Vector3;
  138181. /**
  138182. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  138183. */
  138184. rotation: Vector3;
  138185. /**
  138186. * The world space rotation quaternion of the particle.
  138187. */
  138188. rotationQuaternion: Nullable<Quaternion>;
  138189. /**
  138190. * The uv of the particle.
  138191. */
  138192. uv: Nullable<Vector2>;
  138193. /**
  138194. * The current speed of the particle.
  138195. */
  138196. velocity: Vector3;
  138197. /**
  138198. * The pivot point in the particle local space.
  138199. */
  138200. pivot: Vector3;
  138201. /**
  138202. * Must the particle be translated from its pivot point in its local space ?
  138203. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  138204. * Default : false
  138205. */
  138206. translateFromPivot: boolean;
  138207. /**
  138208. * Index of this particle in the global "positions" array (Internal use)
  138209. * @hidden
  138210. */
  138211. _pos: number;
  138212. /**
  138213. * @hidden Index of this particle in the global "indices" array (Internal use)
  138214. */
  138215. _ind: number;
  138216. /**
  138217. * Group this particle belongs to
  138218. */
  138219. _group: PointsGroup;
  138220. /**
  138221. * Group id of this particle
  138222. */
  138223. groupId: number;
  138224. /**
  138225. * Index of the particle in its group id (Internal use)
  138226. */
  138227. idxInGroup: number;
  138228. /**
  138229. * @hidden Particle BoundingInfo object (Internal use)
  138230. */
  138231. _boundingInfo: BoundingInfo;
  138232. /**
  138233. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  138234. */
  138235. _pcs: PointsCloudSystem;
  138236. /**
  138237. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  138238. */
  138239. _stillInvisible: boolean;
  138240. /**
  138241. * @hidden Last computed particle rotation matrix
  138242. */
  138243. _rotationMatrix: number[];
  138244. /**
  138245. * Parent particle Id, if any.
  138246. * Default null.
  138247. */
  138248. parentId: Nullable<number>;
  138249. /**
  138250. * @hidden Internal global position in the PCS.
  138251. */
  138252. _globalPosition: Vector3;
  138253. /**
  138254. * Creates a Point Cloud object.
  138255. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  138256. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  138257. * @param group (PointsGroup) is the group the particle belongs to
  138258. * @param groupId (integer) is the group identifier in the PCS.
  138259. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  138260. * @param pcs defines the PCS it is associated to
  138261. */
  138262. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  138263. /**
  138264. * get point size
  138265. */
  138266. get size(): Vector3;
  138267. /**
  138268. * Set point size
  138269. */
  138270. set size(scale: Vector3);
  138271. /**
  138272. * Legacy support, changed quaternion to rotationQuaternion
  138273. */
  138274. get quaternion(): Nullable<Quaternion>;
  138275. /**
  138276. * Legacy support, changed quaternion to rotationQuaternion
  138277. */
  138278. set quaternion(q: Nullable<Quaternion>);
  138279. /**
  138280. * Returns a boolean. True if the particle intersects a mesh, else false
  138281. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  138282. * @param target is the object (point or mesh) what the intersection is computed against
  138283. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  138284. * @returns true if it intersects
  138285. */
  138286. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  138287. /**
  138288. * get the rotation matrix of the particle
  138289. * @hidden
  138290. */
  138291. getRotationMatrix(m: Matrix): void;
  138292. }
  138293. /**
  138294. * Represents a group of points in a points cloud system
  138295. * * PCS internal tool, don't use it manually.
  138296. */
  138297. export class PointsGroup {
  138298. /**
  138299. * The group id
  138300. * @hidden
  138301. */
  138302. groupID: number;
  138303. /**
  138304. * image data for group (internal use)
  138305. * @hidden
  138306. */
  138307. _groupImageData: Nullable<ArrayBufferView>;
  138308. /**
  138309. * Image Width (internal use)
  138310. * @hidden
  138311. */
  138312. _groupImgWidth: number;
  138313. /**
  138314. * Image Height (internal use)
  138315. * @hidden
  138316. */
  138317. _groupImgHeight: number;
  138318. /**
  138319. * Custom position function (internal use)
  138320. * @hidden
  138321. */
  138322. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  138323. /**
  138324. * density per facet for surface points
  138325. * @hidden
  138326. */
  138327. _groupDensity: number[];
  138328. /**
  138329. * Only when points are colored by texture carries pointer to texture list array
  138330. * @hidden
  138331. */
  138332. _textureNb: number;
  138333. /**
  138334. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  138335. * PCS internal tool, don't use it manually.
  138336. * @hidden
  138337. */
  138338. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  138339. }
  138340. }
  138341. declare module BABYLON {
  138342. interface Scene {
  138343. /** @hidden (Backing field) */
  138344. _physicsEngine: Nullable<IPhysicsEngine>;
  138345. /** @hidden */
  138346. _physicsTimeAccumulator: number;
  138347. /**
  138348. * Gets the current physics engine
  138349. * @returns a IPhysicsEngine or null if none attached
  138350. */
  138351. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  138352. /**
  138353. * Enables physics to the current scene
  138354. * @param gravity defines the scene's gravity for the physics engine
  138355. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  138356. * @return a boolean indicating if the physics engine was initialized
  138357. */
  138358. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  138359. /**
  138360. * Disables and disposes the physics engine associated with the scene
  138361. */
  138362. disablePhysicsEngine(): void;
  138363. /**
  138364. * Gets a boolean indicating if there is an active physics engine
  138365. * @returns a boolean indicating if there is an active physics engine
  138366. */
  138367. isPhysicsEnabled(): boolean;
  138368. /**
  138369. * Deletes a physics compound impostor
  138370. * @param compound defines the compound to delete
  138371. */
  138372. deleteCompoundImpostor(compound: any): void;
  138373. /**
  138374. * An event triggered when physic simulation is about to be run
  138375. */
  138376. onBeforePhysicsObservable: Observable<Scene>;
  138377. /**
  138378. * An event triggered when physic simulation has been done
  138379. */
  138380. onAfterPhysicsObservable: Observable<Scene>;
  138381. }
  138382. interface AbstractMesh {
  138383. /** @hidden */
  138384. _physicsImpostor: Nullable<PhysicsImpostor>;
  138385. /**
  138386. * Gets or sets impostor used for physic simulation
  138387. * @see http://doc.babylonjs.com/features/physics_engine
  138388. */
  138389. physicsImpostor: Nullable<PhysicsImpostor>;
  138390. /**
  138391. * Gets the current physics impostor
  138392. * @see http://doc.babylonjs.com/features/physics_engine
  138393. * @returns a physics impostor or null
  138394. */
  138395. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  138396. /** Apply a physic impulse to the mesh
  138397. * @param force defines the force to apply
  138398. * @param contactPoint defines where to apply the force
  138399. * @returns the current mesh
  138400. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  138401. */
  138402. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  138403. /**
  138404. * Creates a physic joint between two meshes
  138405. * @param otherMesh defines the other mesh to use
  138406. * @param pivot1 defines the pivot to use on this mesh
  138407. * @param pivot2 defines the pivot to use on the other mesh
  138408. * @param options defines additional options (can be plugin dependent)
  138409. * @returns the current mesh
  138410. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  138411. */
  138412. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  138413. /** @hidden */
  138414. _disposePhysicsObserver: Nullable<Observer<Node>>;
  138415. }
  138416. /**
  138417. * Defines the physics engine scene component responsible to manage a physics engine
  138418. */
  138419. export class PhysicsEngineSceneComponent implements ISceneComponent {
  138420. /**
  138421. * The component name helpful to identify the component in the list of scene components.
  138422. */
  138423. readonly name: string;
  138424. /**
  138425. * The scene the component belongs to.
  138426. */
  138427. scene: Scene;
  138428. /**
  138429. * Creates a new instance of the component for the given scene
  138430. * @param scene Defines the scene to register the component in
  138431. */
  138432. constructor(scene: Scene);
  138433. /**
  138434. * Registers the component in a given scene
  138435. */
  138436. register(): void;
  138437. /**
  138438. * Rebuilds the elements related to this component in case of
  138439. * context lost for instance.
  138440. */
  138441. rebuild(): void;
  138442. /**
  138443. * Disposes the component and the associated ressources
  138444. */
  138445. dispose(): void;
  138446. }
  138447. }
  138448. declare module BABYLON {
  138449. /**
  138450. * A helper for physics simulations
  138451. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  138452. */
  138453. export class PhysicsHelper {
  138454. private _scene;
  138455. private _physicsEngine;
  138456. /**
  138457. * Initializes the Physics helper
  138458. * @param scene Babylon.js scene
  138459. */
  138460. constructor(scene: Scene);
  138461. /**
  138462. * Applies a radial explosion impulse
  138463. * @param origin the origin of the explosion
  138464. * @param radiusOrEventOptions the radius or the options of radial explosion
  138465. * @param strength the explosion strength
  138466. * @param falloff possible options: Constant & Linear. Defaults to Constant
  138467. * @returns A physics radial explosion event, or null
  138468. */
  138469. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  138470. /**
  138471. * Applies a radial explosion force
  138472. * @param origin the origin of the explosion
  138473. * @param radiusOrEventOptions the radius or the options of radial explosion
  138474. * @param strength the explosion strength
  138475. * @param falloff possible options: Constant & Linear. Defaults to Constant
  138476. * @returns A physics radial explosion event, or null
  138477. */
  138478. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  138479. /**
  138480. * Creates a gravitational field
  138481. * @param origin the origin of the explosion
  138482. * @param radiusOrEventOptions the radius or the options of radial explosion
  138483. * @param strength the explosion strength
  138484. * @param falloff possible options: Constant & Linear. Defaults to Constant
  138485. * @returns A physics gravitational field event, or null
  138486. */
  138487. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  138488. /**
  138489. * Creates a physics updraft event
  138490. * @param origin the origin of the updraft
  138491. * @param radiusOrEventOptions the radius or the options of the updraft
  138492. * @param strength the strength of the updraft
  138493. * @param height the height of the updraft
  138494. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  138495. * @returns A physics updraft event, or null
  138496. */
  138497. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  138498. /**
  138499. * Creates a physics vortex event
  138500. * @param origin the of the vortex
  138501. * @param radiusOrEventOptions the radius or the options of the vortex
  138502. * @param strength the strength of the vortex
  138503. * @param height the height of the vortex
  138504. * @returns a Physics vortex event, or null
  138505. * A physics vortex event or null
  138506. */
  138507. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  138508. }
  138509. /**
  138510. * Represents a physics radial explosion event
  138511. */
  138512. class PhysicsRadialExplosionEvent {
  138513. private _scene;
  138514. private _options;
  138515. private _sphere;
  138516. private _dataFetched;
  138517. /**
  138518. * Initializes a radial explosioin event
  138519. * @param _scene BabylonJS scene
  138520. * @param _options The options for the vortex event
  138521. */
  138522. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  138523. /**
  138524. * Returns the data related to the radial explosion event (sphere).
  138525. * @returns The radial explosion event data
  138526. */
  138527. getData(): PhysicsRadialExplosionEventData;
  138528. /**
  138529. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  138530. * @param impostor A physics imposter
  138531. * @param origin the origin of the explosion
  138532. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  138533. */
  138534. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  138535. /**
  138536. * Triggers affecterd impostors callbacks
  138537. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  138538. */
  138539. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  138540. /**
  138541. * Disposes the sphere.
  138542. * @param force Specifies if the sphere should be disposed by force
  138543. */
  138544. dispose(force?: boolean): void;
  138545. /*** Helpers ***/
  138546. private _prepareSphere;
  138547. private _intersectsWithSphere;
  138548. }
  138549. /**
  138550. * Represents a gravitational field event
  138551. */
  138552. class PhysicsGravitationalFieldEvent {
  138553. private _physicsHelper;
  138554. private _scene;
  138555. private _origin;
  138556. private _options;
  138557. private _tickCallback;
  138558. private _sphere;
  138559. private _dataFetched;
  138560. /**
  138561. * Initializes the physics gravitational field event
  138562. * @param _physicsHelper A physics helper
  138563. * @param _scene BabylonJS scene
  138564. * @param _origin The origin position of the gravitational field event
  138565. * @param _options The options for the vortex event
  138566. */
  138567. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  138568. /**
  138569. * Returns the data related to the gravitational field event (sphere).
  138570. * @returns A gravitational field event
  138571. */
  138572. getData(): PhysicsGravitationalFieldEventData;
  138573. /**
  138574. * Enables the gravitational field.
  138575. */
  138576. enable(): void;
  138577. /**
  138578. * Disables the gravitational field.
  138579. */
  138580. disable(): void;
  138581. /**
  138582. * Disposes the sphere.
  138583. * @param force The force to dispose from the gravitational field event
  138584. */
  138585. dispose(force?: boolean): void;
  138586. private _tick;
  138587. }
  138588. /**
  138589. * Represents a physics updraft event
  138590. */
  138591. class PhysicsUpdraftEvent {
  138592. private _scene;
  138593. private _origin;
  138594. private _options;
  138595. private _physicsEngine;
  138596. private _originTop;
  138597. private _originDirection;
  138598. private _tickCallback;
  138599. private _cylinder;
  138600. private _cylinderPosition;
  138601. private _dataFetched;
  138602. /**
  138603. * Initializes the physics updraft event
  138604. * @param _scene BabylonJS scene
  138605. * @param _origin The origin position of the updraft
  138606. * @param _options The options for the updraft event
  138607. */
  138608. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  138609. /**
  138610. * Returns the data related to the updraft event (cylinder).
  138611. * @returns A physics updraft event
  138612. */
  138613. getData(): PhysicsUpdraftEventData;
  138614. /**
  138615. * Enables the updraft.
  138616. */
  138617. enable(): void;
  138618. /**
  138619. * Disables the updraft.
  138620. */
  138621. disable(): void;
  138622. /**
  138623. * Disposes the cylinder.
  138624. * @param force Specifies if the updraft should be disposed by force
  138625. */
  138626. dispose(force?: boolean): void;
  138627. private getImpostorHitData;
  138628. private _tick;
  138629. /*** Helpers ***/
  138630. private _prepareCylinder;
  138631. private _intersectsWithCylinder;
  138632. }
  138633. /**
  138634. * Represents a physics vortex event
  138635. */
  138636. class PhysicsVortexEvent {
  138637. private _scene;
  138638. private _origin;
  138639. private _options;
  138640. private _physicsEngine;
  138641. private _originTop;
  138642. private _tickCallback;
  138643. private _cylinder;
  138644. private _cylinderPosition;
  138645. private _dataFetched;
  138646. /**
  138647. * Initializes the physics vortex event
  138648. * @param _scene The BabylonJS scene
  138649. * @param _origin The origin position of the vortex
  138650. * @param _options The options for the vortex event
  138651. */
  138652. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  138653. /**
  138654. * Returns the data related to the vortex event (cylinder).
  138655. * @returns The physics vortex event data
  138656. */
  138657. getData(): PhysicsVortexEventData;
  138658. /**
  138659. * Enables the vortex.
  138660. */
  138661. enable(): void;
  138662. /**
  138663. * Disables the cortex.
  138664. */
  138665. disable(): void;
  138666. /**
  138667. * Disposes the sphere.
  138668. * @param force
  138669. */
  138670. dispose(force?: boolean): void;
  138671. private getImpostorHitData;
  138672. private _tick;
  138673. /*** Helpers ***/
  138674. private _prepareCylinder;
  138675. private _intersectsWithCylinder;
  138676. }
  138677. /**
  138678. * Options fot the radial explosion event
  138679. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  138680. */
  138681. export class PhysicsRadialExplosionEventOptions {
  138682. /**
  138683. * The radius of the sphere for the radial explosion.
  138684. */
  138685. radius: number;
  138686. /**
  138687. * The strenth of the explosion.
  138688. */
  138689. strength: number;
  138690. /**
  138691. * The strenght of the force in correspondence to the distance of the affected object
  138692. */
  138693. falloff: PhysicsRadialImpulseFalloff;
  138694. /**
  138695. * Sphere options for the radial explosion.
  138696. */
  138697. sphere: {
  138698. segments: number;
  138699. diameter: number;
  138700. };
  138701. /**
  138702. * Sphere options for the radial explosion.
  138703. */
  138704. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  138705. }
  138706. /**
  138707. * Options fot the updraft event
  138708. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  138709. */
  138710. export class PhysicsUpdraftEventOptions {
  138711. /**
  138712. * The radius of the cylinder for the vortex
  138713. */
  138714. radius: number;
  138715. /**
  138716. * The strenth of the updraft.
  138717. */
  138718. strength: number;
  138719. /**
  138720. * The height of the cylinder for the updraft.
  138721. */
  138722. height: number;
  138723. /**
  138724. * The mode for the the updraft.
  138725. */
  138726. updraftMode: PhysicsUpdraftMode;
  138727. }
  138728. /**
  138729. * Options fot the vortex event
  138730. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  138731. */
  138732. export class PhysicsVortexEventOptions {
  138733. /**
  138734. * The radius of the cylinder for the vortex
  138735. */
  138736. radius: number;
  138737. /**
  138738. * The strenth of the vortex.
  138739. */
  138740. strength: number;
  138741. /**
  138742. * The height of the cylinder for the vortex.
  138743. */
  138744. height: number;
  138745. /**
  138746. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  138747. */
  138748. centripetalForceThreshold: number;
  138749. /**
  138750. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  138751. */
  138752. centripetalForceMultiplier: number;
  138753. /**
  138754. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  138755. */
  138756. centrifugalForceMultiplier: number;
  138757. /**
  138758. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  138759. */
  138760. updraftForceMultiplier: number;
  138761. }
  138762. /**
  138763. * The strenght of the force in correspondence to the distance of the affected object
  138764. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  138765. */
  138766. export enum PhysicsRadialImpulseFalloff {
  138767. /** Defines that impulse is constant in strength across it's whole radius */
  138768. Constant = 0,
  138769. /** Defines that impulse gets weaker if it's further from the origin */
  138770. Linear = 1
  138771. }
  138772. /**
  138773. * The strength of the force in correspondence to the distance of the affected object
  138774. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  138775. */
  138776. export enum PhysicsUpdraftMode {
  138777. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  138778. Center = 0,
  138779. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  138780. Perpendicular = 1
  138781. }
  138782. /**
  138783. * Interface for a physics hit data
  138784. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  138785. */
  138786. export interface PhysicsHitData {
  138787. /**
  138788. * The force applied at the contact point
  138789. */
  138790. force: Vector3;
  138791. /**
  138792. * The contact point
  138793. */
  138794. contactPoint: Vector3;
  138795. /**
  138796. * The distance from the origin to the contact point
  138797. */
  138798. distanceFromOrigin: number;
  138799. }
  138800. /**
  138801. * Interface for radial explosion event data
  138802. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  138803. */
  138804. export interface PhysicsRadialExplosionEventData {
  138805. /**
  138806. * A sphere used for the radial explosion event
  138807. */
  138808. sphere: Mesh;
  138809. }
  138810. /**
  138811. * Interface for gravitational field event data
  138812. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  138813. */
  138814. export interface PhysicsGravitationalFieldEventData {
  138815. /**
  138816. * A sphere mesh used for the gravitational field event
  138817. */
  138818. sphere: Mesh;
  138819. }
  138820. /**
  138821. * Interface for updraft event data
  138822. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  138823. */
  138824. export interface PhysicsUpdraftEventData {
  138825. /**
  138826. * A cylinder used for the updraft event
  138827. */
  138828. cylinder: Mesh;
  138829. }
  138830. /**
  138831. * Interface for vortex event data
  138832. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  138833. */
  138834. export interface PhysicsVortexEventData {
  138835. /**
  138836. * A cylinder used for the vortex event
  138837. */
  138838. cylinder: Mesh;
  138839. }
  138840. /**
  138841. * Interface for an affected physics impostor
  138842. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  138843. */
  138844. export interface PhysicsAffectedImpostorWithData {
  138845. /**
  138846. * The impostor affected by the effect
  138847. */
  138848. impostor: PhysicsImpostor;
  138849. /**
  138850. * The data about the hit/horce from the explosion
  138851. */
  138852. hitData: PhysicsHitData;
  138853. }
  138854. }
  138855. declare module BABYLON {
  138856. /** @hidden */
  138857. export var blackAndWhitePixelShader: {
  138858. name: string;
  138859. shader: string;
  138860. };
  138861. }
  138862. declare module BABYLON {
  138863. /**
  138864. * Post process used to render in black and white
  138865. */
  138866. export class BlackAndWhitePostProcess extends PostProcess {
  138867. /**
  138868. * Linear about to convert he result to black and white (default: 1)
  138869. */
  138870. degree: number;
  138871. /**
  138872. * Creates a black and white post process
  138873. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  138874. * @param name The name of the effect.
  138875. * @param options The required width/height ratio to downsize to before computing the render pass.
  138876. * @param camera The camera to apply the render pass to.
  138877. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  138878. * @param engine The engine which the post process will be applied. (default: current engine)
  138879. * @param reusable If the post process can be reused on the same frame. (default: false)
  138880. */
  138881. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  138882. }
  138883. }
  138884. declare module BABYLON {
  138885. /**
  138886. * This represents a set of one or more post processes in Babylon.
  138887. * A post process can be used to apply a shader to a texture after it is rendered.
  138888. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  138889. */
  138890. export class PostProcessRenderEffect {
  138891. private _postProcesses;
  138892. private _getPostProcesses;
  138893. private _singleInstance;
  138894. private _cameras;
  138895. private _indicesForCamera;
  138896. /**
  138897. * Name of the effect
  138898. * @hidden
  138899. */
  138900. _name: string;
  138901. /**
  138902. * Instantiates a post process render effect.
  138903. * A post process can be used to apply a shader to a texture after it is rendered.
  138904. * @param engine The engine the effect is tied to
  138905. * @param name The name of the effect
  138906. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  138907. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  138908. */
  138909. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  138910. /**
  138911. * Checks if all the post processes in the effect are supported.
  138912. */
  138913. get isSupported(): boolean;
  138914. /**
  138915. * Updates the current state of the effect
  138916. * @hidden
  138917. */
  138918. _update(): void;
  138919. /**
  138920. * Attaches the effect on cameras
  138921. * @param cameras The camera to attach to.
  138922. * @hidden
  138923. */
  138924. _attachCameras(cameras: Camera): void;
  138925. /**
  138926. * Attaches the effect on cameras
  138927. * @param cameras The camera to attach to.
  138928. * @hidden
  138929. */
  138930. _attachCameras(cameras: Camera[]): void;
  138931. /**
  138932. * Detaches the effect on cameras
  138933. * @param cameras The camera to detatch from.
  138934. * @hidden
  138935. */
  138936. _detachCameras(cameras: Camera): void;
  138937. /**
  138938. * Detatches the effect on cameras
  138939. * @param cameras The camera to detatch from.
  138940. * @hidden
  138941. */
  138942. _detachCameras(cameras: Camera[]): void;
  138943. /**
  138944. * Enables the effect on given cameras
  138945. * @param cameras The camera to enable.
  138946. * @hidden
  138947. */
  138948. _enable(cameras: Camera): void;
  138949. /**
  138950. * Enables the effect on given cameras
  138951. * @param cameras The camera to enable.
  138952. * @hidden
  138953. */
  138954. _enable(cameras: Nullable<Camera[]>): void;
  138955. /**
  138956. * Disables the effect on the given cameras
  138957. * @param cameras The camera to disable.
  138958. * @hidden
  138959. */
  138960. _disable(cameras: Camera): void;
  138961. /**
  138962. * Disables the effect on the given cameras
  138963. * @param cameras The camera to disable.
  138964. * @hidden
  138965. */
  138966. _disable(cameras: Nullable<Camera[]>): void;
  138967. /**
  138968. * Gets a list of the post processes contained in the effect.
  138969. * @param camera The camera to get the post processes on.
  138970. * @returns The list of the post processes in the effect.
  138971. */
  138972. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  138973. }
  138974. }
  138975. declare module BABYLON {
  138976. /** @hidden */
  138977. export var extractHighlightsPixelShader: {
  138978. name: string;
  138979. shader: string;
  138980. };
  138981. }
  138982. declare module BABYLON {
  138983. /**
  138984. * 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.
  138985. */
  138986. export class ExtractHighlightsPostProcess extends PostProcess {
  138987. /**
  138988. * The luminance threshold, pixels below this value will be set to black.
  138989. */
  138990. threshold: number;
  138991. /** @hidden */
  138992. _exposure: number;
  138993. /**
  138994. * Post process which has the input texture to be used when performing highlight extraction
  138995. * @hidden
  138996. */
  138997. _inputPostProcess: Nullable<PostProcess>;
  138998. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  138999. }
  139000. }
  139001. declare module BABYLON {
  139002. /** @hidden */
  139003. export var bloomMergePixelShader: {
  139004. name: string;
  139005. shader: string;
  139006. };
  139007. }
  139008. declare module BABYLON {
  139009. /**
  139010. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  139011. */
  139012. export class BloomMergePostProcess extends PostProcess {
  139013. /** Weight of the bloom to be added to the original input. */
  139014. weight: number;
  139015. /**
  139016. * Creates a new instance of @see BloomMergePostProcess
  139017. * @param name The name of the effect.
  139018. * @param originalFromInput Post process which's input will be used for the merge.
  139019. * @param blurred Blurred highlights post process which's output will be used.
  139020. * @param weight Weight of the bloom to be added to the original input.
  139021. * @param options The required width/height ratio to downsize to before computing the render pass.
  139022. * @param camera The camera to apply the render pass to.
  139023. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  139024. * @param engine The engine which the post process will be applied. (default: current engine)
  139025. * @param reusable If the post process can be reused on the same frame. (default: false)
  139026. * @param textureType Type of textures used when performing the post process. (default: 0)
  139027. * @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)
  139028. */
  139029. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  139030. /** Weight of the bloom to be added to the original input. */
  139031. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  139032. }
  139033. }
  139034. declare module BABYLON {
  139035. /**
  139036. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  139037. */
  139038. export class BloomEffect extends PostProcessRenderEffect {
  139039. private bloomScale;
  139040. /**
  139041. * @hidden Internal
  139042. */
  139043. _effects: Array<PostProcess>;
  139044. /**
  139045. * @hidden Internal
  139046. */
  139047. _downscale: ExtractHighlightsPostProcess;
  139048. private _blurX;
  139049. private _blurY;
  139050. private _merge;
  139051. /**
  139052. * The luminance threshold to find bright areas of the image to bloom.
  139053. */
  139054. get threshold(): number;
  139055. set threshold(value: number);
  139056. /**
  139057. * The strength of the bloom.
  139058. */
  139059. get weight(): number;
  139060. set weight(value: number);
  139061. /**
  139062. * Specifies the size of the bloom blur kernel, relative to the final output size
  139063. */
  139064. get kernel(): number;
  139065. set kernel(value: number);
  139066. /**
  139067. * Creates a new instance of @see BloomEffect
  139068. * @param scene The scene the effect belongs to.
  139069. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  139070. * @param bloomKernel The size of the kernel to be used when applying the blur.
  139071. * @param bloomWeight The the strength of bloom.
  139072. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  139073. * @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)
  139074. */
  139075. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  139076. /**
  139077. * Disposes each of the internal effects for a given camera.
  139078. * @param camera The camera to dispose the effect on.
  139079. */
  139080. disposeEffects(camera: Camera): void;
  139081. /**
  139082. * @hidden Internal
  139083. */
  139084. _updateEffects(): void;
  139085. /**
  139086. * Internal
  139087. * @returns if all the contained post processes are ready.
  139088. * @hidden
  139089. */
  139090. _isReady(): boolean;
  139091. }
  139092. }
  139093. declare module BABYLON {
  139094. /** @hidden */
  139095. export var chromaticAberrationPixelShader: {
  139096. name: string;
  139097. shader: string;
  139098. };
  139099. }
  139100. declare module BABYLON {
  139101. /**
  139102. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  139103. */
  139104. export class ChromaticAberrationPostProcess extends PostProcess {
  139105. /**
  139106. * The amount of seperation of rgb channels (default: 30)
  139107. */
  139108. aberrationAmount: number;
  139109. /**
  139110. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  139111. */
  139112. radialIntensity: number;
  139113. /**
  139114. * 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))
  139115. */
  139116. direction: Vector2;
  139117. /**
  139118. * 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))
  139119. */
  139120. centerPosition: Vector2;
  139121. /**
  139122. * Creates a new instance ChromaticAberrationPostProcess
  139123. * @param name The name of the effect.
  139124. * @param screenWidth The width of the screen to apply the effect on.
  139125. * @param screenHeight The height of the screen to apply the effect on.
  139126. * @param options The required width/height ratio to downsize to before computing the render pass.
  139127. * @param camera The camera to apply the render pass to.
  139128. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  139129. * @param engine The engine which the post process will be applied. (default: current engine)
  139130. * @param reusable If the post process can be reused on the same frame. (default: false)
  139131. * @param textureType Type of textures used when performing the post process. (default: 0)
  139132. * @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)
  139133. */
  139134. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  139135. }
  139136. }
  139137. declare module BABYLON {
  139138. /** @hidden */
  139139. export var circleOfConfusionPixelShader: {
  139140. name: string;
  139141. shader: string;
  139142. };
  139143. }
  139144. declare module BABYLON {
  139145. /**
  139146. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  139147. */
  139148. export class CircleOfConfusionPostProcess extends PostProcess {
  139149. /**
  139150. * 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.
  139151. */
  139152. lensSize: number;
  139153. /**
  139154. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  139155. */
  139156. fStop: number;
  139157. /**
  139158. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  139159. */
  139160. focusDistance: number;
  139161. /**
  139162. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  139163. */
  139164. focalLength: number;
  139165. private _depthTexture;
  139166. /**
  139167. * Creates a new instance CircleOfConfusionPostProcess
  139168. * @param name The name of the effect.
  139169. * @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.
  139170. * @param options The required width/height ratio to downsize to before computing the render pass.
  139171. * @param camera The camera to apply the render pass to.
  139172. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  139173. * @param engine The engine which the post process will be applied. (default: current engine)
  139174. * @param reusable If the post process can be reused on the same frame. (default: false)
  139175. * @param textureType Type of textures used when performing the post process. (default: 0)
  139176. * @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)
  139177. */
  139178. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  139179. /**
  139180. * 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.
  139181. */
  139182. set depthTexture(value: RenderTargetTexture);
  139183. }
  139184. }
  139185. declare module BABYLON {
  139186. /** @hidden */
  139187. export var colorCorrectionPixelShader: {
  139188. name: string;
  139189. shader: string;
  139190. };
  139191. }
  139192. declare module BABYLON {
  139193. /**
  139194. *
  139195. * This post-process allows the modification of rendered colors by using
  139196. * a 'look-up table' (LUT). This effect is also called Color Grading.
  139197. *
  139198. * The object needs to be provided an url to a texture containing the color
  139199. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  139200. * Use an image editing software to tweak the LUT to match your needs.
  139201. *
  139202. * For an example of a color LUT, see here:
  139203. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  139204. * For explanations on color grading, see here:
  139205. * @see http://udn.epicgames.com/Three/ColorGrading.html
  139206. *
  139207. */
  139208. export class ColorCorrectionPostProcess extends PostProcess {
  139209. private _colorTableTexture;
  139210. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  139211. }
  139212. }
  139213. declare module BABYLON {
  139214. /** @hidden */
  139215. export var convolutionPixelShader: {
  139216. name: string;
  139217. shader: string;
  139218. };
  139219. }
  139220. declare module BABYLON {
  139221. /**
  139222. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  139223. * input texture to perform effects such as edge detection or sharpening
  139224. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  139225. */
  139226. export class ConvolutionPostProcess extends PostProcess {
  139227. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  139228. kernel: number[];
  139229. /**
  139230. * Creates a new instance ConvolutionPostProcess
  139231. * @param name The name of the effect.
  139232. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  139233. * @param options The required width/height ratio to downsize to before computing the render pass.
  139234. * @param camera The camera to apply the render pass to.
  139235. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  139236. * @param engine The engine which the post process will be applied. (default: current engine)
  139237. * @param reusable If the post process can be reused on the same frame. (default: false)
  139238. * @param textureType Type of textures used when performing the post process. (default: 0)
  139239. */
  139240. constructor(name: string,
  139241. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  139242. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  139243. /**
  139244. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  139245. */
  139246. static EdgeDetect0Kernel: number[];
  139247. /**
  139248. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  139249. */
  139250. static EdgeDetect1Kernel: number[];
  139251. /**
  139252. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  139253. */
  139254. static EdgeDetect2Kernel: number[];
  139255. /**
  139256. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  139257. */
  139258. static SharpenKernel: number[];
  139259. /**
  139260. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  139261. */
  139262. static EmbossKernel: number[];
  139263. /**
  139264. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  139265. */
  139266. static GaussianKernel: number[];
  139267. }
  139268. }
  139269. declare module BABYLON {
  139270. /**
  139271. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  139272. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  139273. * based on samples that have a large difference in distance than the center pixel.
  139274. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  139275. */
  139276. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  139277. direction: Vector2;
  139278. /**
  139279. * Creates a new instance CircleOfConfusionPostProcess
  139280. * @param name The name of the effect.
  139281. * @param scene The scene the effect belongs to.
  139282. * @param direction The direction the blur should be applied.
  139283. * @param kernel The size of the kernel used to blur.
  139284. * @param options The required width/height ratio to downsize to before computing the render pass.
  139285. * @param camera The camera to apply the render pass to.
  139286. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  139287. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  139288. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  139289. * @param engine The engine which the post process will be applied. (default: current engine)
  139290. * @param reusable If the post process can be reused on the same frame. (default: false)
  139291. * @param textureType Type of textures used when performing the post process. (default: 0)
  139292. * @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)
  139293. */
  139294. 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);
  139295. }
  139296. }
  139297. declare module BABYLON {
  139298. /** @hidden */
  139299. export var depthOfFieldMergePixelShader: {
  139300. name: string;
  139301. shader: string;
  139302. };
  139303. }
  139304. declare module BABYLON {
  139305. /**
  139306. * Options to be set when merging outputs from the default pipeline.
  139307. */
  139308. export class DepthOfFieldMergePostProcessOptions {
  139309. /**
  139310. * The original image to merge on top of
  139311. */
  139312. originalFromInput: PostProcess;
  139313. /**
  139314. * Parameters to perform the merge of the depth of field effect
  139315. */
  139316. depthOfField?: {
  139317. circleOfConfusion: PostProcess;
  139318. blurSteps: Array<PostProcess>;
  139319. };
  139320. /**
  139321. * Parameters to perform the merge of bloom effect
  139322. */
  139323. bloom?: {
  139324. blurred: PostProcess;
  139325. weight: number;
  139326. };
  139327. }
  139328. /**
  139329. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  139330. */
  139331. export class DepthOfFieldMergePostProcess extends PostProcess {
  139332. private blurSteps;
  139333. /**
  139334. * Creates a new instance of DepthOfFieldMergePostProcess
  139335. * @param name The name of the effect.
  139336. * @param originalFromInput Post process which's input will be used for the merge.
  139337. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  139338. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  139339. * @param options The required width/height ratio to downsize to before computing the render pass.
  139340. * @param camera The camera to apply the render pass to.
  139341. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  139342. * @param engine The engine which the post process will be applied. (default: current engine)
  139343. * @param reusable If the post process can be reused on the same frame. (default: false)
  139344. * @param textureType Type of textures used when performing the post process. (default: 0)
  139345. * @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)
  139346. */
  139347. 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);
  139348. /**
  139349. * Updates the effect with the current post process compile time values and recompiles the shader.
  139350. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  139351. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  139352. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  139353. * @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
  139354. * @param onCompiled Called when the shader has been compiled.
  139355. * @param onError Called if there is an error when compiling a shader.
  139356. */
  139357. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  139358. }
  139359. }
  139360. declare module BABYLON {
  139361. /**
  139362. * Specifies the level of max blur that should be applied when using the depth of field effect
  139363. */
  139364. export enum DepthOfFieldEffectBlurLevel {
  139365. /**
  139366. * Subtle blur
  139367. */
  139368. Low = 0,
  139369. /**
  139370. * Medium blur
  139371. */
  139372. Medium = 1,
  139373. /**
  139374. * Large blur
  139375. */
  139376. High = 2
  139377. }
  139378. /**
  139379. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  139380. */
  139381. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  139382. private _circleOfConfusion;
  139383. /**
  139384. * @hidden Internal, blurs from high to low
  139385. */
  139386. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  139387. private _depthOfFieldBlurY;
  139388. private _dofMerge;
  139389. /**
  139390. * @hidden Internal post processes in depth of field effect
  139391. */
  139392. _effects: Array<PostProcess>;
  139393. /**
  139394. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  139395. */
  139396. set focalLength(value: number);
  139397. get focalLength(): number;
  139398. /**
  139399. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  139400. */
  139401. set fStop(value: number);
  139402. get fStop(): number;
  139403. /**
  139404. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  139405. */
  139406. set focusDistance(value: number);
  139407. get focusDistance(): number;
  139408. /**
  139409. * 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.
  139410. */
  139411. set lensSize(value: number);
  139412. get lensSize(): number;
  139413. /**
  139414. * Creates a new instance DepthOfFieldEffect
  139415. * @param scene The scene the effect belongs to.
  139416. * @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.
  139417. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  139418. * @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)
  139419. */
  139420. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  139421. /**
  139422. * Get the current class name of the current effet
  139423. * @returns "DepthOfFieldEffect"
  139424. */
  139425. getClassName(): string;
  139426. /**
  139427. * 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.
  139428. */
  139429. set depthTexture(value: RenderTargetTexture);
  139430. /**
  139431. * Disposes each of the internal effects for a given camera.
  139432. * @param camera The camera to dispose the effect on.
  139433. */
  139434. disposeEffects(camera: Camera): void;
  139435. /**
  139436. * @hidden Internal
  139437. */
  139438. _updateEffects(): void;
  139439. /**
  139440. * Internal
  139441. * @returns if all the contained post processes are ready.
  139442. * @hidden
  139443. */
  139444. _isReady(): boolean;
  139445. }
  139446. }
  139447. declare module BABYLON {
  139448. /** @hidden */
  139449. export var displayPassPixelShader: {
  139450. name: string;
  139451. shader: string;
  139452. };
  139453. }
  139454. declare module BABYLON {
  139455. /**
  139456. * DisplayPassPostProcess which produces an output the same as it's input
  139457. */
  139458. export class DisplayPassPostProcess extends PostProcess {
  139459. /**
  139460. * Creates the DisplayPassPostProcess
  139461. * @param name The name of the effect.
  139462. * @param options The required width/height ratio to downsize to before computing the render pass.
  139463. * @param camera The camera to apply the render pass to.
  139464. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  139465. * @param engine The engine which the post process will be applied. (default: current engine)
  139466. * @param reusable If the post process can be reused on the same frame. (default: false)
  139467. */
  139468. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  139469. }
  139470. }
  139471. declare module BABYLON {
  139472. /** @hidden */
  139473. export var filterPixelShader: {
  139474. name: string;
  139475. shader: string;
  139476. };
  139477. }
  139478. declare module BABYLON {
  139479. /**
  139480. * Applies a kernel filter to the image
  139481. */
  139482. export class FilterPostProcess extends PostProcess {
  139483. /** The matrix to be applied to the image */
  139484. kernelMatrix: Matrix;
  139485. /**
  139486. *
  139487. * @param name The name of the effect.
  139488. * @param kernelMatrix The matrix to be applied to the image
  139489. * @param options The required width/height ratio to downsize to before computing the render pass.
  139490. * @param camera The camera to apply the render pass to.
  139491. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  139492. * @param engine The engine which the post process will be applied. (default: current engine)
  139493. * @param reusable If the post process can be reused on the same frame. (default: false)
  139494. */
  139495. constructor(name: string,
  139496. /** The matrix to be applied to the image */
  139497. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  139498. }
  139499. }
  139500. declare module BABYLON {
  139501. /** @hidden */
  139502. export var fxaaPixelShader: {
  139503. name: string;
  139504. shader: string;
  139505. };
  139506. }
  139507. declare module BABYLON {
  139508. /** @hidden */
  139509. export var fxaaVertexShader: {
  139510. name: string;
  139511. shader: string;
  139512. };
  139513. }
  139514. declare module BABYLON {
  139515. /**
  139516. * Fxaa post process
  139517. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  139518. */
  139519. export class FxaaPostProcess extends PostProcess {
  139520. /** @hidden */
  139521. texelWidth: number;
  139522. /** @hidden */
  139523. texelHeight: number;
  139524. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  139525. private _getDefines;
  139526. }
  139527. }
  139528. declare module BABYLON {
  139529. /** @hidden */
  139530. export var grainPixelShader: {
  139531. name: string;
  139532. shader: string;
  139533. };
  139534. }
  139535. declare module BABYLON {
  139536. /**
  139537. * The GrainPostProcess adds noise to the image at mid luminance levels
  139538. */
  139539. export class GrainPostProcess extends PostProcess {
  139540. /**
  139541. * The intensity of the grain added (default: 30)
  139542. */
  139543. intensity: number;
  139544. /**
  139545. * If the grain should be randomized on every frame
  139546. */
  139547. animated: boolean;
  139548. /**
  139549. * Creates a new instance of @see GrainPostProcess
  139550. * @param name The name of the effect.
  139551. * @param options The required width/height ratio to downsize to before computing the render pass.
  139552. * @param camera The camera to apply the render pass to.
  139553. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  139554. * @param engine The engine which the post process will be applied. (default: current engine)
  139555. * @param reusable If the post process can be reused on the same frame. (default: false)
  139556. * @param textureType Type of textures used when performing the post process. (default: 0)
  139557. * @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)
  139558. */
  139559. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  139560. }
  139561. }
  139562. declare module BABYLON {
  139563. /** @hidden */
  139564. export var highlightsPixelShader: {
  139565. name: string;
  139566. shader: string;
  139567. };
  139568. }
  139569. declare module BABYLON {
  139570. /**
  139571. * Extracts highlights from the image
  139572. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  139573. */
  139574. export class HighlightsPostProcess extends PostProcess {
  139575. /**
  139576. * Extracts highlights from the image
  139577. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  139578. * @param name The name of the effect.
  139579. * @param options The required width/height ratio to downsize to before computing the render pass.
  139580. * @param camera The camera to apply the render pass to.
  139581. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  139582. * @param engine The engine which the post process will be applied. (default: current engine)
  139583. * @param reusable If the post process can be reused on the same frame. (default: false)
  139584. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  139585. */
  139586. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  139587. }
  139588. }
  139589. declare module BABYLON {
  139590. /** @hidden */
  139591. export var mrtFragmentDeclaration: {
  139592. name: string;
  139593. shader: string;
  139594. };
  139595. }
  139596. declare module BABYLON {
  139597. /** @hidden */
  139598. export var geometryPixelShader: {
  139599. name: string;
  139600. shader: string;
  139601. };
  139602. }
  139603. declare module BABYLON {
  139604. /** @hidden */
  139605. export var geometryVertexShader: {
  139606. name: string;
  139607. shader: string;
  139608. };
  139609. }
  139610. declare module BABYLON {
  139611. /** @hidden */
  139612. interface ISavedTransformationMatrix {
  139613. world: Matrix;
  139614. viewProjection: Matrix;
  139615. }
  139616. /**
  139617. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  139618. */
  139619. export class GeometryBufferRenderer {
  139620. /**
  139621. * Constant used to retrieve the position texture index in the G-Buffer textures array
  139622. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  139623. */
  139624. static readonly POSITION_TEXTURE_TYPE: number;
  139625. /**
  139626. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  139627. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  139628. */
  139629. static readonly VELOCITY_TEXTURE_TYPE: number;
  139630. /**
  139631. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  139632. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  139633. */
  139634. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  139635. /**
  139636. * Dictionary used to store the previous transformation matrices of each rendered mesh
  139637. * in order to compute objects velocities when enableVelocity is set to "true"
  139638. * @hidden
  139639. */
  139640. _previousTransformationMatrices: {
  139641. [index: number]: ISavedTransformationMatrix;
  139642. };
  139643. /**
  139644. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  139645. * in order to compute objects velocities when enableVelocity is set to "true"
  139646. * @hidden
  139647. */
  139648. _previousBonesTransformationMatrices: {
  139649. [index: number]: Float32Array;
  139650. };
  139651. /**
  139652. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  139653. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  139654. */
  139655. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  139656. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  139657. renderTransparentMeshes: boolean;
  139658. private _scene;
  139659. private _multiRenderTarget;
  139660. private _ratio;
  139661. private _enablePosition;
  139662. private _enableVelocity;
  139663. private _enableReflectivity;
  139664. private _positionIndex;
  139665. private _velocityIndex;
  139666. private _reflectivityIndex;
  139667. protected _effect: Effect;
  139668. protected _cachedDefines: string;
  139669. /**
  139670. * Set the render list (meshes to be rendered) used in the G buffer.
  139671. */
  139672. set renderList(meshes: Mesh[]);
  139673. /**
  139674. * Gets wether or not G buffer are supported by the running hardware.
  139675. * This requires draw buffer supports
  139676. */
  139677. get isSupported(): boolean;
  139678. /**
  139679. * Returns the index of the given texture type in the G-Buffer textures array
  139680. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  139681. * @returns the index of the given texture type in the G-Buffer textures array
  139682. */
  139683. getTextureIndex(textureType: number): number;
  139684. /**
  139685. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  139686. */
  139687. get enablePosition(): boolean;
  139688. /**
  139689. * Sets whether or not objects positions are enabled for the G buffer.
  139690. */
  139691. set enablePosition(enable: boolean);
  139692. /**
  139693. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  139694. */
  139695. get enableVelocity(): boolean;
  139696. /**
  139697. * Sets wether or not objects velocities are enabled for the G buffer.
  139698. */
  139699. set enableVelocity(enable: boolean);
  139700. /**
  139701. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  139702. */
  139703. get enableReflectivity(): boolean;
  139704. /**
  139705. * Sets wether or not objects roughness are enabled for the G buffer.
  139706. */
  139707. set enableReflectivity(enable: boolean);
  139708. /**
  139709. * Gets the scene associated with the buffer.
  139710. */
  139711. get scene(): Scene;
  139712. /**
  139713. * Gets the ratio used by the buffer during its creation.
  139714. * How big is the buffer related to the main canvas.
  139715. */
  139716. get ratio(): number;
  139717. /** @hidden */
  139718. static _SceneComponentInitialization: (scene: Scene) => void;
  139719. /**
  139720. * Creates a new G Buffer for the scene
  139721. * @param scene The scene the buffer belongs to
  139722. * @param ratio How big is the buffer related to the main canvas.
  139723. */
  139724. constructor(scene: Scene, ratio?: number);
  139725. /**
  139726. * Checks wether everything is ready to render a submesh to the G buffer.
  139727. * @param subMesh the submesh to check readiness for
  139728. * @param useInstances is the mesh drawn using instance or not
  139729. * @returns true if ready otherwise false
  139730. */
  139731. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  139732. /**
  139733. * Gets the current underlying G Buffer.
  139734. * @returns the buffer
  139735. */
  139736. getGBuffer(): MultiRenderTarget;
  139737. /**
  139738. * Gets the number of samples used to render the buffer (anti aliasing).
  139739. */
  139740. get samples(): number;
  139741. /**
  139742. * Sets the number of samples used to render the buffer (anti aliasing).
  139743. */
  139744. set samples(value: number);
  139745. /**
  139746. * Disposes the renderer and frees up associated resources.
  139747. */
  139748. dispose(): void;
  139749. protected _createRenderTargets(): void;
  139750. private _copyBonesTransformationMatrices;
  139751. }
  139752. }
  139753. declare module BABYLON {
  139754. interface Scene {
  139755. /** @hidden (Backing field) */
  139756. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  139757. /**
  139758. * Gets or Sets the current geometry buffer associated to the scene.
  139759. */
  139760. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  139761. /**
  139762. * Enables a GeometryBufferRender and associates it with the scene
  139763. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  139764. * @returns the GeometryBufferRenderer
  139765. */
  139766. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  139767. /**
  139768. * Disables the GeometryBufferRender associated with the scene
  139769. */
  139770. disableGeometryBufferRenderer(): void;
  139771. }
  139772. /**
  139773. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  139774. * in several rendering techniques.
  139775. */
  139776. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  139777. /**
  139778. * The component name helpful to identify the component in the list of scene components.
  139779. */
  139780. readonly name: string;
  139781. /**
  139782. * The scene the component belongs to.
  139783. */
  139784. scene: Scene;
  139785. /**
  139786. * Creates a new instance of the component for the given scene
  139787. * @param scene Defines the scene to register the component in
  139788. */
  139789. constructor(scene: Scene);
  139790. /**
  139791. * Registers the component in a given scene
  139792. */
  139793. register(): void;
  139794. /**
  139795. * Rebuilds the elements related to this component in case of
  139796. * context lost for instance.
  139797. */
  139798. rebuild(): void;
  139799. /**
  139800. * Disposes the component and the associated ressources
  139801. */
  139802. dispose(): void;
  139803. private _gatherRenderTargets;
  139804. }
  139805. }
  139806. declare module BABYLON {
  139807. /** @hidden */
  139808. export var motionBlurPixelShader: {
  139809. name: string;
  139810. shader: string;
  139811. };
  139812. }
  139813. declare module BABYLON {
  139814. /**
  139815. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  139816. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  139817. * As an example, all you have to do is to create the post-process:
  139818. * var mb = new BABYLON.MotionBlurPostProcess(
  139819. * 'mb', // The name of the effect.
  139820. * scene, // The scene containing the objects to blur according to their velocity.
  139821. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  139822. * camera // The camera to apply the render pass to.
  139823. * );
  139824. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  139825. */
  139826. export class MotionBlurPostProcess extends PostProcess {
  139827. /**
  139828. * Defines how much the image is blurred by the movement. Default value is equal to 1
  139829. */
  139830. motionStrength: number;
  139831. /**
  139832. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  139833. */
  139834. get motionBlurSamples(): number;
  139835. /**
  139836. * Sets the number of iterations to be used for motion blur quality
  139837. */
  139838. set motionBlurSamples(samples: number);
  139839. private _motionBlurSamples;
  139840. private _geometryBufferRenderer;
  139841. /**
  139842. * Creates a new instance MotionBlurPostProcess
  139843. * @param name The name of the effect.
  139844. * @param scene The scene containing the objects to blur according to their velocity.
  139845. * @param options The required width/height ratio to downsize to before computing the render pass.
  139846. * @param camera The camera to apply the render pass to.
  139847. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  139848. * @param engine The engine which the post process will be applied. (default: current engine)
  139849. * @param reusable If the post process can be reused on the same frame. (default: false)
  139850. * @param textureType Type of textures used when performing the post process. (default: 0)
  139851. * @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)
  139852. */
  139853. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  139854. /**
  139855. * Excludes the given skinned mesh from computing bones velocities.
  139856. * 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.
  139857. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  139858. */
  139859. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  139860. /**
  139861. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  139862. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  139863. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  139864. */
  139865. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  139866. /**
  139867. * Disposes the post process.
  139868. * @param camera The camera to dispose the post process on.
  139869. */
  139870. dispose(camera?: Camera): void;
  139871. }
  139872. }
  139873. declare module BABYLON {
  139874. /** @hidden */
  139875. export var refractionPixelShader: {
  139876. name: string;
  139877. shader: string;
  139878. };
  139879. }
  139880. declare module BABYLON {
  139881. /**
  139882. * Post process which applies a refractin texture
  139883. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  139884. */
  139885. export class RefractionPostProcess extends PostProcess {
  139886. /** the base color of the refraction (used to taint the rendering) */
  139887. color: Color3;
  139888. /** simulated refraction depth */
  139889. depth: number;
  139890. /** the coefficient of the base color (0 to remove base color tainting) */
  139891. colorLevel: number;
  139892. private _refTexture;
  139893. private _ownRefractionTexture;
  139894. /**
  139895. * Gets or sets the refraction texture
  139896. * Please note that you are responsible for disposing the texture if you set it manually
  139897. */
  139898. get refractionTexture(): Texture;
  139899. set refractionTexture(value: Texture);
  139900. /**
  139901. * Initializes the RefractionPostProcess
  139902. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  139903. * @param name The name of the effect.
  139904. * @param refractionTextureUrl Url of the refraction texture to use
  139905. * @param color the base color of the refraction (used to taint the rendering)
  139906. * @param depth simulated refraction depth
  139907. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  139908. * @param camera The camera to apply the render pass to.
  139909. * @param options The required width/height ratio to downsize to before computing the render pass.
  139910. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  139911. * @param engine The engine which the post process will be applied. (default: current engine)
  139912. * @param reusable If the post process can be reused on the same frame. (default: false)
  139913. */
  139914. constructor(name: string, refractionTextureUrl: string,
  139915. /** the base color of the refraction (used to taint the rendering) */
  139916. color: Color3,
  139917. /** simulated refraction depth */
  139918. depth: number,
  139919. /** the coefficient of the base color (0 to remove base color tainting) */
  139920. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  139921. /**
  139922. * Disposes of the post process
  139923. * @param camera Camera to dispose post process on
  139924. */
  139925. dispose(camera: Camera): void;
  139926. }
  139927. }
  139928. declare module BABYLON {
  139929. /** @hidden */
  139930. export var sharpenPixelShader: {
  139931. name: string;
  139932. shader: string;
  139933. };
  139934. }
  139935. declare module BABYLON {
  139936. /**
  139937. * The SharpenPostProcess applies a sharpen kernel to every pixel
  139938. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  139939. */
  139940. export class SharpenPostProcess extends PostProcess {
  139941. /**
  139942. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  139943. */
  139944. colorAmount: number;
  139945. /**
  139946. * How much sharpness should be applied (default: 0.3)
  139947. */
  139948. edgeAmount: number;
  139949. /**
  139950. * Creates a new instance ConvolutionPostProcess
  139951. * @param name The name of the effect.
  139952. * @param options The required width/height ratio to downsize to before computing the render pass.
  139953. * @param camera The camera to apply the render pass to.
  139954. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  139955. * @param engine The engine which the post process will be applied. (default: current engine)
  139956. * @param reusable If the post process can be reused on the same frame. (default: false)
  139957. * @param textureType Type of textures used when performing the post process. (default: 0)
  139958. * @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)
  139959. */
  139960. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  139961. }
  139962. }
  139963. declare module BABYLON {
  139964. /**
  139965. * PostProcessRenderPipeline
  139966. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  139967. */
  139968. export class PostProcessRenderPipeline {
  139969. private engine;
  139970. private _renderEffects;
  139971. private _renderEffectsForIsolatedPass;
  139972. /**
  139973. * List of inspectable custom properties (used by the Inspector)
  139974. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  139975. */
  139976. inspectableCustomProperties: IInspectable[];
  139977. /**
  139978. * @hidden
  139979. */
  139980. protected _cameras: Camera[];
  139981. /** @hidden */
  139982. _name: string;
  139983. /**
  139984. * Gets pipeline name
  139985. */
  139986. get name(): string;
  139987. /** Gets the list of attached cameras */
  139988. get cameras(): Camera[];
  139989. /**
  139990. * Initializes a PostProcessRenderPipeline
  139991. * @param engine engine to add the pipeline to
  139992. * @param name name of the pipeline
  139993. */
  139994. constructor(engine: Engine, name: string);
  139995. /**
  139996. * Gets the class name
  139997. * @returns "PostProcessRenderPipeline"
  139998. */
  139999. getClassName(): string;
  140000. /**
  140001. * If all the render effects in the pipeline are supported
  140002. */
  140003. get isSupported(): boolean;
  140004. /**
  140005. * Adds an effect to the pipeline
  140006. * @param renderEffect the effect to add
  140007. */
  140008. addEffect(renderEffect: PostProcessRenderEffect): void;
  140009. /** @hidden */
  140010. _rebuild(): void;
  140011. /** @hidden */
  140012. _enableEffect(renderEffectName: string, cameras: Camera): void;
  140013. /** @hidden */
  140014. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  140015. /** @hidden */
  140016. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  140017. /** @hidden */
  140018. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  140019. /** @hidden */
  140020. _attachCameras(cameras: Camera, unique: boolean): void;
  140021. /** @hidden */
  140022. _attachCameras(cameras: Camera[], unique: boolean): void;
  140023. /** @hidden */
  140024. _detachCameras(cameras: Camera): void;
  140025. /** @hidden */
  140026. _detachCameras(cameras: Nullable<Camera[]>): void;
  140027. /** @hidden */
  140028. _update(): void;
  140029. /** @hidden */
  140030. _reset(): void;
  140031. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  140032. /**
  140033. * Disposes of the pipeline
  140034. */
  140035. dispose(): void;
  140036. }
  140037. }
  140038. declare module BABYLON {
  140039. /**
  140040. * PostProcessRenderPipelineManager class
  140041. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  140042. */
  140043. export class PostProcessRenderPipelineManager {
  140044. private _renderPipelines;
  140045. /**
  140046. * Initializes a PostProcessRenderPipelineManager
  140047. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  140048. */
  140049. constructor();
  140050. /**
  140051. * Gets the list of supported render pipelines
  140052. */
  140053. get supportedPipelines(): PostProcessRenderPipeline[];
  140054. /**
  140055. * Adds a pipeline to the manager
  140056. * @param renderPipeline The pipeline to add
  140057. */
  140058. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  140059. /**
  140060. * Attaches a camera to the pipeline
  140061. * @param renderPipelineName The name of the pipeline to attach to
  140062. * @param cameras the camera to attach
  140063. * @param unique if the camera can be attached multiple times to the pipeline
  140064. */
  140065. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  140066. /**
  140067. * Detaches a camera from the pipeline
  140068. * @param renderPipelineName The name of the pipeline to detach from
  140069. * @param cameras the camera to detach
  140070. */
  140071. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  140072. /**
  140073. * Enables an effect by name on a pipeline
  140074. * @param renderPipelineName the name of the pipeline to enable the effect in
  140075. * @param renderEffectName the name of the effect to enable
  140076. * @param cameras the cameras that the effect should be enabled on
  140077. */
  140078. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  140079. /**
  140080. * Disables an effect by name on a pipeline
  140081. * @param renderPipelineName the name of the pipeline to disable the effect in
  140082. * @param renderEffectName the name of the effect to disable
  140083. * @param cameras the cameras that the effect should be disabled on
  140084. */
  140085. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  140086. /**
  140087. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  140088. */
  140089. update(): void;
  140090. /** @hidden */
  140091. _rebuild(): void;
  140092. /**
  140093. * Disposes of the manager and pipelines
  140094. */
  140095. dispose(): void;
  140096. }
  140097. }
  140098. declare module BABYLON {
  140099. interface Scene {
  140100. /** @hidden (Backing field) */
  140101. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  140102. /**
  140103. * Gets the postprocess render pipeline manager
  140104. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  140105. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  140106. */
  140107. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  140108. }
  140109. /**
  140110. * Defines the Render Pipeline scene component responsible to rendering pipelines
  140111. */
  140112. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  140113. /**
  140114. * The component name helpfull to identify the component in the list of scene components.
  140115. */
  140116. readonly name: string;
  140117. /**
  140118. * The scene the component belongs to.
  140119. */
  140120. scene: Scene;
  140121. /**
  140122. * Creates a new instance of the component for the given scene
  140123. * @param scene Defines the scene to register the component in
  140124. */
  140125. constructor(scene: Scene);
  140126. /**
  140127. * Registers the component in a given scene
  140128. */
  140129. register(): void;
  140130. /**
  140131. * Rebuilds the elements related to this component in case of
  140132. * context lost for instance.
  140133. */
  140134. rebuild(): void;
  140135. /**
  140136. * Disposes the component and the associated ressources
  140137. */
  140138. dispose(): void;
  140139. private _gatherRenderTargets;
  140140. }
  140141. }
  140142. declare module BABYLON {
  140143. /**
  140144. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  140145. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  140146. */
  140147. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  140148. private _scene;
  140149. private _camerasToBeAttached;
  140150. /**
  140151. * ID of the sharpen post process,
  140152. */
  140153. private readonly SharpenPostProcessId;
  140154. /**
  140155. * @ignore
  140156. * ID of the image processing post process;
  140157. */
  140158. readonly ImageProcessingPostProcessId: string;
  140159. /**
  140160. * @ignore
  140161. * ID of the Fast Approximate Anti-Aliasing post process;
  140162. */
  140163. readonly FxaaPostProcessId: string;
  140164. /**
  140165. * ID of the chromatic aberration post process,
  140166. */
  140167. private readonly ChromaticAberrationPostProcessId;
  140168. /**
  140169. * ID of the grain post process
  140170. */
  140171. private readonly GrainPostProcessId;
  140172. /**
  140173. * Sharpen post process which will apply a sharpen convolution to enhance edges
  140174. */
  140175. sharpen: SharpenPostProcess;
  140176. private _sharpenEffect;
  140177. private bloom;
  140178. /**
  140179. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  140180. */
  140181. depthOfField: DepthOfFieldEffect;
  140182. /**
  140183. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  140184. */
  140185. fxaa: FxaaPostProcess;
  140186. /**
  140187. * Image post processing pass used to perform operations such as tone mapping or color grading.
  140188. */
  140189. imageProcessing: ImageProcessingPostProcess;
  140190. /**
  140191. * Chromatic aberration post process which will shift rgb colors in the image
  140192. */
  140193. chromaticAberration: ChromaticAberrationPostProcess;
  140194. private _chromaticAberrationEffect;
  140195. /**
  140196. * Grain post process which add noise to the image
  140197. */
  140198. grain: GrainPostProcess;
  140199. private _grainEffect;
  140200. /**
  140201. * Glow post process which adds a glow to emissive areas of the image
  140202. */
  140203. private _glowLayer;
  140204. /**
  140205. * Animations which can be used to tweak settings over a period of time
  140206. */
  140207. animations: Animation[];
  140208. private _imageProcessingConfigurationObserver;
  140209. private _sharpenEnabled;
  140210. private _bloomEnabled;
  140211. private _depthOfFieldEnabled;
  140212. private _depthOfFieldBlurLevel;
  140213. private _fxaaEnabled;
  140214. private _imageProcessingEnabled;
  140215. private _defaultPipelineTextureType;
  140216. private _bloomScale;
  140217. private _chromaticAberrationEnabled;
  140218. private _grainEnabled;
  140219. private _buildAllowed;
  140220. /**
  140221. * Gets active scene
  140222. */
  140223. get scene(): Scene;
  140224. /**
  140225. * Enable or disable the sharpen process from the pipeline
  140226. */
  140227. set sharpenEnabled(enabled: boolean);
  140228. get sharpenEnabled(): boolean;
  140229. private _resizeObserver;
  140230. private _hardwareScaleLevel;
  140231. private _bloomKernel;
  140232. /**
  140233. * Specifies the size of the bloom blur kernel, relative to the final output size
  140234. */
  140235. get bloomKernel(): number;
  140236. set bloomKernel(value: number);
  140237. /**
  140238. * Specifies the weight of the bloom in the final rendering
  140239. */
  140240. private _bloomWeight;
  140241. /**
  140242. * Specifies the luma threshold for the area that will be blurred by the bloom
  140243. */
  140244. private _bloomThreshold;
  140245. private _hdr;
  140246. /**
  140247. * The strength of the bloom.
  140248. */
  140249. set bloomWeight(value: number);
  140250. get bloomWeight(): number;
  140251. /**
  140252. * The strength of the bloom.
  140253. */
  140254. set bloomThreshold(value: number);
  140255. get bloomThreshold(): number;
  140256. /**
  140257. * The scale of the bloom, lower value will provide better performance.
  140258. */
  140259. set bloomScale(value: number);
  140260. get bloomScale(): number;
  140261. /**
  140262. * Enable or disable the bloom from the pipeline
  140263. */
  140264. set bloomEnabled(enabled: boolean);
  140265. get bloomEnabled(): boolean;
  140266. private _rebuildBloom;
  140267. /**
  140268. * If the depth of field is enabled.
  140269. */
  140270. get depthOfFieldEnabled(): boolean;
  140271. set depthOfFieldEnabled(enabled: boolean);
  140272. /**
  140273. * Blur level of the depth of field effect. (Higher blur will effect performance)
  140274. */
  140275. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  140276. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  140277. /**
  140278. * If the anti aliasing is enabled.
  140279. */
  140280. set fxaaEnabled(enabled: boolean);
  140281. get fxaaEnabled(): boolean;
  140282. private _samples;
  140283. /**
  140284. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  140285. */
  140286. set samples(sampleCount: number);
  140287. get samples(): number;
  140288. /**
  140289. * If image processing is enabled.
  140290. */
  140291. set imageProcessingEnabled(enabled: boolean);
  140292. get imageProcessingEnabled(): boolean;
  140293. /**
  140294. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  140295. */
  140296. set glowLayerEnabled(enabled: boolean);
  140297. get glowLayerEnabled(): boolean;
  140298. /**
  140299. * Gets the glow layer (or null if not defined)
  140300. */
  140301. get glowLayer(): Nullable<GlowLayer>;
  140302. /**
  140303. * Enable or disable the chromaticAberration process from the pipeline
  140304. */
  140305. set chromaticAberrationEnabled(enabled: boolean);
  140306. get chromaticAberrationEnabled(): boolean;
  140307. /**
  140308. * Enable or disable the grain process from the pipeline
  140309. */
  140310. set grainEnabled(enabled: boolean);
  140311. get grainEnabled(): boolean;
  140312. /**
  140313. * @constructor
  140314. * @param name - The rendering pipeline name (default: "")
  140315. * @param hdr - If high dynamic range textures should be used (default: true)
  140316. * @param scene - The scene linked to this pipeline (default: the last created scene)
  140317. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  140318. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  140319. */
  140320. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  140321. /**
  140322. * Get the class name
  140323. * @returns "DefaultRenderingPipeline"
  140324. */
  140325. getClassName(): string;
  140326. /**
  140327. * Force the compilation of the entire pipeline.
  140328. */
  140329. prepare(): void;
  140330. private _hasCleared;
  140331. private _prevPostProcess;
  140332. private _prevPrevPostProcess;
  140333. private _setAutoClearAndTextureSharing;
  140334. private _depthOfFieldSceneObserver;
  140335. private _buildPipeline;
  140336. private _disposePostProcesses;
  140337. /**
  140338. * Adds a camera to the pipeline
  140339. * @param camera the camera to be added
  140340. */
  140341. addCamera(camera: Camera): void;
  140342. /**
  140343. * Removes a camera from the pipeline
  140344. * @param camera the camera to remove
  140345. */
  140346. removeCamera(camera: Camera): void;
  140347. /**
  140348. * Dispose of the pipeline and stop all post processes
  140349. */
  140350. dispose(): void;
  140351. /**
  140352. * Serialize the rendering pipeline (Used when exporting)
  140353. * @returns the serialized object
  140354. */
  140355. serialize(): any;
  140356. /**
  140357. * Parse the serialized pipeline
  140358. * @param source Source pipeline.
  140359. * @param scene The scene to load the pipeline to.
  140360. * @param rootUrl The URL of the serialized pipeline.
  140361. * @returns An instantiated pipeline from the serialized object.
  140362. */
  140363. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  140364. }
  140365. }
  140366. declare module BABYLON {
  140367. /** @hidden */
  140368. export var lensHighlightsPixelShader: {
  140369. name: string;
  140370. shader: string;
  140371. };
  140372. }
  140373. declare module BABYLON {
  140374. /** @hidden */
  140375. export var depthOfFieldPixelShader: {
  140376. name: string;
  140377. shader: string;
  140378. };
  140379. }
  140380. declare module BABYLON {
  140381. /**
  140382. * BABYLON.JS Chromatic Aberration GLSL Shader
  140383. * Author: Olivier Guyot
  140384. * Separates very slightly R, G and B colors on the edges of the screen
  140385. * Inspired by Francois Tarlier & Martins Upitis
  140386. */
  140387. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  140388. /**
  140389. * @ignore
  140390. * The chromatic aberration PostProcess id in the pipeline
  140391. */
  140392. LensChromaticAberrationEffect: string;
  140393. /**
  140394. * @ignore
  140395. * The highlights enhancing PostProcess id in the pipeline
  140396. */
  140397. HighlightsEnhancingEffect: string;
  140398. /**
  140399. * @ignore
  140400. * The depth-of-field PostProcess id in the pipeline
  140401. */
  140402. LensDepthOfFieldEffect: string;
  140403. private _scene;
  140404. private _depthTexture;
  140405. private _grainTexture;
  140406. private _chromaticAberrationPostProcess;
  140407. private _highlightsPostProcess;
  140408. private _depthOfFieldPostProcess;
  140409. private _edgeBlur;
  140410. private _grainAmount;
  140411. private _chromaticAberration;
  140412. private _distortion;
  140413. private _highlightsGain;
  140414. private _highlightsThreshold;
  140415. private _dofDistance;
  140416. private _dofAperture;
  140417. private _dofDarken;
  140418. private _dofPentagon;
  140419. private _blurNoise;
  140420. /**
  140421. * @constructor
  140422. *
  140423. * Effect parameters are as follow:
  140424. * {
  140425. * chromatic_aberration: number; // from 0 to x (1 for realism)
  140426. * edge_blur: number; // from 0 to x (1 for realism)
  140427. * distortion: number; // from 0 to x (1 for realism)
  140428. * grain_amount: number; // from 0 to 1
  140429. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  140430. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  140431. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  140432. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  140433. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  140434. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  140435. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  140436. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  140437. * }
  140438. * Note: if an effect parameter is unset, effect is disabled
  140439. *
  140440. * @param name The rendering pipeline name
  140441. * @param parameters - An object containing all parameters (see above)
  140442. * @param scene The scene linked to this pipeline
  140443. * @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)
  140444. * @param cameras The array of cameras that the rendering pipeline will be attached to
  140445. */
  140446. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  140447. /**
  140448. * Get the class name
  140449. * @returns "LensRenderingPipeline"
  140450. */
  140451. getClassName(): string;
  140452. /**
  140453. * Gets associated scene
  140454. */
  140455. get scene(): Scene;
  140456. /**
  140457. * Gets or sets the edge blur
  140458. */
  140459. get edgeBlur(): number;
  140460. set edgeBlur(value: number);
  140461. /**
  140462. * Gets or sets the grain amount
  140463. */
  140464. get grainAmount(): number;
  140465. set grainAmount(value: number);
  140466. /**
  140467. * Gets or sets the chromatic aberration amount
  140468. */
  140469. get chromaticAberration(): number;
  140470. set chromaticAberration(value: number);
  140471. /**
  140472. * Gets or sets the depth of field aperture
  140473. */
  140474. get dofAperture(): number;
  140475. set dofAperture(value: number);
  140476. /**
  140477. * Gets or sets the edge distortion
  140478. */
  140479. get edgeDistortion(): number;
  140480. set edgeDistortion(value: number);
  140481. /**
  140482. * Gets or sets the depth of field distortion
  140483. */
  140484. get dofDistortion(): number;
  140485. set dofDistortion(value: number);
  140486. /**
  140487. * Gets or sets the darken out of focus amount
  140488. */
  140489. get darkenOutOfFocus(): number;
  140490. set darkenOutOfFocus(value: number);
  140491. /**
  140492. * Gets or sets a boolean indicating if blur noise is enabled
  140493. */
  140494. get blurNoise(): boolean;
  140495. set blurNoise(value: boolean);
  140496. /**
  140497. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  140498. */
  140499. get pentagonBokeh(): boolean;
  140500. set pentagonBokeh(value: boolean);
  140501. /**
  140502. * Gets or sets the highlight grain amount
  140503. */
  140504. get highlightsGain(): number;
  140505. set highlightsGain(value: number);
  140506. /**
  140507. * Gets or sets the highlight threshold
  140508. */
  140509. get highlightsThreshold(): number;
  140510. set highlightsThreshold(value: number);
  140511. /**
  140512. * Sets the amount of blur at the edges
  140513. * @param amount blur amount
  140514. */
  140515. setEdgeBlur(amount: number): void;
  140516. /**
  140517. * Sets edge blur to 0
  140518. */
  140519. disableEdgeBlur(): void;
  140520. /**
  140521. * Sets the amout of grain
  140522. * @param amount Amount of grain
  140523. */
  140524. setGrainAmount(amount: number): void;
  140525. /**
  140526. * Set grain amount to 0
  140527. */
  140528. disableGrain(): void;
  140529. /**
  140530. * Sets the chromatic aberration amount
  140531. * @param amount amount of chromatic aberration
  140532. */
  140533. setChromaticAberration(amount: number): void;
  140534. /**
  140535. * Sets chromatic aberration amount to 0
  140536. */
  140537. disableChromaticAberration(): void;
  140538. /**
  140539. * Sets the EdgeDistortion amount
  140540. * @param amount amount of EdgeDistortion
  140541. */
  140542. setEdgeDistortion(amount: number): void;
  140543. /**
  140544. * Sets edge distortion to 0
  140545. */
  140546. disableEdgeDistortion(): void;
  140547. /**
  140548. * Sets the FocusDistance amount
  140549. * @param amount amount of FocusDistance
  140550. */
  140551. setFocusDistance(amount: number): void;
  140552. /**
  140553. * Disables depth of field
  140554. */
  140555. disableDepthOfField(): void;
  140556. /**
  140557. * Sets the Aperture amount
  140558. * @param amount amount of Aperture
  140559. */
  140560. setAperture(amount: number): void;
  140561. /**
  140562. * Sets the DarkenOutOfFocus amount
  140563. * @param amount amount of DarkenOutOfFocus
  140564. */
  140565. setDarkenOutOfFocus(amount: number): void;
  140566. private _pentagonBokehIsEnabled;
  140567. /**
  140568. * Creates a pentagon bokeh effect
  140569. */
  140570. enablePentagonBokeh(): void;
  140571. /**
  140572. * Disables the pentagon bokeh effect
  140573. */
  140574. disablePentagonBokeh(): void;
  140575. /**
  140576. * Enables noise blur
  140577. */
  140578. enableNoiseBlur(): void;
  140579. /**
  140580. * Disables noise blur
  140581. */
  140582. disableNoiseBlur(): void;
  140583. /**
  140584. * Sets the HighlightsGain amount
  140585. * @param amount amount of HighlightsGain
  140586. */
  140587. setHighlightsGain(amount: number): void;
  140588. /**
  140589. * Sets the HighlightsThreshold amount
  140590. * @param amount amount of HighlightsThreshold
  140591. */
  140592. setHighlightsThreshold(amount: number): void;
  140593. /**
  140594. * Disables highlights
  140595. */
  140596. disableHighlights(): void;
  140597. /**
  140598. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  140599. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  140600. */
  140601. dispose(disableDepthRender?: boolean): void;
  140602. private _createChromaticAberrationPostProcess;
  140603. private _createHighlightsPostProcess;
  140604. private _createDepthOfFieldPostProcess;
  140605. private _createGrainTexture;
  140606. }
  140607. }
  140608. declare module BABYLON {
  140609. /** @hidden */
  140610. export var ssao2PixelShader: {
  140611. name: string;
  140612. shader: string;
  140613. };
  140614. }
  140615. declare module BABYLON {
  140616. /** @hidden */
  140617. export var ssaoCombinePixelShader: {
  140618. name: string;
  140619. shader: string;
  140620. };
  140621. }
  140622. declare module BABYLON {
  140623. /**
  140624. * Render pipeline to produce ssao effect
  140625. */
  140626. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  140627. /**
  140628. * @ignore
  140629. * The PassPostProcess id in the pipeline that contains the original scene color
  140630. */
  140631. SSAOOriginalSceneColorEffect: string;
  140632. /**
  140633. * @ignore
  140634. * The SSAO PostProcess id in the pipeline
  140635. */
  140636. SSAORenderEffect: string;
  140637. /**
  140638. * @ignore
  140639. * The horizontal blur PostProcess id in the pipeline
  140640. */
  140641. SSAOBlurHRenderEffect: string;
  140642. /**
  140643. * @ignore
  140644. * The vertical blur PostProcess id in the pipeline
  140645. */
  140646. SSAOBlurVRenderEffect: string;
  140647. /**
  140648. * @ignore
  140649. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  140650. */
  140651. SSAOCombineRenderEffect: string;
  140652. /**
  140653. * The output strength of the SSAO post-process. Default value is 1.0.
  140654. */
  140655. totalStrength: number;
  140656. /**
  140657. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  140658. */
  140659. maxZ: number;
  140660. /**
  140661. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  140662. */
  140663. minZAspect: number;
  140664. private _samples;
  140665. /**
  140666. * Number of samples used for the SSAO calculations. Default value is 8
  140667. */
  140668. set samples(n: number);
  140669. get samples(): number;
  140670. private _textureSamples;
  140671. /**
  140672. * Number of samples to use for antialiasing
  140673. */
  140674. set textureSamples(n: number);
  140675. get textureSamples(): number;
  140676. /**
  140677. * Ratio object used for SSAO ratio and blur ratio
  140678. */
  140679. private _ratio;
  140680. /**
  140681. * Dynamically generated sphere sampler.
  140682. */
  140683. private _sampleSphere;
  140684. /**
  140685. * Blur filter offsets
  140686. */
  140687. private _samplerOffsets;
  140688. private _expensiveBlur;
  140689. /**
  140690. * If bilateral blur should be used
  140691. */
  140692. set expensiveBlur(b: boolean);
  140693. get expensiveBlur(): boolean;
  140694. /**
  140695. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  140696. */
  140697. radius: number;
  140698. /**
  140699. * The base color of the SSAO post-process
  140700. * The final result is "base + ssao" between [0, 1]
  140701. */
  140702. base: number;
  140703. /**
  140704. * Support test.
  140705. */
  140706. static get IsSupported(): boolean;
  140707. private _scene;
  140708. private _depthTexture;
  140709. private _normalTexture;
  140710. private _randomTexture;
  140711. private _originalColorPostProcess;
  140712. private _ssaoPostProcess;
  140713. private _blurHPostProcess;
  140714. private _blurVPostProcess;
  140715. private _ssaoCombinePostProcess;
  140716. /**
  140717. * Gets active scene
  140718. */
  140719. get scene(): Scene;
  140720. /**
  140721. * @constructor
  140722. * @param name The rendering pipeline name
  140723. * @param scene The scene linked to this pipeline
  140724. * @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 }
  140725. * @param cameras The array of cameras that the rendering pipeline will be attached to
  140726. */
  140727. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  140728. /**
  140729. * Get the class name
  140730. * @returns "SSAO2RenderingPipeline"
  140731. */
  140732. getClassName(): string;
  140733. /**
  140734. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  140735. */
  140736. dispose(disableGeometryBufferRenderer?: boolean): void;
  140737. private _createBlurPostProcess;
  140738. /** @hidden */
  140739. _rebuild(): void;
  140740. private _bits;
  140741. private _radicalInverse_VdC;
  140742. private _hammersley;
  140743. private _hemisphereSample_uniform;
  140744. private _generateHemisphere;
  140745. private _createSSAOPostProcess;
  140746. private _createSSAOCombinePostProcess;
  140747. private _createRandomTexture;
  140748. /**
  140749. * Serialize the rendering pipeline (Used when exporting)
  140750. * @returns the serialized object
  140751. */
  140752. serialize(): any;
  140753. /**
  140754. * Parse the serialized pipeline
  140755. * @param source Source pipeline.
  140756. * @param scene The scene to load the pipeline to.
  140757. * @param rootUrl The URL of the serialized pipeline.
  140758. * @returns An instantiated pipeline from the serialized object.
  140759. */
  140760. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  140761. }
  140762. }
  140763. declare module BABYLON {
  140764. /** @hidden */
  140765. export var ssaoPixelShader: {
  140766. name: string;
  140767. shader: string;
  140768. };
  140769. }
  140770. declare module BABYLON {
  140771. /**
  140772. * Render pipeline to produce ssao effect
  140773. */
  140774. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  140775. /**
  140776. * @ignore
  140777. * The PassPostProcess id in the pipeline that contains the original scene color
  140778. */
  140779. SSAOOriginalSceneColorEffect: string;
  140780. /**
  140781. * @ignore
  140782. * The SSAO PostProcess id in the pipeline
  140783. */
  140784. SSAORenderEffect: string;
  140785. /**
  140786. * @ignore
  140787. * The horizontal blur PostProcess id in the pipeline
  140788. */
  140789. SSAOBlurHRenderEffect: string;
  140790. /**
  140791. * @ignore
  140792. * The vertical blur PostProcess id in the pipeline
  140793. */
  140794. SSAOBlurVRenderEffect: string;
  140795. /**
  140796. * @ignore
  140797. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  140798. */
  140799. SSAOCombineRenderEffect: string;
  140800. /**
  140801. * The output strength of the SSAO post-process. Default value is 1.0.
  140802. */
  140803. totalStrength: number;
  140804. /**
  140805. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  140806. */
  140807. radius: number;
  140808. /**
  140809. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  140810. * Must not be equal to fallOff and superior to fallOff.
  140811. * Default value is 0.0075
  140812. */
  140813. area: number;
  140814. /**
  140815. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  140816. * Must not be equal to area and inferior to area.
  140817. * Default value is 0.000001
  140818. */
  140819. fallOff: number;
  140820. /**
  140821. * The base color of the SSAO post-process
  140822. * The final result is "base + ssao" between [0, 1]
  140823. */
  140824. base: number;
  140825. private _scene;
  140826. private _depthTexture;
  140827. private _randomTexture;
  140828. private _originalColorPostProcess;
  140829. private _ssaoPostProcess;
  140830. private _blurHPostProcess;
  140831. private _blurVPostProcess;
  140832. private _ssaoCombinePostProcess;
  140833. private _firstUpdate;
  140834. /**
  140835. * Gets active scene
  140836. */
  140837. get scene(): Scene;
  140838. /**
  140839. * @constructor
  140840. * @param name - The rendering pipeline name
  140841. * @param scene - The scene linked to this pipeline
  140842. * @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 }
  140843. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  140844. */
  140845. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  140846. /**
  140847. * Get the class name
  140848. * @returns "SSAORenderingPipeline"
  140849. */
  140850. getClassName(): string;
  140851. /**
  140852. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  140853. */
  140854. dispose(disableDepthRender?: boolean): void;
  140855. private _createBlurPostProcess;
  140856. /** @hidden */
  140857. _rebuild(): void;
  140858. private _createSSAOPostProcess;
  140859. private _createSSAOCombinePostProcess;
  140860. private _createRandomTexture;
  140861. }
  140862. }
  140863. declare module BABYLON {
  140864. /** @hidden */
  140865. export var screenSpaceReflectionPixelShader: {
  140866. name: string;
  140867. shader: string;
  140868. };
  140869. }
  140870. declare module BABYLON {
  140871. /**
  140872. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  140873. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  140874. */
  140875. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  140876. /**
  140877. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  140878. */
  140879. threshold: number;
  140880. /**
  140881. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  140882. */
  140883. strength: number;
  140884. /**
  140885. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  140886. */
  140887. reflectionSpecularFalloffExponent: number;
  140888. /**
  140889. * 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]
  140890. */
  140891. step: number;
  140892. /**
  140893. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  140894. */
  140895. roughnessFactor: number;
  140896. private _geometryBufferRenderer;
  140897. private _enableSmoothReflections;
  140898. private _reflectionSamples;
  140899. private _smoothSteps;
  140900. /**
  140901. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  140902. * @param name The name of the effect.
  140903. * @param scene The scene containing the objects to calculate reflections.
  140904. * @param options The required width/height ratio to downsize to before computing the render pass.
  140905. * @param camera The camera to apply the render pass to.
  140906. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  140907. * @param engine The engine which the post process will be applied. (default: current engine)
  140908. * @param reusable If the post process can be reused on the same frame. (default: false)
  140909. * @param textureType Type of textures used when performing the post process. (default: 0)
  140910. * @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)
  140911. */
  140912. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  140913. /**
  140914. * Gets wether or not smoothing reflections is enabled.
  140915. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  140916. */
  140917. get enableSmoothReflections(): boolean;
  140918. /**
  140919. * Sets wether or not smoothing reflections is enabled.
  140920. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  140921. */
  140922. set enableSmoothReflections(enabled: boolean);
  140923. /**
  140924. * Gets the number of samples taken while computing reflections. More samples count is high,
  140925. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  140926. */
  140927. get reflectionSamples(): number;
  140928. /**
  140929. * Sets the number of samples taken while computing reflections. More samples count is high,
  140930. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  140931. */
  140932. set reflectionSamples(samples: number);
  140933. /**
  140934. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  140935. * more the post-process will require GPU power and can generate a drop in FPS.
  140936. * Default value (5.0) work pretty well in all cases but can be adjusted.
  140937. */
  140938. get smoothSteps(): number;
  140939. set smoothSteps(steps: number);
  140940. private _updateEffectDefines;
  140941. }
  140942. }
  140943. declare module BABYLON {
  140944. /** @hidden */
  140945. export var standardPixelShader: {
  140946. name: string;
  140947. shader: string;
  140948. };
  140949. }
  140950. declare module BABYLON {
  140951. /**
  140952. * Standard rendering pipeline
  140953. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  140954. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  140955. */
  140956. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  140957. /**
  140958. * Public members
  140959. */
  140960. /**
  140961. * Post-process which contains the original scene color before the pipeline applies all the effects
  140962. */
  140963. originalPostProcess: Nullable<PostProcess>;
  140964. /**
  140965. * Post-process used to down scale an image x4
  140966. */
  140967. downSampleX4PostProcess: Nullable<PostProcess>;
  140968. /**
  140969. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  140970. */
  140971. brightPassPostProcess: Nullable<PostProcess>;
  140972. /**
  140973. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  140974. */
  140975. blurHPostProcesses: PostProcess[];
  140976. /**
  140977. * Post-process array storing all the vertical blur post-processes used by the pipeline
  140978. */
  140979. blurVPostProcesses: PostProcess[];
  140980. /**
  140981. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  140982. */
  140983. textureAdderPostProcess: Nullable<PostProcess>;
  140984. /**
  140985. * Post-process used to create volumetric lighting effect
  140986. */
  140987. volumetricLightPostProcess: Nullable<PostProcess>;
  140988. /**
  140989. * Post-process used to smooth the previous volumetric light post-process on the X axis
  140990. */
  140991. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  140992. /**
  140993. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  140994. */
  140995. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  140996. /**
  140997. * Post-process used to merge the volumetric light effect and the real scene color
  140998. */
  140999. volumetricLightMergePostProces: Nullable<PostProcess>;
  141000. /**
  141001. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  141002. */
  141003. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  141004. /**
  141005. * Base post-process used to calculate the average luminance of the final image for HDR
  141006. */
  141007. luminancePostProcess: Nullable<PostProcess>;
  141008. /**
  141009. * Post-processes used to create down sample post-processes in order to get
  141010. * the average luminance of the final image for HDR
  141011. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  141012. */
  141013. luminanceDownSamplePostProcesses: PostProcess[];
  141014. /**
  141015. * Post-process used to create a HDR effect (light adaptation)
  141016. */
  141017. hdrPostProcess: Nullable<PostProcess>;
  141018. /**
  141019. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  141020. */
  141021. textureAdderFinalPostProcess: Nullable<PostProcess>;
  141022. /**
  141023. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  141024. */
  141025. lensFlareFinalPostProcess: Nullable<PostProcess>;
  141026. /**
  141027. * Post-process used to merge the final HDR post-process and the real scene color
  141028. */
  141029. hdrFinalPostProcess: Nullable<PostProcess>;
  141030. /**
  141031. * Post-process used to create a lens flare effect
  141032. */
  141033. lensFlarePostProcess: Nullable<PostProcess>;
  141034. /**
  141035. * Post-process that merges the result of the lens flare post-process and the real scene color
  141036. */
  141037. lensFlareComposePostProcess: Nullable<PostProcess>;
  141038. /**
  141039. * Post-process used to create a motion blur effect
  141040. */
  141041. motionBlurPostProcess: Nullable<PostProcess>;
  141042. /**
  141043. * Post-process used to create a depth of field effect
  141044. */
  141045. depthOfFieldPostProcess: Nullable<PostProcess>;
  141046. /**
  141047. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  141048. */
  141049. fxaaPostProcess: Nullable<FxaaPostProcess>;
  141050. /**
  141051. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  141052. */
  141053. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  141054. /**
  141055. * Represents the brightness threshold in order to configure the illuminated surfaces
  141056. */
  141057. brightThreshold: number;
  141058. /**
  141059. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  141060. */
  141061. blurWidth: number;
  141062. /**
  141063. * Sets if the blur for highlighted surfaces must be only horizontal
  141064. */
  141065. horizontalBlur: boolean;
  141066. /**
  141067. * Gets the overall exposure used by the pipeline
  141068. */
  141069. get exposure(): number;
  141070. /**
  141071. * Sets the overall exposure used by the pipeline
  141072. */
  141073. set exposure(value: number);
  141074. /**
  141075. * Texture used typically to simulate "dirty" on camera lens
  141076. */
  141077. lensTexture: Nullable<Texture>;
  141078. /**
  141079. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  141080. */
  141081. volumetricLightCoefficient: number;
  141082. /**
  141083. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  141084. */
  141085. volumetricLightPower: number;
  141086. /**
  141087. * Used the set the blur intensity to smooth the volumetric lights
  141088. */
  141089. volumetricLightBlurScale: number;
  141090. /**
  141091. * Light (spot or directional) used to generate the volumetric lights rays
  141092. * The source light must have a shadow generate so the pipeline can get its
  141093. * depth map
  141094. */
  141095. sourceLight: Nullable<SpotLight | DirectionalLight>;
  141096. /**
  141097. * For eye adaptation, represents the minimum luminance the eye can see
  141098. */
  141099. hdrMinimumLuminance: number;
  141100. /**
  141101. * For eye adaptation, represents the decrease luminance speed
  141102. */
  141103. hdrDecreaseRate: number;
  141104. /**
  141105. * For eye adaptation, represents the increase luminance speed
  141106. */
  141107. hdrIncreaseRate: number;
  141108. /**
  141109. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  141110. */
  141111. get hdrAutoExposure(): boolean;
  141112. /**
  141113. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  141114. */
  141115. set hdrAutoExposure(value: boolean);
  141116. /**
  141117. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  141118. */
  141119. lensColorTexture: Nullable<Texture>;
  141120. /**
  141121. * The overall strengh for the lens flare effect
  141122. */
  141123. lensFlareStrength: number;
  141124. /**
  141125. * Dispersion coefficient for lens flare ghosts
  141126. */
  141127. lensFlareGhostDispersal: number;
  141128. /**
  141129. * Main lens flare halo width
  141130. */
  141131. lensFlareHaloWidth: number;
  141132. /**
  141133. * Based on the lens distortion effect, defines how much the lens flare result
  141134. * is distorted
  141135. */
  141136. lensFlareDistortionStrength: number;
  141137. /**
  141138. * Configures the blur intensity used for for lens flare (halo)
  141139. */
  141140. lensFlareBlurWidth: number;
  141141. /**
  141142. * Lens star texture must be used to simulate rays on the flares and is available
  141143. * in the documentation
  141144. */
  141145. lensStarTexture: Nullable<Texture>;
  141146. /**
  141147. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  141148. * flare effect by taking account of the dirt texture
  141149. */
  141150. lensFlareDirtTexture: Nullable<Texture>;
  141151. /**
  141152. * Represents the focal length for the depth of field effect
  141153. */
  141154. depthOfFieldDistance: number;
  141155. /**
  141156. * Represents the blur intensity for the blurred part of the depth of field effect
  141157. */
  141158. depthOfFieldBlurWidth: number;
  141159. /**
  141160. * Gets how much the image is blurred by the movement while using the motion blur post-process
  141161. */
  141162. get motionStrength(): number;
  141163. /**
  141164. * Sets how much the image is blurred by the movement while using the motion blur post-process
  141165. */
  141166. set motionStrength(strength: number);
  141167. /**
  141168. * Gets wether or not the motion blur post-process is object based or screen based.
  141169. */
  141170. get objectBasedMotionBlur(): boolean;
  141171. /**
  141172. * Sets wether or not the motion blur post-process should be object based or screen based
  141173. */
  141174. set objectBasedMotionBlur(value: boolean);
  141175. /**
  141176. * List of animations for the pipeline (IAnimatable implementation)
  141177. */
  141178. animations: Animation[];
  141179. /**
  141180. * Private members
  141181. */
  141182. private _scene;
  141183. private _currentDepthOfFieldSource;
  141184. private _basePostProcess;
  141185. private _fixedExposure;
  141186. private _currentExposure;
  141187. private _hdrAutoExposure;
  141188. private _hdrCurrentLuminance;
  141189. private _motionStrength;
  141190. private _isObjectBasedMotionBlur;
  141191. private _floatTextureType;
  141192. private _camerasToBeAttached;
  141193. private _ratio;
  141194. private _bloomEnabled;
  141195. private _depthOfFieldEnabled;
  141196. private _vlsEnabled;
  141197. private _lensFlareEnabled;
  141198. private _hdrEnabled;
  141199. private _motionBlurEnabled;
  141200. private _fxaaEnabled;
  141201. private _screenSpaceReflectionsEnabled;
  141202. private _motionBlurSamples;
  141203. private _volumetricLightStepsCount;
  141204. private _samples;
  141205. /**
  141206. * @ignore
  141207. * Specifies if the bloom pipeline is enabled
  141208. */
  141209. get BloomEnabled(): boolean;
  141210. set BloomEnabled(enabled: boolean);
  141211. /**
  141212. * @ignore
  141213. * Specifies if the depth of field pipeline is enabed
  141214. */
  141215. get DepthOfFieldEnabled(): boolean;
  141216. set DepthOfFieldEnabled(enabled: boolean);
  141217. /**
  141218. * @ignore
  141219. * Specifies if the lens flare pipeline is enabed
  141220. */
  141221. get LensFlareEnabled(): boolean;
  141222. set LensFlareEnabled(enabled: boolean);
  141223. /**
  141224. * @ignore
  141225. * Specifies if the HDR pipeline is enabled
  141226. */
  141227. get HDREnabled(): boolean;
  141228. set HDREnabled(enabled: boolean);
  141229. /**
  141230. * @ignore
  141231. * Specifies if the volumetric lights scattering effect is enabled
  141232. */
  141233. get VLSEnabled(): boolean;
  141234. set VLSEnabled(enabled: boolean);
  141235. /**
  141236. * @ignore
  141237. * Specifies if the motion blur effect is enabled
  141238. */
  141239. get MotionBlurEnabled(): boolean;
  141240. set MotionBlurEnabled(enabled: boolean);
  141241. /**
  141242. * Specifies if anti-aliasing is enabled
  141243. */
  141244. get fxaaEnabled(): boolean;
  141245. set fxaaEnabled(enabled: boolean);
  141246. /**
  141247. * Specifies if screen space reflections are enabled.
  141248. */
  141249. get screenSpaceReflectionsEnabled(): boolean;
  141250. set screenSpaceReflectionsEnabled(enabled: boolean);
  141251. /**
  141252. * Specifies the number of steps used to calculate the volumetric lights
  141253. * Typically in interval [50, 200]
  141254. */
  141255. get volumetricLightStepsCount(): number;
  141256. set volumetricLightStepsCount(count: number);
  141257. /**
  141258. * Specifies the number of samples used for the motion blur effect
  141259. * Typically in interval [16, 64]
  141260. */
  141261. get motionBlurSamples(): number;
  141262. set motionBlurSamples(samples: number);
  141263. /**
  141264. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  141265. */
  141266. get samples(): number;
  141267. set samples(sampleCount: number);
  141268. /**
  141269. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  141270. * @constructor
  141271. * @param name The rendering pipeline name
  141272. * @param scene The scene linked to this pipeline
  141273. * @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)
  141274. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  141275. * @param cameras The array of cameras that the rendering pipeline will be attached to
  141276. */
  141277. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  141278. private _buildPipeline;
  141279. private _createDownSampleX4PostProcess;
  141280. private _createBrightPassPostProcess;
  141281. private _createBlurPostProcesses;
  141282. private _createTextureAdderPostProcess;
  141283. private _createVolumetricLightPostProcess;
  141284. private _createLuminancePostProcesses;
  141285. private _createHdrPostProcess;
  141286. private _createLensFlarePostProcess;
  141287. private _createDepthOfFieldPostProcess;
  141288. private _createMotionBlurPostProcess;
  141289. private _getDepthTexture;
  141290. private _disposePostProcesses;
  141291. /**
  141292. * Dispose of the pipeline and stop all post processes
  141293. */
  141294. dispose(): void;
  141295. /**
  141296. * Serialize the rendering pipeline (Used when exporting)
  141297. * @returns the serialized object
  141298. */
  141299. serialize(): any;
  141300. /**
  141301. * Parse the serialized pipeline
  141302. * @param source Source pipeline.
  141303. * @param scene The scene to load the pipeline to.
  141304. * @param rootUrl The URL of the serialized pipeline.
  141305. * @returns An instantiated pipeline from the serialized object.
  141306. */
  141307. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  141308. /**
  141309. * Luminance steps
  141310. */
  141311. static LuminanceSteps: number;
  141312. }
  141313. }
  141314. declare module BABYLON {
  141315. /** @hidden */
  141316. export var tonemapPixelShader: {
  141317. name: string;
  141318. shader: string;
  141319. };
  141320. }
  141321. declare module BABYLON {
  141322. /** Defines operator used for tonemapping */
  141323. export enum TonemappingOperator {
  141324. /** Hable */
  141325. Hable = 0,
  141326. /** Reinhard */
  141327. Reinhard = 1,
  141328. /** HejiDawson */
  141329. HejiDawson = 2,
  141330. /** Photographic */
  141331. Photographic = 3
  141332. }
  141333. /**
  141334. * Defines a post process to apply tone mapping
  141335. */
  141336. export class TonemapPostProcess extends PostProcess {
  141337. private _operator;
  141338. /** Defines the required exposure adjustement */
  141339. exposureAdjustment: number;
  141340. /**
  141341. * Creates a new TonemapPostProcess
  141342. * @param name defines the name of the postprocess
  141343. * @param _operator defines the operator to use
  141344. * @param exposureAdjustment defines the required exposure adjustement
  141345. * @param camera defines the camera to use (can be null)
  141346. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  141347. * @param engine defines the hosting engine (can be ignore if camera is set)
  141348. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  141349. */
  141350. constructor(name: string, _operator: TonemappingOperator,
  141351. /** Defines the required exposure adjustement */
  141352. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  141353. }
  141354. }
  141355. declare module BABYLON {
  141356. /** @hidden */
  141357. export var volumetricLightScatteringPixelShader: {
  141358. name: string;
  141359. shader: string;
  141360. };
  141361. }
  141362. declare module BABYLON {
  141363. /** @hidden */
  141364. export var volumetricLightScatteringPassVertexShader: {
  141365. name: string;
  141366. shader: string;
  141367. };
  141368. }
  141369. declare module BABYLON {
  141370. /** @hidden */
  141371. export var volumetricLightScatteringPassPixelShader: {
  141372. name: string;
  141373. shader: string;
  141374. };
  141375. }
  141376. declare module BABYLON {
  141377. /**
  141378. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  141379. */
  141380. export class VolumetricLightScatteringPostProcess extends PostProcess {
  141381. private _volumetricLightScatteringPass;
  141382. private _volumetricLightScatteringRTT;
  141383. private _viewPort;
  141384. private _screenCoordinates;
  141385. private _cachedDefines;
  141386. /**
  141387. * If not undefined, the mesh position is computed from the attached node position
  141388. */
  141389. attachedNode: {
  141390. position: Vector3;
  141391. };
  141392. /**
  141393. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  141394. */
  141395. customMeshPosition: Vector3;
  141396. /**
  141397. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  141398. */
  141399. useCustomMeshPosition: boolean;
  141400. /**
  141401. * If the post-process should inverse the light scattering direction
  141402. */
  141403. invert: boolean;
  141404. /**
  141405. * The internal mesh used by the post-process
  141406. */
  141407. mesh: Mesh;
  141408. /**
  141409. * @hidden
  141410. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  141411. */
  141412. get useDiffuseColor(): boolean;
  141413. set useDiffuseColor(useDiffuseColor: boolean);
  141414. /**
  141415. * Array containing the excluded meshes not rendered in the internal pass
  141416. */
  141417. excludedMeshes: AbstractMesh[];
  141418. /**
  141419. * Controls the overall intensity of the post-process
  141420. */
  141421. exposure: number;
  141422. /**
  141423. * Dissipates each sample's contribution in range [0, 1]
  141424. */
  141425. decay: number;
  141426. /**
  141427. * Controls the overall intensity of each sample
  141428. */
  141429. weight: number;
  141430. /**
  141431. * Controls the density of each sample
  141432. */
  141433. density: number;
  141434. /**
  141435. * @constructor
  141436. * @param name The post-process name
  141437. * @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)
  141438. * @param camera The camera that the post-process will be attached to
  141439. * @param mesh The mesh used to create the light scattering
  141440. * @param samples The post-process quality, default 100
  141441. * @param samplingModeThe post-process filtering mode
  141442. * @param engine The babylon engine
  141443. * @param reusable If the post-process is reusable
  141444. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  141445. */
  141446. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  141447. /**
  141448. * Returns the string "VolumetricLightScatteringPostProcess"
  141449. * @returns "VolumetricLightScatteringPostProcess"
  141450. */
  141451. getClassName(): string;
  141452. private _isReady;
  141453. /**
  141454. * Sets the new light position for light scattering effect
  141455. * @param position The new custom light position
  141456. */
  141457. setCustomMeshPosition(position: Vector3): void;
  141458. /**
  141459. * Returns the light position for light scattering effect
  141460. * @return Vector3 The custom light position
  141461. */
  141462. getCustomMeshPosition(): Vector3;
  141463. /**
  141464. * Disposes the internal assets and detaches the post-process from the camera
  141465. */
  141466. dispose(camera: Camera): void;
  141467. /**
  141468. * Returns the render target texture used by the post-process
  141469. * @return the render target texture used by the post-process
  141470. */
  141471. getPass(): RenderTargetTexture;
  141472. private _meshExcluded;
  141473. private _createPass;
  141474. private _updateMeshScreenCoordinates;
  141475. /**
  141476. * Creates a default mesh for the Volumeric Light Scattering post-process
  141477. * @param name The mesh name
  141478. * @param scene The scene where to create the mesh
  141479. * @return the default mesh
  141480. */
  141481. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  141482. }
  141483. }
  141484. declare module BABYLON {
  141485. interface Scene {
  141486. /** @hidden (Backing field) */
  141487. _boundingBoxRenderer: BoundingBoxRenderer;
  141488. /** @hidden (Backing field) */
  141489. _forceShowBoundingBoxes: boolean;
  141490. /**
  141491. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  141492. */
  141493. forceShowBoundingBoxes: boolean;
  141494. /**
  141495. * Gets the bounding box renderer associated with the scene
  141496. * @returns a BoundingBoxRenderer
  141497. */
  141498. getBoundingBoxRenderer(): BoundingBoxRenderer;
  141499. }
  141500. interface AbstractMesh {
  141501. /** @hidden (Backing field) */
  141502. _showBoundingBox: boolean;
  141503. /**
  141504. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  141505. */
  141506. showBoundingBox: boolean;
  141507. }
  141508. /**
  141509. * Component responsible of rendering the bounding box of the meshes in a scene.
  141510. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  141511. */
  141512. export class BoundingBoxRenderer implements ISceneComponent {
  141513. /**
  141514. * The component name helpfull to identify the component in the list of scene components.
  141515. */
  141516. readonly name: string;
  141517. /**
  141518. * The scene the component belongs to.
  141519. */
  141520. scene: Scene;
  141521. /**
  141522. * Color of the bounding box lines placed in front of an object
  141523. */
  141524. frontColor: Color3;
  141525. /**
  141526. * Color of the bounding box lines placed behind an object
  141527. */
  141528. backColor: Color3;
  141529. /**
  141530. * Defines if the renderer should show the back lines or not
  141531. */
  141532. showBackLines: boolean;
  141533. /**
  141534. * @hidden
  141535. */
  141536. renderList: SmartArray<BoundingBox>;
  141537. private _colorShader;
  141538. private _vertexBuffers;
  141539. private _indexBuffer;
  141540. private _fillIndexBuffer;
  141541. private _fillIndexData;
  141542. /**
  141543. * Instantiates a new bounding box renderer in a scene.
  141544. * @param scene the scene the renderer renders in
  141545. */
  141546. constructor(scene: Scene);
  141547. /**
  141548. * Registers the component in a given scene
  141549. */
  141550. register(): void;
  141551. private _evaluateSubMesh;
  141552. private _activeMesh;
  141553. private _prepareRessources;
  141554. private _createIndexBuffer;
  141555. /**
  141556. * Rebuilds the elements related to this component in case of
  141557. * context lost for instance.
  141558. */
  141559. rebuild(): void;
  141560. /**
  141561. * @hidden
  141562. */
  141563. reset(): void;
  141564. /**
  141565. * Render the bounding boxes of a specific rendering group
  141566. * @param renderingGroupId defines the rendering group to render
  141567. */
  141568. render(renderingGroupId: number): void;
  141569. /**
  141570. * In case of occlusion queries, we can render the occlusion bounding box through this method
  141571. * @param mesh Define the mesh to render the occlusion bounding box for
  141572. */
  141573. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  141574. /**
  141575. * Dispose and release the resources attached to this renderer.
  141576. */
  141577. dispose(): void;
  141578. }
  141579. }
  141580. declare module BABYLON {
  141581. interface Scene {
  141582. /** @hidden (Backing field) */
  141583. _depthRenderer: {
  141584. [id: string]: DepthRenderer;
  141585. };
  141586. /**
  141587. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  141588. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  141589. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  141590. * @returns the created depth renderer
  141591. */
  141592. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  141593. /**
  141594. * Disables a depth renderer for a given camera
  141595. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  141596. */
  141597. disableDepthRenderer(camera?: Nullable<Camera>): void;
  141598. }
  141599. /**
  141600. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  141601. * in several rendering techniques.
  141602. */
  141603. export class DepthRendererSceneComponent implements ISceneComponent {
  141604. /**
  141605. * The component name helpfull to identify the component in the list of scene components.
  141606. */
  141607. readonly name: string;
  141608. /**
  141609. * The scene the component belongs to.
  141610. */
  141611. scene: Scene;
  141612. /**
  141613. * Creates a new instance of the component for the given scene
  141614. * @param scene Defines the scene to register the component in
  141615. */
  141616. constructor(scene: Scene);
  141617. /**
  141618. * Registers the component in a given scene
  141619. */
  141620. register(): void;
  141621. /**
  141622. * Rebuilds the elements related to this component in case of
  141623. * context lost for instance.
  141624. */
  141625. rebuild(): void;
  141626. /**
  141627. * Disposes the component and the associated ressources
  141628. */
  141629. dispose(): void;
  141630. private _gatherRenderTargets;
  141631. private _gatherActiveCameraRenderTargets;
  141632. }
  141633. }
  141634. declare module BABYLON {
  141635. /** @hidden */
  141636. export var outlinePixelShader: {
  141637. name: string;
  141638. shader: string;
  141639. };
  141640. }
  141641. declare module BABYLON {
  141642. /** @hidden */
  141643. export var outlineVertexShader: {
  141644. name: string;
  141645. shader: string;
  141646. };
  141647. }
  141648. declare module BABYLON {
  141649. interface Scene {
  141650. /** @hidden */
  141651. _outlineRenderer: OutlineRenderer;
  141652. /**
  141653. * Gets the outline renderer associated with the scene
  141654. * @returns a OutlineRenderer
  141655. */
  141656. getOutlineRenderer(): OutlineRenderer;
  141657. }
  141658. interface AbstractMesh {
  141659. /** @hidden (Backing field) */
  141660. _renderOutline: boolean;
  141661. /**
  141662. * Gets or sets a boolean indicating if the outline must be rendered as well
  141663. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  141664. */
  141665. renderOutline: boolean;
  141666. /** @hidden (Backing field) */
  141667. _renderOverlay: boolean;
  141668. /**
  141669. * Gets or sets a boolean indicating if the overlay must be rendered as well
  141670. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  141671. */
  141672. renderOverlay: boolean;
  141673. }
  141674. /**
  141675. * This class is responsible to draw bothe outline/overlay of meshes.
  141676. * It should not be used directly but through the available method on mesh.
  141677. */
  141678. export class OutlineRenderer implements ISceneComponent {
  141679. /**
  141680. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  141681. */
  141682. private static _StencilReference;
  141683. /**
  141684. * The name of the component. Each component must have a unique name.
  141685. */
  141686. name: string;
  141687. /**
  141688. * The scene the component belongs to.
  141689. */
  141690. scene: Scene;
  141691. /**
  141692. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  141693. */
  141694. zOffset: number;
  141695. private _engine;
  141696. private _effect;
  141697. private _cachedDefines;
  141698. private _savedDepthWrite;
  141699. /**
  141700. * Instantiates a new outline renderer. (There could be only one per scene).
  141701. * @param scene Defines the scene it belongs to
  141702. */
  141703. constructor(scene: Scene);
  141704. /**
  141705. * Register the component to one instance of a scene.
  141706. */
  141707. register(): void;
  141708. /**
  141709. * Rebuilds the elements related to this component in case of
  141710. * context lost for instance.
  141711. */
  141712. rebuild(): void;
  141713. /**
  141714. * Disposes the component and the associated ressources.
  141715. */
  141716. dispose(): void;
  141717. /**
  141718. * Renders the outline in the canvas.
  141719. * @param subMesh Defines the sumesh to render
  141720. * @param batch Defines the batch of meshes in case of instances
  141721. * @param useOverlay Defines if the rendering is for the overlay or the outline
  141722. */
  141723. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  141724. /**
  141725. * Returns whether or not the outline renderer is ready for a given submesh.
  141726. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  141727. * @param subMesh Defines the submesh to check readyness for
  141728. * @param useInstances Defines wheter wee are trying to render instances or not
  141729. * @returns true if ready otherwise false
  141730. */
  141731. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  141732. private _beforeRenderingMesh;
  141733. private _afterRenderingMesh;
  141734. }
  141735. }
  141736. declare module BABYLON {
  141737. /**
  141738. * Defines the basic options interface of a Sprite Frame Source Size.
  141739. */
  141740. export interface ISpriteJSONSpriteSourceSize {
  141741. /**
  141742. * number of the original width of the Frame
  141743. */
  141744. w: number;
  141745. /**
  141746. * number of the original height of the Frame
  141747. */
  141748. h: number;
  141749. }
  141750. /**
  141751. * Defines the basic options interface of a Sprite Frame Data.
  141752. */
  141753. export interface ISpriteJSONSpriteFrameData {
  141754. /**
  141755. * number of the x offset of the Frame
  141756. */
  141757. x: number;
  141758. /**
  141759. * number of the y offset of the Frame
  141760. */
  141761. y: number;
  141762. /**
  141763. * number of the width of the Frame
  141764. */
  141765. w: number;
  141766. /**
  141767. * number of the height of the Frame
  141768. */
  141769. h: number;
  141770. }
  141771. /**
  141772. * Defines the basic options interface of a JSON Sprite.
  141773. */
  141774. export interface ISpriteJSONSprite {
  141775. /**
  141776. * string name of the Frame
  141777. */
  141778. filename: string;
  141779. /**
  141780. * ISpriteJSONSpriteFrame basic object of the frame data
  141781. */
  141782. frame: ISpriteJSONSpriteFrameData;
  141783. /**
  141784. * boolean to flag is the frame was rotated.
  141785. */
  141786. rotated: boolean;
  141787. /**
  141788. * boolean to flag is the frame was trimmed.
  141789. */
  141790. trimmed: boolean;
  141791. /**
  141792. * ISpriteJSONSpriteFrame basic object of the source data
  141793. */
  141794. spriteSourceSize: ISpriteJSONSpriteFrameData;
  141795. /**
  141796. * ISpriteJSONSpriteFrame basic object of the source data
  141797. */
  141798. sourceSize: ISpriteJSONSpriteSourceSize;
  141799. }
  141800. /**
  141801. * Defines the basic options interface of a JSON atlas.
  141802. */
  141803. export interface ISpriteJSONAtlas {
  141804. /**
  141805. * Array of objects that contain the frame data.
  141806. */
  141807. frames: Array<ISpriteJSONSprite>;
  141808. /**
  141809. * object basic object containing the sprite meta data.
  141810. */
  141811. meta?: object;
  141812. }
  141813. }
  141814. declare module BABYLON {
  141815. /** @hidden */
  141816. export var spriteMapPixelShader: {
  141817. name: string;
  141818. shader: string;
  141819. };
  141820. }
  141821. declare module BABYLON {
  141822. /** @hidden */
  141823. export var spriteMapVertexShader: {
  141824. name: string;
  141825. shader: string;
  141826. };
  141827. }
  141828. declare module BABYLON {
  141829. /**
  141830. * Defines the basic options interface of a SpriteMap
  141831. */
  141832. export interface ISpriteMapOptions {
  141833. /**
  141834. * Vector2 of the number of cells in the grid.
  141835. */
  141836. stageSize?: Vector2;
  141837. /**
  141838. * Vector2 of the size of the output plane in World Units.
  141839. */
  141840. outputSize?: Vector2;
  141841. /**
  141842. * Vector3 of the position of the output plane in World Units.
  141843. */
  141844. outputPosition?: Vector3;
  141845. /**
  141846. * Vector3 of the rotation of the output plane.
  141847. */
  141848. outputRotation?: Vector3;
  141849. /**
  141850. * number of layers that the system will reserve in resources.
  141851. */
  141852. layerCount?: number;
  141853. /**
  141854. * number of max animation frames a single cell will reserve in resources.
  141855. */
  141856. maxAnimationFrames?: number;
  141857. /**
  141858. * number cell index of the base tile when the system compiles.
  141859. */
  141860. baseTile?: number;
  141861. /**
  141862. * boolean flip the sprite after its been repositioned by the framing data.
  141863. */
  141864. flipU?: boolean;
  141865. /**
  141866. * Vector3 scalar of the global RGB values of the SpriteMap.
  141867. */
  141868. colorMultiply?: Vector3;
  141869. }
  141870. /**
  141871. * Defines the IDisposable interface in order to be cleanable from resources.
  141872. */
  141873. export interface ISpriteMap extends IDisposable {
  141874. /**
  141875. * String name of the SpriteMap.
  141876. */
  141877. name: string;
  141878. /**
  141879. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  141880. */
  141881. atlasJSON: ISpriteJSONAtlas;
  141882. /**
  141883. * Texture of the SpriteMap.
  141884. */
  141885. spriteSheet: Texture;
  141886. /**
  141887. * The parameters to initialize the SpriteMap with.
  141888. */
  141889. options: ISpriteMapOptions;
  141890. }
  141891. /**
  141892. * Class used to manage a grid restricted sprite deployment on an Output plane.
  141893. */
  141894. export class SpriteMap implements ISpriteMap {
  141895. /** The Name of the spriteMap */
  141896. name: string;
  141897. /** The JSON file with the frame and meta data */
  141898. atlasJSON: ISpriteJSONAtlas;
  141899. /** The systems Sprite Sheet Texture */
  141900. spriteSheet: Texture;
  141901. /** Arguments passed with the Constructor */
  141902. options: ISpriteMapOptions;
  141903. /** Public Sprite Storage array, parsed from atlasJSON */
  141904. sprites: Array<ISpriteJSONSprite>;
  141905. /** Returns the Number of Sprites in the System */
  141906. get spriteCount(): number;
  141907. /** Returns the Position of Output Plane*/
  141908. get position(): Vector3;
  141909. /** Returns the Position of Output Plane*/
  141910. set position(v: Vector3);
  141911. /** Returns the Rotation of Output Plane*/
  141912. get rotation(): Vector3;
  141913. /** Returns the Rotation of Output Plane*/
  141914. set rotation(v: Vector3);
  141915. /** Sets the AnimationMap*/
  141916. get animationMap(): RawTexture;
  141917. /** Sets the AnimationMap*/
  141918. set animationMap(v: RawTexture);
  141919. /** Scene that the SpriteMap was created in */
  141920. private _scene;
  141921. /** Texture Buffer of Float32 that holds tile frame data*/
  141922. private _frameMap;
  141923. /** Texture Buffers of Float32 that holds tileMap data*/
  141924. private _tileMaps;
  141925. /** Texture Buffer of Float32 that holds Animation Data*/
  141926. private _animationMap;
  141927. /** Custom ShaderMaterial Central to the System*/
  141928. private _material;
  141929. /** Custom ShaderMaterial Central to the System*/
  141930. private _output;
  141931. /** Systems Time Ticker*/
  141932. private _time;
  141933. /**
  141934. * Creates a new SpriteMap
  141935. * @param name defines the SpriteMaps Name
  141936. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  141937. * @param spriteSheet is the Texture that the Sprites are on.
  141938. * @param options a basic deployment configuration
  141939. * @param scene The Scene that the map is deployed on
  141940. */
  141941. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  141942. /**
  141943. * Returns tileID location
  141944. * @returns Vector2 the cell position ID
  141945. */
  141946. getTileID(): Vector2;
  141947. /**
  141948. * Gets the UV location of the mouse over the SpriteMap.
  141949. * @returns Vector2 the UV position of the mouse interaction
  141950. */
  141951. getMousePosition(): Vector2;
  141952. /**
  141953. * Creates the "frame" texture Buffer
  141954. * -------------------------------------
  141955. * Structure of frames
  141956. * "filename": "Falling-Water-2.png",
  141957. * "frame": {"x":69,"y":103,"w":24,"h":32},
  141958. * "rotated": true,
  141959. * "trimmed": true,
  141960. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  141961. * "sourceSize": {"w":32,"h":32}
  141962. * @returns RawTexture of the frameMap
  141963. */
  141964. private _createFrameBuffer;
  141965. /**
  141966. * Creates the tileMap texture Buffer
  141967. * @param buffer normally and array of numbers, or a false to generate from scratch
  141968. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  141969. * @returns RawTexture of the tileMap
  141970. */
  141971. private _createTileBuffer;
  141972. /**
  141973. * Modifies the data of the tileMaps
  141974. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  141975. * @param pos is the iVector2 Coordinates of the Tile
  141976. * @param tile The SpriteIndex of the new Tile
  141977. */
  141978. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  141979. /**
  141980. * Creates the animationMap texture Buffer
  141981. * @param buffer normally and array of numbers, or a false to generate from scratch
  141982. * @returns RawTexture of the animationMap
  141983. */
  141984. private _createTileAnimationBuffer;
  141985. /**
  141986. * Modifies the data of the animationMap
  141987. * @param cellID is the Index of the Sprite
  141988. * @param _frame is the target Animation frame
  141989. * @param toCell is the Target Index of the next frame of the animation
  141990. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  141991. * @param speed is a global scalar of the time variable on the map.
  141992. */
  141993. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  141994. /**
  141995. * Exports the .tilemaps file
  141996. */
  141997. saveTileMaps(): void;
  141998. /**
  141999. * Imports the .tilemaps file
  142000. * @param url of the .tilemaps file
  142001. */
  142002. loadTileMaps(url: string): void;
  142003. /**
  142004. * Release associated resources
  142005. */
  142006. dispose(): void;
  142007. }
  142008. }
  142009. declare module BABYLON {
  142010. /**
  142011. * Class used to manage multiple sprites of different sizes on the same spritesheet
  142012. * @see http://doc.babylonjs.com/babylon101/sprites
  142013. */
  142014. export class SpritePackedManager extends SpriteManager {
  142015. /** defines the packed manager's name */
  142016. name: string;
  142017. /**
  142018. * Creates a new sprite manager from a packed sprite sheet
  142019. * @param name defines the manager's name
  142020. * @param imgUrl defines the sprite sheet url
  142021. * @param capacity defines the maximum allowed number of sprites
  142022. * @param scene defines the hosting scene
  142023. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  142024. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  142025. * @param samplingMode defines the smapling mode to use with spritesheet
  142026. * @param fromPacked set to true; do not alter
  142027. */
  142028. constructor(
  142029. /** defines the packed manager's name */
  142030. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  142031. }
  142032. }
  142033. declare module BABYLON {
  142034. /**
  142035. * Defines the list of states available for a task inside a AssetsManager
  142036. */
  142037. export enum AssetTaskState {
  142038. /**
  142039. * Initialization
  142040. */
  142041. INIT = 0,
  142042. /**
  142043. * Running
  142044. */
  142045. RUNNING = 1,
  142046. /**
  142047. * Done
  142048. */
  142049. DONE = 2,
  142050. /**
  142051. * Error
  142052. */
  142053. ERROR = 3
  142054. }
  142055. /**
  142056. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  142057. */
  142058. export abstract class AbstractAssetTask {
  142059. /**
  142060. * Task name
  142061. */ name: string;
  142062. /**
  142063. * Callback called when the task is successful
  142064. */
  142065. onSuccess: (task: any) => void;
  142066. /**
  142067. * Callback called when the task is not successful
  142068. */
  142069. onError: (task: any, message?: string, exception?: any) => void;
  142070. /**
  142071. * Creates a new AssetsManager
  142072. * @param name defines the name of the task
  142073. */
  142074. constructor(
  142075. /**
  142076. * Task name
  142077. */ name: string);
  142078. private _isCompleted;
  142079. private _taskState;
  142080. private _errorObject;
  142081. /**
  142082. * Get if the task is completed
  142083. */
  142084. get isCompleted(): boolean;
  142085. /**
  142086. * Gets the current state of the task
  142087. */
  142088. get taskState(): AssetTaskState;
  142089. /**
  142090. * Gets the current error object (if task is in error)
  142091. */
  142092. get errorObject(): {
  142093. message?: string;
  142094. exception?: any;
  142095. };
  142096. /**
  142097. * Internal only
  142098. * @hidden
  142099. */
  142100. _setErrorObject(message?: string, exception?: any): void;
  142101. /**
  142102. * Execute the current task
  142103. * @param scene defines the scene where you want your assets to be loaded
  142104. * @param onSuccess is a callback called when the task is successfully executed
  142105. * @param onError is a callback called if an error occurs
  142106. */
  142107. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  142108. /**
  142109. * Execute the current task
  142110. * @param scene defines the scene where you want your assets to be loaded
  142111. * @param onSuccess is a callback called when the task is successfully executed
  142112. * @param onError is a callback called if an error occurs
  142113. */
  142114. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  142115. /**
  142116. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  142117. * This can be used with failed tasks that have the reason for failure fixed.
  142118. */
  142119. reset(): void;
  142120. private onErrorCallback;
  142121. private onDoneCallback;
  142122. }
  142123. /**
  142124. * Define the interface used by progress events raised during assets loading
  142125. */
  142126. export interface IAssetsProgressEvent {
  142127. /**
  142128. * Defines the number of remaining tasks to process
  142129. */
  142130. remainingCount: number;
  142131. /**
  142132. * Defines the total number of tasks
  142133. */
  142134. totalCount: number;
  142135. /**
  142136. * Defines the task that was just processed
  142137. */
  142138. task: AbstractAssetTask;
  142139. }
  142140. /**
  142141. * Class used to share progress information about assets loading
  142142. */
  142143. export class AssetsProgressEvent implements 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. * Creates a AssetsProgressEvent
  142158. * @param remainingCount defines the number of remaining tasks to process
  142159. * @param totalCount defines the total number of tasks
  142160. * @param task defines the task that was just processed
  142161. */
  142162. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  142163. }
  142164. /**
  142165. * Define a task used by AssetsManager to load meshes
  142166. */
  142167. export class MeshAssetTask extends AbstractAssetTask {
  142168. /**
  142169. * Defines the name of the task
  142170. */
  142171. name: string;
  142172. /**
  142173. * Defines the list of mesh's names you want to load
  142174. */
  142175. meshesNames: any;
  142176. /**
  142177. * Defines the root url to use as a base to load your meshes and associated resources
  142178. */
  142179. rootUrl: string;
  142180. /**
  142181. * Defines the filename of the scene to load from
  142182. */
  142183. sceneFilename: string;
  142184. /**
  142185. * Gets the list of loaded meshes
  142186. */
  142187. loadedMeshes: Array<AbstractMesh>;
  142188. /**
  142189. * Gets the list of loaded particle systems
  142190. */
  142191. loadedParticleSystems: Array<IParticleSystem>;
  142192. /**
  142193. * Gets the list of loaded skeletons
  142194. */
  142195. loadedSkeletons: Array<Skeleton>;
  142196. /**
  142197. * Gets the list of loaded animation groups
  142198. */
  142199. loadedAnimationGroups: Array<AnimationGroup>;
  142200. /**
  142201. * Callback called when the task is successful
  142202. */
  142203. onSuccess: (task: MeshAssetTask) => void;
  142204. /**
  142205. * Callback called when the task is successful
  142206. */
  142207. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  142208. /**
  142209. * Creates a new MeshAssetTask
  142210. * @param name defines the name of the task
  142211. * @param meshesNames defines the list of mesh's names you want to load
  142212. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  142213. * @param sceneFilename defines the filename of the scene to load from
  142214. */
  142215. constructor(
  142216. /**
  142217. * Defines the name of the task
  142218. */
  142219. name: string,
  142220. /**
  142221. * Defines the list of mesh's names you want to load
  142222. */
  142223. meshesNames: any,
  142224. /**
  142225. * Defines the root url to use as a base to load your meshes and associated resources
  142226. */
  142227. rootUrl: string,
  142228. /**
  142229. * Defines the filename of the scene to load from
  142230. */
  142231. sceneFilename: string);
  142232. /**
  142233. * Execute the current task
  142234. * @param scene defines the scene where you want your assets to be loaded
  142235. * @param onSuccess is a callback called when the task is successfully executed
  142236. * @param onError is a callback called if an error occurs
  142237. */
  142238. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  142239. }
  142240. /**
  142241. * Define a task used by AssetsManager to load text content
  142242. */
  142243. export class TextFileAssetTask extends AbstractAssetTask {
  142244. /**
  142245. * Defines the name of the task
  142246. */
  142247. name: string;
  142248. /**
  142249. * Defines the location of the file to load
  142250. */
  142251. url: string;
  142252. /**
  142253. * Gets the loaded text string
  142254. */
  142255. text: string;
  142256. /**
  142257. * Callback called when the task is successful
  142258. */
  142259. onSuccess: (task: TextFileAssetTask) => void;
  142260. /**
  142261. * Callback called when the task is successful
  142262. */
  142263. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  142264. /**
  142265. * Creates a new TextFileAssetTask object
  142266. * @param name defines the name of the task
  142267. * @param url defines the location of the file to load
  142268. */
  142269. constructor(
  142270. /**
  142271. * Defines the name of the task
  142272. */
  142273. name: string,
  142274. /**
  142275. * Defines the location of the file to load
  142276. */
  142277. url: string);
  142278. /**
  142279. * Execute the current task
  142280. * @param scene defines the scene where you want your assets to be loaded
  142281. * @param onSuccess is a callback called when the task is successfully executed
  142282. * @param onError is a callback called if an error occurs
  142283. */
  142284. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  142285. }
  142286. /**
  142287. * Define a task used by AssetsManager to load binary data
  142288. */
  142289. export class BinaryFileAssetTask extends AbstractAssetTask {
  142290. /**
  142291. * Defines the name of the task
  142292. */
  142293. name: string;
  142294. /**
  142295. * Defines the location of the file to load
  142296. */
  142297. url: string;
  142298. /**
  142299. * Gets the lodaded data (as an array buffer)
  142300. */
  142301. data: ArrayBuffer;
  142302. /**
  142303. * Callback called when the task is successful
  142304. */
  142305. onSuccess: (task: BinaryFileAssetTask) => void;
  142306. /**
  142307. * Callback called when the task is successful
  142308. */
  142309. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  142310. /**
  142311. * Creates a new BinaryFileAssetTask object
  142312. * @param name defines the name of the new task
  142313. * @param url defines the location of the file to load
  142314. */
  142315. constructor(
  142316. /**
  142317. * Defines the name of the task
  142318. */
  142319. name: string,
  142320. /**
  142321. * Defines the location of the file to load
  142322. */
  142323. url: string);
  142324. /**
  142325. * Execute the current task
  142326. * @param scene defines the scene where you want your assets to be loaded
  142327. * @param onSuccess is a callback called when the task is successfully executed
  142328. * @param onError is a callback called if an error occurs
  142329. */
  142330. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  142331. }
  142332. /**
  142333. * Define a task used by AssetsManager to load images
  142334. */
  142335. export class ImageAssetTask extends AbstractAssetTask {
  142336. /**
  142337. * Defines the name of the task
  142338. */
  142339. name: string;
  142340. /**
  142341. * Defines the location of the image to load
  142342. */
  142343. url: string;
  142344. /**
  142345. * Gets the loaded images
  142346. */
  142347. image: HTMLImageElement;
  142348. /**
  142349. * Callback called when the task is successful
  142350. */
  142351. onSuccess: (task: ImageAssetTask) => void;
  142352. /**
  142353. * Callback called when the task is successful
  142354. */
  142355. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  142356. /**
  142357. * Creates a new ImageAssetTask
  142358. * @param name defines the name of the task
  142359. * @param url defines the location of the image to load
  142360. */
  142361. constructor(
  142362. /**
  142363. * Defines the name of the task
  142364. */
  142365. name: string,
  142366. /**
  142367. * Defines the location of the image to load
  142368. */
  142369. url: string);
  142370. /**
  142371. * Execute the current task
  142372. * @param scene defines the scene where you want your assets to be loaded
  142373. * @param onSuccess is a callback called when the task is successfully executed
  142374. * @param onError is a callback called if an error occurs
  142375. */
  142376. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  142377. }
  142378. /**
  142379. * Defines the interface used by texture loading tasks
  142380. */
  142381. export interface ITextureAssetTask<TEX extends BaseTexture> {
  142382. /**
  142383. * Gets the loaded texture
  142384. */
  142385. texture: TEX;
  142386. }
  142387. /**
  142388. * Define a task used by AssetsManager to load 2D textures
  142389. */
  142390. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  142391. /**
  142392. * Defines the name of the task
  142393. */
  142394. name: string;
  142395. /**
  142396. * Defines the location of the file to load
  142397. */
  142398. url: string;
  142399. /**
  142400. * Defines if mipmap should not be generated (default is false)
  142401. */
  142402. noMipmap?: boolean | undefined;
  142403. /**
  142404. * Defines if texture must be inverted on Y axis (default is true)
  142405. */
  142406. invertY: boolean;
  142407. /**
  142408. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  142409. */
  142410. samplingMode: number;
  142411. /**
  142412. * Gets the loaded texture
  142413. */
  142414. texture: Texture;
  142415. /**
  142416. * Callback called when the task is successful
  142417. */
  142418. onSuccess: (task: TextureAssetTask) => void;
  142419. /**
  142420. * Callback called when the task is successful
  142421. */
  142422. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  142423. /**
  142424. * Creates a new TextureAssetTask object
  142425. * @param name defines the name of the task
  142426. * @param url defines the location of the file to load
  142427. * @param noMipmap defines if mipmap should not be generated (default is false)
  142428. * @param invertY defines if texture must be inverted on Y axis (default is true)
  142429. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  142430. */
  142431. constructor(
  142432. /**
  142433. * Defines the name of the task
  142434. */
  142435. name: string,
  142436. /**
  142437. * Defines the location of the file to load
  142438. */
  142439. url: string,
  142440. /**
  142441. * Defines if mipmap should not be generated (default is false)
  142442. */
  142443. noMipmap?: boolean | undefined,
  142444. /**
  142445. * Defines if texture must be inverted on Y axis (default is true)
  142446. */
  142447. invertY?: boolean,
  142448. /**
  142449. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  142450. */
  142451. samplingMode?: number);
  142452. /**
  142453. * Execute the current task
  142454. * @param scene defines the scene where you want your assets to be loaded
  142455. * @param onSuccess is a callback called when the task is successfully executed
  142456. * @param onError is a callback called if an error occurs
  142457. */
  142458. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  142459. }
  142460. /**
  142461. * Define a task used by AssetsManager to load cube textures
  142462. */
  142463. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  142464. /**
  142465. * Defines the name of the task
  142466. */
  142467. name: string;
  142468. /**
  142469. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  142470. */
  142471. url: string;
  142472. /**
  142473. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  142474. */
  142475. extensions?: string[] | undefined;
  142476. /**
  142477. * Defines if mipmaps should not be generated (default is false)
  142478. */
  142479. noMipmap?: boolean | undefined;
  142480. /**
  142481. * Defines the explicit list of files (undefined by default)
  142482. */
  142483. files?: string[] | undefined;
  142484. /**
  142485. * Gets the loaded texture
  142486. */
  142487. texture: CubeTexture;
  142488. /**
  142489. * Callback called when the task is successful
  142490. */
  142491. onSuccess: (task: CubeTextureAssetTask) => void;
  142492. /**
  142493. * Callback called when the task is successful
  142494. */
  142495. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  142496. /**
  142497. * Creates a new CubeTextureAssetTask
  142498. * @param name defines the name of the task
  142499. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  142500. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  142501. * @param noMipmap defines if mipmaps should not be generated (default is false)
  142502. * @param files defines the explicit list of files (undefined by default)
  142503. */
  142504. constructor(
  142505. /**
  142506. * Defines the name of the task
  142507. */
  142508. name: string,
  142509. /**
  142510. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  142511. */
  142512. url: string,
  142513. /**
  142514. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  142515. */
  142516. extensions?: string[] | undefined,
  142517. /**
  142518. * Defines if mipmaps should not be generated (default is false)
  142519. */
  142520. noMipmap?: boolean | undefined,
  142521. /**
  142522. * Defines the explicit list of files (undefined by default)
  142523. */
  142524. files?: string[] | undefined);
  142525. /**
  142526. * Execute the current task
  142527. * @param scene defines the scene where you want your assets to be loaded
  142528. * @param onSuccess is a callback called when the task is successfully executed
  142529. * @param onError is a callback called if an error occurs
  142530. */
  142531. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  142532. }
  142533. /**
  142534. * Define a task used by AssetsManager to load HDR cube textures
  142535. */
  142536. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  142537. /**
  142538. * Defines the name of the task
  142539. */
  142540. name: string;
  142541. /**
  142542. * Defines the location of the file to load
  142543. */
  142544. url: string;
  142545. /**
  142546. * Defines the desired size (the more it increases the longer the generation will be)
  142547. */
  142548. size: number;
  142549. /**
  142550. * Defines if mipmaps should not be generated (default is false)
  142551. */
  142552. noMipmap: boolean;
  142553. /**
  142554. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  142555. */
  142556. generateHarmonics: boolean;
  142557. /**
  142558. * 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)
  142559. */
  142560. gammaSpace: boolean;
  142561. /**
  142562. * Internal Use Only
  142563. */
  142564. reserved: boolean;
  142565. /**
  142566. * Gets the loaded texture
  142567. */
  142568. texture: HDRCubeTexture;
  142569. /**
  142570. * Callback called when the task is successful
  142571. */
  142572. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  142573. /**
  142574. * Callback called when the task is successful
  142575. */
  142576. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  142577. /**
  142578. * Creates a new HDRCubeTextureAssetTask object
  142579. * @param name defines the name of the task
  142580. * @param url defines the location of the file to load
  142581. * @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.
  142582. * @param noMipmap defines if mipmaps should not be generated (default is false)
  142583. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  142584. * @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)
  142585. * @param reserved Internal use only
  142586. */
  142587. constructor(
  142588. /**
  142589. * Defines the name of the task
  142590. */
  142591. name: string,
  142592. /**
  142593. * Defines the location of the file to load
  142594. */
  142595. url: string,
  142596. /**
  142597. * Defines the desired size (the more it increases the longer the generation will be)
  142598. */
  142599. size: number,
  142600. /**
  142601. * Defines if mipmaps should not be generated (default is false)
  142602. */
  142603. noMipmap?: boolean,
  142604. /**
  142605. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  142606. */
  142607. generateHarmonics?: boolean,
  142608. /**
  142609. * 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)
  142610. */
  142611. gammaSpace?: boolean,
  142612. /**
  142613. * Internal Use Only
  142614. */
  142615. reserved?: boolean);
  142616. /**
  142617. * Execute the current task
  142618. * @param scene defines the scene where you want your assets to be loaded
  142619. * @param onSuccess is a callback called when the task is successfully executed
  142620. * @param onError is a callback called if an error occurs
  142621. */
  142622. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  142623. }
  142624. /**
  142625. * Define a task used by AssetsManager to load Equirectangular cube textures
  142626. */
  142627. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  142628. /**
  142629. * Defines the name of the task
  142630. */
  142631. name: string;
  142632. /**
  142633. * Defines the location of the file to load
  142634. */
  142635. url: string;
  142636. /**
  142637. * Defines the desired size (the more it increases the longer the generation will be)
  142638. */
  142639. size: number;
  142640. /**
  142641. * Defines if mipmaps should not be generated (default is false)
  142642. */
  142643. noMipmap: boolean;
  142644. /**
  142645. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  142646. * but the standard material would require them in Gamma space) (default is true)
  142647. */
  142648. gammaSpace: boolean;
  142649. /**
  142650. * Gets the loaded texture
  142651. */
  142652. texture: EquiRectangularCubeTexture;
  142653. /**
  142654. * Callback called when the task is successful
  142655. */
  142656. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  142657. /**
  142658. * Callback called when the task is successful
  142659. */
  142660. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  142661. /**
  142662. * Creates a new EquiRectangularCubeTextureAssetTask object
  142663. * @param name defines the name of the task
  142664. * @param url defines the location of the file to load
  142665. * @param size defines the desired size (the more it increases the longer the generation will be)
  142666. * If the size is omitted this implies you are using a preprocessed cubemap.
  142667. * @param noMipmap defines if mipmaps should not be generated (default is false)
  142668. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  142669. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  142670. * (default is true)
  142671. */
  142672. constructor(
  142673. /**
  142674. * Defines the name of the task
  142675. */
  142676. name: string,
  142677. /**
  142678. * Defines the location of the file to load
  142679. */
  142680. url: string,
  142681. /**
  142682. * Defines the desired size (the more it increases the longer the generation will be)
  142683. */
  142684. size: number,
  142685. /**
  142686. * Defines if mipmaps should not be generated (default is false)
  142687. */
  142688. noMipmap?: boolean,
  142689. /**
  142690. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  142691. * but the standard material would require them in Gamma space) (default is true)
  142692. */
  142693. gammaSpace?: boolean);
  142694. /**
  142695. * Execute the current task
  142696. * @param scene defines the scene where you want your assets to be loaded
  142697. * @param onSuccess is a callback called when the task is successfully executed
  142698. * @param onError is a callback called if an error occurs
  142699. */
  142700. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  142701. }
  142702. /**
  142703. * This class can be used to easily import assets into a scene
  142704. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  142705. */
  142706. export class AssetsManager {
  142707. private _scene;
  142708. private _isLoading;
  142709. protected _tasks: AbstractAssetTask[];
  142710. protected _waitingTasksCount: number;
  142711. protected _totalTasksCount: number;
  142712. /**
  142713. * Callback called when all tasks are processed
  142714. */
  142715. onFinish: (tasks: AbstractAssetTask[]) => void;
  142716. /**
  142717. * Callback called when a task is successful
  142718. */
  142719. onTaskSuccess: (task: AbstractAssetTask) => void;
  142720. /**
  142721. * Callback called when a task had an error
  142722. */
  142723. onTaskError: (task: AbstractAssetTask) => void;
  142724. /**
  142725. * Callback called when a task is done (whatever the result is)
  142726. */
  142727. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  142728. /**
  142729. * Observable called when all tasks are processed
  142730. */
  142731. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  142732. /**
  142733. * Observable called when a task had an error
  142734. */
  142735. onTaskErrorObservable: Observable<AbstractAssetTask>;
  142736. /**
  142737. * Observable called when all tasks were executed
  142738. */
  142739. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  142740. /**
  142741. * Observable called when a task is done (whatever the result is)
  142742. */
  142743. onProgressObservable: Observable<IAssetsProgressEvent>;
  142744. /**
  142745. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  142746. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  142747. */
  142748. useDefaultLoadingScreen: boolean;
  142749. /**
  142750. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  142751. * when all assets have been downloaded.
  142752. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  142753. */
  142754. autoHideLoadingUI: boolean;
  142755. /**
  142756. * Creates a new AssetsManager
  142757. * @param scene defines the scene to work on
  142758. */
  142759. constructor(scene: Scene);
  142760. /**
  142761. * Add a MeshAssetTask to the list of active tasks
  142762. * @param taskName defines the name of the new task
  142763. * @param meshesNames defines the name of meshes to load
  142764. * @param rootUrl defines the root url to use to locate files
  142765. * @param sceneFilename defines the filename of the scene file
  142766. * @returns a new MeshAssetTask object
  142767. */
  142768. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  142769. /**
  142770. * Add a TextFileAssetTask to the list of active tasks
  142771. * @param taskName defines the name of the new task
  142772. * @param url defines the url of the file to load
  142773. * @returns a new TextFileAssetTask object
  142774. */
  142775. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  142776. /**
  142777. * Add a BinaryFileAssetTask to the list of active tasks
  142778. * @param taskName defines the name of the new task
  142779. * @param url defines the url of the file to load
  142780. * @returns a new BinaryFileAssetTask object
  142781. */
  142782. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  142783. /**
  142784. * Add a ImageAssetTask to the list of active tasks
  142785. * @param taskName defines the name of the new task
  142786. * @param url defines the url of the file to load
  142787. * @returns a new ImageAssetTask object
  142788. */
  142789. addImageTask(taskName: string, url: string): ImageAssetTask;
  142790. /**
  142791. * Add a TextureAssetTask to the list of active tasks
  142792. * @param taskName defines the name of the new task
  142793. * @param url defines the url of the file to load
  142794. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  142795. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  142796. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  142797. * @returns a new TextureAssetTask object
  142798. */
  142799. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  142800. /**
  142801. * Add a CubeTextureAssetTask 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. * @param extensions defines the extension to use to load the cube map (can be null)
  142805. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  142806. * @param files defines the list of files to load (can be null)
  142807. * @returns a new CubeTextureAssetTask object
  142808. */
  142809. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  142810. /**
  142811. *
  142812. * Add a HDRCubeTextureAssetTask to the list of active tasks
  142813. * @param taskName defines the name of the new task
  142814. * @param url defines the url of the file to load
  142815. * @param size defines the size you want for the cubemap (can be null)
  142816. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  142817. * @param generateHarmonics defines if you want to automatically generate (true by default)
  142818. * @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)
  142819. * @param reserved Internal use only
  142820. * @returns a new HDRCubeTextureAssetTask object
  142821. */
  142822. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  142823. /**
  142824. *
  142825. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  142826. * @param taskName defines the name of the new task
  142827. * @param url defines the url of the file to load
  142828. * @param size defines the size you want for the cubemap (can be null)
  142829. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  142830. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  142831. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  142832. * @returns a new EquiRectangularCubeTextureAssetTask object
  142833. */
  142834. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  142835. /**
  142836. * Remove a task from the assets manager.
  142837. * @param task the task to remove
  142838. */
  142839. removeTask(task: AbstractAssetTask): void;
  142840. private _decreaseWaitingTasksCount;
  142841. private _runTask;
  142842. /**
  142843. * Reset the AssetsManager and remove all tasks
  142844. * @return the current instance of the AssetsManager
  142845. */
  142846. reset(): AssetsManager;
  142847. /**
  142848. * Start the loading process
  142849. * @return the current instance of the AssetsManager
  142850. */
  142851. load(): AssetsManager;
  142852. /**
  142853. * Start the loading process as an async operation
  142854. * @return a promise returning the list of failed tasks
  142855. */
  142856. loadAsync(): Promise<void>;
  142857. }
  142858. }
  142859. declare module BABYLON {
  142860. /**
  142861. * Wrapper class for promise with external resolve and reject.
  142862. */
  142863. export class Deferred<T> {
  142864. /**
  142865. * The promise associated with this deferred object.
  142866. */
  142867. readonly promise: Promise<T>;
  142868. private _resolve;
  142869. private _reject;
  142870. /**
  142871. * The resolve method of the promise associated with this deferred object.
  142872. */
  142873. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  142874. /**
  142875. * The reject method of the promise associated with this deferred object.
  142876. */
  142877. get reject(): (reason?: any) => void;
  142878. /**
  142879. * Constructor for this deferred object.
  142880. */
  142881. constructor();
  142882. }
  142883. }
  142884. declare module BABYLON {
  142885. /**
  142886. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  142887. */
  142888. export class MeshExploder {
  142889. private _centerMesh;
  142890. private _meshes;
  142891. private _meshesOrigins;
  142892. private _toCenterVectors;
  142893. private _scaledDirection;
  142894. private _newPosition;
  142895. private _centerPosition;
  142896. /**
  142897. * Explodes meshes from a center mesh.
  142898. * @param meshes The meshes to explode.
  142899. * @param centerMesh The mesh to be center of explosion.
  142900. */
  142901. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  142902. private _setCenterMesh;
  142903. /**
  142904. * Get class name
  142905. * @returns "MeshExploder"
  142906. */
  142907. getClassName(): string;
  142908. /**
  142909. * "Exploded meshes"
  142910. * @returns Array of meshes with the centerMesh at index 0.
  142911. */
  142912. getMeshes(): Array<Mesh>;
  142913. /**
  142914. * Explodes meshes giving a specific direction
  142915. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  142916. */
  142917. explode(direction?: number): void;
  142918. }
  142919. }
  142920. declare module BABYLON {
  142921. /**
  142922. * Class used to help managing file picking and drag'n'drop
  142923. */
  142924. export class FilesInput {
  142925. /**
  142926. * List of files ready to be loaded
  142927. */
  142928. static get FilesToLoad(): {
  142929. [key: string]: File;
  142930. };
  142931. /**
  142932. * Callback called when a file is processed
  142933. */
  142934. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  142935. private _engine;
  142936. private _currentScene;
  142937. private _sceneLoadedCallback;
  142938. private _progressCallback;
  142939. private _additionalRenderLoopLogicCallback;
  142940. private _textureLoadingCallback;
  142941. private _startingProcessingFilesCallback;
  142942. private _onReloadCallback;
  142943. private _errorCallback;
  142944. private _elementToMonitor;
  142945. private _sceneFileToLoad;
  142946. private _filesToLoad;
  142947. /**
  142948. * Creates a new FilesInput
  142949. * @param engine defines the rendering engine
  142950. * @param scene defines the hosting scene
  142951. * @param sceneLoadedCallback callback called when scene is loaded
  142952. * @param progressCallback callback called to track progress
  142953. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  142954. * @param textureLoadingCallback callback called when a texture is loading
  142955. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  142956. * @param onReloadCallback callback called when a reload is requested
  142957. * @param errorCallback callback call if an error occurs
  142958. */
  142959. 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);
  142960. private _dragEnterHandler;
  142961. private _dragOverHandler;
  142962. private _dropHandler;
  142963. /**
  142964. * Calls this function to listen to drag'n'drop events on a specific DOM element
  142965. * @param elementToMonitor defines the DOM element to track
  142966. */
  142967. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  142968. /**
  142969. * Release all associated resources
  142970. */
  142971. dispose(): void;
  142972. private renderFunction;
  142973. private drag;
  142974. private drop;
  142975. private _traverseFolder;
  142976. private _processFiles;
  142977. /**
  142978. * Load files from a drop event
  142979. * @param event defines the drop event to use as source
  142980. */
  142981. loadFiles(event: any): void;
  142982. private _processReload;
  142983. /**
  142984. * Reload the current scene from the loaded files
  142985. */
  142986. reload(): void;
  142987. }
  142988. }
  142989. declare module BABYLON {
  142990. /**
  142991. * Defines the root class used to create scene optimization to use with SceneOptimizer
  142992. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  142993. */
  142994. export class SceneOptimization {
  142995. /**
  142996. * Defines the priority of this optimization (0 by default which means first in the list)
  142997. */
  142998. priority: number;
  142999. /**
  143000. * Gets a string describing the action executed by the current optimization
  143001. * @returns description string
  143002. */
  143003. getDescription(): string;
  143004. /**
  143005. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  143006. * @param scene defines the current scene where to apply this optimization
  143007. * @param optimizer defines the current optimizer
  143008. * @returns true if everything that can be done was applied
  143009. */
  143010. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  143011. /**
  143012. * Creates the SceneOptimization object
  143013. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  143014. * @param desc defines the description associated with the optimization
  143015. */
  143016. constructor(
  143017. /**
  143018. * Defines the priority of this optimization (0 by default which means first in the list)
  143019. */
  143020. priority?: number);
  143021. }
  143022. /**
  143023. * Defines an optimization used to reduce the size of render target textures
  143024. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  143025. */
  143026. export class TextureOptimization extends SceneOptimization {
  143027. /**
  143028. * Defines the priority of this optimization (0 by default which means first in the list)
  143029. */
  143030. priority: number;
  143031. /**
  143032. * 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
  143033. */
  143034. maximumSize: number;
  143035. /**
  143036. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  143037. */
  143038. step: number;
  143039. /**
  143040. * Gets a string describing the action executed by the current optimization
  143041. * @returns description string
  143042. */
  143043. getDescription(): string;
  143044. /**
  143045. * Creates the TextureOptimization object
  143046. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  143047. * @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
  143048. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  143049. */
  143050. constructor(
  143051. /**
  143052. * Defines the priority of this optimization (0 by default which means first in the list)
  143053. */
  143054. priority?: number,
  143055. /**
  143056. * 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
  143057. */
  143058. maximumSize?: number,
  143059. /**
  143060. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  143061. */
  143062. step?: number);
  143063. /**
  143064. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  143065. * @param scene defines the current scene where to apply this optimization
  143066. * @param optimizer defines the current optimizer
  143067. * @returns true if everything that can be done was applied
  143068. */
  143069. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  143070. }
  143071. /**
  143072. * Defines an optimization used to increase or decrease the rendering resolution
  143073. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  143074. */
  143075. export class HardwareScalingOptimization extends SceneOptimization {
  143076. /**
  143077. * Defines the priority of this optimization (0 by default which means first in the list)
  143078. */
  143079. priority: number;
  143080. /**
  143081. * Defines the maximum scale to use (2 by default)
  143082. */
  143083. maximumScale: number;
  143084. /**
  143085. * Defines the step to use between two passes (0.5 by default)
  143086. */
  143087. step: number;
  143088. private _currentScale;
  143089. private _directionOffset;
  143090. /**
  143091. * Gets a string describing the action executed by the current optimization
  143092. * @return description string
  143093. */
  143094. getDescription(): string;
  143095. /**
  143096. * Creates the HardwareScalingOptimization object
  143097. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  143098. * @param maximumScale defines the maximum scale to use (2 by default)
  143099. * @param step defines the step to use between two passes (0.5 by default)
  143100. */
  143101. constructor(
  143102. /**
  143103. * Defines the priority of this optimization (0 by default which means first in the list)
  143104. */
  143105. priority?: number,
  143106. /**
  143107. * Defines the maximum scale to use (2 by default)
  143108. */
  143109. maximumScale?: number,
  143110. /**
  143111. * Defines the step to use between two passes (0.5 by default)
  143112. */
  143113. step?: number);
  143114. /**
  143115. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  143116. * @param scene defines the current scene where to apply this optimization
  143117. * @param optimizer defines the current optimizer
  143118. * @returns true if everything that can be done was applied
  143119. */
  143120. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  143121. }
  143122. /**
  143123. * Defines an optimization used to remove shadows
  143124. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  143125. */
  143126. export class ShadowsOptimization extends SceneOptimization {
  143127. /**
  143128. * Gets a string describing the action executed by the current optimization
  143129. * @return description string
  143130. */
  143131. getDescription(): string;
  143132. /**
  143133. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  143134. * @param scene defines the current scene where to apply this optimization
  143135. * @param optimizer defines the current optimizer
  143136. * @returns true if everything that can be done was applied
  143137. */
  143138. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  143139. }
  143140. /**
  143141. * Defines an optimization used to turn post-processes off
  143142. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  143143. */
  143144. export class PostProcessesOptimization extends SceneOptimization {
  143145. /**
  143146. * Gets a string describing the action executed by the current optimization
  143147. * @return description string
  143148. */
  143149. getDescription(): string;
  143150. /**
  143151. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  143152. * @param scene defines the current scene where to apply this optimization
  143153. * @param optimizer defines the current optimizer
  143154. * @returns true if everything that can be done was applied
  143155. */
  143156. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  143157. }
  143158. /**
  143159. * Defines an optimization used to turn lens flares off
  143160. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  143161. */
  143162. export class LensFlaresOptimization extends SceneOptimization {
  143163. /**
  143164. * Gets a string describing the action executed by the current optimization
  143165. * @return description string
  143166. */
  143167. getDescription(): string;
  143168. /**
  143169. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  143170. * @param scene defines the current scene where to apply this optimization
  143171. * @param optimizer defines the current optimizer
  143172. * @returns true if everything that can be done was applied
  143173. */
  143174. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  143175. }
  143176. /**
  143177. * Defines an optimization based on user defined callback.
  143178. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  143179. */
  143180. export class CustomOptimization extends SceneOptimization {
  143181. /**
  143182. * Callback called to apply the custom optimization.
  143183. */
  143184. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  143185. /**
  143186. * Callback called to get custom description
  143187. */
  143188. onGetDescription: () => string;
  143189. /**
  143190. * Gets a string describing the action executed by the current optimization
  143191. * @returns description string
  143192. */
  143193. getDescription(): string;
  143194. /**
  143195. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  143196. * @param scene defines the current scene where to apply this optimization
  143197. * @param optimizer defines the current optimizer
  143198. * @returns true if everything that can be done was applied
  143199. */
  143200. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  143201. }
  143202. /**
  143203. * Defines an optimization used to turn particles off
  143204. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  143205. */
  143206. export class ParticlesOptimization extends SceneOptimization {
  143207. /**
  143208. * Gets a string describing the action executed by the current optimization
  143209. * @return description string
  143210. */
  143211. getDescription(): string;
  143212. /**
  143213. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  143214. * @param scene defines the current scene where to apply this optimization
  143215. * @param optimizer defines the current optimizer
  143216. * @returns true if everything that can be done was applied
  143217. */
  143218. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  143219. }
  143220. /**
  143221. * Defines an optimization used to turn render targets off
  143222. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  143223. */
  143224. export class RenderTargetsOptimization extends SceneOptimization {
  143225. /**
  143226. * Gets a string describing the action executed by the current optimization
  143227. * @return description string
  143228. */
  143229. getDescription(): string;
  143230. /**
  143231. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  143232. * @param scene defines the current scene where to apply this optimization
  143233. * @param optimizer defines the current optimizer
  143234. * @returns true if everything that can be done was applied
  143235. */
  143236. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  143237. }
  143238. /**
  143239. * Defines an optimization used to merge meshes with compatible materials
  143240. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  143241. */
  143242. export class MergeMeshesOptimization extends SceneOptimization {
  143243. private static _UpdateSelectionTree;
  143244. /**
  143245. * Gets or sets a boolean which defines if optimization octree has to be updated
  143246. */
  143247. static get UpdateSelectionTree(): boolean;
  143248. /**
  143249. * Gets or sets a boolean which defines if optimization octree has to be updated
  143250. */
  143251. static set UpdateSelectionTree(value: boolean);
  143252. /**
  143253. * Gets a string describing the action executed by the current optimization
  143254. * @return description string
  143255. */
  143256. getDescription(): string;
  143257. private _canBeMerged;
  143258. /**
  143259. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  143260. * @param scene defines the current scene where to apply this optimization
  143261. * @param optimizer defines the current optimizer
  143262. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  143263. * @returns true if everything that can be done was applied
  143264. */
  143265. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  143266. }
  143267. /**
  143268. * Defines a list of options used by SceneOptimizer
  143269. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  143270. */
  143271. export class SceneOptimizerOptions {
  143272. /**
  143273. * Defines the target frame rate to reach (60 by default)
  143274. */
  143275. targetFrameRate: number;
  143276. /**
  143277. * Defines the interval between two checkes (2000ms by default)
  143278. */
  143279. trackerDuration: number;
  143280. /**
  143281. * Gets the list of optimizations to apply
  143282. */
  143283. optimizations: SceneOptimization[];
  143284. /**
  143285. * Creates a new list of options used by SceneOptimizer
  143286. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  143287. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  143288. */
  143289. constructor(
  143290. /**
  143291. * Defines the target frame rate to reach (60 by default)
  143292. */
  143293. targetFrameRate?: number,
  143294. /**
  143295. * Defines the interval between two checkes (2000ms by default)
  143296. */
  143297. trackerDuration?: number);
  143298. /**
  143299. * Add a new optimization
  143300. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  143301. * @returns the current SceneOptimizerOptions
  143302. */
  143303. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  143304. /**
  143305. * Add a new custom optimization
  143306. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  143307. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  143308. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  143309. * @returns the current SceneOptimizerOptions
  143310. */
  143311. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  143312. /**
  143313. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  143314. * @param targetFrameRate defines the target frame rate (60 by default)
  143315. * @returns a SceneOptimizerOptions object
  143316. */
  143317. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  143318. /**
  143319. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  143320. * @param targetFrameRate defines the target frame rate (60 by default)
  143321. * @returns a SceneOptimizerOptions object
  143322. */
  143323. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  143324. /**
  143325. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  143326. * @param targetFrameRate defines the target frame rate (60 by default)
  143327. * @returns a SceneOptimizerOptions object
  143328. */
  143329. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  143330. }
  143331. /**
  143332. * Class used to run optimizations in order to reach a target frame rate
  143333. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  143334. */
  143335. export class SceneOptimizer implements IDisposable {
  143336. private _isRunning;
  143337. private _options;
  143338. private _scene;
  143339. private _currentPriorityLevel;
  143340. private _targetFrameRate;
  143341. private _trackerDuration;
  143342. private _currentFrameRate;
  143343. private _sceneDisposeObserver;
  143344. private _improvementMode;
  143345. /**
  143346. * Defines an observable called when the optimizer reaches the target frame rate
  143347. */
  143348. onSuccessObservable: Observable<SceneOptimizer>;
  143349. /**
  143350. * Defines an observable called when the optimizer enables an optimization
  143351. */
  143352. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  143353. /**
  143354. * Defines an observable called when the optimizer is not able to reach the target frame rate
  143355. */
  143356. onFailureObservable: Observable<SceneOptimizer>;
  143357. /**
  143358. * Gets a boolean indicating if the optimizer is in improvement mode
  143359. */
  143360. get isInImprovementMode(): boolean;
  143361. /**
  143362. * Gets the current priority level (0 at start)
  143363. */
  143364. get currentPriorityLevel(): number;
  143365. /**
  143366. * Gets the current frame rate checked by the SceneOptimizer
  143367. */
  143368. get currentFrameRate(): number;
  143369. /**
  143370. * Gets or sets the current target frame rate (60 by default)
  143371. */
  143372. get targetFrameRate(): number;
  143373. /**
  143374. * Gets or sets the current target frame rate (60 by default)
  143375. */
  143376. set targetFrameRate(value: number);
  143377. /**
  143378. * Gets or sets the current interval between two checks (every 2000ms by default)
  143379. */
  143380. get trackerDuration(): number;
  143381. /**
  143382. * Gets or sets the current interval between two checks (every 2000ms by default)
  143383. */
  143384. set trackerDuration(value: number);
  143385. /**
  143386. * Gets the list of active optimizations
  143387. */
  143388. get optimizations(): SceneOptimization[];
  143389. /**
  143390. * Creates a new SceneOptimizer
  143391. * @param scene defines the scene to work on
  143392. * @param options defines the options to use with the SceneOptimizer
  143393. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  143394. * @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)
  143395. */
  143396. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  143397. /**
  143398. * Stops the current optimizer
  143399. */
  143400. stop(): void;
  143401. /**
  143402. * Reset the optimizer to initial step (current priority level = 0)
  143403. */
  143404. reset(): void;
  143405. /**
  143406. * Start the optimizer. By default it will try to reach a specific framerate
  143407. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  143408. */
  143409. start(): void;
  143410. private _checkCurrentState;
  143411. /**
  143412. * Release all resources
  143413. */
  143414. dispose(): void;
  143415. /**
  143416. * Helper function to create a SceneOptimizer with one single line of code
  143417. * @param scene defines the scene to work on
  143418. * @param options defines the options to use with the SceneOptimizer
  143419. * @param onSuccess defines a callback to call on success
  143420. * @param onFailure defines a callback to call on failure
  143421. * @returns the new SceneOptimizer object
  143422. */
  143423. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  143424. }
  143425. }
  143426. declare module BABYLON {
  143427. /**
  143428. * Class used to serialize a scene into a string
  143429. */
  143430. export class SceneSerializer {
  143431. /**
  143432. * Clear cache used by a previous serialization
  143433. */
  143434. static ClearCache(): void;
  143435. /**
  143436. * Serialize a scene into a JSON compatible object
  143437. * @param scene defines the scene to serialize
  143438. * @returns a JSON compatible object
  143439. */
  143440. static Serialize(scene: Scene): any;
  143441. /**
  143442. * Serialize a mesh into a JSON compatible object
  143443. * @param toSerialize defines the mesh to serialize
  143444. * @param withParents defines if parents must be serialized as well
  143445. * @param withChildren defines if children must be serialized as well
  143446. * @returns a JSON compatible object
  143447. */
  143448. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  143449. }
  143450. }
  143451. declare module BABYLON {
  143452. /**
  143453. * Class used to host texture specific utilities
  143454. */
  143455. export class TextureTools {
  143456. /**
  143457. * Uses the GPU to create a copy texture rescaled at a given size
  143458. * @param texture Texture to copy from
  143459. * @param width defines the desired width
  143460. * @param height defines the desired height
  143461. * @param useBilinearMode defines if bilinear mode has to be used
  143462. * @return the generated texture
  143463. */
  143464. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  143465. }
  143466. }
  143467. declare module BABYLON {
  143468. /**
  143469. * This represents the different options available for the video capture.
  143470. */
  143471. export interface VideoRecorderOptions {
  143472. /** Defines the mime type of the video. */
  143473. mimeType: string;
  143474. /** Defines the FPS the video should be recorded at. */
  143475. fps: number;
  143476. /** Defines the chunk size for the recording data. */
  143477. recordChunckSize: number;
  143478. /** The audio tracks to attach to the recording. */
  143479. audioTracks?: MediaStreamTrack[];
  143480. }
  143481. /**
  143482. * This can help with recording videos from BabylonJS.
  143483. * This is based on the available WebRTC functionalities of the browser.
  143484. *
  143485. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  143486. */
  143487. export class VideoRecorder {
  143488. private static readonly _defaultOptions;
  143489. /**
  143490. * Returns whether or not the VideoRecorder is available in your browser.
  143491. * @param engine Defines the Babylon Engine.
  143492. * @returns true if supported otherwise false.
  143493. */
  143494. static IsSupported(engine: Engine): boolean;
  143495. private readonly _options;
  143496. private _canvas;
  143497. private _mediaRecorder;
  143498. private _recordedChunks;
  143499. private _fileName;
  143500. private _resolve;
  143501. private _reject;
  143502. /**
  143503. * True when a recording is already in progress.
  143504. */
  143505. get isRecording(): boolean;
  143506. /**
  143507. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  143508. * @param engine Defines the BabylonJS Engine you wish to record.
  143509. * @param options Defines options that can be used to customize the capture.
  143510. */
  143511. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  143512. /**
  143513. * Stops the current recording before the default capture timeout passed in the startRecording function.
  143514. */
  143515. stopRecording(): void;
  143516. /**
  143517. * Starts recording the canvas for a max duration specified in parameters.
  143518. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  143519. * If null no automatic download will start and you can rely on the promise to get the data back.
  143520. * @param maxDuration Defines the maximum recording time in seconds.
  143521. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  143522. * @return A promise callback at the end of the recording with the video data in Blob.
  143523. */
  143524. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  143525. /**
  143526. * Releases internal resources used during the recording.
  143527. */
  143528. dispose(): void;
  143529. private _handleDataAvailable;
  143530. private _handleError;
  143531. private _handleStop;
  143532. }
  143533. }
  143534. declare module BABYLON {
  143535. /**
  143536. * Class containing a set of static utilities functions for screenshots
  143537. */
  143538. export class ScreenshotTools {
  143539. /**
  143540. * Captures a screenshot of the current rendering
  143541. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  143542. * @param engine defines the rendering engine
  143543. * @param camera defines the source camera
  143544. * @param size This parameter can be set to a single number or to an object with the
  143545. * following (optional) properties: precision, width, height. If a single number is passed,
  143546. * it will be used for both width and height. If an object is passed, the screenshot size
  143547. * will be derived from the parameters. The precision property is a multiplier allowing
  143548. * rendering at a higher or lower resolution
  143549. * @param successCallback defines the callback receives a single parameter which contains the
  143550. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  143551. * src parameter of an <img> to display it
  143552. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  143553. * Check your browser for supported MIME types
  143554. */
  143555. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  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 mimeType defines the MIME type of the screenshot image (default: image/png).
  143567. * Check your browser for supported MIME types
  143568. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  143569. * to the src parameter of an <img> to display it
  143570. */
  143571. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  143572. /**
  143573. * Generates an image screenshot from the specified camera.
  143574. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  143575. * @param engine The engine to use for rendering
  143576. * @param camera The camera to use for rendering
  143577. * @param size This parameter can be set to a single number or to an object with the
  143578. * following (optional) properties: precision, width, height. If a single number is passed,
  143579. * it will be used for both width and height. If an object is passed, the screenshot size
  143580. * will be derived from the parameters. The precision property is a multiplier allowing
  143581. * rendering at a higher or lower resolution
  143582. * @param successCallback The callback receives a single parameter which contains the
  143583. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  143584. * src parameter of an <img> to display it
  143585. * @param mimeType The MIME type of the screenshot image (default: image/png).
  143586. * Check your browser for supported MIME types
  143587. * @param samples Texture samples (default: 1)
  143588. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  143589. * @param fileName A name for for the downloaded file.
  143590. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  143591. */
  143592. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  143593. /**
  143594. * Generates an image screenshot from the specified camera.
  143595. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  143596. * @param engine The engine to use for rendering
  143597. * @param camera The camera to use for rendering
  143598. * @param size This parameter can be set to a single number or to an object with the
  143599. * following (optional) properties: precision, width, height. If a single number is passed,
  143600. * it will be used for both width and height. If an object is passed, the screenshot size
  143601. * will be derived from the parameters. The precision property is a multiplier allowing
  143602. * rendering at a higher or lower resolution
  143603. * @param mimeType The MIME type of the screenshot image (default: image/png).
  143604. * Check your browser for supported MIME types
  143605. * @param samples Texture samples (default: 1)
  143606. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  143607. * @param fileName A name for for the downloaded file.
  143608. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  143609. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  143610. * to the src parameter of an <img> to display it
  143611. */
  143612. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  143613. /**
  143614. * Gets height and width for screenshot size
  143615. * @private
  143616. */
  143617. private static _getScreenshotSize;
  143618. }
  143619. }
  143620. declare module BABYLON {
  143621. /**
  143622. * Interface for a data buffer
  143623. */
  143624. export interface IDataBuffer {
  143625. /**
  143626. * Reads bytes from the data buffer.
  143627. * @param byteOffset The byte offset to read
  143628. * @param byteLength The byte length to read
  143629. * @returns A promise that resolves when the bytes are read
  143630. */
  143631. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  143632. /**
  143633. * The byte length of the buffer.
  143634. */
  143635. readonly byteLength: number;
  143636. }
  143637. /**
  143638. * Utility class for reading from a data buffer
  143639. */
  143640. export class DataReader {
  143641. /**
  143642. * The data buffer associated with this data reader.
  143643. */
  143644. readonly buffer: IDataBuffer;
  143645. /**
  143646. * The current byte offset from the beginning of the data buffer.
  143647. */
  143648. byteOffset: number;
  143649. private _dataView;
  143650. private _dataByteOffset;
  143651. /**
  143652. * Constructor
  143653. * @param buffer The buffer to read
  143654. */
  143655. constructor(buffer: IDataBuffer);
  143656. /**
  143657. * Loads the given byte length.
  143658. * @param byteLength The byte length to load
  143659. * @returns A promise that resolves when the load is complete
  143660. */
  143661. loadAsync(byteLength: number): Promise<void>;
  143662. /**
  143663. * Read a unsigned 32-bit integer from the currently loaded data range.
  143664. * @returns The 32-bit integer read
  143665. */
  143666. readUint32(): number;
  143667. /**
  143668. * Read a byte array from the currently loaded data range.
  143669. * @param byteLength The byte length to read
  143670. * @returns The byte array read
  143671. */
  143672. readUint8Array(byteLength: number): Uint8Array;
  143673. /**
  143674. * Read a string from the currently loaded data range.
  143675. * @param byteLength The byte length to read
  143676. * @returns The string read
  143677. */
  143678. readString(byteLength: number): string;
  143679. /**
  143680. * Skips the given byte length the currently loaded data range.
  143681. * @param byteLength The byte length to skip
  143682. */
  143683. skipBytes(byteLength: number): void;
  143684. }
  143685. }
  143686. declare module BABYLON {
  143687. /**
  143688. * Class for storing data to local storage if available or in-memory storage otherwise
  143689. */
  143690. export class DataStorage {
  143691. private static _Storage;
  143692. private static _GetStorage;
  143693. /**
  143694. * Reads a string from the data storage
  143695. * @param key The key to read
  143696. * @param defaultValue The value if the key doesn't exist
  143697. * @returns The string value
  143698. */
  143699. static ReadString(key: string, defaultValue: string): string;
  143700. /**
  143701. * Writes a string to the data storage
  143702. * @param key The key to write
  143703. * @param value The value to write
  143704. */
  143705. static WriteString(key: string, value: string): void;
  143706. /**
  143707. * Reads a boolean from the data storage
  143708. * @param key The key to read
  143709. * @param defaultValue The value if the key doesn't exist
  143710. * @returns The boolean value
  143711. */
  143712. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  143713. /**
  143714. * Writes a boolean to the data storage
  143715. * @param key The key to write
  143716. * @param value The value to write
  143717. */
  143718. static WriteBoolean(key: string, value: boolean): void;
  143719. /**
  143720. * Reads a number from the data storage
  143721. * @param key The key to read
  143722. * @param defaultValue The value if the key doesn't exist
  143723. * @returns The number value
  143724. */
  143725. static ReadNumber(key: string, defaultValue: number): number;
  143726. /**
  143727. * Writes a number to the data storage
  143728. * @param key The key to write
  143729. * @param value The value to write
  143730. */
  143731. static WriteNumber(key: string, value: number): void;
  143732. }
  143733. }
  143734. declare module BABYLON {
  143735. /**
  143736. * Options used for hit testing
  143737. */
  143738. export interface IWebXRLegacyHitTestOptions {
  143739. /**
  143740. * Only test when user interacted with the scene. Default - hit test every frame
  143741. */
  143742. testOnPointerDownOnly?: boolean;
  143743. /**
  143744. * The node to use to transform the local results to world coordinates
  143745. */
  143746. worldParentNode?: TransformNode;
  143747. }
  143748. /**
  143749. * Interface defining the babylon result of raycasting/hit-test
  143750. */
  143751. export interface IWebXRLegacyHitResult {
  143752. /**
  143753. * Transformation matrix that can be applied to a node that will put it in the hit point location
  143754. */
  143755. transformationMatrix: Matrix;
  143756. /**
  143757. * The native hit test result
  143758. */
  143759. xrHitResult: XRHitResult | XRHitTestResult;
  143760. }
  143761. /**
  143762. * The currently-working hit-test module.
  143763. * Hit test (or Ray-casting) is used to interact with the real world.
  143764. * For further information read here - https://github.com/immersive-web/hit-test
  143765. */
  143766. export class WebXRHitTestLegacy extends WebXRAbstractFeature {
  143767. /**
  143768. * options to use when constructing this feature
  143769. */
  143770. readonly options: IWebXRLegacyHitTestOptions;
  143771. private _direction;
  143772. private _mat;
  143773. private _onSelectEnabled;
  143774. private _origin;
  143775. /**
  143776. * The module's name
  143777. */
  143778. static readonly Name: string;
  143779. /**
  143780. * The (Babylon) version of this module.
  143781. * This is an integer representing the implementation version.
  143782. * This number does not correspond to the WebXR specs version
  143783. */
  143784. static readonly Version: number;
  143785. /**
  143786. * Populated with the last native XR Hit Results
  143787. */
  143788. lastNativeXRHitResults: XRHitResult[];
  143789. /**
  143790. * Triggered when new babylon (transformed) hit test results are available
  143791. */
  143792. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  143793. /**
  143794. * Creates a new instance of the (legacy version) hit test feature
  143795. * @param _xrSessionManager an instance of WebXRSessionManager
  143796. * @param options options to use when constructing this feature
  143797. */
  143798. constructor(_xrSessionManager: WebXRSessionManager,
  143799. /**
  143800. * options to use when constructing this feature
  143801. */
  143802. options?: IWebXRLegacyHitTestOptions);
  143803. /**
  143804. * execute a hit test with an XR Ray
  143805. *
  143806. * @param xrSession a native xrSession that will execute this hit test
  143807. * @param xrRay the ray (position and direction) to use for ray-casting
  143808. * @param referenceSpace native XR reference space to use for the hit-test
  143809. * @param filter filter function that will filter the results
  143810. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  143811. */
  143812. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  143813. /**
  143814. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  143815. * @param event the (select) event to use to select with
  143816. * @param referenceSpace the reference space to use for this hit test
  143817. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  143818. */
  143819. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  143820. /**
  143821. * attach this feature
  143822. * Will usually be called by the features manager
  143823. *
  143824. * @returns true if successful.
  143825. */
  143826. attach(): boolean;
  143827. /**
  143828. * detach this feature.
  143829. * Will usually be called by the features manager
  143830. *
  143831. * @returns true if successful.
  143832. */
  143833. detach(): boolean;
  143834. /**
  143835. * Dispose this feature and all of the resources attached
  143836. */
  143837. dispose(): void;
  143838. protected _onXRFrame(frame: XRFrame): void;
  143839. private _onHitTestResults;
  143840. private _onSelect;
  143841. }
  143842. }
  143843. declare module BABYLON {
  143844. /**
  143845. * Options used in the plane detector module
  143846. */
  143847. export interface IWebXRPlaneDetectorOptions {
  143848. /**
  143849. * The node to use to transform the local results to world coordinates
  143850. */
  143851. worldParentNode?: TransformNode;
  143852. }
  143853. /**
  143854. * A babylon interface for a WebXR plane.
  143855. * A Plane is actually a polygon, built from N points in space
  143856. *
  143857. * Supported in chrome 79, not supported in canary 81 ATM
  143858. */
  143859. export interface IWebXRPlane {
  143860. /**
  143861. * a babylon-assigned ID for this polygon
  143862. */
  143863. id: number;
  143864. /**
  143865. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  143866. */
  143867. polygonDefinition: Array<Vector3>;
  143868. /**
  143869. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  143870. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  143871. */
  143872. transformationMatrix: Matrix;
  143873. /**
  143874. * the native xr-plane object
  143875. */
  143876. xrPlane: XRPlane;
  143877. }
  143878. /**
  143879. * The plane detector is used to detect planes in the real world when in AR
  143880. * For more information see https://github.com/immersive-web/real-world-geometry/
  143881. */
  143882. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  143883. private _options;
  143884. private _detectedPlanes;
  143885. private _enabled;
  143886. private _lastFrameDetected;
  143887. /**
  143888. * The module's name
  143889. */
  143890. static readonly Name: string;
  143891. /**
  143892. * The (Babylon) version of this module.
  143893. * This is an integer representing the implementation version.
  143894. * This number does not correspond to the WebXR specs version
  143895. */
  143896. static readonly Version: number;
  143897. /**
  143898. * Observers registered here will be executed when a new plane was added to the session
  143899. */
  143900. onPlaneAddedObservable: Observable<IWebXRPlane>;
  143901. /**
  143902. * Observers registered here will be executed when a plane is no longer detected in the session
  143903. */
  143904. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  143905. /**
  143906. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  143907. * This can execute N times every frame
  143908. */
  143909. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  143910. /**
  143911. * construct a new Plane Detector
  143912. * @param _xrSessionManager an instance of xr Session manager
  143913. * @param _options configuration to use when constructing this feature
  143914. */
  143915. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  143916. /**
  143917. * Dispose this feature and all of the resources attached
  143918. */
  143919. dispose(): void;
  143920. protected _onXRFrame(frame: XRFrame): void;
  143921. private _init;
  143922. private _updatePlaneWithXRPlane;
  143923. /**
  143924. * avoiding using Array.find for global support.
  143925. * @param xrPlane the plane to find in the array
  143926. */
  143927. private findIndexInPlaneArray;
  143928. }
  143929. }
  143930. declare module BABYLON {
  143931. /**
  143932. * Configuration options of the anchor system
  143933. */
  143934. export interface IWebXRAnchorSystemOptions {
  143935. /**
  143936. * Should a new anchor be added every time a select event is triggered
  143937. */
  143938. addAnchorOnSelect?: boolean;
  143939. /**
  143940. * should the anchor system use plane detection.
  143941. * If set to true, the plane-detection feature should be set using setPlaneDetector
  143942. */
  143943. usePlaneDetection?: boolean;
  143944. /**
  143945. * a node that will be used to convert local to world coordinates
  143946. */
  143947. worldParentNode?: TransformNode;
  143948. }
  143949. /**
  143950. * A babylon container for an XR Anchor
  143951. */
  143952. export interface IWebXRAnchor {
  143953. /**
  143954. * A babylon-assigned ID for this anchor
  143955. */
  143956. id: number;
  143957. /**
  143958. * Transformation matrix to apply to an object attached to this anchor
  143959. */
  143960. transformationMatrix: Matrix;
  143961. /**
  143962. * The native anchor object
  143963. */
  143964. xrAnchor: XRAnchor;
  143965. }
  143966. /**
  143967. * An implementation of the anchor system of WebXR.
  143968. * Note that the current documented implementation is not available in any browser. Future implementations
  143969. * will use the frame to create an anchor and not the session or a detected plane
  143970. * For further information see https://github.com/immersive-web/anchors/
  143971. */
  143972. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  143973. private _options;
  143974. private _enabled;
  143975. private _hitTestModule;
  143976. private _lastFrameDetected;
  143977. private _onSelect;
  143978. private _planeDetector;
  143979. private _trackedAnchors;
  143980. /**
  143981. * The module's name
  143982. */
  143983. static readonly Name: string;
  143984. /**
  143985. * The (Babylon) version of this module.
  143986. * This is an integer representing the implementation version.
  143987. * This number does not correspond to the WebXR specs version
  143988. */
  143989. static readonly Version: number;
  143990. /**
  143991. * Observers registered here will be executed when a new anchor was added to the session
  143992. */
  143993. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  143994. /**
  143995. * Observers registered here will be executed when an anchor was removed from the session
  143996. */
  143997. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  143998. /**
  143999. * Observers registered here will be executed when an existing anchor updates
  144000. * This can execute N times every frame
  144001. */
  144002. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  144003. /**
  144004. * constructs a new anchor system
  144005. * @param _xrSessionManager an instance of WebXRSessionManager
  144006. * @param _options configuration object for this feature
  144007. */
  144008. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  144009. /**
  144010. * Add anchor at a specific XR point.
  144011. *
  144012. * @param xrRigidTransformation xr-coordinates where a new anchor should be added
  144013. * @param anchorCreator the object o use to create an anchor with. either a session or a plane
  144014. * @returns a promise the fulfills when the anchor was created
  144015. */
  144016. addAnchorAtRigidTransformation(xrRigidTransformation: XRRigidTransform, anchorCreator?: XRAnchorCreator): Promise<XRAnchor>;
  144017. /**
  144018. * attach this feature
  144019. * Will usually be called by the features manager
  144020. *
  144021. * @returns true if successful.
  144022. */
  144023. attach(): boolean;
  144024. /**
  144025. * detach this feature.
  144026. * Will usually be called by the features manager
  144027. *
  144028. * @returns true if successful.
  144029. */
  144030. detach(): boolean;
  144031. /**
  144032. * Dispose this feature and all of the resources attached
  144033. */
  144034. dispose(): void;
  144035. /**
  144036. * If set, it will improve performance by using the current hit-test results instead of executing a new hit-test
  144037. * @param hitTestModule the hit-test module to use.
  144038. */
  144039. setHitTestModule(hitTestModule: WebXRHitTestLegacy): void;
  144040. /**
  144041. * set the plane detector to use in order to create anchors from frames
  144042. * @param planeDetector the plane-detector module to use
  144043. * @param enable enable plane-anchors. default is true
  144044. */
  144045. setPlaneDetector(planeDetector: WebXRPlaneDetector, enable?: boolean): void;
  144046. protected _onXRFrame(frame: XRFrame): void;
  144047. /**
  144048. * avoiding using Array.find for global support.
  144049. * @param xrAnchor the plane to find in the array
  144050. */
  144051. private _findIndexInAnchorArray;
  144052. private _updateAnchorWithXRFrame;
  144053. }
  144054. }
  144055. declare module BABYLON {
  144056. /**
  144057. * Options interface for the background remover plugin
  144058. */
  144059. export interface IWebXRBackgroundRemoverOptions {
  144060. /**
  144061. * Further background meshes to disable when entering AR
  144062. */
  144063. backgroundMeshes?: AbstractMesh[];
  144064. /**
  144065. * flags to configure the removal of the environment helper.
  144066. * If not set, the entire background will be removed. If set, flags should be set as well.
  144067. */
  144068. environmentHelperRemovalFlags?: {
  144069. /**
  144070. * Should the skybox be removed (default false)
  144071. */
  144072. skyBox?: boolean;
  144073. /**
  144074. * Should the ground be removed (default false)
  144075. */
  144076. ground?: boolean;
  144077. };
  144078. /**
  144079. * don't disable the environment helper
  144080. */
  144081. ignoreEnvironmentHelper?: boolean;
  144082. }
  144083. /**
  144084. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  144085. */
  144086. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  144087. /**
  144088. * read-only options to be used in this module
  144089. */
  144090. readonly options: IWebXRBackgroundRemoverOptions;
  144091. /**
  144092. * The module's name
  144093. */
  144094. static readonly Name: string;
  144095. /**
  144096. * The (Babylon) version of this module.
  144097. * This is an integer representing the implementation version.
  144098. * This number does not correspond to the WebXR specs version
  144099. */
  144100. static readonly Version: number;
  144101. /**
  144102. * registered observers will be triggered when the background state changes
  144103. */
  144104. onBackgroundStateChangedObservable: Observable<boolean>;
  144105. /**
  144106. * constructs a new background remover module
  144107. * @param _xrSessionManager the session manager for this module
  144108. * @param options read-only options to be used in this module
  144109. */
  144110. constructor(_xrSessionManager: WebXRSessionManager,
  144111. /**
  144112. * read-only options to be used in this module
  144113. */
  144114. options?: IWebXRBackgroundRemoverOptions);
  144115. /**
  144116. * attach this feature
  144117. * Will usually be called by the features manager
  144118. *
  144119. * @returns true if successful.
  144120. */
  144121. attach(): boolean;
  144122. /**
  144123. * detach this feature.
  144124. * Will usually be called by the features manager
  144125. *
  144126. * @returns true if successful.
  144127. */
  144128. detach(): boolean;
  144129. /**
  144130. * Dispose this feature and all of the resources attached
  144131. */
  144132. dispose(): void;
  144133. protected _onXRFrame(_xrFrame: XRFrame): void;
  144134. private _setBackgroundState;
  144135. }
  144136. }
  144137. declare module BABYLON {
  144138. /**
  144139. * Options for the controller physics feature
  144140. */
  144141. export class IWebXRControllerPhysicsOptions {
  144142. /**
  144143. * Should the headset get its own impostor
  144144. */
  144145. enableHeadsetImpostor?: boolean;
  144146. /**
  144147. * Optional parameters for the headset impostor
  144148. */
  144149. headsetImpostorParams?: {
  144150. /**
  144151. * The type of impostor to create. Default is sphere
  144152. */
  144153. impostorType: number;
  144154. /**
  144155. * the size of the impostor. Defaults to 10cm
  144156. */
  144157. impostorSize?: number | {
  144158. width: number;
  144159. height: number;
  144160. depth: number;
  144161. };
  144162. /**
  144163. * Friction definitions
  144164. */
  144165. friction?: number;
  144166. /**
  144167. * Restitution
  144168. */
  144169. restitution?: number;
  144170. };
  144171. /**
  144172. * The physics properties of the future impostors
  144173. */
  144174. physicsProperties?: {
  144175. /**
  144176. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  144177. * Note that this requires a physics engine that supports mesh impostors!
  144178. */
  144179. useControllerMesh?: boolean;
  144180. /**
  144181. * The type of impostor to create. Default is sphere
  144182. */
  144183. impostorType?: number;
  144184. /**
  144185. * the size of the impostor. Defaults to 10cm
  144186. */
  144187. impostorSize?: number | {
  144188. width: number;
  144189. height: number;
  144190. depth: number;
  144191. };
  144192. /**
  144193. * Friction definitions
  144194. */
  144195. friction?: number;
  144196. /**
  144197. * Restitution
  144198. */
  144199. restitution?: number;
  144200. };
  144201. /**
  144202. * the xr input to use with this pointer selection
  144203. */
  144204. xrInput: WebXRInput;
  144205. }
  144206. /**
  144207. * Add physics impostor to your webxr controllers,
  144208. * including naive calculation of their linear and angular velocity
  144209. */
  144210. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  144211. private readonly _options;
  144212. private _attachController;
  144213. private _controllers;
  144214. private _debugMode;
  144215. private _delta;
  144216. private _headsetImpostor?;
  144217. private _headsetMesh?;
  144218. private _lastTimestamp;
  144219. private _tmpQuaternion;
  144220. private _tmpVector;
  144221. /**
  144222. * The module's name
  144223. */
  144224. static readonly Name: string;
  144225. /**
  144226. * The (Babylon) version of this module.
  144227. * This is an integer representing the implementation version.
  144228. * This number does not correspond to the webxr specs version
  144229. */
  144230. static readonly Version: number;
  144231. /**
  144232. * Construct a new Controller Physics Feature
  144233. * @param _xrSessionManager the corresponding xr session manager
  144234. * @param _options options to create this feature with
  144235. */
  144236. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  144237. /**
  144238. * @hidden
  144239. * enable debugging - will show console outputs and the impostor mesh
  144240. */
  144241. _enablePhysicsDebug(): void;
  144242. /**
  144243. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  144244. * @param xrController the controller to add
  144245. */
  144246. addController(xrController: WebXRInputSource): void;
  144247. /**
  144248. * attach this feature
  144249. * Will usually be called by the features manager
  144250. *
  144251. * @returns true if successful.
  144252. */
  144253. attach(): boolean;
  144254. /**
  144255. * detach this feature.
  144256. * Will usually be called by the features manager
  144257. *
  144258. * @returns true if successful.
  144259. */
  144260. detach(): boolean;
  144261. /**
  144262. * Get the headset impostor, if enabled
  144263. * @returns the impostor
  144264. */
  144265. getHeadsetImpostor(): PhysicsImpostor | undefined;
  144266. /**
  144267. * Get the physics impostor of a specific controller.
  144268. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  144269. * @param controller the controller or the controller id of which to get the impostor
  144270. * @returns the impostor or null
  144271. */
  144272. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  144273. /**
  144274. * Update the physics properties provided in the constructor
  144275. * @param newProperties the new properties object
  144276. */
  144277. setPhysicsProperties(newProperties: {
  144278. impostorType?: number;
  144279. impostorSize?: number | {
  144280. width: number;
  144281. height: number;
  144282. depth: number;
  144283. };
  144284. friction?: number;
  144285. restitution?: number;
  144286. }): void;
  144287. protected _onXRFrame(_xrFrame: any): void;
  144288. private _detachController;
  144289. }
  144290. }
  144291. declare module BABYLON {
  144292. /**
  144293. * Options used for hit testing (version 2)
  144294. */
  144295. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  144296. /**
  144297. * Do not create a permanent hit test. Will usually be used when only
  144298. * transient inputs are needed.
  144299. */
  144300. disablePermanentHitTest?: boolean;
  144301. /**
  144302. * Enable transient (for example touch-based) hit test inspections
  144303. */
  144304. enableTransientHitTest?: boolean;
  144305. /**
  144306. * Offset ray for the permanent hit test
  144307. */
  144308. offsetRay?: Vector3;
  144309. /**
  144310. * Offset ray for the transient hit test
  144311. */
  144312. transientOffsetRay?: Vector3;
  144313. /**
  144314. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  144315. */
  144316. useReferenceSpace?: boolean;
  144317. }
  144318. /**
  144319. * Interface defining the babylon result of hit-test
  144320. */
  144321. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  144322. /**
  144323. * The input source that generated this hit test (if transient)
  144324. */
  144325. inputSource?: XRInputSource;
  144326. /**
  144327. * Is this a transient hit test
  144328. */
  144329. isTransient?: boolean;
  144330. /**
  144331. * Position of the hit test result
  144332. */
  144333. position: Vector3;
  144334. /**
  144335. * Rotation of the hit test result
  144336. */
  144337. rotationQuaternion: Quaternion;
  144338. }
  144339. /**
  144340. * The currently-working hit-test module.
  144341. * Hit test (or Ray-casting) is used to interact with the real world.
  144342. * For further information read here - https://github.com/immersive-web/hit-test
  144343. *
  144344. * Tested on chrome (mobile) 80.
  144345. */
  144346. export class WebXRHitTest extends WebXRAbstractFeature {
  144347. /**
  144348. * options to use when constructing this feature
  144349. */
  144350. readonly options: IWebXRHitTestOptions;
  144351. private _tmpMat;
  144352. private _tmpPos;
  144353. private _tmpQuat;
  144354. private _transientXrHitTestSource;
  144355. private _xrHitTestSource;
  144356. private initHitTestSource;
  144357. /**
  144358. * The module's name
  144359. */
  144360. static readonly Name: string;
  144361. /**
  144362. * The (Babylon) version of this module.
  144363. * This is an integer representing the implementation version.
  144364. * This number does not correspond to the WebXR specs version
  144365. */
  144366. static readonly Version: number;
  144367. /**
  144368. * When set to true, each hit test will have its own position/rotation objects
  144369. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  144370. * the developers will clone them or copy them as they see fit.
  144371. */
  144372. autoCloneTransformation: boolean;
  144373. /**
  144374. * Populated with the last native XR Hit Results
  144375. */
  144376. lastNativeXRHitResults: XRHitResult[];
  144377. /**
  144378. * Triggered when new babylon (transformed) hit test results are available
  144379. */
  144380. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  144381. /**
  144382. * Use this to temporarily pause hit test checks.
  144383. */
  144384. paused: boolean;
  144385. /**
  144386. * Creates a new instance of the hit test feature
  144387. * @param _xrSessionManager an instance of WebXRSessionManager
  144388. * @param options options to use when constructing this feature
  144389. */
  144390. constructor(_xrSessionManager: WebXRSessionManager,
  144391. /**
  144392. * options to use when constructing this feature
  144393. */
  144394. options?: IWebXRHitTestOptions);
  144395. /**
  144396. * attach this feature
  144397. * Will usually be called by the features manager
  144398. *
  144399. * @returns true if successful.
  144400. */
  144401. attach(): boolean;
  144402. /**
  144403. * detach this feature.
  144404. * Will usually be called by the features manager
  144405. *
  144406. * @returns true if successful.
  144407. */
  144408. detach(): boolean;
  144409. /**
  144410. * Dispose this feature and all of the resources attached
  144411. */
  144412. dispose(): void;
  144413. protected _onXRFrame(frame: XRFrame): void;
  144414. private _processWebXRHitTestResult;
  144415. }
  144416. }
  144417. declare module BABYLON {
  144418. /**
  144419. * The motion controller class for all microsoft mixed reality controllers
  144420. */
  144421. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  144422. protected readonly _mapping: {
  144423. defaultButton: {
  144424. valueNodeName: string;
  144425. unpressedNodeName: string;
  144426. pressedNodeName: string;
  144427. };
  144428. defaultAxis: {
  144429. valueNodeName: string;
  144430. minNodeName: string;
  144431. maxNodeName: string;
  144432. };
  144433. buttons: {
  144434. "xr-standard-trigger": {
  144435. rootNodeName: string;
  144436. componentProperty: string;
  144437. states: string[];
  144438. };
  144439. "xr-standard-squeeze": {
  144440. rootNodeName: string;
  144441. componentProperty: string;
  144442. states: string[];
  144443. };
  144444. "xr-standard-touchpad": {
  144445. rootNodeName: string;
  144446. labelAnchorNodeName: string;
  144447. touchPointNodeName: string;
  144448. };
  144449. "xr-standard-thumbstick": {
  144450. rootNodeName: string;
  144451. componentProperty: string;
  144452. states: string[];
  144453. };
  144454. };
  144455. axes: {
  144456. "xr-standard-touchpad": {
  144457. "x-axis": {
  144458. rootNodeName: string;
  144459. };
  144460. "y-axis": {
  144461. rootNodeName: string;
  144462. };
  144463. };
  144464. "xr-standard-thumbstick": {
  144465. "x-axis": {
  144466. rootNodeName: string;
  144467. };
  144468. "y-axis": {
  144469. rootNodeName: string;
  144470. };
  144471. };
  144472. };
  144473. };
  144474. /**
  144475. * The base url used to load the left and right controller models
  144476. */
  144477. static MODEL_BASE_URL: string;
  144478. /**
  144479. * The name of the left controller model file
  144480. */
  144481. static MODEL_LEFT_FILENAME: string;
  144482. /**
  144483. * The name of the right controller model file
  144484. */
  144485. static MODEL_RIGHT_FILENAME: string;
  144486. profileId: string;
  144487. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  144488. protected _getFilenameAndPath(): {
  144489. filename: string;
  144490. path: string;
  144491. };
  144492. protected _getModelLoadingConstraints(): boolean;
  144493. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  144494. protected _setRootMesh(meshes: AbstractMesh[]): void;
  144495. protected _updateModel(): void;
  144496. }
  144497. }
  144498. declare module BABYLON {
  144499. /**
  144500. * The motion controller class for oculus touch (quest, rift).
  144501. * This class supports legacy mapping as well the standard xr mapping
  144502. */
  144503. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  144504. private _forceLegacyControllers;
  144505. private _modelRootNode;
  144506. /**
  144507. * The base url used to load the left and right controller models
  144508. */
  144509. static MODEL_BASE_URL: string;
  144510. /**
  144511. * The name of the left controller model file
  144512. */
  144513. static MODEL_LEFT_FILENAME: string;
  144514. /**
  144515. * The name of the right controller model file
  144516. */
  144517. static MODEL_RIGHT_FILENAME: string;
  144518. /**
  144519. * Base Url for the Quest controller model.
  144520. */
  144521. static QUEST_MODEL_BASE_URL: string;
  144522. profileId: string;
  144523. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  144524. protected _getFilenameAndPath(): {
  144525. filename: string;
  144526. path: string;
  144527. };
  144528. protected _getModelLoadingConstraints(): boolean;
  144529. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  144530. protected _setRootMesh(meshes: AbstractMesh[]): void;
  144531. protected _updateModel(): void;
  144532. /**
  144533. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  144534. * between the touch and touch 2.
  144535. */
  144536. private _isQuest;
  144537. }
  144538. }
  144539. declare module BABYLON {
  144540. /**
  144541. * The motion controller class for the standard HTC-Vive controllers
  144542. */
  144543. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  144544. private _modelRootNode;
  144545. /**
  144546. * The base url used to load the left and right controller models
  144547. */
  144548. static MODEL_BASE_URL: string;
  144549. /**
  144550. * File name for the controller model.
  144551. */
  144552. static MODEL_FILENAME: string;
  144553. profileId: string;
  144554. /**
  144555. * Create a new Vive motion controller object
  144556. * @param scene the scene to use to create this controller
  144557. * @param gamepadObject the corresponding gamepad object
  144558. * @param handness the handness of the controller
  144559. */
  144560. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  144561. protected _getFilenameAndPath(): {
  144562. filename: string;
  144563. path: string;
  144564. };
  144565. protected _getModelLoadingConstraints(): boolean;
  144566. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  144567. protected _setRootMesh(meshes: AbstractMesh[]): void;
  144568. protected _updateModel(): void;
  144569. }
  144570. }
  144571. declare module BABYLON {
  144572. /**
  144573. * A cursor which tracks a point on a path
  144574. */
  144575. export class PathCursor {
  144576. private path;
  144577. /**
  144578. * Stores path cursor callbacks for when an onchange event is triggered
  144579. */
  144580. private _onchange;
  144581. /**
  144582. * The value of the path cursor
  144583. */
  144584. value: number;
  144585. /**
  144586. * The animation array of the path cursor
  144587. */
  144588. animations: Animation[];
  144589. /**
  144590. * Initializes the path cursor
  144591. * @param path The path to track
  144592. */
  144593. constructor(path: Path2);
  144594. /**
  144595. * Gets the cursor point on the path
  144596. * @returns A point on the path cursor at the cursor location
  144597. */
  144598. getPoint(): Vector3;
  144599. /**
  144600. * Moves the cursor ahead by the step amount
  144601. * @param step The amount to move the cursor forward
  144602. * @returns This path cursor
  144603. */
  144604. moveAhead(step?: number): PathCursor;
  144605. /**
  144606. * Moves the cursor behind by the step amount
  144607. * @param step The amount to move the cursor back
  144608. * @returns This path cursor
  144609. */
  144610. moveBack(step?: number): PathCursor;
  144611. /**
  144612. * Moves the cursor by the step amount
  144613. * If the step amount is greater than one, an exception is thrown
  144614. * @param step The amount to move the cursor
  144615. * @returns This path cursor
  144616. */
  144617. move(step: number): PathCursor;
  144618. /**
  144619. * Ensures that the value is limited between zero and one
  144620. * @returns This path cursor
  144621. */
  144622. private ensureLimits;
  144623. /**
  144624. * Runs onchange callbacks on change (used by the animation engine)
  144625. * @returns This path cursor
  144626. */
  144627. private raiseOnChange;
  144628. /**
  144629. * Executes a function on change
  144630. * @param f A path cursor onchange callback
  144631. * @returns This path cursor
  144632. */
  144633. onchange(f: (cursor: PathCursor) => void): PathCursor;
  144634. }
  144635. }
  144636. declare module BABYLON {
  144637. /** @hidden */
  144638. export var blurPixelShader: {
  144639. name: string;
  144640. shader: string;
  144641. };
  144642. }
  144643. declare module BABYLON {
  144644. /** @hidden */
  144645. export var pointCloudVertexDeclaration: {
  144646. name: string;
  144647. shader: string;
  144648. };
  144649. }
  144650. // Mixins
  144651. interface Window {
  144652. mozIndexedDB: IDBFactory;
  144653. webkitIndexedDB: IDBFactory;
  144654. msIndexedDB: IDBFactory;
  144655. webkitURL: typeof URL;
  144656. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  144657. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  144658. WebGLRenderingContext: WebGLRenderingContext;
  144659. MSGesture: MSGesture;
  144660. CANNON: any;
  144661. AudioContext: AudioContext;
  144662. webkitAudioContext: AudioContext;
  144663. PointerEvent: any;
  144664. Math: Math;
  144665. Uint8Array: Uint8ArrayConstructor;
  144666. Float32Array: Float32ArrayConstructor;
  144667. mozURL: typeof URL;
  144668. msURL: typeof URL;
  144669. VRFrameData: any; // WebVR, from specs 1.1
  144670. DracoDecoderModule: any;
  144671. setImmediate(handler: (...args: any[]) => void): number;
  144672. }
  144673. interface HTMLCanvasElement {
  144674. requestPointerLock(): void;
  144675. msRequestPointerLock?(): void;
  144676. mozRequestPointerLock?(): void;
  144677. webkitRequestPointerLock?(): void;
  144678. /** Track wether a record is in progress */
  144679. isRecording: boolean;
  144680. /** Capture Stream method defined by some browsers */
  144681. captureStream(fps?: number): MediaStream;
  144682. }
  144683. interface CanvasRenderingContext2D {
  144684. msImageSmoothingEnabled: boolean;
  144685. }
  144686. interface MouseEvent {
  144687. mozMovementX: number;
  144688. mozMovementY: number;
  144689. webkitMovementX: number;
  144690. webkitMovementY: number;
  144691. msMovementX: number;
  144692. msMovementY: number;
  144693. }
  144694. interface Navigator {
  144695. mozGetVRDevices: (any: any) => any;
  144696. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  144697. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  144698. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  144699. webkitGetGamepads(): Gamepad[];
  144700. msGetGamepads(): Gamepad[];
  144701. webkitGamepads(): Gamepad[];
  144702. }
  144703. interface HTMLVideoElement {
  144704. mozSrcObject: any;
  144705. }
  144706. interface Math {
  144707. fround(x: number): number;
  144708. imul(a: number, b: number): number;
  144709. }
  144710. interface WebGLRenderingContext {
  144711. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  144712. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  144713. vertexAttribDivisor(index: number, divisor: number): void;
  144714. createVertexArray(): any;
  144715. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  144716. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  144717. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  144718. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  144719. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  144720. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  144721. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  144722. // Queries
  144723. createQuery(): WebGLQuery;
  144724. deleteQuery(query: WebGLQuery): void;
  144725. beginQuery(target: number, query: WebGLQuery): void;
  144726. endQuery(target: number): void;
  144727. getQueryParameter(query: WebGLQuery, pname: number): any;
  144728. getQuery(target: number, pname: number): any;
  144729. MAX_SAMPLES: number;
  144730. RGBA8: number;
  144731. READ_FRAMEBUFFER: number;
  144732. DRAW_FRAMEBUFFER: number;
  144733. UNIFORM_BUFFER: number;
  144734. HALF_FLOAT_OES: number;
  144735. RGBA16F: number;
  144736. RGBA32F: number;
  144737. R32F: number;
  144738. RG32F: number;
  144739. RGB32F: number;
  144740. R16F: number;
  144741. RG16F: number;
  144742. RGB16F: number;
  144743. RED: number;
  144744. RG: number;
  144745. R8: number;
  144746. RG8: number;
  144747. UNSIGNED_INT_24_8: number;
  144748. DEPTH24_STENCIL8: number;
  144749. MIN: number;
  144750. MAX: number;
  144751. /* Multiple Render Targets */
  144752. drawBuffers(buffers: number[]): void;
  144753. readBuffer(src: number): void;
  144754. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  144755. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  144756. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  144757. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  144758. // Occlusion Query
  144759. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  144760. ANY_SAMPLES_PASSED: number;
  144761. QUERY_RESULT_AVAILABLE: number;
  144762. QUERY_RESULT: number;
  144763. }
  144764. interface WebGLProgram {
  144765. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  144766. }
  144767. interface EXT_disjoint_timer_query {
  144768. QUERY_COUNTER_BITS_EXT: number;
  144769. TIME_ELAPSED_EXT: number;
  144770. TIMESTAMP_EXT: number;
  144771. GPU_DISJOINT_EXT: number;
  144772. QUERY_RESULT_EXT: number;
  144773. QUERY_RESULT_AVAILABLE_EXT: number;
  144774. queryCounterEXT(query: WebGLQuery, target: number): void;
  144775. createQueryEXT(): WebGLQuery;
  144776. beginQueryEXT(target: number, query: WebGLQuery): void;
  144777. endQueryEXT(target: number): void;
  144778. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  144779. deleteQueryEXT(query: WebGLQuery): void;
  144780. }
  144781. interface WebGLUniformLocation {
  144782. _currentState: any;
  144783. }
  144784. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  144785. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  144786. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  144787. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  144788. interface WebGLRenderingContext {
  144789. readonly RASTERIZER_DISCARD: number;
  144790. readonly DEPTH_COMPONENT24: number;
  144791. readonly TEXTURE_3D: number;
  144792. readonly TEXTURE_2D_ARRAY: number;
  144793. readonly TEXTURE_COMPARE_FUNC: number;
  144794. readonly TEXTURE_COMPARE_MODE: number;
  144795. readonly COMPARE_REF_TO_TEXTURE: number;
  144796. readonly TEXTURE_WRAP_R: number;
  144797. readonly HALF_FLOAT: number;
  144798. readonly RGB8: number;
  144799. readonly RED_INTEGER: number;
  144800. readonly RG_INTEGER: number;
  144801. readonly RGB_INTEGER: number;
  144802. readonly RGBA_INTEGER: number;
  144803. readonly R8_SNORM: number;
  144804. readonly RG8_SNORM: number;
  144805. readonly RGB8_SNORM: number;
  144806. readonly RGBA8_SNORM: number;
  144807. readonly R8I: number;
  144808. readonly RG8I: number;
  144809. readonly RGB8I: number;
  144810. readonly RGBA8I: number;
  144811. readonly R8UI: number;
  144812. readonly RG8UI: number;
  144813. readonly RGB8UI: number;
  144814. readonly RGBA8UI: number;
  144815. readonly R16I: number;
  144816. readonly RG16I: number;
  144817. readonly RGB16I: number;
  144818. readonly RGBA16I: number;
  144819. readonly R16UI: number;
  144820. readonly RG16UI: number;
  144821. readonly RGB16UI: number;
  144822. readonly RGBA16UI: number;
  144823. readonly R32I: number;
  144824. readonly RG32I: number;
  144825. readonly RGB32I: number;
  144826. readonly RGBA32I: number;
  144827. readonly R32UI: number;
  144828. readonly RG32UI: number;
  144829. readonly RGB32UI: number;
  144830. readonly RGBA32UI: number;
  144831. readonly RGB10_A2UI: number;
  144832. readonly R11F_G11F_B10F: number;
  144833. readonly RGB9_E5: number;
  144834. readonly RGB10_A2: number;
  144835. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  144836. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  144837. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  144838. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  144839. readonly DEPTH_COMPONENT32F: number;
  144840. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  144841. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  144842. 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;
  144843. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  144844. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  144845. readonly TRANSFORM_FEEDBACK: number;
  144846. readonly INTERLEAVED_ATTRIBS: number;
  144847. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  144848. createTransformFeedback(): WebGLTransformFeedback;
  144849. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  144850. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  144851. beginTransformFeedback(primitiveMode: number): void;
  144852. endTransformFeedback(): void;
  144853. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  144854. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  144855. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  144856. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  144857. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  144858. }
  144859. interface ImageBitmap {
  144860. readonly width: number;
  144861. readonly height: number;
  144862. close(): void;
  144863. }
  144864. interface WebGLQuery extends WebGLObject {
  144865. }
  144866. declare var WebGLQuery: {
  144867. prototype: WebGLQuery;
  144868. new(): WebGLQuery;
  144869. };
  144870. interface WebGLSampler extends WebGLObject {
  144871. }
  144872. declare var WebGLSampler: {
  144873. prototype: WebGLSampler;
  144874. new(): WebGLSampler;
  144875. };
  144876. interface WebGLSync extends WebGLObject {
  144877. }
  144878. declare var WebGLSync: {
  144879. prototype: WebGLSync;
  144880. new(): WebGLSync;
  144881. };
  144882. interface WebGLTransformFeedback extends WebGLObject {
  144883. }
  144884. declare var WebGLTransformFeedback: {
  144885. prototype: WebGLTransformFeedback;
  144886. new(): WebGLTransformFeedback;
  144887. };
  144888. interface WebGLVertexArrayObject extends WebGLObject {
  144889. }
  144890. declare var WebGLVertexArrayObject: {
  144891. prototype: WebGLVertexArrayObject;
  144892. new(): WebGLVertexArrayObject;
  144893. };
  144894. // Type definitions for WebVR API
  144895. // Project: https://w3c.github.io/webvr/
  144896. // Definitions by: six a <https://github.com/lostfictions>
  144897. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  144898. interface VRDisplay extends EventTarget {
  144899. /**
  144900. * Dictionary of capabilities describing the VRDisplay.
  144901. */
  144902. readonly capabilities: VRDisplayCapabilities;
  144903. /**
  144904. * z-depth defining the far plane of the eye view frustum
  144905. * enables mapping of values in the render target depth
  144906. * attachment to scene coordinates. Initially set to 10000.0.
  144907. */
  144908. depthFar: number;
  144909. /**
  144910. * z-depth defining the near plane of the eye view frustum
  144911. * enables mapping of values in the render target depth
  144912. * attachment to scene coordinates. Initially set to 0.01.
  144913. */
  144914. depthNear: number;
  144915. /**
  144916. * An identifier for this distinct VRDisplay. Used as an
  144917. * association point in the Gamepad API.
  144918. */
  144919. readonly displayId: number;
  144920. /**
  144921. * A display name, a user-readable name identifying it.
  144922. */
  144923. readonly displayName: string;
  144924. readonly isConnected: boolean;
  144925. readonly isPresenting: boolean;
  144926. /**
  144927. * If this VRDisplay supports room-scale experiences, the optional
  144928. * stage attribute contains details on the room-scale parameters.
  144929. */
  144930. readonly stageParameters: VRStageParameters | null;
  144931. /**
  144932. * Passing the value returned by `requestAnimationFrame` to
  144933. * `cancelAnimationFrame` will unregister the callback.
  144934. * @param handle Define the hanle of the request to cancel
  144935. */
  144936. cancelAnimationFrame(handle: number): void;
  144937. /**
  144938. * Stops presenting to the VRDisplay.
  144939. * @returns a promise to know when it stopped
  144940. */
  144941. exitPresent(): Promise<void>;
  144942. /**
  144943. * Return the current VREyeParameters for the given eye.
  144944. * @param whichEye Define the eye we want the parameter for
  144945. * @returns the eye parameters
  144946. */
  144947. getEyeParameters(whichEye: string): VREyeParameters;
  144948. /**
  144949. * Populates the passed VRFrameData with the information required to render
  144950. * the current frame.
  144951. * @param frameData Define the data structure to populate
  144952. * @returns true if ok otherwise false
  144953. */
  144954. getFrameData(frameData: VRFrameData): boolean;
  144955. /**
  144956. * Get the layers currently being presented.
  144957. * @returns the list of VR layers
  144958. */
  144959. getLayers(): VRLayer[];
  144960. /**
  144961. * Return a VRPose containing the future predicted pose of the VRDisplay
  144962. * when the current frame will be presented. The value returned will not
  144963. * change until JavaScript has returned control to the browser.
  144964. *
  144965. * The VRPose will contain the position, orientation, velocity,
  144966. * and acceleration of each of these properties.
  144967. * @returns the pose object
  144968. */
  144969. getPose(): VRPose;
  144970. /**
  144971. * Return the current instantaneous pose of the VRDisplay, with no
  144972. * prediction applied.
  144973. * @returns the current instantaneous pose
  144974. */
  144975. getImmediatePose(): VRPose;
  144976. /**
  144977. * The callback passed to `requestAnimationFrame` will be called
  144978. * any time a new frame should be rendered. When the VRDisplay is
  144979. * presenting the callback will be called at the native refresh
  144980. * rate of the HMD. When not presenting this function acts
  144981. * identically to how window.requestAnimationFrame acts. Content should
  144982. * make no assumptions of frame rate or vsync behavior as the HMD runs
  144983. * asynchronously from other displays and at differing refresh rates.
  144984. * @param callback Define the eaction to run next frame
  144985. * @returns the request handle it
  144986. */
  144987. requestAnimationFrame(callback: FrameRequestCallback): number;
  144988. /**
  144989. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  144990. * Repeat calls while already presenting will update the VRLayers being displayed.
  144991. * @param layers Define the list of layer to present
  144992. * @returns a promise to know when the request has been fulfilled
  144993. */
  144994. requestPresent(layers: VRLayer[]): Promise<void>;
  144995. /**
  144996. * Reset the pose for this display, treating its current position and
  144997. * orientation as the "origin/zero" values. VRPose.position,
  144998. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  144999. * updated when calling resetPose(). This should be called in only
  145000. * sitting-space experiences.
  145001. */
  145002. resetPose(): void;
  145003. /**
  145004. * The VRLayer provided to the VRDisplay will be captured and presented
  145005. * in the HMD. Calling this function has the same effect on the source
  145006. * canvas as any other operation that uses its source image, and canvases
  145007. * created without preserveDrawingBuffer set to true will be cleared.
  145008. * @param pose Define the pose to submit
  145009. */
  145010. submitFrame(pose?: VRPose): void;
  145011. }
  145012. declare var VRDisplay: {
  145013. prototype: VRDisplay;
  145014. new(): VRDisplay;
  145015. };
  145016. interface VRLayer {
  145017. leftBounds?: number[] | Float32Array | null;
  145018. rightBounds?: number[] | Float32Array | null;
  145019. source?: HTMLCanvasElement | null;
  145020. }
  145021. interface VRDisplayCapabilities {
  145022. readonly canPresent: boolean;
  145023. readonly hasExternalDisplay: boolean;
  145024. readonly hasOrientation: boolean;
  145025. readonly hasPosition: boolean;
  145026. readonly maxLayers: number;
  145027. }
  145028. interface VREyeParameters {
  145029. /** @deprecated */
  145030. readonly fieldOfView: VRFieldOfView;
  145031. readonly offset: Float32Array;
  145032. readonly renderHeight: number;
  145033. readonly renderWidth: number;
  145034. }
  145035. interface VRFieldOfView {
  145036. readonly downDegrees: number;
  145037. readonly leftDegrees: number;
  145038. readonly rightDegrees: number;
  145039. readonly upDegrees: number;
  145040. }
  145041. interface VRFrameData {
  145042. readonly leftProjectionMatrix: Float32Array;
  145043. readonly leftViewMatrix: Float32Array;
  145044. readonly pose: VRPose;
  145045. readonly rightProjectionMatrix: Float32Array;
  145046. readonly rightViewMatrix: Float32Array;
  145047. readonly timestamp: number;
  145048. }
  145049. interface VRPose {
  145050. readonly angularAcceleration: Float32Array | null;
  145051. readonly angularVelocity: Float32Array | null;
  145052. readonly linearAcceleration: Float32Array | null;
  145053. readonly linearVelocity: Float32Array | null;
  145054. readonly orientation: Float32Array | null;
  145055. readonly position: Float32Array | null;
  145056. readonly timestamp: number;
  145057. }
  145058. interface VRStageParameters {
  145059. sittingToStandingTransform?: Float32Array;
  145060. sizeX?: number;
  145061. sizeY?: number;
  145062. }
  145063. interface Navigator {
  145064. getVRDisplays(): Promise<VRDisplay[]>;
  145065. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  145066. }
  145067. interface Window {
  145068. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  145069. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  145070. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  145071. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  145072. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  145073. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  145074. }
  145075. interface Gamepad {
  145076. readonly displayId: number;
  145077. }
  145078. type XRSessionMode =
  145079. | "inline"
  145080. | "immersive-vr"
  145081. | "immersive-ar";
  145082. type XRReferenceSpaceType =
  145083. | "viewer"
  145084. | "local"
  145085. | "local-floor"
  145086. | "bounded-floor"
  145087. | "unbounded";
  145088. type XREnvironmentBlendMode =
  145089. | "opaque"
  145090. | "additive"
  145091. | "alpha-blend";
  145092. type XRVisibilityState =
  145093. | "visible"
  145094. | "visible-blurred"
  145095. | "hidden";
  145096. type XRHandedness =
  145097. | "none"
  145098. | "left"
  145099. | "right";
  145100. type XRTargetRayMode =
  145101. | "gaze"
  145102. | "tracked-pointer"
  145103. | "screen";
  145104. type XREye =
  145105. | "none"
  145106. | "left"
  145107. | "right";
  145108. interface XRSpace extends EventTarget {
  145109. }
  145110. interface XRRenderState {
  145111. depthNear?: number;
  145112. depthFar?: number;
  145113. inlineVerticalFieldOfView?: number;
  145114. baseLayer?: XRWebGLLayer;
  145115. }
  145116. interface XRInputSource {
  145117. handedness: XRHandedness;
  145118. targetRayMode: XRTargetRayMode;
  145119. targetRaySpace: XRSpace;
  145120. gripSpace: XRSpace | undefined;
  145121. gamepad: Gamepad | undefined;
  145122. profiles: Array<string>;
  145123. }
  145124. interface XRSessionInit {
  145125. optionalFeatures?: XRReferenceSpaceType[];
  145126. requiredFeatures?: XRReferenceSpaceType[];
  145127. }
  145128. interface XRSession extends XRAnchorCreator {
  145129. addEventListener: Function;
  145130. removeEventListener: Function;
  145131. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  145132. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  145133. requestAnimationFrame: Function;
  145134. end(): Promise<void>;
  145135. renderState: XRRenderState;
  145136. inputSources: Array<XRInputSource>;
  145137. // hit test
  145138. requestHitTestSource(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  145139. requestHitTestSourceForTransientInput(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  145140. // legacy AR hit test
  145141. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  145142. // legacy plane detection
  145143. updateWorldTrackingState(options: {
  145144. planeDetectionState?: { enabled: boolean; }
  145145. }): void;
  145146. }
  145147. interface XRReferenceSpace extends XRSpace {
  145148. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  145149. onreset: any;
  145150. }
  145151. type XRPlaneSet = Set<XRPlane>;
  145152. type XRAnchorSet = Set<XRAnchor>;
  145153. interface XRFrame {
  145154. session: XRSession;
  145155. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  145156. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  145157. // AR
  145158. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult> ;
  145159. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  145160. // Anchors
  145161. trackedAnchors?: XRAnchorSet;
  145162. // Planes
  145163. worldInformation: {
  145164. detectedPlanes?: XRPlaneSet;
  145165. };
  145166. }
  145167. interface XRViewerPose extends XRPose {
  145168. views: Array<XRView>;
  145169. }
  145170. interface XRPose {
  145171. transform: XRRigidTransform;
  145172. emulatedPosition: boolean;
  145173. }
  145174. interface XRWebGLLayerOptions {
  145175. antialias?: boolean;
  145176. depth?: boolean;
  145177. stencil?: boolean;
  145178. alpha?: boolean;
  145179. multiview?: boolean;
  145180. framebufferScaleFactor?: number;
  145181. }
  145182. declare var XRWebGLLayer: {
  145183. prototype: XRWebGLLayer;
  145184. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  145185. };
  145186. interface XRWebGLLayer {
  145187. framebuffer: WebGLFramebuffer;
  145188. framebufferWidth: number;
  145189. framebufferHeight: number;
  145190. getViewport: Function;
  145191. }
  145192. declare class XRRigidTransform {
  145193. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  145194. position: DOMPointReadOnly;
  145195. orientation: DOMPointReadOnly;
  145196. matrix: Float32Array;
  145197. inverse: XRRigidTransform;
  145198. }
  145199. interface XRView {
  145200. eye: XREye;
  145201. projectionMatrix: Float32Array;
  145202. transform: XRRigidTransform;
  145203. }
  145204. interface XRInputSourceChangeEvent {
  145205. session: XRSession;
  145206. removed: Array<XRInputSource>;
  145207. added: Array<XRInputSource>;
  145208. }
  145209. interface XRInputSourceEvent extends Event {
  145210. readonly frame: XRFrame;
  145211. readonly inputSource: XRInputSource;
  145212. }
  145213. // Experimental(er) features
  145214. declare class XRRay {
  145215. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  145216. origin: DOMPointReadOnly;
  145217. direction: DOMPointReadOnly;
  145218. matrix: Float32Array;
  145219. }
  145220. declare enum XRHitTestTrackableType {
  145221. "point",
  145222. "plane"
  145223. }
  145224. interface XRHitResult {
  145225. hitMatrix: Float32Array;
  145226. }
  145227. interface XRTransientInputHitTestResult {
  145228. readonly inputSource: XRInputSource;
  145229. readonly results: Array<XRHitTestResult>;
  145230. }
  145231. interface XRHitTestResult {
  145232. getPose(baseSpace: XRSpace): XRPose | undefined;
  145233. }
  145234. interface XRHitTestSource {
  145235. cancel(): void;
  145236. }
  145237. interface XRTransientInputHitTestSource {
  145238. cancel(): void;
  145239. }
  145240. interface XRHitTestOptionsInit {
  145241. space: XRSpace;
  145242. entityTypes?: Array<XRHitTestTrackableType>;
  145243. offsetRay?: XRRay;
  145244. }
  145245. interface XRTransientInputHitTestOptionsInit {
  145246. profile: string;
  145247. entityTypes?: Array<XRHitTestTrackableType>;
  145248. offsetRay?: XRRay;
  145249. }
  145250. interface XRAnchor {
  145251. // remove?
  145252. id?: string;
  145253. anchorSpace: XRSpace;
  145254. lastChangedTime: number;
  145255. detach(): void;
  145256. }
  145257. interface XRPlane extends XRAnchorCreator {
  145258. orientation: "Horizontal" | "Vertical";
  145259. planeSpace: XRSpace;
  145260. polygon: Array<DOMPointReadOnly>;
  145261. lastChangedTime: number;
  145262. }
  145263. interface XRAnchorCreator {
  145264. // AR Anchors
  145265. createAnchor(pose: XRPose | XRRigidTransform, referenceSpace: XRReferenceSpace): Promise<XRAnchor>;
  145266. }